Pairs Trading with Cointegration Tests and Z-Score Signals
Summary
The document outlines a daily pairs-trading strategy for related equities, implemented in R and illustrated with Johannesburg Stock Exchange shares. It selects similar companies, calculates a price ratio as the spread, estimates its mean and standard deviation, and uses the resulting z-score for entry and exit signals. Augmented Dickey-Fuller tests over several lookback windows screen pairs for cointegration before signals are acted on. The project also describes transaction tracking, slippage, return calculations, and portfolio reporting, including drawdowns and Sharpe ratios.
Backtests cover same-asset dual listings as a form of arbitrage and sector-based portfolios. The reported results vary by pair and period; the author observes weaker returns later in the sample and says higher slippage can quickly erode profits. The approach is explicitly not risk-free: spreads can trend instead of reverting. The author also flags limited pair availability, sensitivity to parameters, end-of-day data, and a prototype implementation that needs improvement. Reported tests and performance are historical and do not establish future profitability.
Key ideas
- The strategy measures relative prices with a pair ratio and treats deviations from its historical mean as potential mean-reversion signals.
- Cointegration screening uses Augmented Dickey-Fuller tests across multiple observation windows.
- Z-score thresholds determine when to open and close paired positions, subject to passing the cointegration tests.
- Slippage, leverage, and the period tested materially affect reported returns and drawdowns.
- A spread can keep trending, so pairs trading carries risk and requires further validation.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.