Pairs trading & cointegration
≈commoditisedThe simplest stat arb: find two cointegrated names, and when their spread diverges, short the rich and buy the cheap, betting on reversion. The z-score triggers entry and exit. Competed away in liquid equities; a clean teaching case everywhere.
See it move
What to notice. The spread between two cointegrated names is stationary: it wanders but reverts. Trade it when it's stretched past ±2.0σ and exit at the mean. Tighten the threshold for more round-trips and more cost; widen it for fewer, cleaner ones.
What is a pairs trade?
A pairs trade is a market-neutral position: long one instrument, short a related one, sized so the combination is a mean-reverting spread. You profit when the spread closes, whichever way the market moves. It is the simplest and best-known case of statistical arbitrage.
Pick two names that move together for a real reason, such as two airlines, two payment networks, or an ETF and a near-substitute. When one drifts cheap against the other with no fundamental cause, you buy the cheap one and short the rich one, then unwind when they converge. Because you are long and short, a market-wide move cancels. Only the relative move matters.
The position is unit of A and units of B, where is the hedge ratio that makes the combination market-neutral and the spread stationary. Gatev, Goetzmann and Rouwenhorst (2006) trace the practice to Nunzio Tartaglia's quantitative group at Morgan Stanley in the mid-1980s. They report that the group made about $50 million in 1987 and was disbanded in 1989 after a couple of poor years. Their own test used daily US data from 1962 to 2002 and a simple distance rule: match stocks whose normalised prices move closely together, open a pair when the gap reaches two historical standard deviations, close it when the prices next cross. Top pairs earned average annualised excess returns of up to 11%, above conservative estimates of transaction costs.
Correlation is not enough: you need cointegration
Correlation tells you whether two series move together period to period, and it can be high by coincidence with nothing pulling the prices back together. Cointegration is stronger: a linear combination of the two price levels is stationary, with a fixed mean it reverts to. Only a stationary spread is reliably mean-reverting, so that is what a pairs trade needs.
The trap is the spurious regression. Granger and Newbold (1974) showed that if you regress one random walk on a completely unrelated one, you will often get a high R² and a "significant" slope. Trade the residual as if it were a spread and you are trading noise that drifts off and never returns. Correlation of returns says nothing about whether the price levels stay tethered.
Engle and Granger (1987) gave the standard definition. Two non-stationary series , (each a random walk, integrated of order one, ) are cointegrated if some combination is stationary (). That stationary combination is the tradable spread. The economic picture is a shared stochastic trend plus a mean-reverting deviation. Note that Gatev et al. did not use cointegration; their distance method is a separate, simpler way to pick pairs.
The simplest test is the Engle–Granger two-step. First, estimate the relationship by OLS: regress on to get the hedge ratio and the residual . Second, run an Augmented Dickey–Fuller (ADF) test on that residual. If you reject the unit-root null, the residual is stationary and is your spread. Three limits apply. The test is in-sample and direction-dependent, since regressing A on B gives a slightly different from B on A. Johansen (1988) extends cointegration testing to more than two series and treats them symmetrically, which is what you need for baskets. And multiple testing bites hard: scan 5,000 pairs at and about 250 will pass by chance. Re-validate out of sample and insist on an economic reason the pair should be tied together (see backtesting & simulation).
▸ Show the derivation: Engle–Granger and the stationary spread optional
Let each price be a random walk with a unit root, so the change is stationary but the level is not. They are cointegrated if a weighting makes the residual stationary.
The Granger representation theorem, proved in Engle and Granger (1987), then guarantees an error-correction model: when the spread is positive (A rich), A's expected change is negative, pulling the spread back. The negative loading on last period's spread is the mathematical statement of "the spread reverts".
Step 1 estimates by OLS, super-consistent under cointegration. Step 2 runs ADF on the estimated residual: regress its change on its lag plus lagged differences, and test the unit-root null against a negative root.
Use the Engle–Granger critical values rather than the standard ADF ones. The residual is estimated, which shifts the distribution of the test statistic, and the standard values would make you reject the null too readily and accept spurious pairs.
The spread, the hedge ratio and the z-score: entry and exit
You standardise the spread into a z-score, the number of standard deviations it sits from its rolling mean, enter when is large and exit as returns toward zero. The z-score makes "how mispriced" comparable across pairs and across time.
The hedge ratio is the OLS slope from the cointegrating regression: how many units of B offset one unit of A. Re-estimate it on a rolling basis. A drifting is an early warning that the relationship is changing under you.
The rules follow directly. Short the spread (sell A, buy units of B) when , say , which is the same two-deviation trigger Gatev et al. used. Go long the spread (buy A, sell units of B) when . Exit when crosses , often zero and sometimes . Stop out when , say 3 to 4, because a spread that keeps widening is not reverting and you want to be out before it becomes a regime break.
Avellaneda and Lee (2010) test a variant on US equities: they model each stock's residual against a factor model as a mean-reverting process, convert it to an "s-score", open at an absolute score above 1.25, and close longs at −0.50 and shorts at 0.75. They estimate over a 60-day window, keep only names whose reversion time is under half that window, and charge 5 basis points a trade. The point for any design is the same: asymmetric bands and a cost assumption belong in the rules from the start.
The threshold trade-off is the core of the design. A wide entry band () gives fewer, larger trades and longer holds. A narrow band () gives more, smaller trades that struggle to clear costs. The best choice depends on the half-life, the spread volatility and the round-trip cost on both legs. Push down to chase more trades and net P&L falls once costs bite, as the worked example shows.
The half-life: how fast does the spread revert? (Ornstein–Uhlenbeck)
The half-life is the expected time for a deviation to shrink by half, and it sets your holding period and your capital turnover. Model the spread as an Ornstein–Uhlenbeck process, fit its speed , and the half-life is . Elliott, van der Hoek and Malcolm (2005) use this kind of mean-reverting model, observed with noise, as the standard academic treatment of the pairs spread. A half-life of hours means fast turnover. A half-life of weeks means slow turnover and more exposure to a break.
Fitting it takes one regression. Discretise the process to AR(1) form, , and then and . A more negative means faster reversion. This is the same regression as the ADF test: stationarity and reversion speed are two readings of one fit. The half-life gates profitability because you get roughly one independent bet per half-life, and each round trip captures about one spread standard deviation. A 3-day half-life on a spread whose sigma clears costs is tradable. A 6-week half-life gives about eight bets a year (52 divided by 6 is 8.7) and a long exposure to the relationship breaking mid-trade.
▸ Show the derivation: OU half-life from the discrete fit optional
The OU SDE has an exact discrete solution: the next value is a weighted blend of the long-run mean and the current value, with the weight on the current value an exponential decay, plus mean-zero noise.
Match this to the AR(1) regression . The autoregressive coefficient is exactly the decay factor, so the speed falls straight out as a log.
A deviation decays as ; set that equal to one half and solve for the half-life. In practice fit the difference form (so ); for small , the speed is approximately .
What kills a pairs trade? Regime break, crowding and costs
Three things: a regime break, crowding, and costs. The first is sudden, the second gradual, and the third is always present. Together they explain why relative-value P&L is negatively skewed, with many small wins and an occasional large loss.
Regime break is the tail risk. Cointegration is an estimated, historical property, not a law. When the economic link changes (one airline is acquired, a payment network loses a partner, an index reconstitutes), the spread that always reverted starts to trend, and the z-score keeps signalling "enter" while you lose money. A hard stop, a rolling re-test of cointegration, and position sizes that survive the spread not reverting are all mandatory.
Crowding and rising risk shrink the edge. Do and Faff (2010) extended the Gatev et al. test to June 2009. The mean monthly excess return of the top 20 pairs fell from 0.86% in 1962–1988 to 0.37% in 1989–2002 and 0.24% in 2003–2009. They attribute up to 70% of the decline to rising arbitrage risks rather than competition alone, and the strategy still did well in the 2000–02 bear market and the 2007–09 crisis. So the simple distance trade has shrunk to a fraction of its early returns without disappearing. Capital arbitrages deviations faster and smaller (see capacity & alpha decay), until the gross gap no longer clears costs.
Costs are paid four times. Every trade pays the spread, fees and market impact on two legs, in and out, and shorting adds borrow cost and recall risk. A spread that looks profitable gross is routinely unprofitable net, so model costs first rather than last.
The canonical crowding event is the August 2007 "quant quake". Khandani and Lo (2011) document two unwinds of equity market-neutral positions, on 1 August 2007 (10:45 to 11:30) and from the open on 6 August to 1:00pm, with losses concentrated in the week of 6 August. Many supposedly diversified portfolios lost together within days. Your real risk is not a single pair but the population of traders holding your pairs.
Worked example
A pairs trade on a cointegrated pair, using illustrative numbers. The cointegrating regression gives hedge ratio and intercept near zero, so the spread is . Over the 60-day fit window the spread has mean and standard deviation . The AR(1) fit gives per day, so per day and the half-life is days. The exact discrete value is ln(0.5) / ln(0.77), about 2.7 days, so the small-b approximation overstates it slightly. Rules: enter at , exit at , stop at .
The good trade. The spread widens to , so . You sell 1 A and buy 0.8 B, shorting the spread. On average the gap halves in about three days, and in this case it snaps back to () within that time and you unwind. Gross is per unit of spread, market-neutral throughout.
The bad case. Instead of reverting, the spread widens to () and the stop fires for a loss of about gross (1.40 less 0.80) plus costs. A re-test shows the ADF residual is no longer stationary: the relationship broke after a corporate action on B. The correct response is to stop trading the pair, not to average down. Adding to a broken spread is how a small loss becomes a blow-up. The IX-COINT explorer above lets you set , , the reversion speed and the z-bands and read off the half-life and net P&L. Real hedge ratios, volatilities, half-lives and costs have to be measured pair by pair.
Sources
- Gatev, E., Goetzmann, W. N. and Rouwenhorst, K. G. (2006). "Pairs trading: Performance of a relative-value arbitrage rule". Review of Financial Studies 19(3), 797–827. doi.org/10.1093/rfs/hhj020
- Do, B. and Faff, R. (2010). "Does simple pairs trading still work?". Financial Analysts Journal 66(4), 83–95. doi.org/10.2469/faj.v66.n4.1
- Engle, R. F. and Granger, C. W. J. (1987). "Co-integration and error correction: Representation, estimation, and testing". Econometrica 55(2), 251–276. doi.org/10.2307/1913236
- Granger, C. W. J. and Newbold, P. (1974). "Spurious regressions in econometrics". Journal of Econometrics 2(2), 111–120. doi.org/10.1016/0304-4076(74)90034-7
- Johansen, S. (1988). "Statistical analysis of cointegration vectors". Journal of Economic Dynamics and Control 12(2–3), 231–254. doi.org/10.1016/0165-1889(88)90041-3
- Elliott, R. J., van der Hoek, J. and Malcolm, W. P. (2005). "Pairs trading". Quantitative Finance 5(3), 271–276. doi.org/10.1080/14697680500149370
- Avellaneda, M. and Lee, J.-H. (2010). "Statistical arbitrage in the US equities market". Quantitative Finance 10(7), 761–782. doi.org/10.1080/14697680903124632
- Khandani, A. E. and Lo, A. W. (2011). "What happened to the quants in August 2007? Evidence from factors and transactions data". Journal of Financial Markets 14(1), 1–46. doi.org/10.1016/j.finmar.2010.07.005