Module 10 Trading Systems

Chapter 7

PTM1,C5 – The Pair Trade

198

7.1 – Quick Reminder

We closed the previous chapter with a note on Density curve and how the value of the density curve helps us spot pair trading opportunity. In this chapter, we will work towards identifying and initiating an actual trade and learning other dynamics associated with a pair trade.

Just as a reminder – the techniques we have discussed so far in pair trading (i.e from chapter 1 through 7) is from the book called ‘Trading Pair’, by Mark Whistler. The good part about this technique is the simplicity and the part that I’m not too conformable with this technique is also its simplicity. Over time I’ve improved technique to pair trade, which I will discuss from the next chapter onwards.

Why not discuss the 2nd method directly, you may ask – well, this is because I think Mark Whistler method to pair trade lays an excellent foundation and it helps understand the slightly more complex pair trading technique better. So let me attempt to finish the Mark Whistler’s method in this chapter and move to the next method to pair trade.

Now, because I’ll discuss this other technique to pair trade, I’ll take the liberty to not really get into the nuances of the trade set up. I’ll instead focus on the broad trade set up.

So let’s get started on it.

7.2 – Digging into Density curve

The density curve acts as a key trigger for us to identify an opportunity to trade. I want you to pay attention to the following two things –

  1. The density curve is calculated based on the time series data, and the time series data in our context is the ‘ratio’ – as you may recall from the previous chapter, the main inputs to calculate the density curve is the ratio’s time series, the ratio’s mean, and the ratio’s standard deviation
  2. The density curve is a value – varying between 1 and 0. The value of the density curve helps us understand the probability of the ratio, falling back to the mean.

I understand the 2nd statement may confuse some of the readers, but at this point, I’d suggest you keep this statement in mind. You will understand what I mean by this as we proceed.

Let us spend a little time on the normal distribution, I know we have discussed this multiple times in the past, but bear with me one more time.

The time series data (like the ratio) typically have an average (or mean) value. For example, the average value for the ratio time series is 1.87 (we calculated this in the earlier chapter). More often than not, the value of the ratio tends to lie around the mean value. If the value of the ratio drifts away from the mean, then one can expect the value of the ratio to gravitate back to the mean.

For example, if the latest value of the ratio shoots up to 2.5, then over time, one can expect the value of the ratio to fall to 1.87 and likewise if the value of the ratio plummets.

Now here is a question – If the ratio drifts away from the mean (which is bound to happen on a daily basis), is there a way wherein we can quantify the probability of the ratio to move back to the mean, again?

For example, if the latest ratio value is at 2.5, we all know it will fall to a mean of 1.87, but what is the probability of this occurring? Is it 10%, 20% or 90%?

This is where the density curve comes in handy. The value of the density curve tells us how far, in terms of standard deviation, the ratio has deviated away from its mean. Now, if the value is in terms of standard deviation, then naturally there is a probability assigned to it, and eventually, this probability helps us set up a trade.

Let me give you a quick example.

Consider the following data –

Latest ratio – 2.87

Ratio Mean – 1.87

Density curve – 0.92

Here is how you will interpret this data – the 0.92 value of the density curve indicates that the latest ratio of 2.87 has approximately deviated to the 2nd standard deviation and there is approximately 95% chance that the ratio of 2.87 will fall back to its average value of 1.87.

How did we arrive at this? I mean what tells us that the ratio of 2.87 is approximately near the 2nd standard deviation? Well, we infer this by looking at the corresponding density curve value i.e. 0.92.

The density curve value from 0 to 1 represents the standard deviation values. For example –

  1. The density curve of 0.16 implies that the corresponding value is at the -1 standard deviation below the mean
  2. The density curve value of 0.84 implies that the corresponding value is at the +1 standard deviation above the mean
  3. The density curve value of 0.997 implies that the corresponding value is at the 3 standard deviations above the mean

Once I know the standard deviation, I’ll also know the probability.

But How did I arrive at 0.16, 0.84, 0.997 etc in the first place? Well, these are standard deviation values, I will skip dwelling further into standard deviation, instead give you a table which you can use as a ready reckoner –

Density Curve value How many Standard deviation away Probability of reverting to mean
0.16 – 1 SD 65%
0.025 – 2 SD 95%
0.003 –  3 SD 99.7%
0.84 + 1 SD 65%
0.974 + 2 SD 95%
0.997 + 3 SD 99.7%

Given the above, if I see the density curve value of around 0.19, I know the ratio is around the – 1st standard deviation, hence the probability of the ratio to move back to mean is around 65%. Or if the density curve value is around 0.999, I know the value is around the – 3SD, hence the probability of the ratio to move back to mean is around 99.7%

So on and so forth.

7.3 – The first pair trade

So, finally, here we are, very close to showcasing our first Pair trade. Few points to remember –

  1. The ratio is calculated by dividing Stock A over Stock B. In our example, Stock A is Axis Bank and Stock B is ICICI Bank. So Ratio = Axis Bank / ICICI Bank
  2. The ratio value changes daily, based on the stock prices of Axis Bank and ICICI Bank
  3. The ratio and its corresponding density curve value has to be calculated daily

The trading philosophy is as below –

  1. If two business are alike and operate in the same landscape – like Axis Bank and ICICI Bank, then their stock prices tend to move together
  2. Any change in the business landscape will affect the stock prices of both the companies
  3. A stray incident can cause the stock price of one company to deviate away from the stock price of the other. On such days, the ratio to deviates
  4. We look for such deviations to identify good trading opportunities

