At a glance
- Bets that
- The spread between two related assets reverts to its mean
- Market exposure
- Approximately neutral if hedge ratio is correct
- Key statistic
- Z-score of the spread, and cointegration test
- Holding period
- Days to weeks
- Main risk
- The economic relationship breaking permanently
Key takeaways
- Pairs trading is mean reversion applied to a spread rather than to a price, which removes most directional market risk.
- Correlation is not sufficient. You need cointegration: a relationship where the spread itself is stationary and tends to return to a mean.
- The hedge ratio determines neutrality and must be estimated and periodically re-estimated, not assumed to be one-to-one.
- The characteristic disaster is a structural break: a merger, a regulatory change, or a fundamental divergence that makes the spread never return.
- Costs are doubled because every trade involves two instruments, and short legs incur borrow costs.
The core idea
Two instruments driven by the same economic forces, for example two large integrated oil companies, tend to move together. When one temporarily outperforms the other for reasons unrelated to fundamentals, the spread between them widens. A pairs trade sells the outperformer and buys the underperformer, profiting when the spread narrows back to its usual level.
Because you are simultaneously long and short, the overall market direction largely cancels out. A market-wide crash affects both legs, so the position is insulated from the direction risk that makes single-name mean reversion dangerous. What remains is the risk specific to the relationship itself.
Selecting a pair: correlation is not enough
Two series can be highly correlated in returns while drifting apart indefinitely in price. What you need is cointegration: a linear combination of the two price series that is stationary, meaning it fluctuates around a stable mean rather than wandering.
- 1
Start with an economic reason
Same industry, same input costs, same regulatory regime, or a structural link such as an ETF and its components. A pair found only by data mining across thousands of combinations is almost certainly spurious.
- 2
Estimate the hedge ratio
Regress the price of A on the price of B. The slope coefficient is the hedge ratio: how many units of B to trade against one unit of A. Using log prices makes the relationship proportional rather than absolute.
- 3
Test the residual for stationarity
Apply an augmented Dickey-Fuller test to the residual series. A significant result suggests the spread is mean reverting. Estimate the half-life of reversion to set your expected holding period.
- 4
Check stability over sub-periods
Re-estimate on separate windows. If the hedge ratio or the mean shifts substantially between periods, the relationship is not stable enough to trade.
- 5
Confirm tradability
Both legs must be liquid enough to enter and exit together, and the short leg must be borrowable at a reasonable cost. A theoretically perfect pair with an expensive borrow is not a strategy.
Computing the spread and the signal
1. Hedge ratio from regression over lookback N (e.g. 120 days):
log(P_A) = alpha + beta * log(P_B) + residual
2. Spread:
spread_t = log(P_A,t) - beta * log(P_B,t)
3. Z-score over rolling window M (e.g. 60 days):
z_t = (spread_t - mean(spread)) / stdev(spread)
4. Signals:
z > +2.0 -> short A, long beta units of B (spread too wide)
z < -2.0 -> long A, short beta units of B
|z| < 0.5 -> close the position
|z| > 4.0 -> stop out: the relationship may have broken
5. Half-life of reversion (Ornstein-Uhlenbeck estimate) sets the
expected holding period and the maximum time stop.The entry and exit thresholds involve a trade-off. Wider entry thresholds produce fewer trades with higher probability of reversion; narrower ones produce more trades and more false signals. Two standard deviations for entry and half a standard deviation for exit is the conventional starting point, and like all parameters it should show a performance plateau rather than a spike.
Worked example
Two regional bank stocks, A at 62.00 and B at 44.00. Regression over 120 days gives a hedge ratio of 1.35 in log terms, and the current z-score of the spread is +2.4, meaning A is unusually expensive relative to B.
Over the next nine sessions the spread narrows and the z-score falls to +0.4. Both legs are closed. The gain is the convergence of the spread, less two round-trip commissions, two spreads, and the borrow cost on the short leg for nine days. Note that the position can be profitable while both stocks rise, or while both fall: only the relative move matters.
The risks that actually matter
| Risk | What happens | Mitigation |
|---|---|---|
| Structural break | A merger, fraud, or strategy change makes the spread never revert | Hard z-score stop, news monitoring, exclude names with pending corporate actions |
| Hedge ratio drift | The estimated beta becomes stale and the position is no longer neutral | Re-estimate on a rolling basis; cap net exposure |
| Borrow cost or recall | The short leg becomes expensive or is bought in | Check borrow before entry; prefer liquid, easily borrowed names |
| Correlated crowding | Many pairs strategies unwind simultaneously in a stress event | Limit total gross exposure; diversify across sectors |
| Doubled transaction costs | Two legs, two spreads, two commissions | Require an expected move several times the round-trip cost |
| Dividend and corporate actions | Unexpected cash flows distort the spread | Adjust series for dividends; avoid ex-dividend windows on single legs |
Variations and extensions
- Basket versus single name. Trade one stock against a sector ETF rather than against another single stock. The basket leg is far more stable and removes idiosyncratic risk on one side.
- [Statistical arbitrage](/library/strategy-styles/statistical-arbitrage). Generalise from pairs to a portfolio of many simultaneous relationships, using principal components or factor models to define the expected relationship.
- Futures calendar spreads. Trade one contract month against another in the same commodity. The relationship is structural rather than statistical, and margin requirements are much lower.
- ETF versus underlying basket. Exploit temporary divergence between an ETF and its constituents. Heavily arbitraged by professionals, but wider variants exist in less liquid ETFs.
- Cross-venue crypto pairs. The same asset on different venues, or a perpetual against spot. See crypto funding rates.
Frequently asked questions
Is pairs trading still profitable?
The simple version, trading obvious pairs of large-cap stocks on a z-score rule, has been heavily competed for decades and offers thin returns after costs. Variants remain viable where competition is lower: less liquid names, cross-asset relationships, structural spreads such as futures calendars, and crypto venue differences. Expect to work harder for the same edge than early practitioners did.
What is the difference between correlation and cointegration?
Correlation measures whether two series move together in the short run. Cointegration means a specific combination of their prices is stationary, so that when they diverge there is a tendency to return. Two assets can be 95 percent correlated in daily returns and still drift apart permanently, which is exactly the scenario that loses money in a pairs trade.
How many pairs should I trade at once?
Enough to diversify the risk of any single relationship breaking, typically five to twenty, with strict limits on gross exposure and on the number of pairs within one sector. Because pairs strategies tend to unwind together in stress events, the diversification is smaller than the position count suggests.
Does pairs trading require shorting?
The classic form does, which means margin approval, borrow availability, and borrow costs. Alternatives that avoid shorting include using inverse ETFs for one leg, expressing the spread through options, or trading futures calendar spreads where both legs are futures contracts and no borrow is needed.
What lookback should I use for the z-score?
It should relate to the estimated half-life of mean reversion. A common approach sets the z-score window at two to four times the half-life. Very short windows generate noise; very long ones make the strategy slow to recognise that a relationship has changed. Test a range and require a plateau rather than optimising a single value.
Test this idea before you trade it
Describe the rules in plain language and AlgoTrader AI turns them into a structured strategy blueprint with a configurable historical backtest, cost assumptions, and exportable code.
Build a backtestKeep reading
- StrategiesStatistical Arbitrage: Trading Many Small Edges at Once
- StrategiesMean Reversion Strategy: How to Trade the Snap Back
- StrategiesArbitrage Trading Strategies: What Is Real and What Is Marketing
- RiskHedging Strategies: Paying to Reduce Risk, Deliberately
- RiskCorrelation and Diversification: Counting Bets, Not Positions
- Algo & QuantQuantitative Trading Explained: What Quants Actually Do
Referenced by
Educational use only. This guide explains how a strategy works. It is not investment advice, not a recommendation, and no result described here is a forecast. Test any approach on historical and out-of-sample data, size positions conservatively, and never risk money you cannot afford to lose.