> ## Documentation Index
> Fetch the complete documentation index at: https://raymondchang.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Stat arb and pairs

> Pairs selection, hedge ratios, OU residual models, and the s-score framework.

> [!NOTE]
>
> **Status of this page:** P0 draft. Methods are standard; empirical performance claims are limited to what the cited papers report. Validation of any pairs strategy should follow [Backtest bias taxonomy](https://raymondchang.me/quantitative-research/backtesting/bias-taxonomy.md).

## 1. Two ways to form pairs

**Distance method (Gatev, Goetzmann and Rouwenhorst, 2006).** Normalise price series, pick the pair with the smallest sum of squared deviations over a formation period, and trade divergences beyond a threshold during a trading period. The paper reports average annualised excess returns of up to about 11% on self-financing portfolios over 1962-2002, with profits typically above conservative cost estimates, and links profitability to a common factor. Later decay in profitability is documented in the literature; treat the 1962-2002 figure as historical.

**Cointegration method.** Test whether a linear combination of two non-stationary prices is stationary (Engle and Granger, 1987). The residual is the spread.

## 2. Hedge ratio estimation

| Method | Idea | Weakness |
| - | - | - |
| OLS on log prices (Engle-Granger step 1) | Static beta | Not symmetric in the two legs; unstable beta |
| Total least squares | Symmetric treatment | Scale sensitivity |
| Johansen | Multi-asset cointegrating vectors | Needs long samples; sensitive to lag choice |
| Kalman filter | Time-varying beta | State noise parameters are another degree of freedom |

Estimate beta only on the formation window and freeze it in the test window, otherwise the test is contaminated.

## 3. Ornstein-Uhlenbeck residual model

Model the spread X as dX = kappa (m - X) dt + sigma dW. Discretely, X\_{t+1} = a + b X\_t + e, with b = exp(-kappa dt). Key outputs:

* Half-life = -ln 2 / ln b (in sampling units). Verified examples: b = 0.90 gives 6.6 periods, b = 0.95 gives 13.5, b = 0.99 gives 69.0.
* Equilibrium std = sigma / sqrt(2 kappa).
* **s-score** = (X - m) / sigma\_eq, used as the entry/exit variable.

Avellaneda and Lee (2010) use residuals from factor regressions (sector ETFs or PCA factors) rather than pairs, trade on s-scores, and filter on fast mean reversion (kappa above roughly 252/30, i.e. a reversion time under about 30 trading days; check the paper for the exact rule). Their reported results show weaker performance after 2002 relative to the earlier period.

## 4. Practical filters

* Cointegration p-value is not a stability guarantee; re-test on rolling windows and require economic linkage (same industry, ETF vs constituents, ADR vs local line, share classes).
* Remove pairs with event risk: M\&A, index inclusion, suspension.
* Size by spread volatility, cap by liquidity of the thinner leg.
* Cost model must include short-borrow fee and the crossing cost on both legs.

## 5. Failure modes

* **Regime break:** the pair stops being related; mean reversion becomes trend. Use a stop on the s-score and on time-in-trade.
* **Crowding:** many participants unwind together.
* **Multiple testing:** scanning thousands of pairs guarantees spurious cointegration. Apply a multiple-testing correction; Harvey, Liu and Zhu (2016) argue for a t-ratio hurdle above 3.0 for new factor claims, and the same logic applies to pair scanning.

## Points to verify

* Exact filter threshold and sample used in Avellaneda and Lee (2010) before citing it numerically.
* Short-sale availability and uptick/designated-security rules for the HK names used.

## Sources

* Gatev, Goetzmann and Rouwenhorst (2006), Pairs Trading: Performance of a Relative-Value Arbitrage Rule, Review of Financial Studies 19(3).
* Engle and Granger (1987), Co-integration and Error Correction, Econometrica 55(2). [Link](https://econometricsociety.org/publications/econometrica/1987/03/01/co-integration-and-error-correction-representation-estimation)
* Avellaneda and Lee (2010), Statistical arbitrage in the US equities market, Quantitative Finance.
* Harvey, Liu and Zhu (2016), and the Cross-Section of Expected Returns, RFS 29(1). [NBER](https://nber.org/papers/w20592)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.