Pair Trading: Diversify & Hedge

Pair trading combines a long position in one asset with a short position in another to trade their relative performance. It aims to reduce exposure to shared market drivers, but it is not automatically market-neutral or protected against losses. The relationship can change, the spread can keep widening, and the short leg introduces borrowing and execution risks.
A useful pair-trading process connects an economic reason for the relationship with a defined spread, a hedge ratio, entry and exit rules, and realistic costs. LuxAlgo charts can help compare the assets, while Quant can help build research indicators and explicit chart strategies. A complete two-leg simulation must also account for both positions and their financing.
Finding Related Asset Pairs
Correlation and Cointegration Answer Different Questions
Start with assets that have a plausible shared driver: similar businesses, related ETFs, currencies exposed to common factors, or linked commodity contracts. Then examine whether the relationship is stable enough to investigate. Similar company names or a visually matching chart are only a starting point.
Correlation measures linear association between the chosen series over a specified sample. For co-movement research, use consistently sampled returns and state the lookback. Correlating two trending price levels can produce a reassuring number without a useful trading relationship.
| Correlation | What it describes | What it does not prove |
|---|---|---|
| Near +1 | Strong positive linear co-movement in the measured series | That a price spread will revert or that equal dollar positions remove risk |
| Near 0 | Little linear association in that sample | Independence or the absence of nonlinear relationships |
| Near −1 | Strong inverse linear co-movement | That a conventional long-short pair is the appropriate hedge |
There is no universal 0.80 threshold that validates a pair. The LuxAlgo Historical Correlation indicator can help inspect how measured relationships evolve. Check the selected inputs, anchor and reset settings before interpreting its values. Correlation output is not a cointegration test.
Cointegration asks whether an appropriate combination of nonstationary series is stationary. In practical terms, the individual price series may wander while a modeled residual has more stable statistical behavior. That supports investigating mean reversion; it does not establish future convergence or profitability after costs.
The augmented Engle–Granger test tests the null of no cointegration and assumes the input series are integrated of order one. Its residual test uses cointegration-specific inference; applying an ordinary ADF test to each asset separately does not establish cointegration. The Johansen method evaluates cointegration rank in a multivariate system, with results affected by lag and deterministic-term choices.
Examples to Research
- Stocks: two companies in the same industry may share demand and input costs, but earnings surprises, leverage and business mix can drive persistent separation. AAPL and MSFT are research examples, not a validated pair merely because both are large technology companies.
- Currencies: EUR/USD and GBP/USD share a dollar component, but their correlation depends on the sample and policy environment. Long one and short the other creates a cross-currency exposure whose size depends on units and exchange rates.
- Commodities: WTI and Brent have related economic drivers, but location, quality, transport constraints and contract maturities affect the spread. Futures multipliers, expiry and rolling costs belong in the model.
Validate Before Looking at the Trading Result
Align timestamps, currencies and trading sessions. Handle stock splits and dividends consistently, distinguish adjusted research prices from executable prices, and avoid letting stale prices make a spread appear stable. Use a formation period to select candidates and estimate the model, then evaluate an untouched later trading period.
Testing hundreds of combinations makes false discoveries more likely. Record rejected candidates and parameter trials, check relationship stability across windows, and define a scheduled review process. A low historical p-value is evidence under the test’s assumptions, not a guarantee that the same relationship survives an acquisition, policy change or supply shock.
Making Pair Trades
Define the Spread Before Choosing a Direction
One simple price-level model is S = price of A − h × price of B − c, where h is an estimated hedge coefficient and c is an intercept. Fit them using information available before the trading period. Other models use log prices or a price ratio; those choices change how the signal relates to position sizing.
Standardize the spread as z = (S − historical mean of S) / historical standard deviation of S. State the estimation window and how it is updated. Do not generate a signal when the denominator is zero or the data is incomplete. A z-score describes deviation within that model; it does not establish intrinsic overvaluation.
For a positive h in the price-level model, a high positive spread suggests investigating a short in A and a long in h units of B. A low negative spread suggests the reverse. If the coefficient is negative, the conventional opposite-direction trade no longer represents that model; investigate the specification rather than forcing a long-short interpretation.
Match Position Size to the Hedge Model
Dollar neutrality, beta neutrality and statistical spread hedging are different objectives. Equal dollar exposure is easy to describe, but assets with different market sensitivities can leave substantial net market exposure. A price-level hedge coefficient describes units of B per unit of A; a coefficient estimated from log prices is not automatically a share-count ratio.
Worked example, using invented prices: assume h = 2 and c = 0, with A at $104 and B at $50. The spread is $4. If its previously estimated mean is $0 and standard deviation is $2, z = 2. A short-spread trade of 100 shares of A and 200 shares of B has these outcomes:
| Leg | Entry | Convergence exit | Profit or loss |
|---|---|---|---|
| Short 100 A | Sell at $104 | Buy back at $102 | +$200 |
| Long 200 B | Buy at $50 | Sell at $51 | +$200 |
| Combined | Gross exposure $20,400 | Spread reaches $0 | +$400 before all costs |
The starting net dollar exposure is −$400: $10,000 long minus $10,400 short. The trade follows the assumed spread coefficient, but is not exactly dollar-neutral. Gross exposure is the sum of the absolute leg values; it is not the same as margin required or account equity.
If A instead rises to $110 and B falls to $49, the short loses $600 and the long loses $200, for an $800 combined loss before costs. Both legs can lose at once. On a hypothetical $50,000 account, those $400 and $800 outcomes equal +0.8% and −1.6% of account equity before costs, not returns on the short-sale proceeds.
Set a pair-level loss budget and size both legs together using an adverse spread scenario, then allow for gaps and costs. A planned $500 loss limit is not a guaranteed maximum. Stress the hedge coefficient and liquidity assumptions as well as the observed spread volatility.
Write Entry and Exit Rules in Advance
| Rule | Illustrative research specification | What to verify |
|---|---|---|
| Entry | Enter after a completed-bar z-score crosses above +2 or below −2 | Use the correct direction, pre-estimated model and next available executable quotes |
| Convergence exit | Close both legs when the spread crosses its modeled mean | Calculate each leg’s actual P&L, including costs |
| Adverse move | Close at a defined pair-level dollar loss or an adverse z-score threshold | A changing standard deviation can change z without recovering the dollar loss |
| Time or relationship exit | Exit after a fixed holding period or a documented model-break condition | Choose the rule before testing and model both closing orders |
These thresholds are examples, not optimal settings. For a short spread entered near +2, movement toward +3 is adverse; for a long spread near −2, movement toward −3 is adverse. Define which exit takes priority and avoid repeatedly widening the boundary to keep a losing position open.
Video: Pairs Trading and Mean Reversion
Spencer Pao’s educational walkthrough introduces a quantitative pairs-trading approach. “Quant” in the original video title refers to quantitative trading; this is not a demonstration of LuxAlgo’s coding agent. Apply the correlation-versus-cointegration distinction above when evaluating the simplified examples, and assess any reported results independently.
Risk Control
Plan for Relationship and Execution Failures
- Structural breaks: an earnings shock, merger, regulation or changing supply conditions can make the old spread mean irrelevant.
- Short-selling costs: borrow fees, recalls, dividend obligations and margin requirements can change while the position is open. Investor.gov’s short-sale bulletin also explains why an unhedged stock short has theoretically unlimited loss potential.
- Legging risk: one order can fill while the other fails or fills at a worse price. Specify what to do with incomplete execution; two ordinary orders are not an atomic pair trade.
- Liquidity and gaps: a trading halt or price jump can prevent an intended simultaneous exit. Stop orders do not guarantee an execution price.
- Leverage: small net exposure can conceal large gross positions and financing demands. Monitor both legs and available collateral.
Measure Net Results After Costs
Track combined mark-to-market P&L and each leg separately. Include commissions and bid-ask costs on entry and exit, stock borrow, financing, dividends or futures roll effects where applicable. The worked example’s $400 gross gain becomes $280 if the actual total costs are $120; that amount is illustrative, not an estimate for a particular broker.
A price alert is a notification unless a separately configured execution system acts on it. Live data, a chart script or a WebSocket connection alone does not guarantee that both positions will close. Test disconnections, rejected orders and recovery procedures in the execution environment you intend to use.
Diversify by Underlying Exposure
Review correlations between pair-level returns and common risk factors, not just correlations between the individual stocks. Several pairs containing the same company or the same sector can concentrate risk. A long position in one pair may offset a short position elsewhere while leaving costs and model complexity.
Allocate capital using conservative loss and liquidity scenarios, cap shared exposures, and review the portfolio on a defined schedule. Adding pairs can reduce concentration when their risks differ, but it does not guarantee lower volatility during a market shock.
Trading Software Guide
Research the Relationship on LuxAlgo Charts
Use LuxAlgo’s multi-chart layout to place both assets beside each other, match the interval and inspect the same dates. Keep symbol synchronization off when the purpose is to compare different assets. Check each market’s session, currency and data source before treating candles as simultaneous observations.
Quant, our coding agent, can help write a spread or z-score research indicator when the required series and functions are available. Specify both symbols, aligned intervals, the spread definition and calculation window. Review the generated code against a small manually calculated sample before relying on the plot.
If you convert an idea to a chart strategy, inspect its order logic and Trades Log. A signal that reads a second symbol does not by itself prove that the backtest traded both assets. Do not present a single-chart strategy report as combined pair performance unless the implementation explicitly models both legs, cash flows, margin and costs.
Use Tools That Cover the Complete Trade
For statistical testing, packages such as statsmodels provide documented cointegration methods. For portfolio evaluation, use a backtesting setup that can track both assets with synchronized prices and realistic fills. Report net P&L, drawdown, holding time, turnover, exposure, borrowing assumptions and the untouched evaluation period.
Specialist software can complement this research. Pair Trading Lab distinguishes its web analysis and backtesting tools from PTL Trader, its separate execution application. Its documentation lists Interactive Brokers connectivity, paper-account support and instrument/account restrictions. PTL Trader itself is not a charting or backtesting application.
PairTrade Finder is another specialist product discussed in this area, but compare current vendor documentation, data coverage, costs and execution behavior before choosing a tool. A vendor’s historical return chart or testimonial is not a forecast for your account. Avoid selecting software on an unsupported monthly-return claim.
How to Get Started
- Choose one economically plausible pair and document why its relationship might persist.
- Define aligned data, the spread model and the formation period before examining trading results.
- Check statistical assumptions and evaluate fixed rules on a later period, including both legs and costs.
- Paper-test execution failures, borrow constraints and pair-level exits.
- Review results and shared portfolio exposures before considering additional pairs.
Pair trading is a way to express a relative-value hypothesis. Its advantage depends on the quality of the relationship, sizing and execution—not simply holding one long and one short position.
Read next