What is Pairs Trading?
Pairs trading is a market-neutral, statistical arbitrage technique. It pairs a long position in one security with a short position in another security that has historically moved with it. The aim is to capture the change in the relative price of the two, rather than the direction of the market as a whole.
This article explains the core concepts, the mathematics behind the method, how pairs are commonly selected, and a worked example using the Nifty 50 and Bank Nifty indices. It describes how the method works; it does not say that it will work in any given period.
See what markets are pricing in
Live indices, sector moves and market breadth — the backdrop to every story we publish.
The Idea Behind Pairs Trading
The premise is that the spread between two related securities fluctuates around a long-run average. When the spread moves unusually far from that average, the strategy takes a long position in the relatively cheaper leg and a short position in the relatively richer leg. It then closes both when the spread returns toward its average.
Nifty 50 and Bank Nifty are a convenient illustration because banking is a large weight in the Nifty 50, so the two indices share a common driver. Their co-movement is high but not perfect, and the gap between them changes over time.
Mathematics Behind Pairs Trading
Four statistical ideas are used.
- Correlation measures how closely the returns or prices of two securities move together, on a scale from -1 to +1.
- Co-integration looks at the long-term relationship. Two price series can each wander without limit, yet a particular linear combination of them can stay bounded. That is co-integration.
- Stationarity means a series has a roughly constant mean and variance over time. Only a stationary series can be described as mean reverting.
- Mean reversion is the tendency of a stationary series to return toward its average after a deviation.
The Engle-Granger two-step method is a common co-integration test. First, regress one price series on the other. Second, test the regression residuals for a unit root using the Augmented Dickey-Fuller (ADF) test. If the residuals are stationary, the pair is said to be co-integrated.
How Pair Trading Works
The usual workflow has five steps.
- Universe and pair selection. Candidates are often grouped by sector or business similarity. Statistical grouping such as hierarchical clustering, which builds a dendrogram from the distance between price histories, is another common approach.
- Testing. Candidate pairs are checked for correlation and co-integration over a look-back window.
- Spread construction. A hedge ratio is estimated, normally by regression, and the spread is defined as the residual.
- Signals. The spread is standardised (a z-score) and entry and exit thresholds are set.
- Risk controls. Position size, stop levels and periodic re-testing of the relationship are specified.
The flowchart below summarises the process.

The Pair Trading Equation
The spread can be written as a linear combination of the two prices:
Spread = P1 - β × P2 - α
- P1 is the price of the first asset and P2 the price of the second.
- β is the hedge ratio, the coefficient of the second asset in the linear combination. It is typically estimated by linear regression.
- α is a constant that centres the spread on its historical average.
When the spread is far above its mean, the rule goes short P1 and long β units of P2. When it is far below, the position is reversed. The position gains if the spread moves back toward its mean and loses if it moves further away.
Get research like this in your inbox
The week’s research that mattered, in five minutes. Joined by 2L+ investors.
Worked Example: Correlation and Co-integration
The first step in the Nifty and Bank Nifty example is to compare the price data of the two indices.

In the sample used for this illustration the two series showed a correlation of about 80%. Correlation alone is not enough, because two trending series can look correlated without any lasting link. A co-integration test addresses that gap by testing whether a stable long-run relationship exists.
Stationarity and mean reversion
Running the standard co-integration test from Python's statsmodels library on the sample indicated that the two series were co-integrated. The next step is to find a stationary relationship to trade. A plot of the raw spread between the two series shows no obvious tendency to return to a mean.

The regression residuals between the two series, however, look stationary, and the ADF test on them agrees. This is why the hedge ratio is estimated by regression rather than by simply taking the price difference or ratio.

A stationary residual means that large deviations have, historically, been followed by a drift back toward the average. That is a statement about the sample, and relationships can change.
Pair Trading Stock List
A pair trading stock list is a set of securities that tend to move together because they share an industry, customer base or macro driver. Such lists are usually built from sector classification first and then screened statistically. The pairs below are widely used textbook examples of similar businesses. Their inclusion is illustrative and is not a recommendation, and a pair's statistical relationship must be re-tested before use.
| Stock A | Stock B | Common link |
|---|---|---|
| Coca-Cola | PepsiCo | Beverages |
| Shell | BP | Integrated oil and gas |
| Walmart | Costco | Large-format retail |
| Visa | Mastercard | Card payment networks |
| Exxon Mobil | Chevron | Integrated oil and gas |
| Ford | General Motors | Automobiles |
In India, banks, IT services companies, FMCG firms and oil marketing companies are examples of groups with shared drivers. In the Indian cash market, short positions in delivery trades are generally not available to retail participants, so short legs are usually taken through single-stock or index futures. Margin, lot size and cost rules for those contracts are set by the exchanges and SEBI and change from time to time, so the current circulars should be checked.
Implementing the Strategy in Code
The example was written with the Zipline backtesting library. The first step is an initialisation function that defines the global variables. In the example, commission and slippage were set to zero, which is a simplification that real trading does not share.

Next, a handler function receives incoming data at every minute bar and updates the spread.

Finally, the model produces a trading signal and places orders. In the example the rule is to buy the relatively undervalued index and sell the relatively overvalued one when the standardised spread is beyond 1.5 in either direction, and to close both positions when it falls inside 0.5. Order weights depend on the signal and a constant. The thresholds are parameters, not fixed values, and different choices produce different results.


Characteristics and Risks of Pairs Trading
Characteristics
- The position is designed to be market neutral, so its result depends mainly on the relative performance of the two legs rather than on the market direction.
- Offsetting long and short legs are intended to reduce exposure to broad market (systematic) risk.
- The method relies on statistical regularities in historical data, which are assumptions, not guarantees.
Risks
- Relationship breakdown. Corporate events, regulation, mergers or economic shifts can permanently change how two securities relate, and the spread may not revert.
- Divergence before convergence. A spread can widen well beyond its historical range before it narrows, creating losses on open positions.
- Execution risk. Two legs must be traded at the same time, so timing gaps and slippage matter.
- Leverage and margin. Short positions and futures require margin, which magnifies gains and losses.
- Costs. Frequent trading adds brokerage, taxes, impact cost and financing costs, which can erode small spread gains.
- Model risk. Results from a backtest depend on the sample period, parameters, and cost assumptions; the example above used zero costs and does not represent live results.
Past results in a backtest do not indicate what a live strategy will earn, so no performance figures are quoted here.
Further Reading
- Best Quantitative Investment Strategies
- Types of Quant Investment Strategies
- Best Quant Funds That Beat The Stock Market
- Artificial Intelligence in Investing
- Trade to Trade (T2T) Stocks: What It Is & How to Trade?
Track the factors behind this research
Momentum, value, quality and low-vol — updated factor performance for Indian markets.
FAQ
What are the key components of pairs trading?
Pair selection, co-integration analysis, spread measurement, entry and exit signals, and risk management.
What criteria are used when selecting pairs?
High historical correlation, similar sector or business drivers, and a statistically stable co-integrating relationship.
What are typical entry and exit rules?
A position is opened when the standardised spread moves beyond a chosen threshold and closed when it returns toward the mean or hits a predefined limit.
How is risk managed in pairs trading?
Common tools are stop levels on the spread, limits on position size relative to volatility, and periodic re-testing of the pair.
What analysis techniques are used?
Co-integration tests such as Engle-Granger with ADF, correlation analysis, historical backtesting and risk modelling.
This article is for educational purposes only and is not investment advice.