← Learning Academy

Cointegration & Z-Score

Cointegration is the statistical foundation of pairs trading. Two stocks can be correlated without being cointegrated — and only cointegrated pairs have the mean-reverting property that makes pairs trading viable.

8 min read Intermediate

Correlation vs cointegration

Two stocks can be highly correlated — moving up and down together over a period — without being cointegrated. Correlation measures whether they move together over the sample period. Cointegration tests whether their long-run relationship is stable and mean-reverting.

An analogy: a drunk person and their dog walking home. Their paths are correlated (they're generally moving in the same direction) but not necessarily cointegrated (the dog may wander far from the owner and not return). A cointegrated pair is like the drunk person on a leash — the dog can wander, but there's a force pulling it back to the owner's path.

Critical distinction: High correlation does not guarantee cointegration. Always test for cointegration before trading a pair — correlation alone will lead to false signals and regime-break losses.

The Engle-Granger test

The most common cointegration test for pairs trading is the Engle-Granger two-step test:

  1. Estimate the long-run relationship: Regress the price of Stock A on the price of Stock B to find the hedge ratio (β): Price_A = α + β × Price_B + ε
  2. Test the residuals for stationarity: If the residuals (ε) are stationary (mean-reverting), the pair is cointegrated. The Augmented Dickey-Fuller (ADF) test is used to test this — a p-value below 0.05 indicates stationarity (cointegration).

A pair that passes this test has a statistically verified tendency to mean-revert when the spread stretches. One that fails it does not — spreads in non-cointegrated pairs can wander indefinitely.

The cointegration health score

A single cointegration test is a snapshot. For trading, you want to know how consistently the pair has maintained its cointegration over rolling windows. A health score (0–100) aggregates:

A health score above 70 indicates a pair that has consistently maintained its cointegrated relationship. Below 50 indicates the relationship is breaking down — proceed with caution. Below 30 means the pair should not be traded as a pairs strategy.

The z-score as the trade signal

Once a pair's cointegration health is confirmed, the z-score of the residuals (the spread) becomes the actionable signal. The z-score measures how far the current spread has stretched from its long-run mean, in units of standard deviations:

Z = (Current Spread − μ) / σ

Where μ is the rolling mean of the spread and σ is its rolling standard deviation. High z-score = spread has stretched unusually wide = convergence bet. The trade is sized and entered based on the z-score magnitude and the pair's health score.

When cointegration breaks down

Cointegration is not permanent. It can break when:

Monitoring cointegration health on a rolling basis — and stopping trading a pair when health falls below threshold — is essential risk management for pairs strategies. A pair that was valid last quarter may not be valid today.

Practical parameters

See cointegration health scores for your pairs in BetaWatchdog
BetaWatchdog runs cointegration tests and scores each pair's health on a 0–100 scale.
Join Waitlist →