How markets actually work

Correlation vs cointegration

M2 — Quantitative finance fundamentals

Pairs trading rests on one claim: two assets have wandered apart, and they will come back together. Everything hangs on whether that second half is true — and the statistic most people reach for to check it cannot answer the question at all.

The trap, quantified

Take two random walks that are completely independent. No shared factor, no relationship of any kind — one is not informative about the other in any way. Simulate 500 steps, 2,000 times, and measure how correlated they look:

   two INDEPENDENT random walks, 500 steps, 2,000 trials

                        median |corr|    P(|corr| > 0.5)   P(|corr| > 0.8)
   ───────────────────────────────────────────────────────────────────────
   correlation of
   LEVELS  (prices)         0.43              41%                7%
   correlation of
   RETURNS (changes)        0.03               0%                —

Two unrelated series show a level-correlation above 0.5 more than 40% of the time, and above 0.8 in one case in fourteen. Screen a few thousand pairs on price correlation and you will find hundreds of beautiful, utterly meaningless relationships.

This is the spurious regression problem (Granger & Newbold, 1974). It happens because correlation assumes stationary data, and prices are not stationary — they wander. Two independent wanderers will, by chance, often wander in vaguely similar directions over any finite window, and the correlation statistic dutifully reports that as a relationship.

Notice the second row is fine. Returns are roughly stationary, and their correlation behaves — 0.03, as it should for independent series. So the first rule is simply: never compute a correlation on prices. If you must use correlation, use it on returns.

But even that doesn't get you what a pairs trade needs.

Two different claims

   CORRELATION (of returns)          COINTEGRATION (of levels)
   ─────────────────────────────────────────────────────────────────────
   "they move together day to day"   "they cannot drift apart forever"
   short-run co-movement             long-run equilibrium
   memoryless — says nothing         has memory — says the GAP is
   about the accumulated gap         mean-reverting
   ─────────────────────────────────────────────────────────────────────
   supports:  hedging, risk models   supports:  mean-reversion trading

The two are genuinely independent properties, and both off-diagonal cases are real:

Highly correlated, not cointegrated. Two tech stocks whose daily returns correlate at 0.9, but one compounds at 15% a year and the other at 5%. They move together and separate permanently. Trade the spread and you are short a trend — you will fade a divergence that never closes, adding to the loser all the way down. This is the classic way pairs traders are destroyed, and correlation gave no warning.

Cointegrated, weakly correlated. A stock and its own convertible bond, or a commodity and a producer of it. Daily returns can be noisy and only loosely related, while the levels are bound by an arbitrage or an economic identity that reliably reasserts itself.

Only the second is tradeable as mean reversion. Correlation is the wrong instrument, measured on the wrong quantity, answering a different question.

Cointegration, stated properly

   x and y are each I(1)        — non-stationary; their DIFFERENCES are
                                  stationary (i.e. random-walk-like prices)

   they COINTEGRATE if there exists β such that

            s  =  y − βx        is I(0)  — stationary

   β is the HEDGE RATIO, s is the SPREAD

So cointegration says: the individual series wander without bound, but this particular combination of them does not. There is an equilibrium, and deviations from it are temporary. That is exactly the statement a mean-reversion trade needs, and it is a statement about levels, which is why correlation could never have supplied it.

Two standard tests:

  • Engle–Granger, two steps: regress y on x by OLS to get β̂, then run an ADF (augmented Dickey–Fuller) test for a unit root on the residual. Reject the unit root → the spread is stationary → cointegrated. One trap: because β was estimated, the usual ADF critical values are wrong and too generous — use the Engle–Granger critical values instead. Skipping this is a common way to find cointegration that isn't there.
  • Johansen, for three or more series at once, which also handles the case of several independent cointegrating relationships. Necessary for baskets; overkill for a pair.

Half-life — the number that decides the trade

Knowing the spread reverts is not enough. You need to know how fast, because that determines everything downstream. Model the spread as Ornstein–Uhlenbeck:

   ds  =  θ(μ − s)dt  +  σ dW           θ = speed of reversion

   estimate by regressing the CHANGE on the LEVEL:

        Δsₜ  =  a  +  b·sₜ₋₁ + ε        with   θ = −b

                             ln 2
        half-life  =  ────────────────
                            −b

If b is not significantly negative, there is no reversion to trade — the regression itself is a cointegration check.

Half-life is the single most operationally useful number in the whole exercise:

   half-life        what it implies
   ──────────────────────────────────────────────────────────────────
   minutes          you are in M1.6 territory. Latency and queue
                    position decide whether you exist. Costs are
                    paid hundreds of times a day.
   days to weeks    tractable. Hold for roughly a half-life or two;
                    costs are amortised over a meaningful move.
   many months      the statistics are hopeless — a 6-month half-life
                    gives you a handful of independent observations
                    per decade, so you cannot tell the edge from zero
                    (M2.1's standard error).

It also sets your cost budget, which is the link back to M1. A spread with a two-week half-life is crossed a few times a month; one with a two-hour half-life is crossed hundreds of times, and pays spread and impact on every crossing. The same statistical edge is a business at one speed and a donation at the other.

The risk nobody models

Cointegration is an empirical regularity, not a law of nature. The relationship exists because of something real — a shared input cost, a substitution effect, a corporate structure — and that something can change.

   what breaks a cointegrating relationship
   ─────────────────────────────────────────────────────────
   a merger, spin-off, or capital restructuring
   a regulatory change hitting one side only
   a genuine divergence in business model or margins
   the trade becoming crowded, then unwinding at once

The failure mode is cruel by construction. A structural break looks identical to an unusually good entry — the spread is further from its mean than it has ever been, so your z-score is screaming, so you size up. The signal is loudest exactly when it is wrong.

Which is why a pairs trade needs a risk rule that does not come from the signal: a stop on the spread, a maximum holding period of a few half-lives, and a periodic re-test of the cointegration itself on recent data. M2.6 puts all of that together.

Source: Ernie Chan, Algorithmic Trading, ch.2–3 for the practical treatment including half-life. Granger & Newbold (1974), “Spurious regressions in econometrics”, is short and worth reading for the simulation above. Engle & Granger (1987) for the test; any decent time-series text for Johansen.