Pairs Trading: A Practical Guide to the Cointegration Spread Strategy

Micro Alphas Research8 min read

Pairs trading is the original and most intuitive form of statistical arbitrage: take two securities whose prices normally move together, wait for the gap between them to widen abnormally, then go long the laggard and short the leader and profit as the gap closes. Because the position is long one security and short another, it is broadly market-neutral — if the whole market drops, both legs drop together and the trade's profit or loss depends only on the relative move between the two names.

The strategy is often traced to a quantitative group at Morgan Stanley in the mid-1980s, where Nunzio Tartaglia's team — with Gerry Bamberger frequently credited for the original approach — built one of the first systematic pairs-trading operations. Four decades later it remains the cleanest worked example of the whole stat-arb family, which is why it is the right place to learn the mechanics. This guide walks through the full method step by step: selecting a pair, testing for mean reversion with a cointegration test, estimating the hedge ratio, turning the spread into a z-score signal, setting entry and exit rules, managing the risk that the relationship breaks, and avoiding the pitfalls that have eroded the simple edge over time.

Key Takeaways

  • Pairs trading is the two-security case of statistical arbitrage: a market-neutral bet that an abnormally wide spread between two related securities will revert to its historical relationship.
  • The relationship must be cointegrated, not merely correlated. Correlation describes co-movement of returns; cointegration guarantees the level of the spread is anchored and mean-reverting. The standard check is the Engle–Granger two-step with an Augmented Dickey–Fuller test on the spread.
  • The workflow is: select an economically linked pair → confirm cointegration → estimate the hedge ratio → build the spread and standardize it to a z-score → enter at an extreme (e.g. ±2σ), exit near the mean → control risk.
  • Divergence risk is the central danger: cointegration is estimated from history and can break (a merger, a fundamental shift), turning a "reverting" spread into an unbounded loss. Stops, a re-checked economic rationale, and the mean-reversion half-life are the controls.
  • The simple edge has decayed: profitable in Gatev, Goetzmann and Rouwenhorst's 1962–2002 study, it weakened after 2002 (Do and Faff) as spreads compressed and the trade crowded — so realistic cost modeling and fresh pairs matter more than ever.

What Pairs Trading Is

A pairs trade has two legs held simultaneously: a long position in the security that has become relatively cheap and a short position in the one that has become relatively expensive, sized so the combination has little or no net market exposure. The trade makes money when the two prices converge back toward their normal relationship, regardless of whether they converge by the cheap one rising, the expensive one falling, or both. The art is in choosing pairs whose relationship is genuinely stable and in defining "abnormally wide" precisely enough to trade.

Step 1 — Selecting a Candidate Pair

Good pairs start with an economic reason to move together, not just a backtest that says they did. Two firms in the same industry with similar business models (two gold miners, two regional banks, an integrated oil major and a refiner), a stock and a sector ETF, two share classes of the same company, or an ETF and a close substitute all have a structural reason for their prices to track. Starting from an economic link guards against the worst failure mode in this strategy — a pair that was cointegrated by chance over the sample and has no reason to stay that way out of sample.

Screening purely statistically across thousands of candidate pairs is possible but dangerous: test enough pairs and some will pass a cointegration test by luck alone, the multiple-testing problem in disguise. An economic prior plus a cointegration test is far more robust than a brute-force search.

Step 2 — Testing for Cointegration

This is the step that separates pairs trading from naive "buy the one that fell" trading. The crucial distinction is correlation versus cointegration: two stocks can have a 0.95 return correlation and still drift apart permanently, while two cointegrated stocks can have modest correlation yet a spread that always snaps back. Pairs trading needs the second property.

The standard test is the Engle–Granger two-step. Regress one price on the other to estimate the long-run relationship, take the residual (the spread), then test whether that residual is stationary using an Augmented Dickey–Fuller (ADF) test. If the ADF test rejects the unit-root null, the spread is mean-reverting and the pair is cointegrated. The caution that motivates the whole test is the spurious-regression problem identified by Granger and Newbold (1974): regressing one random walk on another routinely produces an impressive-looking but meaningless relationship, so a significance test on the spread's stationarity — not the regression's R² — is what actually matters.

Step 3 — The Hedge Ratio and the Spread

The hedge ratio (often written β) is how many units of security B to short against one unit of long A so the combination is market-neutral. The simplest estimate is the slope from the ordinary-least-squares regression of A on B; the spread is then the residual of that regression:

spreadt = At − β · Bt

