Kalman Pairs Trading

Statistical-arbitrage strategy that screens the universe for cointegrated pairs, fits a time-varying hedge ratio with a Kalman filter, and takes a mean-reverting position when the spread crosses an entry threshold.

Overview

Pairs trading exploits the tendency of cointegrated assets to revert toward a long-run equilibrium. Two log-prices are cointegrated when their linear combination is stationary; the resulting spread is a mean-reverting series that admits a contrarian trading rule. The Kalman filter generalises the static OLS hedge ratio into a time-varying state, naturally adapting to changing relationships.

This is the only Folio Lab method that produces a signed (long–short) portfolio: the dependent leg is taken in the direction opposite the current spread sign, and the independent leg is balanced by the time-varying hedge ratio. Diagnostics include the cointegration p-value, half-life, and current z-score.

Algorithm

Step 1 — Pair screening

For every ordered pair of log-prices in the universe, run the augmented Engle–Granger cointegration test. Pairs with are kept as candidates.

Step 2 — OLS seed and Kalman state

For each cointegrated pair , fit a static OLS regression to seed the Kalman filter. Then run a Kalman filter where the state is :

The filter delivers a smoothed time-varying spread .

Step 3 — Half-life filter

Estimate the spread half-life by regressing on . Pairs with half-life outside trading days are discarded — too fast to be tradeable, too slow to be useful.

Step 4 — Best-pair selection

Among eligible pairs, pick the one minimising lexicographically — most cointegrated, fastest mean-reversion, largest current dislocation.

Step 5 — Position

The signed spread direction sets which leg goes long vs short. Folio Lab exposes diagnostics — including a “watch” flag and a“active” flag — so callers can decide whether to enter the trade.

Advantages & Limitations

Advantages

  • Market-neutral: Long-short structure has limited beta exposure.
  • Time-varying: Kalman filter adapts to relationship drift.
  • Statistical filter: Cointegration plus half-life constraints reduce false positives.
  • Diagnostics: p-value, half-life, z-score, exposures all surfaced.

Limitations

  • Single-pair concentration: The output is one pair, not a diversified book.
  • Cointegration breakage: Relationships can fail; spreads can stay wide.
  • Combinatorial scan: Cost is quadratic in universe size.
  • Permits short positions: Requires a short-enabled mandate.

References

  • Engle, R. F., & Granger, C. W. J. (1987). "Co-integration and Error Correction: Representation, Estimation, and Testing." Econometrica, 55(2), 251-276.
  • Gatev, E., Goetzmann, W. N., & Rouwenhorst, K. G. (2006). "Pairs trading: Performance of a relative-value arbitrage rule." Review of Financial Studies, 19(3), 797-827.
  • Vidyamurthy, G. (2004). Pairs Trading: Quantitative Methods and Analysis. Wiley.