Pairs Trade Calculator

Test whether two related stocks move together, how far their spread has stretched, and how a simple mean-reversion rule would have traded it.

Try:
Z-score
0.60
inside ±2
Correlation (30d)
0.74
moderate
Hedge ratio (β)
0.533
$0.53 of PEP per $1 of KO
Cointegration p
0.717
not cointegrated
Half-life
271.3 days
slow
Signal
No signal
223 sessions · 30-day window

Prices, rebased

Both stocks rebased to 100 at the start of the range, so you can see when they drifted apart.

Spread z-score

30-day window · now 0.60

How many standard deviations the hedged spread sits from its rolling average. Beyond ±2 (shaded) is the usual entry zone; markers show entries by the rule tested below.

Is the relationship holding?

Rolling correlation of daily returns (left) and rolling 60-day hedge ratio (right). A falling correlation or drifting beta warns that the pair is decoupling.

Daily returns, last year

slope 0.53

Each dot is one day's return for both stocks. A tight cloud along the fitted line means they move together; its slope is the hedge ratio.

How the z-score rule would have done

6 trades · 4 winners · avg -0.48% · 23.3 days held

Enter when |z| reaches 2 (short the stretched stock, buy the other in the hedge ratio), exit when z crosses back through 0 or after 60 trading days. Returns are the change in the hedged log spread, before costs, borrow and slippage. In-sample: the hedge ratio uses the whole period.

Trades

EntrySideDaysReturn
2026-09-18short KO33+-3.24%
2026-06-10short KO60-7.75%
2026-04-28short KO26-3.08%
2026-04-16long KO5+2.36%
2026-02-17short KO12+2.83%
2026-01-09short KO21+0.86%
2025-11-07short KO16+1.90%

Pairs trading handbook

Why pairs? Pairs trading bets on relative performance: when two historically linked stocks diverge, sell the stretched one and buy the laggard, expecting the gap to close. Market direction largely cancels out.

Choosing a pair. Start with a real economic link — competitors (KO/PEP), a stock and its sector ETF, two share classes (GOOGL/GOOG), a commodity pair (GLD/SLV). Look for correlation above 0.8, a cointegration p-value under 0.05 (the spread has tended to revert) and a half-life you can live with (days, not months).

Reading the numbers. Z-score — how stretched the spread is now. Hedge ratio (β) — dollars of stock 2 per dollar of stock 1 to neutralise shared moves. Cointegration — Engle-Granger test on the past year of prices; low p-values mean a stable long-run relationship. Half-life — typical days for a gap to halve.

Execution. Size legs by the hedge ratio, scale in (half size at |z| = 2, add if it stretches), exit near zero, and set a stop if the gap keeps widening — relationships break on earnings, mergers and regime changes. Shorting has borrow costs; the rule test above ignores them. Educational only — not a trading recommendation (see Terms §17).

Looking for candidates? The Pairs Screener ranks stretched pairs across the market.