← All lessons

Cointegration basics

Tell a reverting series from a trending one · 9 min

ProGoal: Tell a reverting series from a trending oneBefore this: PairsFurther reading: Chan, Algorithmic Trading
Three unlabeled series
0.851.592.320499
  • Series A
  • Series B
  • Series C

One trends, one reverts, one is a random walk. Can you tell by eye?

Predict first

Two random walks are built to share most of their daily moves: their return correlation is 0.9. Will the spread between them revert to a mean?

A series reverts if it is pulled back toward a level. The simplest test regresses each day's change on the previous day's level: a clearly negative slope means a pull back.

Δyₜ = a + b × yₜ₋₁ + noise (Dickey–Fuller regression)
half-life = ln 2 ÷ −ln(1 + b) · reverting if the t-statistic of b is below about −2.86

A second check is the variance ratio: the variance of 10-day returns divided by 10 times the variance of 1-day returns. About 1 for a random walk, below 1 when moves reverse, above 1 when they continue. Two series are cointegrated when some mix of them (a spread) reverts even though each wanders: that is what makes a pair tradable.

Tests on a few years of data are noisy, and at the 5% level one random walk in twenty passes by chance. Testing a hundred candidate pairs and trading the five that pass is a recipe for trading noise (Track C, multiple testing).

Measure them: which is which?
0.480.821.170749
  • Series 1
  • Series 2
  • Series 3
SeriesVariance ratio (10 days)Dickey–Fuller tHalf-lifeYour call
Series 11.22-1.16284 d
Series 21.02-3.0333 d
Series 30.44-4.4614 d

Variance ratio below 1: moves tend to reverse. Above 1: they tend to continue. A Dickey–Fuller t below −2.86 rejects a random walk at the 5% level. Three years of data is not much, so the tests can disagree.

Correlated is not cointegrated: two random walks built to share most of their daily moves have a return correlation of 0.73, yet the spread between them has a Dickey–Fuller t of -0.25: it wanders off and never has to come back.

Generated markets, not real data. They show how a rule depends on the market it meets; they do not predict how real markets behave.

Worked calculation

Half-life from a regression slope

Regression slope b
−0.08 per day
Share of the gap kept each day
1 − 0.08 = 0.92
Half-life
ln 2 ÷ −ln 0.92 = 0.693 ÷ 0.0834 = 8.3 days
After 2 half-lives
a quarter of the gap is left
Check yourself
3 questions

Two stocks have daily returns correlated 0.85, but their spread has a Dickey–Fuller t of −1.1. What do you conclude?

A series has a 10-day variance ratio of 0.62 and a Dickey–Fuller t of −3.4. What is it most likely?

A spread closes 25% of its gap to the mean each day (b = −0.25). What is its half-life?

Missed questions come back for review after one day, then three, then a week.

Practice

A spread closes 10% of its distance to the mean each day (regression slope b = -0.1). What is the half-life of a deviation, in days?

Hint: Each day keeps (1 + b) of the deviation. Half-life = ln 2 ÷ −ln(1 + b).

More in Drills →

Closing round

Three years of a fresh generated market are on screen; the next two years do not exist yet. Tune the rule on what you can see, commit to two predictions, then generate the future.

0.98×1.09×1.19×0625
  • Your rule so far
Sharpe before split0.32
Return before split7.1%
Max drawdown before-10.2%
Dickey–Fuller t (log price)-1.52

Over the next two years, after costs, this rule will…

What kind of market is this?

Generated markets, not real data. They show how a rule depends on the market it meets; they do not predict how real markets behave.