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.
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
Signals
Trade Logic
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:
- 1Find correlated pairs: Identify two stocks with high historical correlation (>0.80) and an economic reason to move together (same industry, competitors, etc.).
- 2Calculate the spread: Track the price ratio or difference between the stocks. When it deviates significantly from its historical mean, a trading opportunity exists.
- 3Identify rich vs cheap: The stock with positive demeaned return is "rich" (overperformed); the one with negative demeaned return is "cheap" (underperformed).
- 4Trade 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.
1Simple Returns
Returns for stocks A and B from time t₁ to t₂. Prices are adjusted for splits and dividends.
2Log Returns (Alternative)
Log returns are often preferred as they are additive over time and approximately normal.
3Mean Return
Average return of the pair. Used as the benchmark for determining rich vs cheap.
4Demeaned Returns
Stock is "rich" if demeaned return > 0, "cheap" if < 0. Short the rich, buy the cheap.
5Dollar-Neutral Constraint
Dollar value of long position equals dollar value of short position. Q is number of shares (negative for short).
6Total Investment
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
- Screen for pairs with correlation > 0.80 over 12-24 months
- Require economic rationale (same industry, similar business model)
- Test for cointegration using Augmented Dickey-Fuller test
- Avoid pairs where one stock has pending corporate actions
- Prefer liquid stocks with tight bid-ask spreads
Entry Rules
- 1Calculate spread (price ratio or difference) between stocks
- 2Compute z-score: (current spread - mean) / standard deviation
- 3Enter when z-score exceeds ±2.0 (spread diverged 2 standard deviations)
- 4Short the outperformer (rich), buy the underperformer (cheap)
- 5Ensure dollar-neutral: equal dollar amounts long and short
Exit Rules
- Exit when spread reverts to mean (z-score crosses 0)
- Take partial profits at z-score ±1.0
- Stop-loss if z-score exceeds ±4.0 (spread keeps diverging)
- Time-based exit after 20-30 trading days if no reversion
- Exit immediately if fundamental relationship breaks
Position Sizing
- 1Allocate 2-5% of portfolio per pair trade
- 2Equal dollar amounts to long and short legs
- 3Account for margin requirements on short positions
- 4Diversify across 5-10 pairs to reduce single-pair risk
- 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.
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.
- 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
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).
- 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.
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.
- 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
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.
- 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
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).
- 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
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.
Risks & Limitations
The spread may keep diverging instead of reverting. Correlation breakdown can lead to significant losses.
The shorted stock may spike due to short covering, forcing you to cover at a loss.
Difficulty executing both legs simultaneously can create unintended directional exposure.
Hard-to-borrow stocks have high borrowing fees that eat into profits.
Pairs trading has become crowded. Returns have declined as more traders exploit the strategy.
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