StocksIntermediateMarket Neutral

Pairs Trading Strategy

Identify historically correlated stock pairs and profit when they diverge. Short the "rich" stock, buy the "cheap" stock, and wait for mean reversion.

Lookback
12-24 months
Entry
2σ divergence
Exit
Mean reversion
Position
Dollar-neutral

Overview

The pairs trading strategy is a classic mean-reversion approach that identifies two historically correlated stocks and trades their relative value. When the spread between them diverges, you bet on convergence.

The key insight: short the "rich" stock (positive demeaned return) and buy the "cheap" stock (negative demeaned return). The strategy is dollar-neutral, meaning equal dollar amounts are allocated to long and short positions.

This market-neutral approach profits regardless of market direction—what matters is the relative performance of the two stocks. When correlation breaks down temporarily, pairs traders step in to capture the reversion.

Key Insight

Mean Reversion
Bet on spread convergence
Dollar Neutral
Equal long and short exposure

Signals

Entry signal (|z| > 2)
Exit signal (z crosses 0)

Trade Logic

z > +2: Short A, Long B
z < -2: Long A, Short B
z → 0: Exit position

Key Insight

The spread tends to revert to its mean (z = 0). Enter when divergence is extreme, exit when it normalizes. Dollar-neutral positioning eliminates market risk.

Research

Research on pairs trading, statistical arbitrage, and mean reversion strategies.

The Mathematics

In Plain English

The math behind this strategy is straightforward. Here's what you're actually doing:

  1. 1
    Find correlated pairs: Identify two stocks with high historical correlation (>0.80) and an economic reason to move together (same industry, competitors, etc.).
  2. 2
    Calculate the spread: Track the price ratio or difference between the stocks. When it deviates significantly from its historical mean, a trading opportunity exists.
  3. 3
    Identify rich vs cheap: The stock with positive demeaned return is "rich" (overperformed); the one with negative demeaned return is "cheap" (underperformed).
  4. 4
    Trade dollar-neutral: Short the rich stock and buy the cheap stock with equal dollar amounts. This eliminates market exposure.

That's it. The formulas below just express this process precisely.

Technical Formulas

1
Simple Returns

Formula
R_A = \frac{P_A(t_2)}{P_A(t_1)} - 1 \quad R_B = \frac{P_B(t_2)}{P_B(t_1)} - 1

Returns for stocks A and B from time t₁ to t₂. Prices are adjusted for splits and dividends.

2
Log Returns (Alternative)

Formula
R_A = \ln\left(\frac{P_A(t_2)}{P_A(t_1)}\right) \quad R_B = \ln\left(\frac{P_B(t_2)}{P_B(t_1)}\right)

Log returns are often preferred as they are additive over time and approximately normal.

3
Mean Return

Formula
\bar{R} = \frac{1}{2}(R_A + R_B)

Average return of the pair. Used as the benchmark for determining rich vs cheap.

4
Demeaned Returns

Formula
\tilde{R}_A = R_A - \bar{R} \quad \tilde{R}_B = R_B - \bar{R}

Stock is "rich" if demeaned return > 0, "cheap" if < 0. Short the rich, buy the cheap.

5
Dollar-Neutral Constraint

Formula
P_A Q_A + P_B Q_B = 0

Dollar value of long position equals dollar value of short position. Q is number of shares (negative for short).

6
Total Investment

Formula
P_A |Q_A| + P_B |Q_B| = I

Total capital deployed equals target investment I. Half goes to long, half to short.

Correlation vs CointegrationNote

Correlation measures how returns move together; cointegration measures whether prices maintain a stable relationship over time. Cointegrated pairs are generally better for pairs trading as the spread is mean-reverting by definition.

Strategy Rules

Pair Selection

  1. Screen for pairs with correlation > 0.80 over 12-24 months
  2. Require economic rationale (same industry, similar business model)
  3. Test for cointegration using Augmented Dickey-Fuller test
  4. Avoid pairs where one stock has pending corporate actions
  5. Prefer liquid stocks with tight bid-ask spreads

Entry Rules

  1. 1Calculate spread (price ratio or difference) between stocks
  2. 2Compute z-score: (current spread - mean) / standard deviation
  3. 3Enter when z-score exceeds ±2.0 (spread diverged 2 standard deviations)
  4. 4Short the outperformer (rich), buy the underperformer (cheap)
  5. 5Ensure dollar-neutral: equal dollar amounts long and short

Exit Rules

  1. Exit when spread reverts to mean (z-score crosses 0)
  2. Take partial profits at z-score ±1.0
  3. Stop-loss if z-score exceeds ±4.0 (spread keeps diverging)
  4. Time-based exit after 20-30 trading days if no reversion
  5. Exit immediately if fundamental relationship breaks

Position Sizing

  1. 1Allocate 2-5% of portfolio per pair trade
  2. 2Equal dollar amounts to long and short legs
  3. 3Account for margin requirements on short positions
  4. 4Diversify across 5-10 pairs to reduce single-pair risk
  5. 5Reduce size during high volatility regimes

Implementation Guide

Pairs trading requires identifying suitable pairs, monitoring spreads, and executing coordinated long-short trades. Here's a practical approach.

