How to do pair trading?


Pair trading is based on statical analysis, most strategies uses co relation between 2 symbols. When the historical correlation is broken, it sells the overpriced and buys the under priced symbol hoping that the co relation returns to the historical average.

This link will give you the basic idea of pair trading


To add to the general understanding of pair trading where we trade two scrips based on their historical correlation as explained by this link, I'm giving you information on how you can do this on your trading terminal. You can use the spread order window to execute this kind of a trade in some brokerage firms. The exchange generates just one order number for orders entered through the spread window, but your admin positions will show you two positions. In some cases, if the spread order window doesn't work, you can use the Basket Order window. The key is to place market orders because you need to enter and exit both these stocks (futures) at the same time.

Check out this link for a detailed explanation on how to execute your orders.


Pair Trading is a very lose term for what should actually be called a 'Relative Value Trading'. They all belong to a family of trading style called the 'Statistical Arbitrage'. Honestly its difficult to explain this here, reason being it requires some amount of background knowledge on statistic and business fundamentals. 

Assuming you are comfortable with both, here is a brief step by step approach to Relative Value Trading aka 'Pair Trading'..

Step 1) Identify two companies that are similar in terms of business fundamentals - Sales, margins, debt, EV, market cap, regulators, cashflow etc. 

Step 2) Check how the price movement for these two stocks are - you can use a simple correlation test to see if there are any similarities

Step 3) Run a linear regression between the two stocks to extract - Alpha, Beta, P values and residuals

Step 4) Check if the residuals are co integrated

By the time you reach step 4, you should have a fair sense on whether the the two stocks are worth pursuing as a pair. If yes..

Step 5) Construct a beta neutral or a rupee neutral strategy to identify position sizing (how many future lots to go long and how many to go short, how many stocks to buy in spot etc). This should be done for both the stocks

Step 6) Set up a tracking system to spot opportunities in market

Step 7) If you find a good opportunity - execute using a spread order as Hanan suggested and give time for the  trade to evolve. 

Please note, this is just a nutshell of what is otherwise a very elaborate process. 

I've been through this earlier - here is a quick tip from my past experience. Pair Trading does not work on all sectors. Works very well on banking and few metal stocks!

Happy Pairing.  


The pair trade/trading is a market neutral trading strategy of matching a long position with a short position in two stocks of the same sector.

This enables traders to profit from virtually any market conditions and creates a hedge against the sector and the overall market that the two stocks are in.

If the market or the sector movers in one direction or the other, the gain on the long stock is offset by a loss on the short.

You can visit for learning purpose

Check out the below link to understand Pair Trading and download the related Excel sheet:

I think this works well for ICICI with HDFC Bk. The business model, sector of both the companies being the same

I would suggest you back test, point is on the face of it, both ICICI and HDFC looks similar (in fact they are) but going by blind subjectivity leads to a bias. The point of any trading system is to eliminate biases! Hence kindly back test before you conclude.

Although there’'s value to be gained from statistical regression, Pair trading can be done without it. I remember reading a good book (Free Capital by Guy Thomas …highly recommended) about a day trader who just picked it up on the fly while trading in FTSE stocks.

Maybe Manabukun, I haven’t read that book, hence cant comment :slight_smile:

Basically, One thing I learnt from all the investors in that book. “Keep It Simple”. if it’s too complicated, it’s too clsoe to call. :slight_smile:

Hi Karthik,

Can you please guide on constructing beta neutral strategy. An example or pseudo code would suffice.
If I am trading SBIN-PNB (futures) pair, how would I determine how many lots to buy and how many to sell?
For, eg here is the Hedge Ratio for X:SBIN and Y:PNB : 0.0763 (Beta). How would I calculate the lot size?

I wont be able to give out a code for this, however a detailed pair trading module on Varsity is due. Will work on it as soon as the current module is through.

No worries. Thanks…

In Varsity Module on pair trading you mentioned that Adf value should be 5% for a pair to be considered for trading. I back-tested for Nifty defined list of IT and Bank stocks between June 2020 to June 2021 ,observed profitable trades generated for pairs with ADF values greater than 50%.
Is there a specific rule that only ADF less than 5% should be considered or the one’s which generate consistent results can be considered as well.

Also is it safe to backtest or trade for next 3 months based on the Regression parameters generated at a given point.

Pair trading is a strategy in which you have to match long and short positions. It’s not that profitable so be sure before using it.