Lessons/Statistical Arbitrage
Quant Investing · Lesson 5 of 5

Statistical Arbitrage

Pairs trading and the mathematics of mean reversion · 17 min

What Is Statistical Arbitrage?

Statistical arbitrage (stat arb) is a family of strategies that exploit statistical relationships between asset prices — rather than fundamental value or macroeconomic views. Unlike pure arbitrage (which exploits risk-free mispricings), stat arb involves statistical regularities that are highly likely but not guaranteed to hold.

The most famous stat arb strategy is pairs trading, popularized by Morgan Stanley's quant group in the 1980s. The idea: find two stocks whose prices historically move together (high correlation). When they diverge unusually far, bet on the spread returning to its historical mean.

The Pairs Trading Mechanics

Consider Coca-Cola (KO) and PepsiCo (PEP). They're both consumer staples, compete in the same market, have similar business profiles, and their stock prices tend to move together. If KO suddenly jumps 5% while PEP stays flat (for no apparent fundamental reason), a pairs trader would:

  1. Short KO (bet it falls back toward its historical relationship with PEP)
  2. Long PEP (bet it rises toward KO, or at least doesn't fall)

The position is hedged against market direction — if the whole market sells off, both stocks fall, and the long-short position stays approximately flat. Profit comes only from the KO-PEP spread reverting.

Finding Cointegrated Pairs

Two price series that move together in the long run are called cointegrated. Cointegration is stronger than correlation: two series can be highly correlated yet drift apart indefinitely. Cointegration implies they share a common stochastic trend — they can diverge temporarily but must revert.

Mathematically: if P₁ and P₂ are cointegrated with coefficient β, then the spread:

S = P₁ − β × P₂

is stationary — it has a stable long-run mean and variance. Stationarity is detectable with the Augmented Dickey-Fuller (ADF) test.

Step to find β (the hedge ratio): regress P₁ on P₂ using OLS. The slope coefficient is β. This tells you how many shares of P₂ to hold for each share of P₁ to make the spread stationary.

Trading the Spread

Once you have a cointegrated pair and a stationary spread S with mean μ_S and standard deviation σ_S:

z-score = (S − μ_S) / σ_S
  • When z-score > +2: spread is unusually wide → sell P₁, buy P₂ (short the spread)
  • When z-score < −2: spread is unusually narrow → buy P₁, sell P₂ (long the spread)
  • When z-score → 0: spread has mean-reverted → close position

The ±2 sigma threshold is a common choice, but optimal thresholds depend on the speed of reversion, transaction costs, and signal half-life.

Risks and Limitations

Relationship breakdown: Pairs can stop cointegrating. Coke and Pepsi move together because they compete in the same market — but if Coke acquires a tech company and pivots its strategy, the relationship breaks permanently. No statistical test can tell you in advance if today's divergence is a temporary blip or a regime change.

Crowding: When many funds run the same pairs trade, the positions unwind simultaneously when markets stress. The August 2007 "quant quake" was exactly this: dozens of stat arb funds holding similar pairs all began unwinding simultaneously, causing cascading losses across strategies that had never lost money historically.

Execution: Requires simultaneously entering both legs. Any delay between legs creates gap risk — the spread might move further before the second leg executes.

Borrow availability: Short selling requires borrowing shares. For popular short targets, borrow costs can be substantial and eat into returns.

Knowledge Check
Q1 of 3
Two stocks are said to be 'cointegrated' if:
Q2 of 3
In pairs trading, when the spread z-score rises above +2 standard deviations, you:
Q3 of 3
The August 2007 'quant quake' illustrated the risk of:
Coding ExercisePython · runs in browser
+100 XP
Implement `compute_spread`, `zscore`, and `pairs_trade_signals`.
Write your solution, then run