A Real Pairs Trading Strategy
Breaking down a profitable strategy I built a couple years ago
Introduction
In this article, we will go into detail about an equities strategy I built in 2020. This was traded live for a few months and delivered 30% returns on a 2.7 Sharpe (over about 4 months) until I stopped trading equities (crypto is more exciting).
My journey into quant started with options and volatility trading (really early days). I quickly realized I knew nothing about volatility trading and instead fell in love with the field of pairs trading. This was a field I researched for a while and even wrote papers in. The strategy we discuss today trades a portfolio of equities.
There are a few optimizations which add to the performance that I’ve left out the exact details on, but for most of them, I still cover what they achieve so readers can come up with their own ways to benefit from the ideas behind them.
General Strategy Overview
This strategy is built around multivariate pairs trading and uses the optimization approach to pairs trading. It is quite a complex strategy, but all of the alpha comes from simple and elegant ideas. This is the way to do it; the complexity of a strategy is usually inverse to alpha. You could do this very simply; it would just suck. Each idea that adds complexity has clear reasoning - we aren’t randomly slapping an LSTM on it or anything.
We generate a portfolio of assets (4-6) with some optimization objectives for the spread and portfolio characteristics. Reduce turnover with some simple methods. Repeat this step 10-30x to generate 10-30 portfolios. Use a validation technique to pick the best ones for robustness, then trade the top portfolios live.
Putting this into a list of steps:
Identify the universe of assets to trade (liquid, has short margin, and maybe even some filters for characteristics like removing meme stonks).
Generate portfolios by optimizing for an ensemble of objectives.
Sit still for a short out-of-sample “validation” period where we do not trade.
Compare the in-sample portfolios vs. validation period portfolios and ensure we didn’t overfit (ex. - ultra mean-reverting now barely mean-reverting OR stationary portfolio now drifting off into space).
Trade the selected portfolios in a 3rd and final test set using a slightly modified Bollinger Bands implementation.
Continuously monitor for the decay of statistical properties and shut down decayed portfolios.
We’ll walk through this list and the considerations in the following sections.
Universe Selection (1)
This part starts with the basics - what assets are not going to cause issues. We want assets with a decent amount of liquidity and availability of short margin. That’s the first step, and it usually just means we trade only S&P500 stocks because margin availability is like a $250,000 dataset.
After this, we run into an issue with universe size. 500 assets are far too many to optimize over because we’ll overfit, so we shrink it down. Our universe size is actually a parameter for the strategy and has a pretty big impact on results. This should be informed by the timeframe of mean-reversion we want to capture.
Longer-term pairs trading warrants a smaller universe as there is a higher risk of overfitting, and inversely shorter-term pairs trading lets us have larger universes as we look for more transitory relationships than robust ones. Hence we fit more.
My previous articles on pairs trading have explored this and used real data to show it happening in practice. Feel free to check them out.
As a related component to universe selection, we also need to think about the size of our train, validation, and test periods in terms of samples. I can give the same algorithm hourly data and daily data, and I’ll get different results even if the length of the train, validation, and test periods are the same in terms of time. Sampling less frequently removes noise, and as a rule of thumb, there is more noise per data point as we go down timeframes.
When we are doing short-term pairs trading, we need more samples due to the higher noise per sample. With long-term pairs trading, this just adds noise and confuses our optimization algorithm with relationships that are significant but transitory. With short-term pairs trading, we can just use validation to know when the portfolio has decayed and take advantage of these transitory relationships, whereas long-term pairs trading does not capture these relationships because they’re gone by the time we get to the test set. The data agrees with this observation of optimal sample sizes when you test it out - the more you do, the more intuition you build.
The universe can be randomly split into equal slices of a certain size, but there are smarter ways to do things. I won’t cover the exact details, but here are some pointers:
Clustering algorithms (DBSCAN recommended) based on:
Factor exposures
Fundamentals
Time series characteristics (Hurst, volatility, mkt cap adj. volume, etc.)
Maximize similarity (correlation and the mix) as an objective using a greedy algorithm to shrink 500 → 50 (arbitrary example).
Group by industry
Top/bottom XX by some characteristic (use the metrics above in 1c).
Group by beta to things like political polls or exposure to macroeconomic variables (ex. CPI)
Depending on the level of optimization done to create the universe, 20-70 is optimal for this strategy. 50-70 being no optimization (randomly split into buckets). 20-30 being a fair bit of optimization in our universe selection. Play around with it and see what feels right.
I’ve given a few ideas, and there is not a specific one that is the correct option. Test them, see what works, and ensemble the versions that work for maximum diversification points.
Optimization Objectives (2a)
We have primary and secondary objectives. Our primary objectives capture what makes us money, and our secondary objectives capture what loses us money.
Mean-reversion makes us money. Simple as that. Here are our metrics:
Hurst
Portmanteau
VAR(1) Predictability
Crossing Statistic
SNVR