Explaining cointegration approach to pairs trading
Correlation measures short-term comovement but can be misleading since it doesn’t guarantee a stable long-term relationship. Cointegration checks if a linear combination of two stock prices forms a stationary spread, indicating a mean-reverting equilibrium. The approach involves regressing one stock’s prices on another to estimate a hedge ratio, then testing the residuals (spread) for stationarity using the Augmented Dickey–Fuller test. If stationary, the pair is cointegrated, and you monitor the spread’s z-score; when it exceeds 2, you trade by shorting the overpriced stock and going long the underpriced one, closing positions as the spread reverts.
In simple correlation‑based pairs trading you look for two series that tend to move up and down together and bet that they'll continue to do so. The problem is that correlation is just a contemporaneous co‑movement statistic: two trending series can have a high correlation without any tendency to come back together if they diverge, and correlations themselves are unstable over time. A high correlation doesn't tell you anything about a long‑run equilibrium or mean‑reversion in the price spread, which is what a pairs strategy needs to be profitable.
The cointegration approach tries to formalise that mean‑reverting spread. Two non‑stationary price series, (P_t^A) and (P_t^B), are said to be cointegrated if there exists a linear combination (P_t^A - \beta P_t^B) that is stationary. One way to estimate (\beta) is to run an ordinary least squares regression of one price series on the other over a historical window:
P_t^A = \alpha + \beta P_t^B + \epsilon_t.
The fitted slope (\beta) acts as a hedge ratio, and the residuals (\epsilon_t) are your synthetic “spread.” If that residual series is stationary, it means the two prices tend to revert to a stable relationship defined by (\alpha + \beta P_t^B).
To check stationarity you can apply a unit‑root test such as the Augmented Dickey–Fuller (ADF) test to the residuals. A test statistic below the chosen critical value allows you to reject the null of a unit root and treat the spread as mean‑reverting.
Once you have a cointegrated pair and a spread series, you can monitor how far the current spread deviates from its historical mean. A common normalization is the z‑score, (z_t = (\epsilon_t - \bar{\epsilon})/\sigma_\epsilon), where (\bar{\epsilon}) and (\sigma_\epsilon) are the mean and standard deviation of the residuals. When (|z_t|) exceeds a threshold such as 2, you interpret the spread as unusually wide: if (z_t > 2) you would short the first asset and go long the second in proportion to (\beta), betting on convergence; if (z_t < -2) you would take the opposite. The position is closed when the z‑score reverts toward zero.