So essentially, a pair trader tracks the ratio and its corresponding density curve value. A pair trade is set up when the ratio (and the density curve) has deviated convincingly enough from the mean value.

This leads us to the next obvious question – what is convincingly enough? Or in other words, at what value of the density curve, should we initiate the trade?

Here is a general guideline to set up a pair trade –

Trade Type Trigger (density curve) Standard Deviation Target Stoploss
Long Between 0.025 & 0.003 Between 2nd & 3rd 0.25 or lower 0.003 or higher
Short Between 0.975& 0.997 Between 2nd & 3rd 0.975 or lower 0.997 or higher

The idea is to initiate a trade (either long or short) when the ratio is between 2nd and 3rd standard deviation and square off the position as it goes below the 2nd standard deviation. Obviously, the closer it goes toward the mean, the higher is your profit.

Lets set up a trade based on the above table, for this, I’d suggest you download the excel sheet available towards the end of the previous chapter.

On 25th Oct 2017, the density curve value was 0.05234 and the corresponding ratio value was 1.54. This is a decent long pair trade set up. Although this does not fall within the preview of a long trade (we need the density curve to be between 0.025 and 0.003), I guess this is the best value in the time series we are considering.

If the ratio is defined as Stock A / Stock B, then –

  1. A long trade requires you to buy Stock A and Sell Stock B
  2. A short trade requires you to sell Stock A and Buy Stock B

We have defined the ratio as Axis / ICIC, hence, on 25th closing, one would –

  1. Buy Axis Bank @ Rs.473
  2. Sell ICICI Bank @ 305.7

The lot size for Axis is 1200, hence the contract value is 1200 * 473 = Rs.567,600/-. The lot size of ICICI Bank is 2750, hence the contract value is Rs.840,675/-.

Ideally, we need to stay long and short of the same Rupee value. This is also called ‘Rupee Neutrality’, but I’ll skip this part for now. We will take the concept of Rupee neutrality to a different dimension when we take up the next pair trading technique.

So, once the trade is set up, we now have to wait for the pair to move towards the mean. Ideally, the best pair trade is when you initiate a trade near the 3rd SD and wait for the ratio to move to the mean, but then this could happen over a long period, and the mark to market could be quite painful. In the absence of deep pockets to accommodate for mark to market, one has to be quick in closing a pair trade.

On 31st Oct 2017, the ratio moved up to 1.743 and the corresponding density curve value was 0.26103, which is roughly the target density curve value. Hence once can consider closing the trade.

We Sell Axis Bank @ 523 and buy back ICIC at 300.1. The P&L and other details are as follows –

Date Stock Trade Lot Size Sq off date Sq off Price P&L
25th Oct Axis Bank Buy @ 473 1200 31st Oct Sell @ 523 50*1200 = 60K
25th Oct ICICI Bank Sell @ 305.7 2750 31st Oct Buy @300.1 5.6*2750 =15.4K
Total P&L Rs.75,400/-

 

If you notice, the bulk of the profits comes from Axis Bank, this indicates that Axis Bank had deviated away from the regular trading pattern.

Not bad eh?

Let’s look at a short trade now.

On 9th August 2016, the density curve printed a value of 0.99063156, close enough to initiate a short pair trade. Remember in a short trade, we sell Axis and buy ICICI.

If you find it confusing to remember which one to buy and sell, think of it this way – the numerator is the dominating stock, so if the pair trade demands you to go long, then buy the numerator. Likewise, if the pair trade is to short, the short the numerator. Whatever you do with the numerator, the opposite trade happens with the denominator.

Hence we sell Axis Bank (numerator) and sell ICICI Bank (denominator).

Trade details are as follows –

  • Short Axis @ 574.1
  • Buy ICICI @ 245.35
  • Ratio – 2.34
  • Corresponding Density Curve value – 0.99063156

Once initiated, the opportunity close this trade occurred on 8th Sept, (yes, the trade was held open for almost a month). The trade details were –

  • Buy Axis @ 571
  • Sell ICICI @ 276.33
  • Ratio – 2.27
  • Corresponding Density Curve value – 0.979182

Agreed, once could have waited a bit longer to for the density curve to fall further, but then like I said before, the pair trader has to strike a balance between the time and mark to markets.

The P&L for the trade is as below –

Date Stock Trade Lot Size Sq off date Sq off Price P&L
9th Aug Axis Bank Sell @ 574.1 1200 8th Sept Buy @ 571 3.1*1200 = 3.72K
9th Aug ICICI Bank Buy @ 245.3 2750 8th Sept Sell @276.33 31.03*2750 = 85.3K
Total P&L Rs.89,052/-

Again, the bulk of the profit comes from one of the stocks i.e ICICI, indicating that ICICI had probably deviated away from its course.

I must confess, both the trades did not really fall under the prescribed table giving you the guideline to enter and exit the pair trade. But like I said before, use the table as a reference and build your expertise around it.

I’d encourage you to look for any other opportunities in the Axis & ICICI Bank example.

