Jocimar Lopes / Perfil
This article describes the use of CSV files for backtesting portfolio weights updates in a mean-reversion-based strategy that uses statistical arbitrage through cointegrated stocks. It goes from feeding the database with the results of a Rolling Windows Eigenvector Comparison (RWEC) to comparing the backtest reports. In the meantime, the article details the role of each RWEC parameter and its impact in the overall backtest result, showing how the comparison of the relative drawdown can help us to further improve those parameters.
This article proposes using Rolling Windows Eigenvector Comparison for early imbalance diagnostics and portfolio rebalancing in a mean-reversion statistical arbitrage strategy based on cointegrated stocks. It contrasts this technique with traditional In-Sample/Out-of-Sample ADF validation, showing that eigenvector shifts can signal the need for rebalancing even when IS/OOS ADF still indicates a stationary spread. While the method is intended mainly for live trading monitoring, the article concludes that eigenvector comparison could also be integrated into the scoring system—though its actual contribution to performance remains to be tested.
This article describes two additional scoring criteria used for selection of baskets of stocks to be traded in mean-reversion strategies, more specifically, in cointegration based statistical arbitrage. It complements a previous article where liquidity and strength of the cointegration vectors were presented, along with the strategic criteria of timeframe and lookback period, by including the stability of the cointegration vectors and the time to mean reversion (half-time). The article includes the commented results of a backtest with the new filters applied and the files required for its reproduction are also provided.
In this article, we propose a scoring system for mean-reversion strategies based on statistical arbitrage of cointegrated stocks. The article suggests criteria that go from liquidity and transaction costs to the number of cointegration ranks and time to mean-reversion, while taking into account the strategic criteria of data frequency (timeframe) and the lookback period for cointegration tests, which are evaluated before the score ranking properly. The files required for the reproduction of the backtest are provided, and their results are commented on as well.
This article proposes an asset screening process for a statistical arbitrage trading strategy through cointegrated stocks. The system starts with the regular filtering by economic factors, like asset sector and industry, and finishes with a list of criteria for a scoring system. For each statistical test used in the screening, a respective Python class was developed: Pearson correlation, Engle-Granger cointegration, Johansen cointegration, and ADF/KPSS stationarity. These Python classes are provided along with a personal note from the author about the use of AI assistants for software development.
This article describes a simple but comprehensive statistical arbitrage pipeline for trading a basket of cointegrated stocks. It includes a fully functional Python script for data download and storage; correlation, cointegration, and stationarity tests, along with a sample Metatrader 5 Service implementation for database updating, and the respective Expert Advisor. Some design choices are documented here for reference and for helping in the experiment replication.
This article presents a sample MQL5 Service implementation for updating a newly created database used as source for data analysis and for trading a basket of cointegrated stocks. The rationale behind the database design is explained in detail and the data dictionary is documented for reference. MQL5 and Python scripts are provided for the database creation, schema initialization, and market data insertion.
This article presents a sample Expert Advisor implementation for trading a basket of four Nasdaq stocks. The stocks were initially filtered based on Pearson correlation tests. The filtered group was then tested for cointegration with Johansen tests. Finally, the cointegrated spread was tested for stationarity with the ADF and KPSS tests. Here we will see some notes about this process and the results of the backtests after a small optimization.
This article aims to provide a trader-friendly, gentle introduction to the most common cointegration tests, along with a simple guide to understanding their results. The Engle-Granger and Johansen cointegration tests can reveal statistically significant pairs or groups of assets that share long-term dynamics. The Johansen test is especially useful for portfolios with three or more assets, as it calculates the strength of cointegrating vectors all at once.
This article describes the fundamentals of portfolio-level statistical arbitrage. Its goal is to facilitate the understanding of the principles of statistical arbitrage to readers without deep math knowledge and propose a starting point conceptual framework. The article includes a working Expert Advisor, some notes about its one-year backtest, and the respective backtest configuration settings (.ini file) for the reproduction of the experiment.
Este artigo é a última parte de uma série que descreve nossas etapas de desenvolvimento de um cliente MQL5 nativo para o protocolo MQTT 5.0. Embora a biblioteca ainda não esteja pronta para produção, nesta parte, usaremos nosso cliente para atualizar um símbolo personalizado com ticks (ou taxas) obtidos de outro corretor. Por favor, veja o final deste artigo para mais informações sobre o status atual da biblioteca, o que falta para que ela esteja totalmente em conformidade com o protocolo MQTT 5.0, um possível roadmap, e como acompanhar e contribuir para seu desenvolvimento.
Este artigo é a sexta parte de uma série que descreve nossas etapas de desenvolvimento de um cliente MQL5 nativo para o protocolo MQTT 5.0. Nesta parte, comentamos as principais mudanças em nosso primeiro refatoramento, como chegamos a um modelo viável para nossas classes de construção de pacotes, como estamos construindo pacotes PUBLISH e PUBACK, e a semântica por trás dos Códigos de Motivo PUBACK.
Este artigo é a quinta parte de uma série que descreve as etapas de desenvolvimento de um cliente MQL5 nativo para o protocolo MQTT 5.0. Nesta parte, vamos detalhar a estrutura dos pacotes PUBLISH, configuraremos seus flags de publicação, codificaremos os nomes dos tópicos e estabeleceremos identificadores de pacotes quando necessário.
Este artigo é a quarta parte de uma série que descreve as etapas do desenvolvimento de um cliente MQL5 nativo para o protocolo MQTT. Nesta parte, examinamos as propriedades do MQTT v5.0, sua semântica, como lemos algumas delas e também fornecemos um breve exemplo de como as propriedades podem ser usadas para expandir o protocolo.
Este artigo faz parte de uma série que descreve as etapas do desenvolvimento de um cliente MQL5 nativo para o protocolo MQTT. Nesta parte, descrevemos em detalhes como aplicar o princípio do desenvolvimento orientado por testes para implementar a troca de pacotes CONNECT/CONNACK. Ao final desta etapa, nosso cliente DEVE ser capaz de agir apropriadamente ao trabalhar com todos os possíveis resultados do servidor ao tentar se conectar.
Este artigo faz parte de uma série que descreve as etapas do desenvolvimento de um cliente MQL5 nativo para o protocolo MQTT. Nesta parte, descrevemos como está organizando nosso código, os primeiros arquivos de cabeçalho e classes, e como escrever testes. Este artigo também inclui notas breves sobre o desenvolvimento orientado por testes (Test-Driven Development) e sua aplicação neste projeto.
Este artigo apresenta a primeira tentativa de desenvolver um cliente MQTT nativo para o MQL5. MQTT é um protocolo de troca de dados no formato "publicador - assinante". Ele é leve, aberto, simples e projetado para ser facilmente implementado. Isso o torna aplicável em muitas situações.
Esse artigo descreve quatro métodos de conexão do código MQL5 ao banco de dados Postgres e apresenta um guia passo a passo para configurar um ambiente de desenvolvimento para um deles, a API REST, por meio do Windows Subsystem for Linux (WSL). Além disso, mostra-se um aplicativo de demonstração para a API com o código MQL5 necessário para inserir dados e consultar as respectivas tabelas, bem como um EA de demonstração para usar esses dados.