Dear ncube,
When I tryed to play every cells...its giving now errors ...chart not showing ...please give step by step instructions to how to use it..its runs only once ?or we can run whenever we need after updating CSV ?
View attachment 26965
First time you start Jupyter Notebook, you need to run 1st cell with the core functions in PairTrading.ipynb. After that you can selectively run the other cells to try different combinations:
After opening the PairTrading.ipynb in jupyter follow this sequence:
1. Run the 1st cell with the import statements once, this will load all the libraries and function into python interpreter.
#importing the required python libraries
import pandas as pd
......
2. Now run the 2nd cell to load the updated stock data. once this is successfully run, the stock data is loaded into returns & df pandas dataframe.
returns,df = loaddata('D://stockdata_20180726.csv')
3. Run the 3rd cell to select the stock pairs that you want to analyse. S1 is the Y stock & S2 is the X stock, just need to change the stock names.
S1 = returns['TCS']
S2 = returns['WIPRO']
4. Run the 4th cell to find the cointegration significance for these 2 stocks.
find_cointegration_significance()
5. Plot the pairs with zscore.
You need to run the 1st & 2nd cells only once, cells 3-5 can be repeated any number of time for different stock combination. If you need to track multiple stock pairs at the same time, copy and paste these 3 cell into a new cell at the bottom of the file and just change the stock pair names.