Guys, Just wrote a python code to update the master file with the daily nse bhavcopy file. Please add the following codes to the PairTrading.ipynb
1. Add the following function into the cell with other functions:
def update_eod(df,eodfile):
eod = pd.read_csv(eodfile, header=None,index_col=[0],usecols=[0,5])
df = df.append(eod.T).dropna(axis=1).reset_index(drop=True)
df.to_csv('C://stockdata.csv')
return df
2. Add a new cell after after the cell which reads the master file and add the following python statement
df = update_eod(df,'C://eod.txt')
View attachment 27044
How it works:
1. Every day download the EOD NSE bhavcopy text file and rename it as eod.txt, place it in the same folder as master file.
2. Next time you run the PairTrading.ipynb it will append the master file with the eod.txt content and overwrite the master file with updated data.
Hope this helps..Enjoy Pair Trading..