1

Screen for Candidate Pairs

Start with stocks in the same industry or sector. Calculate pairwise correlations over the past 12-24 months. Filter for pairs with correlation above 0.80. Common examples: Coca-Cola/Pepsi, Visa/Mastercard, Home Depot/Lowe's.

Tips
  • Use sector ETF holdings as your starting universe
  • Screen for similar market caps to avoid size mismatches
  • Financial data providers like Yahoo Finance show correlation data
2

Test for Cointegration

High correlation isn't enough—test whether the spread is mean-reverting. Use the Augmented Dickey-Fuller (ADF) test on the price spread or ratio. A p-value below 0.05 suggests the spread is stationary (mean-reverting).

Tips
  • Python: from statsmodels.tsa.stattools import adfuller
  • Cointegration is more robust than correlation for pairs trading
  • Re-test periodically as relationships can break down

Past cointegration doesn't guarantee future cointegration. Always have a stop-loss.

3

Calculate the Spread

Track the ratio (Price_A / Price_B) or difference (Price_A - Price_B) over time. Calculate the historical mean and standard deviation. Normalize to a z-score for easier interpretation.

Tips
  • Price ratio is often preferred as it's scale-independent
  • Use a rolling window (20-60 days) for mean and std dev
  • Z-score = (current spread - mean) / standard deviation
4

Set Entry and Exit Rules

Enter when z-score exceeds ±2.0 (spread is 2 standard deviations from mean). Exit when z-score returns to 0. Set stop-loss at ±4.0 to limit losses if spread keeps diverging.

Tips
  • More conservative: enter at ±2.5, exit at ±0.5
  • Consider scaling in: 1/3 at 2.0, 1/3 at 2.5, 1/3 at 3.0
  • Track win rate and average profit/loss to calibrate thresholds
5

Execute Dollar-Neutral Trades

When entering, calculate share quantities so dollar values are equal. If Stock A is $100 and Stock B is $50, and you're deploying $10,000: short 50 shares of A ($5,000) and buy 100 shares of B ($5,000).

Tips
  • Execute both legs simultaneously to minimize slippage
  • Use limit orders for better execution
  • Some brokers offer "pair order" functionality

Broker Requirements

Pairs trading requires the ability to short stocks, which means a margin account. Ensure your broker has shares available to short for your target pairs. Interactive Brokers, TD Ameritrade, and Fidelity all support short selling with good availability.

Helpful Tools & Resources

Pair Screening
Finviz, TradingView, Portfolio123, PairTradeFinder
Analysis
Python (statsmodels), R, Excel
Execution
Interactive Brokers, TD Ameritrade, TradeStation
Research
SSRN, Quantpedia, Seeking Alpha

Strategy Variations

Explore different ways to implement this strategy, each with its own trade-offs and benefits.

Distance Method

Classic approach using price distance (sum of squared deviations). Simple but effective.

Cointegration-Based

Uses statistical cointegration tests. More rigorous pair selection with better mean-reversion properties.

Kalman Filter

Dynamic hedge ratio that adapts to changing relationships. More complex but captures regime changes.

Machine Learning

Use ML to identify pairs and predict spread movements. Can uncover non-obvious relationships.

Consider combining multiple variations or testing them against your specific investment goals and risk tolerance.

Risks & Limitations

High(2)
Medium(3)
Divergence RiskHigh

The spread may keep diverging instead of reverting. Correlation breakdown can lead to significant losses.

Impact:
Short SqueezeHigh

The shorted stock may spike due to short covering, forcing you to cover at a loss.

Impact:
Execution RiskMedium

Difficulty executing both legs simultaneously can create unintended directional exposure.

Impact:
Borrow CostsMedium

Hard-to-borrow stocks have high borrowing fees that eat into profits.

Impact:
Declining AlphaMedium

Pairs trading has become crowded. Returns have declined as more traders exploit the strategy.

Impact:
Understanding these risks is essential for proper position sizing and portfolio construction. Consider combining with other strategies to mitigate individual risk factors.

References

  • Gatev, E., Goetzmann, W. N., & Rouwenhorst, K. G. (2006). Pairs Trading: Performance of a Relative-Value Arbitrage Rule. Review of Financial Studies, 19(3), 797-827 [Link] [PDF]
  • Vidyamurthy, G. (2004). Pairs Trading: Quantitative Methods and Analysis. Wiley Trading Series [Link]
  • Krauss, C. (2017). Statistical Arbitrage Pairs Trading Strategies: Review and Outlook. Journal of Economic Surveys, 31(2), 513-545 [Link]
  • Engle, R. F., & Granger, C. W. J. (1987). Co-Integration and Error Correction: Representation, Estimation, and Testing. Econometrica, 55(2), 251-276 [Link]
  • Sarmento, S. M., & Horta, N. C. G. (2020). Enhancing a Pairs Trading Strategy with Machine Learning. Expert Systems with Applications, 158, 113490 [Link]

Ready to Explore More Strategies?

Access our complete library of academic-backed trading strategies across stocks, options, ETFs, and more.

Browse All Stock Strategies