§1.3 — Trading
Statistical Arbitrage Backtester
Pairs-trading backtester across S&P 500 constituents using cointegration and inverse-volatility sizing.
walk-forward 2020-01-03 to 2023-12-29: -19% (1x) vs. +57% SPY · Sharpe -0.78 · max drawdown -23%
This page originally led with +121% (Sharpe 0.73). That number did not survive out-of-sample validation — below is what changed and why.
backtest only — never traded live, not connected to any broker
1. research process — same strategy, three versions
v1 picked pairs, hedge ratios and z-score parameters on the full sample, acted on a same-bar close (look-ahead), and a positional-argument bug fed the wrong stop-loss and cost settings into the pair ranking. Fixing the bugs (v2, top 10 pairs) made the in-sample result look better (Sharpe 3.4) — a sign the in-sample fit, not the strategy, was producing the return. v3 re-estimates everything on a 2-year formation window and trades the next 6 months with those estimates frozen (8 folds, 1,005 out-of-sample days).
2. walk-forward out-of-sample return, 2020-01-03 to 2023-12-29
Pairs chosen by cointegration p-value only (p<0.01, top 10 per fold), never by backtest Sharpe. Equal-weighted, 1x, no borrow costs on the short leg. 2 of 8 folds were profitable; the cointegrating relationships found in each formation window did not persist into the next.
3. what leverage does to a negative edge
Same out-of-sample returns scaled by L, minus 5%/yr financing on the borrowed part. Leverage multiplies the loss and adds volatility drag; at 10x the worst day (-38%) is enough to nearly wipe the account.
honest limitations
One parameter set and a short window that includes March 2020. The universe is 50 current mega-caps (survivorship bias), with no borrow or market-impact costs beyond a linear slippage term. A nested search over entry/exit z-score and p-value cutoff, chosen only on formation data, did not help (1x Sharpe −1.04). Next: sector-matched pairs, log prices and a rolling hedge ratio.
v1 as originally published — in-sample, kept for comparison
Not predictive: pairs, hedge ratios and the slippage grid were all fit on the data they were scored on. The slippage sensitivity grid shown here before was also an artifact — a units error meant the volatility term had no effect on cost.
top 10 cointegrated pairs — S&P 500, 2018–2023 (in-sample)
v1 portfolio — top 5 pairs, 5x, in-sample
drawdown
the signal — one pair's z-score (in-sample fit)
The single best pair by Sharpe (PM–UNH): real hedge-ratio-adjusted spread z-score, 2018–2023. Crossing ±2 opens a full position, ±0.5 a half position, back toward 0 exits.