The idea is simple and the practice is not. Two stocks that look alike can drift apart for years, a merger can end a relationship overnight, and in India a short position in a stock cannot be carried overnight in the ordinary cash market. This guide explains how pairs trading works, why cointegration matters more than correlation, how to test a pair, the trading rules, two worked examples with rupee figures, how traders in India hold both legs, the costs, and the mistakes that sink most pair strategies.
Pairs trading at a glance
| Part | What it means |
|---|---|
| The idea | Buy the stock that has fallen behind its partner, sell the one that has run ahead, close both when the gap returns |
| What is traded | The spread: one price minus a multiple of the other |
| The test | Cointegration: does the spread return to a stable level? |
| The signal | The z-score of the spread, such as entry at ±2 and exit at 0 |
| Market exposure | Small if the hedge ratio is right; never exactly zero |
| How Indian traders hold a short | Stock futures, securities lending and borrowing, or intraday only |
| Main risk | The relationship breaks and the spread keeps widening |
A short history of pairs trading
Pairs trading grew out of the trading desks of the 1980s. At Morgan Stanley, a group led by Nunzio Tartaglia built computer programs that looked for stocks whose prices usually moved together and traded them when they drifted apart.1 The method spread to hedge funds and proprietary desks through the late 1980s and 1990s, and became one of the first strategies that ran on rules and computers rather than on a trader's judgement.
The statistics behind it came from economics. In 1987 Robert Engle and Clive Granger published the idea of cointegration: two series that each wander freely can still be tied together so that a combination of them stays stable.2 Engle and Granger shared the Nobel prize in economics in 2003 for this and related work.3 Søren Johansen later gave a test that works on more than two series at once.
The best-known study of pairs trading appeared in 2006. Evan Gatev, William Goetzmann and Geert Rouwenhorst tested a simple rule on US stocks from 1962 onwards: match each stock with the one whose past prices tracked it most closely, and trade when the two drifted apart.4 They found that the rule earned excess returns over the decades they studied, and that the returns shrank in the later years as more traders used the idea. Later work found the same fading: as a strategy becomes well known, the gaps it trades close faster and the profit per trade falls.
In India, the tools for holding both legs arrived in stages. Stock futures began trading on the NSE in November 2001, which gave traders a way to hold a short position in a stock beyond the day.5 In December 2007 SEBI announced a framework for short selling and for securities lending and borrowing, which opened another route to an overnight short in the cash market.6 Since then, retail traders have run pairs mostly through stock futures, with intraday pairs in the cash market as the other common route.
How pairs trading works
Some stocks move together because they share the same drivers: two large private banks face the same interest rates and loan growth, two IT services companies sell to the same clients abroad, two cement makers face the same fuel costs and construction cycle. Their prices rarely move in lockstep, but the gap between them may stay inside a range over time.
When the gap stretches far from its usual level, a pairs trader:
- Buys the stock that has fallen behind, and
- Sells the stock that has run ahead,
then closes both when the gap returns to normal. If the whole market falls, the long position loses and the short position gains, and the two roughly offset. If the whole market rises, the reverse happens. What decides the result is the spread between the two, not the direction of the market.
There are two ways to size the legs. Rupee-neutral sizing puts the same rupee amount on each side. Ratio sizing uses the hedge ratio from the cointegration test, so the legs are sized to the measured relationship rather than to equal amounts. The two give different positions when the stocks trade at very different prices or move by different amounts, and ratio sizing is the one that matches the spread you tested.
That is the appeal, and it is also the limit. A pair is only market-neutral if the two legs are sized correctly and the relationship between the stocks holds. When one company has news of its own, a result, a merger, a regulator's order, the two legs stop offsetting each other and the trade becomes an ordinary bet on one stock.
Correlation is not enough: cointegration
Two stocks can be highly correlated in their daily moves and still drift apart for years. Correlation measures whether daily returns tend to move in the same direction on the same day. It says nothing about whether the price gap returns to a stable level.
A simple example shows the difference. Stock A rises 1.0% on every day the market rises and stock B rises 1.1%; on down days A falls 1.0% and B falls 1.1%. Their daily returns are almost perfectly correlated. Yet over a few years B pulls further and further ahead, because its moves are slightly larger, and the gap never comes back. A trader who sold B and bought A each time the gap looked wide would lose every time.
Cointegration is the property pairs traders need. Two prices are cointegrated if some combination of them, such as stock A minus a fixed multiple of stock B, tends to return to a stable average. The prices themselves can wander anywhere; the combination cannot wander far for long. That combination is the spread, and the fixed multiple is the hedge ratio.
Testing a pair for cointegration
The Engle–Granger method has three steps:
- Regress the price of stock A on the price of stock B over a formation period, such as one year of daily closes. The slope of the line is the hedge ratio, written here as h.
- Compute the spread for each day: A − h × B.
- Test the spread for stationarity with an Augmented Dickey–Fuller (ADF) test. A stationary series keeps returning to its average. A low p-value, such as below 0.05, suggests the spread tends to revert; a high one suggests it does not.
The pairs cointegration tester on this site runs these steps for two NSE stocks.
The half-life of the spread
A pair that reverts in two days and a pair that reverts in four months are different trades. The half-life measures how long the spread takes, on average, to close half of the gap from its average. It is estimated by regressing the day's change in the spread on the previous day's spread. If that slope is λ (a negative number for a reverting spread), the half-life in days is about −ln 2 ÷ λ.
| Half-life | What it means for the trade |
|---|---|
| 2 to 10 days | Suits a trade held for days to two weeks; enough trades in a year to judge the rule |
| 10 to 40 days | Positions held for weeks; futures legs often need a roll across expiry |
| Over 60 days | Slow; capital is tied up and the relationship has time to break |
| No clear half-life | The spread may not revert at all |
Checks beyond the test
A test result is not a reason on its own. Before trading a pair, check:
- The business link. Is there a reason the two should stay tied, such as the same sector, the same customers or the same costs? A pair with no reason behind it is usually a pattern found by chance.
- Stability. Run the test on two or three separate years. A pair that passes in one year only is fragile.
- The hedge ratio over time. If the ratio moves a lot from one year to the next, the spread you trade today may not be the one you tested.
- Liquidity. Both stocks, or both futures, must trade enough that your orders fill near the screen price.
Where Indian traders look for candidate pairs
Candidates come from groups of companies whose results depend on the same few things:
| Group | Shared drivers | What can break the link |
|---|---|---|
| Large private banks | Interest rates, loan growth, credit costs | A merger, a change of management, a regulator's action on one bank |
| Public sector banks | Government policy, bad-loan cycles | A recapitalisation or merger affecting one bank |
| IT services | US and European tech spending, the rupee | A large client win or loss, a results surprise |
| Cement makers | Construction demand, fuel and freight costs | Capacity additions, an acquisition |
| Oil marketing companies | Crude prices, government pricing decisions | A change in policy on one company's business |
| Two-wheeler makers | Rural demand, fuel prices | A new product cycle or export shift at one maker |
A stock against its own sector index, through index futures where they exist, is another common pair. It has one advantage: the index cannot be acquired or delisted, so one of the two legs cannot break suddenly.
Reading a pair backtest
When you test a pair rule on past data, the total profit is the least useful number. Look at:
- How many trades closed at the exit level, and how many at the stop or the time limit. A pair that often hits its stop is not reverting reliably.
- The worst single trade. It usually comes from a broken pair, and it tells you what the strategy costs when it goes wrong.
- The holding time of each trade compared with the half-life you estimated. Trades that last much longer than the half-life point to a weakening relationship.
- The results by year. A pair whose profits come from one year only is likely to have been a chance fit.
- The result after costs of every order, including rolls.
The trading rules
- Formation: test candidate pairs from the same sector on a year of data and keep those that pass the cointegration test and the checks above.
- Standardise: convert the spread into a z-score: (spread − its average) ÷ its standard deviation, both measured on the formation period or on a rolling window.
- Entry: when the z-score rises above +2, sell A and buy h units of B for each unit of A. When it falls below −2, buy A and sell h units of B.
- Exit: close both legs when the z-score returns to 0, or to a small band around it.
- Stop: close both legs if the z-score reaches ±3.5, or after a maximum holding period such as three times the half-life.
- Re-test: repeat the formation step regularly, such as each quarter, because relationships change.
The levels of 2, 0 and 3.5 are common starting points, not rules. A wider entry gives fewer trades with more room to revert; a tighter stop limits the damage when a pair breaks but cuts more trades that would have recovered.
A worked example: a bank pair in the cash market, intraday
This is a hypothetical example.
- Two private bank stocks, A and B, pass the cointegration test with a hedge ratio of 0.8. On the formation data the spread A − 0.8 × B averages ₹120 with a standard deviation of ₹15.
- At 10:15 am the spread reaches ₹153, a z-score of 2.2. The trader sells 500 shares of A at ₹1,653 and buys 400 shares of B at ₹1,875. That is 0.8 shares of B for each share of A.
- By 2:40 pm the spread has narrowed to ₹125, a z-score of 0.3. The trader closes both legs: A is bought back at ₹1,641 and B is sold at ₹1,895.
- The short in A gains (1,653 − 1,641) × 500 = ₹6,000. The long in B gains (1,895 − 1,875) × 400 = ₹8,000. The gross result is ₹14,000.
From that come the costs of four orders: brokerage, STT on the two sell orders, exchange charges, stamp duty on the two buys, and GST. With intraday rates and ₹20 an order, they come to a few hundred rupees here. The point of the example is not the figure: it is that the result came from the gap closing, not from the direction of the banking sector. Both legs could have fallen or both risen, and the result would have been similar as long as the gap closed.
Because both legs are in the cash market, both must be closed the same day. If the gap had not closed by the end of the session, the trader would have had to close both at whatever the spread was at that moment.
A worked example: holding a pair with stock futures
To hold a pair for days, Indian traders usually use stock futures for both legs. The difficulty is that futures come in fixed lots, so the hedge ratio can only be matched roughly.
Suppose stock C's futures have a lot of 550 shares and stock D's a lot of 700 shares, and the hedge ratio is 1.3 shares of D for each share of C.
- One lot of C is 550 shares, so the ideal D position is 550 × 1.3 = 715 shares.
- One lot of D is 700 shares, which is close: the pair is 2% short of the ideal ratio.
- If the ratio were 1.6 instead, the ideal D position would be 880 shares. One lot (700) is 20% short and two lots (1,400) are 59% over. The trader would need several lots of C to find a combination close to the ratio, such as 4 lots of C (2,200 shares) against 5 lots of D (3,500 shares, a ratio of 1.59).
The leftover mismatch is a small position in one stock that the pair does not hedge. It is part of the risk, and it grows as the prices move. A pair that cannot be sized close to its ratio with lots you can afford is better left alone.
Futures also expire. A pair held into the last week of the month has to be rolled: both near-month futures closed and both next-month futures opened, which doubles the orders and the costs for that week.
Pairs trading in Indian markets
Holding a short position in a stock overnight is not possible in the ordinary cash market, because an intraday short sale must be squared off the same day. Traders use one of three routes:
| Route | How the short is held | Points to know |
|---|---|---|
| Stock futures | A sold futures contract | Only stocks with futures; fixed lots; margin on both legs; monthly rolls |
| Securities lending and borrowing (SLB) | Borrowed shares, sold in the cash market | A lending fee; borrowing must be available for that stock; not every broker offers it |
| Intraday pairs | A same-day short sale | No overnight risk; the spread must close within the session |
Margin is the other constraint. A futures pair needs margin on both legs. Some brokers give a margin benefit when two positions offset each other, but a pair of different stocks usually does not qualify for the large hedge benefit that a hedged index option position gets. Plan for the full margin of both legs.
Costs on four orders
A pair has four orders for every round trip: two to enter and two to exit. Rolling futures adds four more each month. Since 1 April 2026, STT on futures is 0.05% of the value of each sell order,7 and brokerage, exchange charges, stamp duty on buys and GST come on top. On a pair worth ₹10 lakh on each side, STT alone on the two sell orders of a round trip is about ₹1,000. A spread that reverts by a small amount many times a month can be eaten by these costs; check the expected gain per trade against them before you trade.
Running a pair strategy on QuantPower
QuantPower runs algos made of legs on futures, stocks and options, and orders go to your own broker account through its official API from the two static IPs included with your account. A pair can be set up this way:
- Find the pair with the cointegration tester and your own checks. Note the hedge ratio, the half-life and the z-score levels.
- Build two algos of two legs each: one that sells A futures and buys B futures in the lot combination closest to the ratio, and one that does the opposite. Each algo is off until you switch it on.
- Compute the z-score in your own code, spreadsheet or charting tool, and send its entry and exit signals to a QuantPower webhook. An entry hit switches the linked algo on and enters now; an exit hit stops it and squares off both legs. A webhook can be linked to up to 10 algos, and you can have up to 20 webhooks.
- Set the account's safety rules: Smart Exit to square off every position and stop the algos at a set loss or profit for the whole account, a daily loss limit that refuses new orders once the day's loss reaches it, and the kill switch to stop a segment until its next session.
- Test in Forward test first. The same algos run with test money, so you can see fills and timing on live prices before any order reaches your broker.
Forward test costs 100 tokens per algo per 28 days and a live algo 200 tokens per 28 days (1 token = ₹1, GST extra). A pair of opposite algos switched on as needed is charged once for each algo per 28-day cycle, and a webhook hit that restarts an algo already paid for costs nothing more. To check the rules on past data first, our guide on how to backtest trading strategies explains how to test them fairly.
How to run a pair strategy well
- Start from a reason, then test. Pick pairs whose businesses are tied, then test them. Testing every possible pair in the market and keeping the ones that pass finds chance patterns.
- Separate formation and trading. Choose pairs and their hedge ratios on one period and trade them on the next. Never judge a pair on the data you used to pick it.
- Size so a broken pair is survivable. Assume one pair in your list will break each year, and size each pair so that a stop at ±3.5 is a loss you can carry.
- Spread the risk. Five unrelated pairs at small size are safer than one large pair.
- Watch for news. A result date, a merger, a block deal or a change in index weights can break a pair. Many traders close a pair before scheduled company events.
- Re-test on a schedule and drop pairs whose test results or hedge ratios have changed.
- Count every cost, including rolls, borrowing fees and the slippage of placing two orders that are not filled at the same instant.
Common mistakes
- Trading correlation, not cointegration. Two stocks that move together day by day can still drift apart for good.
- Testing too many pairs. At a 5% test level, one pair in twenty passes by chance. Test 400 pairs and about 20 will pass with no real link at all. See our guide on avoiding overfitting.
- Ignoring the half-life. A pair that reverts over months ties up margin and gives the relationship time to break.
- No stop. Waiting for a broken pair to come back is how pair traders take their largest losses.
- Ignoring lot mismatch. A pair sized at the wrong ratio carries a hidden bet on one stock.
- Survivorship bias in testing. Testing only stocks listed today leaves out the pairs that ended in a merger or delisting, which are exactly the cases that lose.
- Forgetting the roll. A futures pair held across expiry has a week of doubled costs and a short gap between the old and new contracts.
Where pairs trading is going
The simple two-stock pair is now well known, and the gaps it trades close faster than they once did. Research and practice have moved in three directions. The first is baskets: a stock traded against a weighted group of its peers, or against a sector index, rather than against one partner. The second is better statistics: tests that allow the hedge ratio to change over time, and models that estimate how fast a spread reverts in different market conditions. The third is wider data: company filings, news and analysts' estimates used to judge whether a gap is a temporary drift or the start of a lasting change.
In India, the pool of stocks with futures, the lot sizes and the margin rules all shape what pairs are practical. Contract sizes for derivatives have been raised more than once, which makes small pairs harder to size. A trader planning a pair strategy should check the current futures list, lot sizes and margin before choosing pairs.
Start with 500 free tokens
Connect your broker, build a strategy and test it on paper before a single live order goes out.
Frequently asked questions
What is pairs trading?
Buying one stock and selling a related one when the gap between them is unusually wide, and closing both when the gap returns to its usual level. The result depends on the gap, not on the direction of the market.
What is the difference between correlation and cointegration?
Correlation measures whether daily returns move together. Cointegration measures whether the price gap tends to return to a stable level, which is what a pairs trade needs.
Can I short stocks overnight for pairs trading in India?
Not in the regular cash market. Traders use stock futures or securities lending and borrowing for overnight short positions, or trade pairs intraday and close both legs the same day.
How long does a pairs trade usually last?
It depends on the pair's half-life, the average time the spread takes to close half its gap. Pairs with a half-life of a few days to two weeks suit most traders; slower pairs tie up margin for longer.
What z-score levels should I use?
Entry at ±2, exit at 0 and a stop at ±3.5 are common starting points. Test levels around them on data you did not use to pick the pair, and keep a level only if nearby levels give similar results.
Is pairs trading risk-free?
No. If the relationship between the stocks breaks, the spread can keep widening and cause large losses on both legs. A stop on the z-score and a limit on holding time are essential.
Related guides
- Walk-forward testing: checking a pair on data it was not chosen on
- Stock correlation matrix: finding candidates by how they move together
- Backtesting: testing rules on past prices before they trade
References
- Ganapathy Vidyamurthy, *Pairs Trading: Quantitative Methods and Analysis*, Wiley (2004), on the origins of pairs trading at Morgan Stanley in the 1980s
- R. F. Engle and C. W. J. Granger, "Co-Integration and Error Correction: Representation, Estimation, and Testing", *Econometrica* 55(2), 251–276 (1987)
- The Nobel Prize, "The Sveriges Riksbank Prize in Economic Sciences 2003" (nobelprize.org)
- E. Gatev, W. N. Goetzmann and K. G. Rouwenhorst, "Pairs Trading: Performance of a Relative-Value Arbitrage Rule", *Review of Financial Studies* 19(3), 797–827 (2006)
- NSE, history of the equity derivatives segment: stock futures from November 2001 (nseindia.com)
- SEBI, circular on short selling and securities lending and borrowing, 20 December 2007 (sebi.gov.in)
- Union Budget 2026-27: securities transaction tax on futures and options raised from 1 April 2026 (indiabudget.gov.in)