A static OLS hedge ratio assumes the relationship is constant. Because real relationships drift, practitioners often re-estimate β over a rolling window or let it update dynamically with a Kalman filter — an approach Ernest Chan popularizes in his algorithmic-trading work. A dynamic hedge ratio adapts as the equilibrium shifts but adds parameters and the risk of chasing noise; a rolling-window OLS is the common, transparent middle ground.

Step 4 — From Spread to Signal

A raw spread in price units is not directly tradable; it has to be standardized so "how far from normal" is comparable over time. The standard transform is the z-score: subtract the spread's rolling mean and divide by its rolling standard deviation.

zt = (spreadt − mean) / standard deviation

The z-score is the trading signal. A common rule set is:

  • Enter short the spread (short A, long B) when z rises above an upper threshold, e.g. +2 — the spread is unusually rich and expected to fall.
  • Enter long the spread (long A, short B) when z falls below a lower threshold, e.g. −2 — the spread is unusually cheap and expected to rise.
  • Exit as the spread reverts toward its mean, e.g. when z crosses back through 0 (or a small band around it).
  • Stop out if z keeps widening past a far threshold, e.g. ±3.5 — evidence the relationship may have broken rather than stretched.

The thresholds trade off frequency against reliability: tighter entry bands trade more often on weaker signals, wider bands trade rarely on stronger ones. They should be chosen on out-of-sample data and discounted for the number of variants tried, never optimized in-sample until the backtest looks perfect.

A Worked Illustration

The numbers below are invented to show the shape of a single round-trip pairs trade; they are not real prices.

DaySpread z-scoreAction
0+2.1Spread richly above mean → short A, long B (enter)
4+1.3Reverting → hold
9+0.1Back near the mean → close both legs (exit, profit)
+3.6(Alternative) spread kept widening → stop-loss, relationship suspect

The mean-reversion half-life — derived from fitting an Ornstein–Uhlenbeck or AR(1) model to the spread — tells you roughly how many days a deviation takes to decay halfway back, which sets a realistic expected holding period and a sanity check on the exit. If a spread's estimated half-life is 50 days, a strategy that expects to be flat within 3 days is mis-specified.

Step 5 — Risk Management

The defining risk of pairs trading is not the market — it is the pair itself coming apart. Controls that matter:

  • Divergence stop. Exit when the z-score blows through a far threshold. A spread that keeps widening is telling you the cointegration may have broken; holding "because it must revert" is how a market-neutral trade becomes an unbounded loss.
  • Re-test the relationship. Periodically re-run the cointegration test on recent data. A pair that no longer passes should be retired, not traded on faith in old parameters.
  • Watch for corporate events. Mergers, spin-offs, index changes, and earnings shocks can sever the economic link instantly; a calendar of known events prevents trading into a structural break.
  • Diversify across pairs. Any single pair can break; a book of many weakly correlated pairs is what turns a small per-trade edge into a stable information ratio, the breadth principle of statistical arbitrage.
  • Charge realistic costs. Pairs trading is high-turnover and double-sided (two legs, entry and exit). Commissions, slippage, the bid-ask spread, and short-borrow fees routinely turn a paper edge into a real loss.

A Python Sketch

The skeleton below shows the standard cointegration-test-and-z-score workflow with statsmodels; it is illustrative pseudocode, not a turnkey trading system.

import numpy as np
import statsmodels.api as sm
from statsmodels.tsa.stattools import coint, adfuller

# a, b: aligned price series for the two securities
score, pvalue, _ = coint(a, b)          # Engle-Granger cointegration test
if pvalue < 0.05:                        # spread is plausibly stationary
    beta = sm.OLS(a, sm.add_constant(b)).fit().params[1]   # hedge ratio
    spread = a - beta * b
    z = (spread - spread.rolling(60).mean()) / spread.rolling(60).std()

    # signals: short spread when rich, long when cheap, exit near mean
    enter_short = z > 2.0
    enter_long  = z < -2.0
    exit_trade  = z.abs() < 0.1

Real implementations add a rolling or Kalman-updated hedge ratio, transaction-cost accounting, position sizing, borrow-availability checks, and rigorous out-of-sample validation with a deflated Sharpe ratio to guard against over-fitting the thresholds.

