Pair Trading - Exploring The Low Risk Statistical Arbitrage Trading Concepts

@Vevensa_P , Yes, pairs can be easily screened using some python looping function, but it will take some dedicated coding efforts as I do not have any ready-made code for it. I am sorry I will not be able to help you in this regard as I will be busy with my office work for next few months.
@ncube,
That's Ok. No need to say sorry. This thread is good start for me. Thank you.
 

VJAY

Well-Known Member
the linear regression on the 2 stocks every day and measure the stock daily position size based on the new beta value for that day, I will then sell or buy more of the Long stock so that the hedge is maintained on daily basis.This helps in reducing the volatility in the portfolio and drawdown is reduced.
Dear ncube,
If you still visit here please reply ..in above quote you said you check beta daily basis for maintain hedge...how you run linear regression when market not closed that day ?...Or you look beta value EOD and do the balance of hedge using new beta next morning.....Or you look beta manually near EOD and make adjustments?if so how you do it manually?
 

VJAY

Well-Known Member
Dear ncube ,
One more doubt about the same beta :)
1535290556263.png

1535290614094.png

The important parameter in the above formula is Beta. So using Beta we can calulate what should be the size of each stock for proper hedging. Lets say the beta value it 0.5, the the formula can be simplified to:

Y = 0.5 * X (ignore constant & error)

This means if we buy 100 shares of X then we need 50 shares of Y for hedging.
Here beta value is 0.695 so is it 0.695*X.... means 0.695*500(if X qty is 500)=347.5 rounded 348
so Tcs =500 qty then Infy =only 348 ?!!!!!or its 500+348=848? ...some confusion ...
 

ncube

Well-Known Member
Dear ncube,
If you still visit here please reply ..in above quote you said you check beta daily basis for maintain hedge...how you run linear regression when market not closed that day ?...Or you look beta value EOD and do the balance of hedge using new beta next morning.....Or you look beta manually near EOD and make adjustments?if so how you do it manually?
It would be best if one can measure the beta values each day near the close of the day as this will help smooth any over-night surprises. However sometimes I dont get time to monitor the markets during office hours, hence I considered only EOD values in the evening from home.

Dear ncube ,
One more doubt about the same beta :)
View attachment 27814
View attachment 27815


Here beta value is 0.695 so is it 0.695*X.... means 0.695*500(if X qty is 500)=347.5 rounded 348
so Tcs =500 qty then Infy =only 348 ?!!!!!or its 500+348=848? ...some confusion ...
Yes, It is confusing as we use price to calculate the quantity. Its easy if you modify the formula to calculate X given Y quantity: X = Y/beta

X-Qty = Y-Qty/0.695

So if Y-Qty = 500, then X-Qty = 500/0.695 = 719.42 =~ 720
 

VJAY

Well-Known Member
It would be best if one can measure the beta values each day near the close of the day as this will help smooth any over-night surprises. However sometimes I dont get time to monitor the markets during office hours, hence I considered only EOD values in the evening from home.


Yes, It is confusing as we use price to calculate the quantity. Its easy if you modify the formula to calculate X given Y quantity: X = Y/beta

X-Qty = Y-Qty/0.695

So if Y-Qty = 500, then X-Qty = 500/0.695 = 719.42 =~ 720
Thanks to taking time from your busy schedules ncube ..now cleared...
 
For 27/08:

pValue= 0.005469972307628801
Y = AXISBANK Price : 639.9
X = ICICIBANK Price : 330.15
zScore: 2.438

pValue= 0.0422270431434219
Y = AXISBANK Price : 639.9
X = YESBANK Price : 374.2
zScore: 2.119
 

VJAY

Well-Known Member
Dear ncube,
can we get following fig by one coding?if its possible the we can claculate Z score whenever we need to put CMP price of pair in this excell file which shared in zerodha's pairtrading tutorial....

1535331932969.png
 

VJAY

Well-Known Member
For 27/08:

pValue= 0.005469972307628801
Y = AXISBANK Price : 639.9
X = ICICIBANK Price : 330.15
zScore: 2.438

pValue= 0.0422270431434219
Y = AXISBANK Price : 639.9
X = YESBANK Price : 374.2
zScore: 2.119
1535332152260.png

Dear Vevensa,
why these difference in P value figures?..Are you using same code which shared by ncube in your notebook?