## 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 2^{nd} 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 –

- 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
- 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 2^{nd} 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 2^{nd} 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 2^{nd} 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 –

- The density curve of 0.16 implies that the corresponding value is at the -1 standard deviation below the mean
- The density curve value of 0.84 implies that the corresponding value is at the +1 standard deviation above the mean
- 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 – 1^{st} 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 –

- 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
- The ratio value changes daily, based on the stock prices of Axis Bank and ICICI Bank
- The ratio and its corresponding density curve value has to be calculated daily

The trading philosophy is as below –

- 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
- Any change in the business landscape will affect the stock prices of both the companies
- 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
- 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 2^{nd} & 3rd |
0.25 or lower | 0.003 or higher |

Short | Between 0.975& 0.997 | Between 2^{nd} & 3^{rd} |
0.975 or lower | 0.997 or higher |

The idea is to initiate a trade (either long or short) when the ratio is between 2^{nd} and 3^{rd} standard deviation and square off the position as it goes below the 2^{nd} 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 25^{th} 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 –

- A long trade requires you to buy Stock A and Sell Stock B
- A short trade requires you to sell Stock A and Buy Stock B

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

- Buy Axis Bank @ Rs.473
- 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 3^{rd} 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 |
---|---|---|---|---|---|---|

25^{th} Oct |
Axis Bank | Buy @ 473 | 1200 | 31^{st} Oct |
Sell @ 523 | 50*1200 = 60K |

25^{th} Oct |
ICICI Bank | Sell @ 305.7 | 2750 | 31^{st} 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 9^{th} 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 8^{th} 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 |
---|---|---|---|---|---|---|

9^{th} Aug |
Axis Bank | Sell @ 574.1 | 1200 | 8^{th} Sept |
Buy @ 571 | 3.1*1200 = 3.72K |

9^{th} Aug |
ICICI Bank | Buy @ 245.3 | 2750 | 8^{th} 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.

- Everything we have learned so far accounts to about 25% of what I intend to discuss going ahead
- These first 7 chapter discusses a very basic pair trading technique, mainly to help lay a foundation
- We have not adhered to strict trade definitions – stop loss, targets etc. If you notice, I’ve kept things quite generic
- Neutrality of both the positions is a key angle, we have not discussed that yet
- We are yet to discuss the risk associated with Pair trading
- Pair trading is a margin money guzzler, so one needs to have sufficient funds to pair trade, but the P&L is worth it
- 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

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

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

Yes, it is the futures.

PAIR trading can only be done in Futures.

It can be done with a combination of futures and spot as well. Will discuss more on this in the following chapters.

sir i have done tata motor vs tata dvr through method 1. i got density curve 0.65 to 0.67 so when to take position

When the density curve hits 0.997, I have explained this in the chapter.

Is it necessary that it will hit 0.997 ?

It is all about the degree of conviction you’d need 🙂

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….??

Yes, in fact, the excel sheet has these calculations.

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

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

You certainly can.

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

Starting next week, hopefully.

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 🙂

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.

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.

Yes, both z-score and BB are variants of the density curve. So that’s good enough, Akash.

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).

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.

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

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

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?

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.

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.

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.

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:)

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.

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

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.

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

Unfortunately, this is available only in English, for now.

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

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.

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

can we use this for option….

No, works well with Futures.

Sir How to decide the target and stop loss.

Check the table, please.

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.

I’m not sure about the software, you can do this in excel, but can get quite cumbersome.

Hi Karthik,

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

You can calculate this in excel, I’ve not really used any software for this.

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?

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.

So are you saying that if the trading system is built with enough intelligence that would provide an edge over other traders?

Absolutely!

Sir this was just a thought. Do you think pairs trading can be done between nifty and nifty ETFs? Do you think there are opportunities are there between them?

I’m not sure Sundeep, I need to relook at this. But certainly an interesting idea 🙂

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

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.

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

