Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Pair Trading : Having some issue with understanding the St.Dev and Profit relationship

Hi All,

Currently I am working on a strategy for a stock with a correlation of 0.93 and is highly cointergrated (Indian stocks) , The strategy is profitable , but there are losses .
Anyways , The issue here is . There are trades where the Standard Deviation from the mean reduces , i.e the spread of the 2 stocks get much closer to the mean , but doesn't cross it and despite that it produces a loss .
Below is one such trade which occurred . It would be awesome if someone could help me out with WHY this happens , as statistically it makes sense that when the St.Dev reduces and the spread gets closer to the mean , I should profit , but sadly I seem to only profit when the -St.Dev become +ST.Dev in one days time . Below an excel file has been attached with a sample of the results .

The pattern seems to be constant . throughout , I make a loss if the I enter a trade where ST.DEV is + and by the next day if it doesnt turn into a -ST.DEV i dont make a profit .

X   Y   LN(X)   LN(Y)   LN(X)-LN9(Y)        Mean    Std.Deviation   Z Score Trades  Buy Price   Sell Price  
950.08  191.42  6.856546192 5.254469967 1.602076225 0.018153642 -0.001512551    0.022659005 0.867919525  
1005.46 190.04  6.913200427 5.247234576 1.665965851 0.063889626 -0.000596494    0.022966553 2.807827593 SELL    190.04  1005.46  
1041.65 189.65  6.948561273 5.245180268 1.703381005 0.037415154 0.000289288 0.025828799 1.437382621 SELL    189.65  1041.65  
1016.59 192.06  6.924209168 5.257807823 1.666401345 -0.03697966 0.002458505 0.026745595 -1.474566733    BUY 1016.59 192.06  
1035.5  185.37  6.942639681 5.222353828 1.720285853 0.053884508 0.001226811 0.02773885  1.89833743  SELL    185.37  1035.5  
1011.55 187.56  6.919239087 5.234098794 1.685140293 -0.03514556 0.002420558 0.029107401 -1.290603641    BUY 1011.55 187.56  
1032.89 185.72  6.940115977 5.224240163 1.715875814 0.030735522 0.001176025 0.029713258 0.994825161  
1032.85 188.94  6.94007725  5.241429504 1.698647746 -0.017228068    0.002234233 0.030193529 -0.644585182  
1028.22 196.65  6.935584431 5.281425499 1.654158932 -0.044488814    0.000751921 0.029853684 -1.515415459    BUY 1028.22 196.65  
1035.41 198.41  6.942552763 5.290335597 1.652217166 -0.001941766    -0.000136097    0.031037957 -0.058176158  
1062.27 199.95  6.968163407 5.298067335 1.670096071 0.017878906 1.59366E-05 0.03082218  0.579549186  
1054.16 199.7   6.96049952  5.29681624  1.66368328  -0.006412792    -0.000437613    0.031004862 -0.192717475  
1079.79 195.64  6.984521857 5.276276236 1.708245621 0.044562341 -0.000508898    0.031030248 1.452493666 SELL    195.64  1079.79  
1089.28 195.35  6.993272207 5.274792822 1.718479385 0.010233764 0.00163061  0.031782763 0.270686154         
3 responses

Perhaps the z score changed because the mean moved. I had a similar problem a while ago: https://www.quantopian.com/posts/model-slash-beta-slippage-in-dynamic-spread-mean-reversion-models

Never satisfactorily resolved it...

Hey Simon ,

I just checkd and you were right . the mean moves . I guess using a weighted avg. mean or a longer period mean would seem to be a better option . but then we would have to compensate on the frequency of the trades ...
have u been able to identify any way to improve the condition/trades

Nope, this seems to be a key problem with moving mean reversion.