Discussing the article: "Statistical Arbitrage Through Cointegrated Stocks (Part 4): Real-time Model Updating"

 

Check out the new article: 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.

It’s time to start updating our cointegration model in real-time. More specifically, it’s time to start updating the relative weight of each stock in our trading portfolio with the more recent calculations, while the Expert Advisor is running. Until now, we have been using the same portfolio weights in our explanations and backtests. They were useful as a simplification to ease the understanding of the process and the meaning and workings of the underlying statistical tests. But in real life, these portfolio weights are changing practically every time a new data point arrives, that is, at each new closed bar, in our case.

But first, a bit of context, a quick recap to make sure we are all on the same page.

We are developing a kind of poor man’s statistical arbitrage framework - a stat arb pipeline designed for the average retail trader, with a consumer notebook, and a regular network bandwidth. Here, in this series of articles, we are documenting and describing the statistical tests used for finding highly correlated assets for pairs trading, cointegrated stocks for portfolio building, and also the tests used for assessing the stationarity of their relative spreads, which is required for mean reversion strategies like ours.

Author: Jocimar Lopes