Different results using Jupyter Notebook and using spreadsheet provided in the course

Course: Pairs Trading Strategy in Python



I have created my own Jupyter notebook from the existing example in the course in order to find cointegration between two assets. In my example, I import the assets data from Yahoo finance rather than using a .csv



Assets are DGR.AX and ENR.AX (Australian stock exchange) 



I am getting different results using the macros file named "ADF Test" and using the jupyter notebook to find out what days the two assets are cointegrated.



Files in Google Drive:

'ADF Test' (Macro) with data already loaded and calculated

Quantra 1st Course Notebook = Jupyter notebook downloaded in Python

  • exportedFile.xlsx = result of the notebook where i compare both datas (see columns in red) and manually calculate the spread, average, std etc to see if that's correct (and it was!)



    note that the only difference between what you guys trying to do in your notebook and mine is that i use the average of the 30d spread in the day 31st, rather than in the day 30, so i just have to move one cell down.



    let me know if you have issues opening the jupyter notebook or if i should export it in other format

i have also tried using Apple and IBM rather than these two small aussie stocks - and still having same mismatch)

Hi Jose,



It seems that the t-statistic value, or the critical value of the ADF test could be different, which might give the mismatch. Right now, according to the exported file you have shared, the average, z-score and the std are the same.



Thus, you can check the significance value, which you have taken as 5% in both cases, and the t-statistic along with the critical values of the ADF test to see if there is any difference.



Ideally, the python method will be preferred as you can perform backtest on a large dataset in a shorter period of time as compared to Excel macros.