This project studies relationship persistence, not how to tune a pairs-trading backtest until it looks profitable.
The experiment begins with economically plausible equity pairs, tests formation-period cointegration, freezes the fitted relationship, and then asks whether that same equilibrium survives in unseen data. A predeclared robustness grid tests whether the conclusions depend on formation length, candidate breadth, Johansen lag structure, forward horizon, or conventional z-score choices.
-
Most apparent cointegration decays quickly. Across the robustness grid, only about 25% of complete selected relationship/configuration cases survive the primary 60–100 observation forward test; survival falls to roughly 17% at 126 observations.
-
In-sample specification robustness is not temporal robustness. How often a pair is selected across 27 reasonable formation designs has almost no association with its later survival (Spearman rho ≈ 0.05).
-
The selection architecture is not universally superior to matched controls. A clear selected-pair advantage appears under the three-year formation design, but not consistently under two-year or 2.5-year formation windows.
-
Conventional formation-strength statistics do not provide a reliable ranking rule for future persistence.
-
The trading overlay is parameter-sensitive. At 10 bps per unit of turnover, the predeclared z-score grid moves the mean 100-observation simulated result from roughly −0.73% to +0.91%. The familiar |z| = 2 entry rule is therefore treated as a benchmark, not an optimum.
A simple pairs-trading notebook can produce a convincing story:
find a pair → show a cointegration p-value → choose a z-score threshold → report Sharpe.
That workflow makes it too easy to confuse in-sample fit with durable structure.
This project instead asks:
If a pair looks cointegrated today, how much should that actually increase confidence that the relationship remains mean reverting tomorrow?
The first discovery architecture was deliberately conservative. It was then retained as a benchmark while a higher-power V2 architecture introduced:
- formation-only factor-neighbour and residual-co-movement candidate generation;
- symmetric Johansen rank testing;
- explicit evidence tiers;
- supporting Engle-Granger multiplicity diagnostics;
- no automatic exclusion of negatively correlated candidates.
For every selected relationship, the formation-period Johansen vector is frozen.
The primary question is whether that same spread remains stationary and mean reverting in the next unseen observations. Matched rank-0 controls are selected using formation information only.
Before reading the robustness results, the study freezes a 27-design grid:
- formation history: 504 / 630 / 756 observations;
- candidate breadth: narrow / base / wide;
- Johansen lagged differences: 1 / 2 / 5.
Forward horizons are 60, 100, and 126 observations.
A separate predeclared z-score grid treats simulated returns as a secondary consequence, not the primary research endpoint.
The robust result is negative: formation-period cointegration is considerably more common than durable forward equilibrium.
The apparent selection advantage is conditional on the longest formation window. This is retained as a qualified result rather than generalized.
Examples make the distinction concrete:
- CMS/XEL: selected in 27/27 designs and survives in 27/27.
- AET/HUM: selected in 24/27 designs and survives in 0/24.
- ITW/MMM: selected in 12/27 designs and survives in 0/12.
- AVB/CLX: selected only in the nine three-year designs and survives in 9/9.
Most failures reflect a loss of spread stationarity rather than a narrow miss on the half-life rule.
No cell is promoted as an optimized strategy. The point of the surface is to show that simulated performance is sensitive to a conventional heuristic choice.
Formation-period equity cointegration is easier to discover than durable mean reversion. Most fitted relationships decay out of sample, and even relationships that are stable across many reasonable formation specifications can fail temporally.
This repository does not claim:
- that cointegrated equity pairs are generally persistent;
- that a statistically stronger formation pair is necessarily more durable;
- that the discovery architecture universally beats matched controls;
- that z = 2 is an optimal entry threshold;
- or that the study constitutes a production trading strategy.
cointegration-stability/
├── README.md
├── requirements.txt
├── tests/
│ └── test_core.py
├── .github/workflows/
│ └── tests.yml
├── data/
│ └── README.md
├── docs/
│ ├── METHODOLOGY.md
│ ├── RESULTS.md
│ ├── LIMITATIONS.md
│ ├── RESEARCH_DECISIONS.md
│ └── REFERENCES.md
├── figures/
│ ├── 01_precision_power_funnel.png
│ ├── 02_forward_survival_by_horizon.png
│ ├── 03_selected_vs_controls.png
│ ├── 04_design_stability_vs_survival.png
│ ├── 05_failure_taxonomy.png
│ └── 06_zscore_sensitivity.png
├── notebooks/
│ ├── 01_discovery_precision_power.ipynb
│ ├── 02_forward_persistence.ipynb
│ └── 03_robustness_failure_analysis.ipynb
├── src/
│ ├── config.py
│ ├── core.py
│ ├── run_experiment.py
│ └── make_figures.py
└── results/
├── tables/
└── audit/
Create an environment and install the dependencies:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtPlace the historical validation archive at data/data.zip, then run the frozen robustness protocol:
python -m src.run_experimentGenerated audit files and tables are written to results/generated/, which is git-ignored. To regenerate the committed presentation figures from the compact result tables:
python -m src.make_figuresThe full protocol is computationally heavier than the notebooks because it rebuilds candidate sets, integration diagnostics, Johansen tests, Engle-Granger support tests, matched controls, forward persistence outcomes, and the z-score sensitivity grid from the source archive.
The repository keeps the predeclared Gate 3 protocol and its SHA-256 hash, as well as the Gate 2 method-correction note.
The correction is important: a preliminary forward implementation emphasized a fresh short-window Johansen re-estimation. Before finalizing the result, the primary endpoint was changed to the scientifically cleaner question—whether the formation-fitted relationship itself remains stationary forward. The preliminary diagnostic was retained rather than deleted.
- Gatev, E., Goetzmann, W. N., & Rouwenhorst, K. G. Pairs Trading: Performance of a Relative-Value Arbitrage Rule. NBER Working Paper 7032; later published in The Review of Financial Studies.
- Statsmodels documentation: Johansen cointegration rank testing (
coint_johansen). - Statsmodels documentation: Augmented Engle-Granger cointegration testing (
coint). - Statsmodels documentation: multiple-testing corrections (
multipletests). - Historical validation panel: Teddy Koker,
survivorship-free-spy. Seedocs/REFERENCES.mdanddata/README.md.
This is a historical quantitative-research validation project. Raw market data is not redistributed, and simulated trading results are not presented as live investment recommendations.





