Pairs Trading Cointegration Scanner
Run Engle-Granger cointegration tests, compute hedge ratios, plot spreads with z-score signals, and backtest a pairs trading strategy.
Feb 23, 2026, Eric
The Core Idea
Two stocks can be individually non-stationary (trending) but their spread can be stationary — they are tied together by an economic relationship. This is cointegration. A pairs trading strategy exploits this: when the spread deviates from its mean, bet on reversion. Cointegration is the mathematical foundation of pairs trading, statistical arbitrage, and relative value strategies.
Pair Selection
400 observations loaded
Engle-Granger Cointegration Test
Hedge Ratio (β)
1.3458
Intercept (α)
2.5695
ADF Test Stat
-7.808
p-value
0.0050
Visual Analysis
Price Series
Spread (A − β·B − α)
Z-Score with Signals
Backtest Equity Curve
Backtest Results
Total Return
-56.60
Round-Trip Trades
17
Win Rate
100.0%
Avg Trade PnL
4.297
Max Drawdown
56.60
Sharpe Ratio
-2.99