I’m in the process of explaining one, the next chapter will the first installment, will be out next week.

Kartick,

Please rectify your Density Curve Table (with corresponding Sigma).

Thanks & Regards,

Rajib.

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

This is, in fact, a module to explain all the arbitrage opportunities that a retail trader could employ.

So by when we can expect that module?

We are working on the same module. We intend to complete this module by 2-3 months. Thanks.

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?

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.

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?

The subsequent chapters will have contain all the information, Nikhil.

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.

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

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).

Ahhh, I think with the table, the other things also got messed up. Let me relook at this. Thanks again 🙂

Karthik, the tables dont seem to be updated yet. So am a bit confused about the long part of the trade. Pls update. thx

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

Yes, trades based on this is not very frequent.

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.

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.

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.

Absolutely, the correlations should show consistency in change.

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.

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

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.

Are you sure about this? I’m not sure if the values can go above 1.

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

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

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.

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.

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

Thanks Vineet. Are you looking for spot or futures price? I’ve taken the spot prices.

Dear Sir

Thanks for your reply But I have checked the spot price on zerodha platform, so I think the price taken by me is correct as per my knowledge. Please correct me if I am wrong.

Thanks

Let me recheck this, Vineet. Thanks.

Dear Sir

Thank you sir..:)

Welcome!

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

I’ve never used that.

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

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

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

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

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

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.

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

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).

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

Thanks

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

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

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

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

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

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.

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

No signal on that, Anand.

sir i have used 250 observations only which is 1 year data as per nse website ratio is 1.04 density curve is 0.000940322

as on 01-Jun-18. did i miss any corporate action?

You need to check this, Anand. I don’t know which stocks you are tracking : )

https://docs.google.com/spreadsheets/d/1Ph29pBu_ahgA0XVaV16-6cHWYB7pcDka8-zAMTM27OA/edit?usp=sharing

sir please check above sheet if possible i have double checked but it is still showing same result

Anand, this looks correct to me. What is the context?

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

I get your point, Anish. The mean and SD is not expected to change drastically.

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.

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.

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.

Yes, will make the correction, thanks for pointing out!

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.

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

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 ?

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

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 😀

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

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 😀

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

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?

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

Can I use stocks from different sectors showing good correlation?

Please suggest.

Check out Banks, automobiles, and metals.

Thank You.

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?

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.

Dear Karthik,

How to decide final pair for trade if there is a tie between two?

Which factors need to consider?

Please guide.

ADF score and your insights into the sector should help.

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.

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.

WHEN YOU WILL TEACH Rupee Neutrality ?

I’ve not practiced Rupee neutrality, so I guess I’m not the right person to talk about that strategy.

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 )

You should update it with recent data points, Rayen.

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

Ah, I need to check this as well. I’m not aware of this. Are you checking the data for the same time period?

Yes sir I also check GoldM and SilverM. Both are 0.85+ correlated but GoldGuinea and SilverMicro are 0.45 correlated

I put 30-Apr expiry bhav copy data from MCX website from Jan 2 to Apr 4

Like I said, please do check the purity of the bullion.

I think the purity would not match, Videndra.

Sorry sir i dont understand by purity. how to check purity? Please help

By purity, I mean the carat of the gold.

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.

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.

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.

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

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….

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

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?

Yeah, this is to ensure you are long and short approximately same Rupee value.

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?

I’m not sure about the lot sizes, but how would this be a loss?

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.

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.

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?

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.

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

Ah, I need to double check this. Will do.

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..

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.

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!

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

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

I’m not sure at this point, maybe we could sometime later this year.

Ok sir thanks.

Good luck!

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.

I personally prefer M2, Rohit.

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.

I’m not sure about this Rohit, I don’t know anyone in Delhi.

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.

Check this Rohit – http://www.real-statistics.com/time-series-analysis/autoregressive-processes/augmented-dickey-fuller-test/