Pair Trading - Exploring The Low Risk Statistical Arbitrage Trading Concepts

ncube

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
As Vijay has already mentioned, the concept is the same for both intraday & positional. Just that for positional we do not close the pair at eod. However I have observed that intraday pair trading using the zscore calculated at daily timeframe is not working well. Hence its better to stick to positional trades. You may refer to the steps which I have replied in Vijay's post explaining how to trade the HCLTECH-TCS pair today.

There is not much changes made in the code, if you read through the thread from the beginning you will know the changes I have made to the strategy. Basically I started building this strategy in this thread itself. The only addition to the code is that I have now integrated it into my backtesting platform for automation, otherwise it the same.
 

VJAY

Well-Known Member
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:

View attachment 29084
Dear ncube,
Am getting this error when I tryed to add these scrips in my notebook

1538617478292.png
 

VJAY

Well-Known Member
Looks like this stock is not there in your excel sheet. You may need to add the data for this stock.
Yes I added it downloading as new and pasted in stockdata file...
1538619083871.png
 

VJAY

Well-Known Member
Check if you have run all the cells again after adding the data to the file. To verify if the returns are calculated run this in a new cell.if there is data it will output it.

returns['IL&FSTRANS']
Yes ITS SHOWING output
 

VJAY

Well-Known Member
Yes ITS SHOWING output
Got the fault...its something with space.....need one space before IL&FSTRANS!!!!!Why only for this scrip it is needed?there is no space in my data file!!!!
ADD:Restarting kernal rectified this space problem too :)
 
Last edited:

VJAY

Well-Known Member
Dear ncube,p value of this pair is not more ?

1538621070673.png
 

ncube

Well-Known Member
Got the fault...its something with space.....need one space before IL&FSTRANS!!!!!Why only for this scrip it is needed?there is no space in my data file!!!!
ADD:Restarting kernal rectified this space problem too :)
In Excel, you may not be able to see the space, if you open the file in wordpad or notepad, you would see there is a space. Anyway just place the cursor at the begining of the name in excel and enter delete and verify.
 

ncube

Well-Known Member
Dear ncube,p value of this pair is not more ?

View attachment 29103
Not sure, I am at office now will check in the evening, but this pair is output in my system. Please check if these 2 pairs have any split/bonus in the last 200 days, in which case pValue would be impacted. You can quickly check for splits by plotting the pairs as follows:
returns[['IL&FSTRANS','ITDCEM']].plot()
 
Last edited: