Tools

Cointegrated — or just correlated?

Two assets can move together for years and still be untradeable as a pair. Correlation says they wiggle in step day to day; cointegration says their spread keeps coming back. Build a pair, slide the cointegration strength, and watch the correlation stay high while the spread quietly turns into a random walk that drifts away.

What it shows: a pairs trade bets that a spread mean-reverts. That only works if the two assets are cointegrated — a stable long-run relationship — not merely correlated. This simulator estimates the hedge ratio by OLS over a formation window (Engle–Granger step 1), runs a simplified Dickey–Fuller test on the residual spread (step 2), then trades a z-score rule out-of-sample with no look-ahead. It's the intuition behind the pairs trading and statistical arbitrage guides.

All series are synthetic — nothing here is a performance figure or investment advice. The Dickey–Fuller test is simplified (no lag augmentation) and uses the Engle–Granger residual-based 5% critical value of −3.34 for the intuition; production work augments with lagged differences and MacKinnon p-values. Related tools: Backtest Overfitting Simulator · Information Coefficient Calculator · Signal Decay Calculator · Signal Combination Simulator · Correlation Heatmap · VPIN & the Volume Clock · Signal Skill Explorer.

Build a pair

Two assets are built from a shared trend (so they co-move and their returns correlate strongly) plus a spread that mixes a mean-reverting part with a random-walk part. Cointegration strength sets the mix. Watch the correlation stay high while only the stationary spread stays tradeable.

0% = two independent random walks · 100% = a truly stationary spread

how fast the mean-reverting part pulls back to the mean

open a trade when the spread is this many σ from its mean

close the trade when the spread returns inside this band

3.0 years · first half = formation, second half = out-of-sample trading

a break shifts the hedge ratio out-of-sample

re-rolls the random draws — the cointegration verdict barely moves; the P&L jumps around
a link that reopens this exact pair + rule — send it to a colleague

Frequently asked

Isn't high correlation enough to trade a pair?
No — that is the central lesson. Two assets can be around 0.9 correlated in returns yet have a spread that never mean-reverts (not cointegrated), so a pairs trade on them eventually blows up. Only a cointegrated spread is tradeable; correlation and cointegration are different things.
What does the cointegration test actually do?
It runs the Engle-Granger two-step: an OLS hedge ratio on a formation window, then a Dickey-Fuller test on the residual spread against the critical value of about minus 3.34. Trading then happens out-of-sample on a later window via a z-score rule, with no look-ahead.
What is the structural-break toggle showing?
That passing the formation test is not a guarantee. Flip it and a pair that tested cointegrated still breaks down out-of-sample when the underlying relationship shifts — a reminder that cointegration can be regime-dependent.
How do I relate this to my own pair?
Use the cointegration-strength slider to watch the verdict flip while correlation stays high, and judge the out-of-sample equity curve rather than the in-sample fit — the out-of-sample behaviour is what your live trade would experience.
Is the profit and loss real?
No. All series are synthetic and the equity curve is illustrative, with the Dickey-Fuller step simplified for teaching. It is not investment advice.