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.
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.60How 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.53Each 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 heldEnter 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
| Entry | Side | Days | Return |
|---|---|---|---|
| 2026-09-18 | short KO | 33+ | -3.24% |
| 2026-06-10 | short KO | 60 | -7.75% |
| 2026-04-28 | short KO | 26 | -3.08% |
| 2026-04-16 | long KO | 5 | +2.36% |
| 2026-02-17 | short KO | 12 | +2.83% |
| 2026-01-09 | short KO | 21 | +0.86% |
| 2025-11-07 | short KO | 16 | +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.