Common Pitfalls

  • Confusing correlation with cointegration. The single most common error — trading a highly correlated pair whose spread is not actually anchored, so it drifts away and never reverts.
  • Over-fitting the thresholds. Tuning entry/exit bands and lookback windows until the backtest is beautiful guarantees disappointment live; this is textbook backtest overfitting.
  • Ignoring costs and short constraints. A spread that looks profitable gross can be a loser net of the bid-ask spread, slippage, and the cost or unavailability of borrowing the short leg.
  • Look-ahead bias. Computing the hedge ratio, mean, or standard deviation using data the strategy would not have had in real time inflates results; everything must be rolling and point-in-time.
  • Assuming the edge is permanent. Simple pairs trading has decayed since the early studies; a static recipe will erode like any other published signal.

Pairs Trading in the Broader Picture

Pairs trading is the two-security special case of statistical arbitrage, and everything it teaches scales up: cointegration becomes a factor model whose residuals you trade; the single z-score becomes a cross-sectional ranking over hundreds of names; the one divergence stop becomes portfolio-level risk control across many spreads. Learning it cleanly on two securities is the fastest way to understand the whole market-neutral family — and to appreciate why the discipline matters more than any single pair, because individual relationships decay and the edge has to be continually re-validated and refreshed. For the broader strategy family, variants, and the crowding risks that hit market-neutral books, see the statistical arbitrage hub.

Frequently asked questions

What is pairs trading?+

Pairs trading is a market-neutral strategy that trades the spread between two securities whose prices normally move together. When the gap between them widens abnormally, the trader goes long the relatively cheap security and short the relatively expensive one, profiting as the spread reverts to its historical relationship. Because it holds one long and one short leg, broad market moves largely cancel out and the profit depends on the relative move between the two names. It is the original and simplest form of statistical arbitrage.

What is the difference between correlation and cointegration in pairs trading?+

Correlation measures whether two securities’ returns move together over a window; cointegration measures whether the level of the spread between them is anchored and mean-reverting. They are different: two stocks can be highly correlated yet drift apart permanently, and two cointegrated stocks can have modest correlation yet a spread that reliably snaps back. Pairs trading needs cointegration, not just correlation — which is why the standard workflow tests the spread for stationarity with an Augmented Dickey–Fuller test rather than relying on a correlation coefficient.

How do you test whether two stocks are cointegrated?+

The standard approach is the Engle–Granger two-step. First regress one price on the other to estimate the long-run relationship and take the residual, which is the spread. Then run an Augmented Dickey–Fuller (ADF) test on that spread to check whether it is stationary — that is, mean-reverting rather than a random walk. If the ADF test rejects the unit-root null at a sensible significance level, the pair is cointegrated and the spread is tradable. This guards against the spurious-regression problem Granger and Newbold warned about, where regressing two unrelated random walks produces an impressive but meaningless fit.

What entry and exit rules do pairs traders use?+

The spread is standardized to a z-score (its deviation from a rolling mean in units of rolling standard deviation), and trades are triggered on that score. A common rule set enters short the spread when the z-score rises above an upper band such as +2, enters long when it falls below a lower band such as −2, exits as the score reverts toward zero, and stops out if the score keeps widening past a far threshold such as ±3.5 — a sign the relationship may have broken. Tighter bands trade more often on weaker signals; wider bands trade rarely on stronger ones, and thresholds should be chosen out-of-sample.

What are the main risks of pairs trading?+

The central risk is divergence: cointegration is estimated from history and can break — a merger, spin-off, regulatory shock, or fundamental shift can sever the link so the spread keeps widening instead of reverting, turning a market-neutral trade into an unbounded loss. The controls are a divergence stop-loss, periodic re-testing of the relationship, awareness of corporate events, and diversification across many weakly correlated pairs. High turnover also makes transaction costs — commissions, slippage, the bid-ask spread, and short-borrow fees — a decisive risk that can erase a paper edge.

Does pairs trading still work?+

The simple, classic version has largely decayed. Gatev, Goetzmann and Rouwenhorst documented profitable distance-based pairs trading over 1962–2002, but returns fell later in that sample, and Do and Faff found simple pairs trading substantially less profitable after 2002 and often unprofitable once realistic costs were included. Decimalization compressed spreads and cheap computing crowded the trades. Pairs trading can still contribute as part of a diversified, well-hedged, low-cost statistical-arbitrage book using fresher relationships, but any static published recipe should be expected to erode over time.

μα

Micro Alphas Research

Micro Alphas publishes reference explainers on quantitative signal research — signal attribution, alpha decay, market microstructure, and the methods quant teams use to find and protect their edge. Figures are sourced; we correct errors.

About us & editorial standards →

Related research