I hope the P&L of pair trade is incentivizing you enough to learn more about pair trading. I’ll deliberately stop here, to ensure you soak in everything that we have discussed. I’ll leave you with few final points.

  1. Everything we have learned so far accounts to about 25% of what I intend to discuss going ahead
  2. These first 7 chapter discusses a very basic pair trading technique, mainly to help lay a foundation
  3. We have not adhered to strict trade definitions – stop loss, targets etc. If you notice, I’ve kept things quite generic
  4. Neutrality of both the positions is a key angle, we have not discussed that yet
  5. We are yet to discuss the risk associated with Pair trading
  6. Pair trading is a margin money guzzler, so one needs to have sufficient funds to pair trade, but the P&L is worth it
  7. For a given pair, at the most 2-3 signals is what you can expect in a year. So one has to track multiple pairs to find continuous opportunities in the market

Anyway, I hope I’ve managed to ignite your curiosity to learn more on Pair Trading. I’m eager to move forward, I hope you are too!

Download the excel sheet.


Key takeaways from this chapter

  1. The density curve acts as a key trigger to initiate a pair trade
  2. A pair trade is initiated when the ratio drifts to a value between 2 and 3 standard deviation
  3. A pair trade is closed when the ratio approaches the mean
  4. Long pair trade requires you to buy the numerator and sell the denominator
  5. Short pair trade requires you to sell the numerator and buy the denominator
  6. Typically, the bulk of P&L comes from one of the stocks which have deviated away from the regular pair trade
  7. Pair trade can be live for an extended period, but the P&L makes the wait worth it
  8. Pair trade is a margin money guzzler.

