Quant500 Academy

5. Cointegration: the formal basis behind pairs trading

Level 5: Time series: why the past does not repeat itself the same way

Two companies from the same sector, same business, same customers, same regulatory risks. It looks like the obvious pair to trade together.

It may not be one at all. And there is a specific statistical test that decides the matter, far better than sectoral intuition.

From intuition to a formal concept

In the market theory course you saw pairs trading intuitively. You look for two assets whose price tends to move together in a stable way, and when the difference between the two departs from the usual, you bet that it will converge again.

This module gives that idea its formal statistical basis, and the central concept underpinning it is cointegration.

Two wanderers that never separate

The starting point is something that may seem paradoxical at first sight.

Two price series can each be, separately, non-stationary. That is, they can behave like random walks that drift away without limit from any fixed level, just as you saw in module 2.

And yet a specific combination of the two may be stationary.

Concretely, take the price of asset A and subtract from it a certain amount of the price of asset B multiplied by a fixed coefficient, called the hedge ratio. It is possible for that combination, called the spread, to oscillate stably around a constant level instead of drifting away without limit.

When that happens, A and B are said to be cointegrated. Cointegration is, in essence, the formal statistical assertion that a long-term equilibrium relationship exists between the price levels of two assets, even though each one individually wanders with no fixed course.

Cointegration is not correlation

It is essential to distinguish cointegration from simple correlation, because they are easily confused and they measure different things:

The two uncomfortable combinations are the ones to keep in mind:

In practice both properties usually go hand in hand when there is a real economic reason behind them, such as two companies from the same sector exposed to the same fundamental factors.

But they are not interchangeable, nor does one automatically imply the other, and confusing them is a frequent error when selecting candidates for pairs trading.

The arithmetic of two spreads

A numerical example clarifies the difference between a pair that works and one that does not.

Imagine the spread between two drinks manufacturers from the same sector, computed as the price of A minus 1.2 times the price of B, oscillating over several years between -5 and +5 around a mean of 0, with no underlying trend. It rises, it falls, it comes back to the center, again and again.

That behavior — oscillating within bounds around a fixed level — is the visual signature of a stationary series, and it suggests that the pair is a reasonable candidate for a spread reversion strategy.

Compare it now with another pair of companies from sectors with no relationship at all between them. Their spread over the same period goes from 0 to 40 in a more or less sustained way, never returning to levels close to the origin.

That second spread behaves like one more random walk, non-stationary. And although the daily return correlation between the two companies might look reasonable at first glance, there is no evidence whatsoever of an equilibrium relationship to sustain a convergence bet.

Trading that second pair as if it were a pairs trade would be betting that something returns to a center which, statistically, never existed.

The technical requirement and the two steps

There is a technical requirement worth mentioning, if only briefly.

For two series to be able to be cointegrated, both must individually be the same type of non-stationary process. Concretely, each one must behave like a series that becomes stationary after applying one difference to it, what is known as integrated of order one.

This rules out, for example, trying to cointegrate the price level of a share with a quantity that is already stationary by nature, such as a short-term interest rate that oscillates within a bounded range: the comparison does not have the same statistical basis.

In practice this translates into a fairly common two-step procedure:

What separates a genuine pair from a coincidence

That check is not a dispensable technical detail.

It is precisely what separates a genuine pairs trading relationship from a spurious correlation of the kind you saw in module 2, where two unrelated non-stationary series could show a high correlation of levels out of pure statistical coincidence.

Cointegration is exactly the tool designed to distinguish the two cases. And the result often contradicts intuition:

When the equilibrium breaks down

Trusting sectoral intuition without statistically verifying the behavior of the spread has consequences.

It is one of the most common reasons why a pairs trading strategy that looked solid on paper starts accumulating losses when the spread, which historically reverted, instead starts drifting away without returning: the equilibrium relationship has broken down.

That risk — that a statistical relationship valid over one period stops being so later on — is the thread connecting this module with the last one of the level, on rolling windows.

The rest of Quant500

What you are learning, applied to the index every day:

The model portfolio, weekly in your inbox

Every Saturday, its week in one minute: how it went, the best and the worst, and which insiders bought with their own money. Plus, the day the model is rebuilt, which stocks come in and which go out. A simulation, not advice. At most one email a week, no ads, no account; one-click unsubscribe. Made by one person: Pol Gracia.

A model portfolio with simulated results, not a personalized recommendation. Your email is used for this only: privacy.

Behind the Academy and the rest of Quant500 there is one person: Pol Gracia Serrahima.