Skip to main content

Data and machine learning · 13 min read

Pairs trading and cointegration

Betting that two related prices come back together: cointegration, the half-life of a spread, and why correlation isn't enough.

Before you start

  • Random walks and Brownian motion
  • Backtesting without look-ahead bias (this track)

By the end you'll be able to

  • Explain the difference between correlation and cointegration
  • Estimate a hedge ratio and the half-life of a spread
  • Backtest a z-score pairs strategy without look-ahead
  • Explain why cointegration tests need Dickey–Fuller critical values

Two companies in the same business often move together: two oil producers, two banks, a stock and its index. Pairs trading bets that when they drift apart, they will come back together: buy the one that fell behind, short the one that ran ahead. The idea is sound only when the link between them is real, and telling a real link from a coincidence is what this lesson is about.

Symbol / termMeaning
xtx_t, yty_tLog prices of the two assets
β\betaThe hedge ratio: units of xx shorted per unit of yy held
sts_tThe spread, yt−βxt−αy_t - \beta x_t - \alpha
cointegratedTwo series that wander, but whose spread is stable and keeps reverting
half-lifeDays for a deviation of the spread to shrink by half
zz-scoreThe spread minus its mean, in standard deviations

The rest of this lesson needs lifetime access

It will be part of lifetime access, which is coming soon: every lesson in all four tracks, including lessons added later, for one payment.

See pricing

Already have access? Sign in