198 comments

  1. Pradeep says:

    Sir about the instrument, when you say buy axis bank or icici, are you referring to the stock or its Futures?

  2. Lalit Singhal says:

    Hello Karthik…!!

    If i first find correlation between the stocks, then Ratio of the two stocks, Then Average of the Ratio. Than from the Average of the Ratio if i calculate SD1 & 2 (+-) will it work or not….??

  3. Onkar Shinde says:

    One can use http://www.screener.in to find out about companies with similar business.

  4. Onkar Shinde says:

    Sir can we use pair trading between crude oil and brent oil??

  5. Arpan says:

    When is the next part of the relative value trading coming out?

    • Karthik Rangappa says:

      Starting next week, hopefully.

      • Arpan Patra says:

        Hi

        Thank you for your reply, looking forward to the remaining part of the lesson.

        As a request, I would love to get some information on the backtesting part for the pairs trading model. I can help you with any programming help if needed related to that.

        And a big thank you for sharing knowledge 🙂

        • Karthik Rangappa says:

          Arpan, thanks. I will probably put up the guideline for programmers. I will do this for the 2nd part of pair trading. Maybe open this up for all, so that everybody can benefit.

  6. Akash Patel says:

    Sirji, nice article.
    i m using z-score/BB with 2&3 SD to initiate trade, instead of Density Curve. is it go? and doing well. i got this idea from “https://www.tradingfloor.com/posts/has-equity-pairs-trading-had-its-day-6291833” long time back. that is doing good for me. please give your valuable inputs.
    thanks.

  7. Saurabh Patel says:

    Hi Karthik,
    First – your articles are really good for a beginner.
    We can do pair trade only on futures, as we have to short one of the instruments.
    I’ve a few doubts:
    1. we’re using stock prices to calculate density curve, and we’ll be trading futures, so would that work fine?
    2. As we saw that the pair trade was open for around a month, so how do we know which month’s future should we trade in?
    2. Lot sizes are different here, so is it possible that due to that difference, sometimes loss might turn out to be more than profit, if the losing future has significantly higher lot size than the winning one.
    3. If we’re doing this in futures, then is it possible to execute this opportunity with options? (one call and one put, probably first/second month expiry, and choosing strikes as to minimise the margin).

    • Karthik Rangappa says:

      1) Yes, that is absolutely fine.
      2) Great point – always opt for current month contract, be prepared to roll over if required.
      3) Yes, hence the concept of Rupee neutrality. Will talk about this in detail as we move forward
      4) Nope, when it comes to pair trading, the emphasis is on the price movement, which is captured by futures. Options has many other forces acting on it besides the price movement – like volatility and time.

  8. Shivansh Juneja says:

    When we go long or short why do we use the numerator as the main thing?

    • Karthik Rangappa says:

      The numerator thing was only to help the reader remember which stock to buy and sell when going long or short on the pair 🙂

      • swapnil says:

        Suppose while tracking the pair I used axis bank in numerator and icici bank in denominator & trade signal generates to buy the pair.
        while taking this trade I need to buy axis and sell icici, can i do the opposite?

        • Karthik Rangappa says:

          The trade is always with respect to the denominator. So buy ICICI and sell Axis. I’d suggest you check out the 2nd method to pair trade.

  9. Gary says:

    Hi Karthik,
    You have a natural flair for explaining a complex subject in a very lucid manner, really appreciate you doing it.
    That said I have a question:
    Why do the pair trading, just go Long whichever one of the two has deviated the most. Since it will give you the biggest bang for the buck (Rs) once it reverts back to it’s mean. Just a thought…………
    Keep up the good work.

    • Karthik Rangappa says:

      Remember, you are trading a ratio here and not really the stock. A ratio is defined by the stock prices of two different stocks, hence it is mandatory to go long and short at the same time. If not, this will be a naked position, which can be quite risky.

  10. Deepu says:

    Thanks for the excellent write-up once again. Feeling privileged.

    Couple of queries:
    1. Do we need to keep the number of count of the data to 496 or it should keep on increasing as we add the current data ? What is the ideal count of data range to look for ongoing basis ?

    2. Can we get the complete table of the density curve and the corresponding Standard deviation ? What does .49 or .25 density curve will signify ?

    Thanks once again.

    Eagerness to know when the next chapter is coming up:)

    • Karthik Rangappa says:

      1) You need to update the data every day to see the latest value of the ratio and density curve. You need to look back for at least 1 year, 2 will be great
      2) Will try and do that sometime soon.

      I’ll target to put up the next chapter sometime this or next week max.

      • Deepu says:

        Hi Karthik,

        Request your input on the below:

        Can we get the complete table of the density curve and the corresponding Standard deviation ? What does .49 or .25 density curve will signify ?

        Thanks in advance

        • Karthik Rangappa says:

          I’ve summarised the table with few important points that matter. Will try and put out the entire table, although I think that may not really be required.

  11. Anand says:

    Hi Karthik
    I wanna read the all Chapter in Hindi because I am more comfortable in hindi as compare to English, so what to do for this? Please reply me
    Thanks

  12. SAMIR says:

    Karthik,
    Could please provide a list of equities/indices in Indian market that have good correlation and can be considered as good candidates for pair trading.
    Thanks and regards,
    Samir

    • Karthik Rangappa says:

      That would be tough call, Samir. You will have to identify this – for example, maybe IndusInd Bank and Yes Bank have good correlation. Or stocks like Ambuja – ACC, ITC – HUL, Dabur-Marico etc.

    • Ganesh K says:

      you will find mot highly correlated pairs in private banking space.

  13. rahul says:

    can we use this for option….

  14. tarun says:

    Sir How to decide the target and stop loss.

  15. Shikhar says:

    Happy to see you open this subject for us. Thanks Sir..And Sir kindly suggest a good software to do all this data collection and calculation.

  16. Prem says:

    Hi Karthik,
    Very nice material on Pair trading. Is there any software which provides density curve and other variables mentioned by you?

  17. Sundeep says:

    Sir do you think pairs trading still has relevance in Indian markets? If more people do the same don’t you think the opportunities will almost diminish over the time? I’ve never traded pairs and am just curious. Do you think they’re still profitable?

    • Karthik Rangappa says:

      I understand what you are hinting at. The effectiveness of the pair trading really depends upon the way you define pair trading. Most people I know employ simple pair trading strtagies. I dont think this has any relavence in today’s market circumstance.

  18. puneet says:

    sir, is there any way we can capture the difference between the sopt price and futures of a security eg. Nifty. for eaxample lets say Nifty spot is at 10700 and nifty futures is at 10720. on the day of expiry both the prices converge and we keep the difference.

    Rgds

    • Karthik Rangappa says:

      Not always, but you can sometimes. But then this a space where algos are quite active, I quite doubt the retail participants can capute this effectievly.

  19. Sundeep says:

    Sir can you name few other statistical arbitrage techniques like pairs trading?

  20. Rajib says:

    Kartick,
    Please rectify your Density Curve Table (with corresponding Sigma).
    Thanks & Regards,
    Rajib.

  21. Tushar says:

    Hello Karthik,

    I’m associated with Zerodha since last two years and active trader on your platform. I regularly read your articles and they are adding great value to the knowledge.
    Appreciate if you could write an article on arbitrage opportunities available for retail investors and how one can spot that? Do we mandatorily required software to generate arbitrage signals?

    Waiting for your reply
    Many thanks in advance

  22. Yadnesh says:

    Hi Karthik, thanks for the information. My query is- how much historical data(in terms of past dates closing prices) we should consider while performing standard deviation study of the stock in general, does data for longer duration considered good over short span. Also, will the trend of stock impact on this study?

    • Karthik Rangappa says:

      I’d suggest a look back period of at least 1 year. Ideally, the trend should not impact, because both the stocks would have behaved the same.

  23. Nikhil says:

    Hello Karthik,
    Margin required to take this trade of ICIC and AXIS is actually 1.9L when I checked in margin calculator. According to this, returns from this kind of trade are pretty good. I also wanted to ask you if there is a way to find out the amount of loss a trader could suffer in case the stoploss triggers?

  24. AP says:

    Karthik, in section 7.2, the table has wrong values for ‘density’ values (actually cumulative probabilities) and the SD values. For instance, you associate density value of 0.16 with +1 SD and 0.84 with -1 SD. It should be the other way.

    • Karthik Rangappa says:

      Dont know how I missed this one, thanks. Have made the necessary changes.

      • AP says:

        Karthik, now the target and stop-loss values in the table in section 7.3 don’t look right. The long entry-trigger (Between 0.025 & 0.003) also satisfies the Target (0.25 or lower) and Stop Loss (0.003 or higher) conditions simultaneously. I think they should have been “0.25 or higher” for Target and “0.003 or lower” for Stop Loss.

        Also, the target for short position is too close to entry. If it is symmetrical to long position, the target would be 0.75 or lower (instead of “0.975 or lower” mentioned in the table).

  25. Jay says:

    How to take the trade ? Wait till the said density curve? Not all times the exact value comes

  26. Rajib says:

    Kartick,
    Whats the time frame should one used to derive correlation n stand deviation? Like in some cases if we test correlation from 2005 to till date the correlation is lets say 0.5 but while testing it from 2014 its 0.8 again differ if test from 2017. So ideally what should be the lookback period? You can find this sort of different readings in many pairs specifically in metal n real estate sectors of F&O segment.
    Thanks in advance.
    Rajib.

    • Karthik Rangappa says:

      Ideally, you should look at 6 months, 1, year, 2-year correlations to get a sense of the shift in correlations. A pair is considered highly correlated if they the numbers display consistency.

      • Rajib says:

        Got it…So if any pair showing a shift towards more correlation say from 0.56(2 year) to 0.67(year) to 0.78 (6 months) and 2nd different pair showed a shift like 0.79 (2 years) to 0.72 (year) to 0.67 (6months) then I should give more weightage to the first pair rather than 2nd one though the long term correlation of 2nd pair is much more than the 1st one…. correct me if I wrong…
        Thanks & Regards,
        Rajib.

        • Karthik Rangappa says:

          Absolutely, the correlations should show consistency in change.

          • Rajib says:

            Kartick,
            sorry to disturb you again… while calculating sigma to evaluate normal distribution curve which data set should we use…6 months or year or 2 year…
            Thanks& Regards,
            Rajib.

          • Karthik Rangappa says:

            You can run this similar to correlations (because sigma also changes) – so 6 months, 1 year, and 2 years.

  27. Tarun Taragi says:

    Sir if density curve value is greater than 1,then what to do?
    As i have made corelation on IGL& GAIL . And i have taken 2 years data.
    But on most the days there density curve ratio is more than 1 even some case more than 2.

  28. Rajaram says:

    Hi Karthik,

    The density curve table and its values corresponding to the standard deviations, are the values standard. I mean irrespective of the underlying security, should we use the table as a guideline to initiate a trade.

    Is there also a trigger price or entry trigger of these trades. Do we enter the trade the next day, based the closing prices.

    Regards

    • Rajaram says:

      I also see a discrepancy in the trade that you had depicted.
      9th Aug Axis Bank Sell @ 574.1 1200 8th Sept Buy @ 571 3.1*1200 = 3.72K
      8th Sep Axis bank value is 619 atleast the spot price, not sure on how is it depicted at 571. I’m not sure if the future premium is going to be in that range. Similar issue I see for ICICI in 2016

      • Karthik Rangappa says:

        I’ve taken the spot prices to calculate these, Rajaram. I’ve not looked at futures. This is with the assumption that the futures would depict values similar to spot.

    • Karthik Rangappa says:

      Yes, the values are standard. You have two options – either to initiate as and when the density curve values trigger or initiate around the closing. By the way, I’d suggest you look at the regression-based pair trading technique.

  29. vineet kumar says:

    Karthik Sir

    Sorry to correct you, but the value of axis bank and icici bank taken by you are wrong, because on 9th of august the value of icici bank is around 225 and axis bank is around 575, same is on 8th september the value of axis bank is around 619 and for icici its around 245, please correct me if I am wrong sir

    Thanks

  30. Shyamal d dattani says:

    hi . any body using screener by pairtrade.in. in ???

  31. KUMAR MAYANK says:

    Hello sir
    I have a confusion. We can trade using correlation method discussed here only when the data series of ratio is stationary around its mean. How could we know whether the ratio is stationary time series data? Can you help me so that i could draw a graph of ratio-time series on excel?
    Thanks
    Varsity student

    • Karthik Rangappa says:

      You need to run an ADF test for this, Mayank. I’ve explained more on it the latest chapter.

      • KUMAR MAYANK says:

        So what i need to do is to select a strongly correlated pair of stocks, find the ratio of their closing prices and then run AFD test on time series data of ratios to know if they are stationary or not. If i get to know that the data has high probability of being a stationary time series then only i should look for an opportunity to trade by tracking density curve. Am i correct?
        Thanks
        Varsity student

        • Karthik Rangappa says:

          Mayank, I think you are mixing up both the techniques. Chapter 3 – 7 is 1st method, and 8 onwards is another method involving ADF.

          • KUMAR MAYANK says:

            I am talking about the first method (based on correlation). What I want to say is that we can trade only when the ratio reverts back to its mean and it (reverting back of ratios) is possible only when the data series of ratio is stationary around its fixed mean. If data series of ratio is non stationary it may drift away from its mean having variable mean and variance. And if it is so then how we could apply the concept of mean reversion on non stationary time series data (here data is ratio)? I guess our first aim should be to find whether the ratio is stationary or not. Am i clear to you, sir?
            Thanks
            Varsity student

          • Karthik Rangappa says:

            Ah, now I get it. Yes, that makes sense. YOu can check for the stationarity of the ratio series in the same way, as in use the ADF test. If the series is stationary, you can look for trading opportunities. However, I’ve not done this Mayank, so cannot really comment on the outcome. Good luck and do share the results with us. Thanks.

  32. KUMAR MAYANK says:

    Hello sir
    Thanks for your prompt reply! I don’t have an ADF plug in so i couldn’t test the stationarity of the ratio series. But i did plot the graph of ratio-time so that i could visualise if it behaves like stationary time series or not. Here is the link of screen shot.
    http://prntscr.com/jcuo7x
    It almost behaves like a sine or cosine graph with a slightly trending mean. Next i plotted its frequency histogram to visualise if it fits in the normal distribution plot or not. Here is the link.
    http://prntscr.com/jcus56
    I find it doesn’t fit perfectly in the normal distribution plot. Now my question is: 1. Is it acceptable to consider this plot as normal distribution? 2. If not, then how could we apply the concept of std. deviation and density curve on ratio series data? I have tagged you in a twitter post of mine for the same query.
    Thanks
    Varsity student

    • Karthik Rangappa says:

      Guess you tagged me on Twitter as well 🙂

      This looks like an ND for me, just that its skewed to the right (sorry, I guess I said left on twitter).

      • KUMAR MAYANK says:

        Well, this normal distribution is skewed. Can we still treat it as ND and apply std dev on this data series?
        Thanks

        • Karthik Rangappa says:

          Yup, you can. I’m keen to know the outcome, so please do share the results here. Thanks.

          • KUMAR MAYANK says:

            Hello sir
            I have have installed EViews statistical package for one year trial period 🙂 In the “lag length” drop menu of ADF test section there are many options available like Schwarz Info Criterion, Hann-Quin criterion, Modified Akaik, T- static each giving different P value for the same max lag of 15. You may see it here:
            http://prntscr.com/jdu0xn
            Even it gives value below the threshold value of 0.05 the header reads as Null Hypothesis: Residual has a unit root. If the series has a unit root how could it be a stationary series? I have taken a screen shot here:
            http://prntscr.com/jdu7m4
            Thanks
            Varsity student

          • KUMAR MAYANK says:

            Hello sir
            I run the ADF test on the pair data downloaded from varsity. In the lag selection i checked the automatic lag selection header. So by Schwarz Info Criteria (SIC) and lag length 17 the p value was noted 0.2489. By other criteria but with the same lag length of 17 the p value remained 0.2489. I run ADF test on ratio of different set of pairs but all were non stationary even though the pairs were co-integrated. I guess trading on just ratio is not as much convincing as one based on regression analysis.
            Thanks
            Varsity student

          • Karthik Rangappa says:

            Exactly, hence the reason why I prefer the 2nd method!

  33. Debasis Mukherjee says:

    Sir,

    Can we use the Pair Trade method to any stock and its future pair? Just today I saw Titan was down, but Titan May Fut was down about 0.3% more. But now the difference is only 0.06%. If we use same stock and its future then residual calculation may not needed as same stock and its fut is more co-related than two different bank.

    With regards

    • Karthik Rangappa says:

      You can use it across any two different stocks which exhibit pair trading characteristics. The same stocks and its futures is more of a cash and carry arb.

  34. Anand says:

    AS PER THIS METHOD THERE IS A LIVE EXAMPLE OF BUY VEDL SELL HINDALCO IN MKT RIGHT NOW USING LAST 1 YEAR DATA

  35. Anish says:

    Hi Karthik,

    To calculated the mean and SD in the sheet “Pair Data” you have used data for Axis and ICICI from 4th Dec 2015-4th Dec 2017. And you are using that mean and SD in to find the position of the ratio in the ND curve. Isnt that incorporating data from the future to trigger trades in the past ?

    Thanks

  36. swapnil says:

    Dear Karthik,

    1. There are many stocks which are from different sectors or having difference businesses still showing good correlation.
    Can we you such pairs for pair trading?
    example. adniports and bajajfinance, adniports and hindalco, adaniports & LT.
    ASIANPAINT & HUL, BAJAJ-AUTO & bharti airtel.
    As of now I am only considering correlation not rupee neutrality.

    2. Can I use nifty 50 stocks with nifty next 50 stocks to find pairs?

    Please suggest.

    • Karthik Rangappa says:

      Yes to both your queries, Swapnil. In fact, one of the thoughts is that you should not really be subjective while selecting pairs. You should go with the numbers. I’d suggest you give this approach a try.

  37. Sebastine says:

    I think it is a typo in the above chapter: “Hence we sell Axis Bank (numerator) and sell ICICI Bank (denominator)”. I think it should be Buy ICICI Bank here.

  38. Priya says:

    Do we not use correlation here beyond identification? For highly correlated stocks like tata motors and tata motors dvr CP corr – 0.99 returns correlation – 0.91, do we have a relaxation of the norms. for in a period of 250+ days, I found exactly only one data point that falls in the upper criteria and none in the lower.

    • Karthik Rangappa says:

      Well, perhapse in the case of TM and TM DVR. But its always safer to run by the corr for other pairs.

      • Priya says:

        Sorry my question was not clear. the 2 SD showed only one opportunity. I see a few dozen in 1SD… would that be too risky ? or is it ok relax the 2 SD rule a bit to 1.5 SD or something ?

        • Karthik Rangappa says:

          Ah like that. No not at all, as long as you have some past stats on the behaviour.

          • Priya says:

            grt. thx. there was a 2 SD opportunity today and I have opened a trade, will update you as and when I close it on how it went. Excited 😀

          • Karthik Rangappa says:

            Good luck, Priya. Make sure you check all the stats well before the trade. Let us know 🙂

          • Priya says:

            Hey Karthik , I closed the trade yesterday after 11 days and 1 rollover. a 2.5 % return, not bad for a hedged position. It did quite test me with expanding a lot more before it started coming together. I should have listed to you and waited till 2.5 SD to initiate, would have fared better. Thanks much though. I could sleep well even with a open position due to the natural hedge 😀

          • Karthik Rangappa says:

            Good luck, Priya. Hope more profits roll your way 🙂

  39. swapnil says:

    Dear Karthik,

    Which parameters need to be consider while selecting stocks for pair trading?
    The one you already mentioned is stocks from same sector or business.
    Any other parameters?

    • Karthik Rangappa says:

      Ideally, they belong to the same sector and of similar size.

      • swapnil says:

        Can I use stocks from different sectors showing good correlation?
        Please suggest.

        • Karthik Rangappa says:

          Check out Banks, automobiles, and metals.

          • swapnil says:

            Thank You.

          • swapnil says:

            Suppose I have taken a position which is currently in loss and now there is expiry and I don’t want to square off my position,
            can I rollover this position to next month contract?
            Should I rollover it?
            Any risk in rolling over it?
            How many times I can rollover it?
            Any way to recover this loss from same trade?

          • Karthik Rangappa says:

            You can rollover, and you can rollover as many times as you’d want. However, rollover does not guarantee recovery from a loss-making trade.

  40. swapnil says:

    Dear Karthik,
    How to decide final pair for trade if there is a tie between two?
    Which factors need to consider?
    Please guide.

  41. prathik says:

    Sir, how do i conclude if two stocks constitute a pair so that if they are not a pair i can skip tracking them daily for opportunities.I want to use the pair strategy discussed in this chapter.

    • Karthik Rangappa says:

      Pick up stock belonging to the same sector (like BPCL-HPCL, Infy-TCS, Tata Motors-Tata Motors DVR etc), you will have a greater chance of finding pairs that make sense.

  42. JAYA says:

    WHEN YOU WILL TEACH Rupee Neutrality ?

  43. RAYEN DIAS says:

    Data points must be fixed or variable ( say i have data of 100 days,is it necessary to stick with it or i can add up the present day data without deleting the 100th day )

  44. Virendra says:

    Pls help why is it that copper and lead have 0.9 correlation but copper mini and lead mini have 0.45 correlation?

  45. nikhil says:

    Hello
    Is this method not good enough to trade? Do I have to try the second method you wrote?
    Second method seems to require some tools and knowledge about coding and stuff which I dont have..
    Which method do you recommend ?
    And if you could mention some pros and cons between these two pair trading methods..?
    Thank you sir.

    • Karthik Rangappa says:

      Nikhil, both the techniques are quite good, although I prefer the 2nd one. The first one is simple to implement and involves basic stats while the 2nd one is stats heavy. This is the only difference.

  46. nikhil says:

    Hello,
    Sir I have tested some pairs and found that some pair with correlation of 0.4 and 0.5 also works well.. Is this correlation number enough? And also some pairs with high correlation like 0.9 or 0.85 does not give good results? Could you throw some light on this please….
    Thanks Sir.

    • Karthik Rangappa says:

      Correlation is not necessarily the best way to pair trade, Nikhil. Do check the other method later in the module.

      • nikhil says:

        Sir I have read the second method also but I dont have enough tools or knowledge about programming…
        So I stared to test some of the pairs from this first method.. Seems to work well but the above question still remains….

        • Karthik Rangappa says:

          Thats ok, Nikhil. If it works for you then it is good..but do keep a close watch on the risk.

  47. Avinash says:

    Why Stock A is Axis Bank and Stock B is ICICI bank? Can’t we flip them( stock A – ICICI and Stock B – Axis)? What is the reason behind this? Is that the price of Axis is higher so are you using it as numerator?

  48. avinash says:

    Tried Pair trading for TATA MOTOR and TATA DVR ( stock A- tata motor and stock B -tata Dvr).
    At density curve value – 0.035 – Stock price of Tata motor – 448 and Dvr is 273
    When the Density curve value reached – 0.25, Price of Tata motor and Dvr are – 384 and 227 respectively.
    In this case, It would be a loss if we buy one and sell other. Any solution for this?

  49. Neehar says:

    Hi Karthik,
    Is it possible to identify such an opportunity with streak? (finding ratios and density values etc) Also I wanted to ask whether you have any plan to start a module on ‘Quantitative Trading’ (Basics)because I am sure many people like me are very much interested in it.

    • Karthik Rangappa says:

      I’m not sure if this is possible via Streak. Let me check though. QA is on the agenda, but I’m not sure if I will be able to do justice. Trying to see if I can find a collaborator for this.

  50. Sumit says:

    Karthik I’ve been trying to read on Quantitative Trading and without much success. What are some other kinds of Quant Trading Strategies other than Pairs Trading? Where do I get started?

    • Karthik Rangappa says:

      Sumit, Pair trading itself can be done in multiple ways. Did you read the 2nd method to Pair trade? Else, I’d suggest you take a look at it, we have discussed the same next chapter onwards.

  51. Aniruddhsinh Rathod says:

    Hello,

    I think i have found two typos in the chapter:(Correct me if i’m wrong)

    1) In the table of general guidelines of pair trading for long position the target should be 0.025 or higher and stoploss should be 0.003 or lower.
    2)In the example of short pair trade it is written that sell axis and sell icici both.

    THANKS

  52. Gomsi says:

    HI Karthik,
    Very Informative chapter. Keep up the good work!!
    well as far as Pairs Trade chapter is concerned , i have heard market people talking about the term Z Score in Pair Trading
    can u please throw us some light on that and how different it is from Density curve which we use.

    Thanks..

    • Karthik Rangappa says:

      Z score is nothing but the divergence from the average. It tells you where the standard deviation is….for example, 1.5SD away from mean or 2 SD away from the mean etc.

  53. Thimmappa says:

    Sir. Many thanks for such wonderful insights. Does the first method still works? If so any idea what is the win loss ratio?
    Thanks again!

    • Karthik Rangappa says:

      Methods still work, Thimmappa. However, you will have to improvise on them over time and calibrate it to your risk-reward temperament.

  54. Thimmappa says:

    Thanks for the response sir. Can we expect some more systems in this chapter?

  55. Thimmappa says:

    Ok sir thanks.

  56. ROHIT GUPTA says:

    Dear Karthik,
    I think I should trade pair trade of method 1 instead of method 2 because I have not got ADF test. What do you think, can I make consistently by using method 1 of paid trade? Pl reply me soon.

  57. Rohit Gupta says:

    I want to learn how to find ADF test. So I want to ask whom can I meet personally in Delhi to learn ADF test please? Pl reply me soon as I am going to Delhi for some personal affairs this week.

  58. ROHIT GUPTA says:

    If you prefer M2 then at least pl help me where to find ADF test so that I trade based on M2 because I have trading account with Zerodha.

  59. Ajay says:

    Hi Karthik,

    Can I keep rolling a pair trade for many months until it eventually breaks even?

    Took a pair in Nifty & Banknifty but it went opposite to my estimate. Sitting on a big loss.
    Now I need to decide whether to roll over or accept losses. My thinking is that as it must mean revert sometime in next months, so can I roll it over to next expiries and wait ?

    In your experience, do such a trade eventually breakeven sometime in future (even if needs rolling it for 6 months)?

    • Karthik Rangappa says:

      You can Ajay, as long as you have a deep pocket to hold. However, if the spread diverges to 3SD or beyond, it is better to exit and book a loss.

  60. Ajay says:

    Thanks Karthik. You are right, I could have recouped some losses if I had rolled over on Expiry day as
    Banknifty has again started outperforming Nifty since last 2 days…..(I was long BN). It was opposite for 10 days before that…
    When I took the position (BN- long, N-short) , the spread (ratio based) was around -1.5 SD around 10 July.
    I took the trade thinking it will probably continue towards -2 SD atleast.
    But it reversed from -1.5 SD and came close to mean 2 days ago.
    Now instead of crossing the mean and going towards +ve SD, it seems to be going back again towards -1SD since last 2 days( BN outperforming N).

    I think I will have to read your density curve chapter again to better understand when is it the optimal time to pull the trigger

    By the way, what’s you view : Will BN keep outperforming N for next few days?

    • Karthik Rangappa says:

      Yes, there are two important things here – maintaining SL at 3SD (or at whatever level you think is good) and to allocate capital in such a way that we have a decent buffer for drawdowns.

      Not sure about BN 🙂

  61. ROHIT GUPTA says:

    I have studied http://www.real-statistics.com/time-series-analysis/autoregressive-processes/augmented-dickey-fuller-test/ recommended by you but I got no understand from where to start and where to find ADF test value. Pl tell me the details and help me.
    Thanks

  62. ROHIT GUPTA says:

    I was awaiting for your reply regarding ADF test which you would look up again and will tell me but I got no response till date. Pl help me as I have stopped trading intraday or swing trading because I am getting loss. So I want to trade on pair trade of method 2 but I have not understood properly how to use ADF test.

    • Karthik Rangappa says:

      Rohit, I’m unfortunately not in a position to give you a commitment on this. I’m looking for sources as well.

  63. ROHIT GUPTA says:

    Then how do you do pair trade of method 2? You yourself told that the method 2 is best for pair trade if you don’t know how to use ADF test? How can you tell this method is best?

  64. ROHIT GUPTA says:

    Very Thanks for giving me information. But before purchasing, I want to ask in the following lines:
    1. Is the site given by you reliable?
    2. Which type of purchasing should I whether commercial or student/non-profit as I am an individual?
    3. If I purchase this, would I be able to install without problem? As I tried to install ADF test from Realstatistics resource pack but it has got problem I tried to solve but failed? Please give me suggestion so that I would not get wasted of money.
    4. I have read the example of how to use. What parameters should be given in ADF test like Length, options, test_down,alpha, return_type etc?
    Thanks again for replying me.

    • Karthik Rangappa says:

      1) I dont know since I’ve not used the site. I’d suggest you look up for online reviews
      2) You will have to self assess that 🙂
      3) I guess so. Since this is a paid version, you are also entitled to get support from them. Maybe you should write to and clarify all these things before buying
      4) I need to understand the context of these parameters, Rohit.

  65. ROHIT GUPTA says:

    I have installed spiderfinaancial.com. I want to ask you for ADF test
    1. which parameter i.e. price or daily % return be used?
    2. To satisfy ADF test, should either of individual stock be less than 0.05% or both stocks be less than 0.05%
    3. What should be number in lag order?
    pl reply me soon

    • Karthik Rangappa says:

      Rohit,

      1) If it is for pair trading, it has to be on the residuals and not on stock prices or returns
      2) 0.005% of what?
      3) Lag order should be the cube root of the number of data points i.e if you have 1000 data points, then the lag order is 10.

  66. ROHIT GUPTA says:

    sorry to disturb you once again. I want to ask one more question in addition to above my questions, how to evaluate ADF test the combination of both stocks. As in the spiderfinancial , only one stock is accepted for ADF test.

    • Karthik Rangappa says:

      So like I mentioned in my previous comment, use the residuals (single time series) and not stock returns or the prices.

  67. rohit gupta says:

    Very very thanks for replying me. I got your point. My last question: What variables should I choose viz no constant and no trend, constant and no trend, constant and trend? What these variables mean and which to choose which is given in the output of specialfinancial.com after run ADF test? Again many thanks for getting response.

  68. Dipesh Koyande says:

    Hello Sir,
    First, I would like to thank you for providing us brief knowledge about trading in such amazing way which can be understood by even by novice trader.
    I have a question regarding pair trading.
    Can we use this technique in other instruments such as commodities?
    If yes then how?

Post a comment