Pair Trading - Exploring The Low Risk Statistical Arbitrage Trading Concepts

kingkrunal

Well-Known Member
New pair for tomorrow: APLAPOLLO-VEDL:
Nice thread and just what i was looking for.. but lot of code changes and technical thingy in here... i read all the pages.. (did not actually installed anything)
Is there any place where all are in one page or something ? Or the steps are in sequential manner as the thread goes on ?

I am mostly interested in the positional pair trading.. so did not find lot of info on it.. may be one or two post .
ncube bro - any reference to it ? and the above charts are the example of what the code setup will provide in the end ?

thanks
 

VJAY

Well-Known Member
Nice thread and just what i was looking for.. but lot of code changes and technical thingy in here... i read all the pages.. (did not actually installed anything)
Is there any place where all are in one page or something ? Or the steps are in sequential manner as the thread goes on ?

I am mostly interested in the positional pair trading.. so did not find lot of info on it.. may be one or two post .
ncube bro - any reference to it ? and the above charts are the example of what the code setup will provide in the end ?

thanks
Dear kingkrunal,
there is not much code changed what its in begining few posts of this thread .....yes when pairs find out same for intra or positional ..and how to trade positional ncube explained it in 2 posts very well.....
 

VJAY

Well-Known Member
The last value 10000 is the amt you want to invest in each stock in increments. I am trying a slightly different approach to managing the pairs. Instead of buying futures lots, I use cash and start with small increments. I.e at each eod, if the zscore is more than +/- 2.0 then I make adjustments. For the stock to be bought I take Positional trade and for the stock to be shorted, I short it in the morning as MIS order.
i.e after the 1st trade getnew_zScore(SS1,SS2,275,103,20,10000), if the zscore is more than +/-2.0 then I take the 2nd trade next day by investing another 10000. i.e getnew_zScore(SS1,SS2,275,103,20,20000) to get the new qty for the stocks.

Use getnew_zScore(SS1,SS2,275,103,20,10000) only if you want to make adjustment before eod, else you can just use get_beta(S1,S2,lb=20,amt=10000) after end of day to get the new qty for next day.
Dear ncube,
Can you please explain this entry and adjustment once more with one example....as 1st entry with 1buy and 1 short and eod adjustments and next days adjustments ...
 

VJAY

Well-Known Member
Dear ncube,
Can you please explain this entry and adjustment once more with one example....as 1st entry with 1buy and 1 short and eod adjustments and next days adjustments ...
Or we can go one live example....for today
HCLTECH(1098.4)-TCS(2255.55)
pValue-0.0073
zScore-(-2.27)

So we enter today with this quantity...
1538531191128.png


suppose for entry we use todays 1st 15 min bar....
so if today 1st 15 bar breakout in HCLTECH then we enter long 9 qty ...are we enter short in TCS @ same time or wait for breakdown of 15 to enter in it ?as you earlier said for positional we need to enter trades in both scrips in same time....
Just for education purpose we can take this trade in live..
 

ncube

Well-Known Member
Or we can go one live example....for today
HCLTECH(1098.4)-TCS(2255.55)
pValue-0.0073
zScore-(-2.27)

So we enter today with this quantity...
View attachment 29039

suppose for entry we use todays 1st 15 min bar....
so if today 1st 15 bar breakout in HCLTECH then we enter long 9 qty ...are we enter short in TCS @ same time or wait for breakdown of 15 to enter in it ?as you earlier said for positional we need to enter trades in both scrips in same time....
Just for education purpose we can take this trade in live..
Bit busy today, will reply to other posts in detail later. Yes we can take this HCLTECH-TCS trade today, Actually I am planning to track next 10 pairs, I am currently holding the 3 pair trades posted earlier so will not take this trade, but we can track it.

As I have posted in the last few posts I am using a slightly different approach now for positional trading, this is more easy to trade and lower risk. If we are taking postions in futures where the lot size is big it is better to take both the trades at the same time. However the approach I am currently following is to average the cost of the stocks by buying them in increments of 10K.

Steps for HCLTECH-TCS:
1. Keep a Buy SL order for 9 HCLTECH above the 1st 15 min candle. (This will be CNC order and we will carry it till mean reversion)
2. Keep a Sell SL order for 4 TCS below the 1st 15 min candle. (This will be MIS order and will be closed at around 3pm)
3. We dont make any adjustment at eod.
4. In the evening we will check the zscore for the pair again. If it is still lower than -2.0, then we will repeat the steps 1 & 2 in increments. i.e
Keep a Buy SL for another 9 HCLTECH stock CNC order (If this get executed we will have 18 stocks by eod)
Keep a Sell SL for total 8 TCS (4+4) MIS order which will be closed by eod.

What we are doing basically is that we try to average the price of stocks in increments as we know that the pairs will eventually mean revert.
And to keep the pairs hedged, we short the other stocks daily.

1538533919013.png
 
Last edited:

VJAY

Well-Known Member
Bit busy today, will reply to other posts in detail later. Yes we can take this HCLTECH-TCS trade today, Actually I am planning to track next 10 pairs, I am currently holding the 3 pair trades posted earlier so will not take this trade, but we can track it.

As I have posted in the last few posts I am using a slightly different approach now for positional trading, this is more easy to trade and lower risk. If we are taking postions in futures where the lot size is big it is better to take both the trades at the same time. However the approach I am currently following is to average the cost of the stocks by buying them in increments of 10K.

Steps for HCLTECH-TCS:
1. Keep a Buy SL order for 9 HCLTECH above the 1st 15 min candle. (This will be CNC order and we will carry it till mean reversion)
2. Keep a Sell SL order for 4 TCS below the 1st 15 min candle. (This will be MIS order and will be closed at around 3pm)
3. We dont make any adjustment at eod.
4. In the evening we will check the zscore for the pair again. If it is still lower than -2.0, then we will repeat the steps 1 & 2 in increments. i.e
Keep a Buy SL for another 9 HCLTECH stock CNC order (If this get executed we will have 18 stocks by eod)
Keep a Sell SL for total 8 TCS (4+4) MIS order which will be closed by eod.

What we are doing basically is that we try to average the price of stocks in increments as we know that the pairs will eventually mean revert.
And to keep the pairs hedged, we short the other stocks daily.

View attachment 29042
Thanks ncube ....Now I got it clear :)
 

VJAY

Well-Known Member
Or we can go one live example....for today
HCLTECH(1098.4)-TCS(2255.55)
pValue-0.0073
zScore-(-2.27)

So we enter today with this quantity...
View attachment 29039

suppose for entry we use todays 1st 15 min bar....
so if today 1st 15 bar breakout in HCLTECH then we enter long 9 qty ...are we enter short in TCS @ same time or wait for breakdown of 15 to enter in it ?as you earlier said for positional we need to enter trades in both scrips in same time....
Just for education purpose we can take this trade in live..
Today only Short trade triggered in TCS...so short @2223 exit at 3.15 @2164......59*4=236...will check zscore at evening
 

VJAY

Well-Known Member
Today only Short trade triggered in TCS...so short @2223 exit at 3.15 @2164......59*4=236...will check zscore at evening
Now zscore is -0.794...so I think this trade over
 

ncube

Well-Known Member
Now zscore is -0.794...so I think this trade over
Yes, since there is no buy trade that has happened today, no point taking new position in this pair at this zscore, one can look for other opportunities. Check the following pair, looks interesting:

1538570798507.png
 
Last edited: