Sector-neutral
pairs trading,
end to end.
An interactive lab built from the literature: cointegration via Engle-Granger, hedge ratios from rolling OLS and a Kalman filter, walk-forward backtests with realistic frictions, and risk-parity sizing across pairs. Bring no data — six pairs come pre-loaded.
Live render of the MEGA-WHEN synthetic spread. Bands at ±2σ, hedge ratio from full-sample OLS, z-score on a 60-day rolling window.
From a price universe to a risk-managed book.
Six stages, each with its own page. The Lab walks the same pipeline a desk would: filter, fit, forecast, size, execute.
Six modules, one mental model.
Pair Lab
Pick a pair, watch OLS and Kalman fight over the hedge ratio, see the spread, z-score, rolling-ADF and Bertram-band overlay live.
Methods
ADF + Engle-Granger + Johansen, KPSS (opposite null), Variance Ratio, Hurst, CUSUM — every test a desk runs before trusting a pair, side-by-side.
Strategies
Cointegration vs Distance method (Gatev-Goetzmann-Rouwenhorst) vs OU s-score (Avellaneda-Lee). Same pair, three trading rules, one chart.
Backtest Studio
Walk-forward, every parameter tunable, costs baked into Sharpe, bootstrap CI, equity vs buy-and-hold, trade heatmap by entry-z × holding period.
Risk Lab
VaR / CVaR, Ulcer, Pain, Sterling, information ratio, return-distribution moments, stationary-bootstrap Sharpe CI on every pair.
Portfolio
Risk-parity sizing, β-to-market, Amihud liquidity + KPSS screens, capacity proxy and a correlation-of-pairs heatmap.
Theory
23 sections: Engle-Granger, Johansen/VECM, ADF, KPSS, VR, Hurst, CUSUM, Kalman, OU half-life, Bertram bands, distance, s-score, risk metrics, bootstrap.
Glossary
Plain-English definitions for every term used elsewhere in the Lab.
Demo data
Twelve synthetic pairs across twelve sectors — strong, moderate, weak, slow, volatile, structurally broken, independent — each with its own seeded RNG.
The papers behind every module.
Two-step procedure: estimate the long-run relationship, then test residuals for a unit root. Foundation of the entire pairs framework.
Finite-sample response surfaces for ADF and cointegration test critical values. Used directly to compute T-adjusted thresholds in this app.
Empirical demonstration that mean-reverting pairs delivered ~11% annualized excess return 1962–2002. The seminal benchmark.
Mean-reverting Gaussian state-space model — the textbook motivation for using a Kalman filter to estimate hedge ratios.
PCA / sector-residual approach with the s-score signal. Maps neatly onto the sector-neutral framing used here.
Explicit decomposition showing how transaction costs gradually erode pairs profitability post-2002. Why the Backtest Studio takes costs seriously.
Analytic optimal entry/exit bands for an Ornstein-Uhlenbeck spread under fixed costs. Reference for the band-suggestion overlay.
Equal-risk-contribution portfolio construction. Used in Portfolio to size pairs by risk rather than capital.
Daily price-impact-per-dollar-of-volume measure. Used here to filter out pairs whose worse leg is too thin to trade.
Trace and max-eigenvalue tests give the full rank of the cointegration space. The Methods page runs the 2-variable form against Osterwald-Lenum CVs.
Reverses the ADF null. A pair worth trading rejects ADF and fails to reject KPSS — the Lab requires both.
Variance ratio test with heteroskedasticity-robust z. The Methods page reports VR(q) at six horizons from 2 to 64.
Rescaled-range slope tells you whether a series is mean-reverting (H<0.5), random (H=0.5), or trending (H>0.5).
CUSUM of recursive residuals with Brownian-motion bands. The Lab's primary breakdown-warning system.
Conditional VaR / Expected Shortfall — coherent risk measure used throughout the Risk Lab.
Stationary bootstrap with geometric block lengths. Honest standard errors on Sharpe under serial correlation.
Implementations are educational and audited against textbook results; the synthetic universe is constructed so OLS, ADF, Engle-Granger, OU and Kalman behave as theory predicts.