Home / Glossary / Cointegration (Pairs Trading)
FinanceCointegration (Pairs Trading)
Two non-stationary prices whose linear combo is stationary.
Two stocks can each wander randomly yet move together long-term — their spread is mean-reverting. Pairs trading shorts the rich leg and buys the cheap leg, betting the spread closes. Tested with the Engle–Granger or Johansen procedure.
Formula / theory
Engle–Granger: regress A on B, test residuals for stationarity (ADF)
In Python
from statsmodels.tsa.stattools import coint score, pvalue, _ = coint(asset_a, asset_b) # pvalue < 0.05 ⇒ cointegrated, tradeable pair