Jocimar Lopes
Jocimar Lopes
developer free worker
Jocimar Lopes
已发布文章Statistical Arbitrage Through Cointegrated Stocks (Part 9): Backtesting Portfolio Weights Updates
Statistical Arbitrage Through Cointegrated Stocks (Part 9): Backtesting Portfolio Weights Updates

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.

Jocimar Lopes
已发布文章Statistical Arbitrage Through Cointegrated Stocks (Part 8): Rolling Windows Eigenvector Comparison for Portfolio Rebalancing
Statistical Arbitrage Through Cointegrated Stocks (Part 8): Rolling Windows Eigenvector Comparison for Portfolio Rebalancing

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.

2
Chacha Ian Maroa
Chacha Ian Maroa 2025.12.05
Great article
Jocimar Lopes
已发布文章Statistical Arbitrage Through Cointegrated Stocks (Part 7): Scoring System 2
Statistical Arbitrage Through Cointegrated Stocks (Part 7): Scoring System 2

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.

3
Jocimar Lopes
已发布文章Statistical Arbitrage Through Cointegrated Stocks (Part 6): Scoring System
Statistical Arbitrage Through Cointegrated Stocks (Part 6): Scoring System

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.

2
Jocimar Lopes
已发布文章Statistical Arbitrage Through Cointegrated Stocks (Part 5): Screening
Statistical Arbitrage Through Cointegrated Stocks (Part 5): Screening

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.

2
Jocimar Lopes
已发布文章Statistical Arbitrage Through Cointegrated Stocks (Part 4): Real-time Model Updating
Statistical Arbitrage Through Cointegrated Stocks (Part 4): Real-time Model Updating

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.

1
Jocimar Lopes
已发布文章Statistical Arbitrage Through Cointegrated Stocks (Part 3): Database Setup
Statistical Arbitrage Through Cointegrated Stocks (Part 3): Database Setup

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.

1
Jocimar Lopes
已发布文章Statistical Arbitrage Through Cointegrated Stocks (Part 2): Expert Advisor, Backtests, and Optimization
Statistical Arbitrage Through Cointegrated Stocks (Part 2): Expert Advisor, Backtests, and Optimization

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.

1
Jocimar Lopes
已发布文章Statistical Arbitrage Through Cointegrated Stocks (Part 1): Engle-Granger and Johansen Cointegration Tests
Statistical Arbitrage Through Cointegrated Stocks (Part 1): Engle-Granger and Johansen Cointegration Tests

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.

1
Jocimar Lopes
已发布文章通过配对交易中的均值回归进行统计套利:用数学战胜市场
通过配对交易中的均值回归进行统计套利:用数学战胜市场

本文描述了投资组合层面的统计套利基础知识。其目标是帮助没有深厚数学知识的读者理解统计套利的原则,并提出一个概念性的起点框架。文章包含一个可运行的智能交易系统(EA)、一些关于其一年回测的笔记,以及用于复现实验的相应回测配置设置(.ini 文件)。

Ishtiaq Ahmad
Ishtiaq Ahmad 2025.04.11
Mystery solved. 😊😊😊
Jocimar Lopes
已发布文章为 MetaTrader 5 开发 MQTT 客户端:TDD 方法 - 最终篇
为 MetaTrader 5 开发 MQTT 客户端:TDD 方法 - 最终篇

本文是介绍我们针对 MQTT 5.0 协议的本机 MQL5 客户端的开发步骤系列文章的最后一部分。尽管该库尚未投入实际使用,但在此部分中,我们将使用我们的客户端来更新来自另一个经纪商的报价(或利率)的自定义交易品种。请参阅本文底部以获取有关该库的当前状态的更多信息、它与 MQTT 5.0 协议完全兼容所缺少的内容、可能的路线图以及如何关注和促进其发展。

Jocimar Lopes
已发布文章为 Metatrader 5 开发 MQTT 客户端:TDD 方法 - 第 6 部分
为 Metatrader 5 开发 MQTT 客户端:TDD 方法 - 第 6 部分

本文是介绍我们针对 MQTT 5.0 协议的本地 MQL5 客户端的开发步骤的系列文章的第六部分。在本部分中,我们会讨论我们第一次重构中的主要变化,我们如何为我们的数据包构建类得出可行的蓝图,我们如何构建 PUBLISH 和 PUBACK 数据包,以及 PUBACK 原因代码背后的语义。

Jocimar Lopes
已发布文章为 Metatrader 5 开发 MQTT 客户端:TDD 方法 - 第 5 部分
为 Metatrader 5 开发 MQTT 客户端:TDD 方法 - 第 5 部分

本文是系列文章的第五部分,介绍了我们为 MQTT 5.0 协议开发本地 MQL5 客户端的步骤。在这一部分中,我们将介绍 PUBLISH 数据包的结构、如何设置其发布标志(Publish Flag)、如何对主题名称(Topic Name)字符串进行编码,以及在需要时如何设置数据包标识符(Packet Identifier)。

Jocimar Lopes
已发布文章为 Metatrader 5 开发MQTT客户端:TDD方法——第4部分
为 Metatrader 5 开发MQTT客户端:TDD方法——第4部分

本文是一系列文章的第四部分,介绍了我们为 MQTT 协议开发本机 MQL5 客户端的步骤。在这一部分中,我们将描述什么是 MQTT v5.0 属性,它们的语义,以及我们如何阅读其中的一些属性,并提供一个如何使用属性来扩展协议的简短示例。

Jocimar Lopes
已发布文章为 MetaTrader 5 开发MQTT客户端:TDD方法——第3部分
为 MetaTrader 5 开发MQTT客户端:TDD方法——第3部分

本文是一系列文章的第三部分,介绍了我们为MQTT协议开发本机MQL5客户端的步骤。在这一部分中,我们详细描述了如何使用测试驱动开发来实现CONNECT/CONNACK数据包交换的操作行为部分。在这一步骤结束时,我们的客户端必须能够在处理连接尝试可能产生的任何服务器结果时表现得正常。

Jocimar Lopes
已发布文章为 MetaTrader 5 开发一款 MQTT 客户端:TDD 方式 - 第2部分
为 MetaTrader 5 开发一款 MQTT 客户端:TDD 方式 - 第2部分

本文是描述 MQTT 协议的本机MQL5客户端开发步骤系列文章的一部分。在这一部分中,我们将描述我们的代码组织、第一个头文件和类,以及我们如何编写测试。本文还包括关于测试驱动开发实践以及我们如何将其应用于该项目的简要说明。

Jocimar Lopes
已发布文章为 MetaTrader 5 开发一款 MQTT 客户端:TDD 方式
为 MetaTrader 5 开发一款 MQTT 客户端:TDD 方式

本文汇报为 MQL5 开发原生 MQTT 客户端的首次尝试。MQTT 是一种客户端-服务器之间发布/订阅消息的传输协议。它轻巧、开放、简单,并且易于实施。这些特性令其非常适合在多种情况下使用。

Jocimar Lopes
已发布文章如何将 MetaTrader 5 与 PostgreSQL 连接
如何将 MetaTrader 5 与 PostgreSQL 连接

本文讲述了将 MQL5 代码与 Postgres 数据库连接的四种方法,并提供了一个分步教程,指导如何使用 Windows 子系统 Linux (WSL) 为 REST API 设置一个开发环境。 所提供 API 的演示应用程序,配以插入数据并查询相应数据表的 MQL5 代码,以及消化此数据的演示智能系统。

· 2 1089
Jocimar Lopes
已在MQL5.community注册