Python Code for downloading all Bhavcopy

 

from nsepy.history import get_price_list
import numpy as np
import pandas as pd
from datetime import datetime,date,time,timedelta
from nsepy import get_history
df1 = []
for i in range(1, 65):
    d = datetime.today() - timedelta(i)
    if d.weekday() <= 4:
        prices = get_price_list(datetime.today() - timedelta(i))
        df = pd.DataFrame(prices)
        df1.append(df)
df1 = pd.concat(df1)
print(df1)
# df1['H_L'] = df1['HIGH'] - df1['LOW']
# df1['C_O'] = df1['CLOSE'] - df1['OPEN']
# df1.pivot(df1['SYMBOL'], df1['CLOSE'], df1['TIMESTAMP'])
# df2 = df1.pivot('SYMBOL','TIMESTAMP','CLOSE')
# print(df2)
# df2.to_csv('C:\\Users\\mahen\\OneDrive\\Documents\\Bhavcopy.csv')


C:\Users\mahen\PycharmProjects\pythonProject\venv\Scripts\python.exe “C:/Users/mahen/PycharmProjects/pythonProject/venv/bhavcopy multiple.py”

Output

SYMBOL SERIES OPEN … TIMESTAMP TOTALTRADES ISIN
0 20MICRONS EQ 97.00 … 05-AUG-2022 24898 INE144J01027
1 21STCENMGM EQ 24.30 … 05-AUG-2022 179 INE253B01015
3 3IINFOLTD EQ 40.50 … 05-AUG-2022 4129 INE748C01038
4 3MINDIA EQ 23500.00 … 05-AUG-2022 2119 INE470A01017
5 3PLAND EQ 14.85 … 05-AUG-2022 29 INE105C01023
… … … … … … … …
2211 ZOTA EQ 276.90 … 03-JUN-2022 366 INE358U01012
2212 ZUARI EQ 143.50 … 03-JUN-2022 6424 INE840M01016
2213 ZUARIGLOB EQ 157.65 … 03-JUN-2022 1342 INE217A01012
2214 ZYDUSLIFE EQ 365.60 … 03-JUN-2022 19105 INE010B01027
2215 ZYDUSWELL EQ 1564.05 … 03-JUN-2022 2477 INE768C01010

[82835 rows x 13 columns]

Process finished with exit code 0

By AskMahe.com

Hi, AskMahe.com is the Brainchild of Mahendran Paramasivan who is interested in bringing the latest technology to the common people and corporates. We are a team and we are providing supports on Technology and innovation as per industrial standard. We are supporting with the help of analysis we made on Technology and innovation to help corporate companies and individuals. We bring the latest updates of technology and innovation in front of the eyes of our readers, clients, and people. We have resources in Cloud computing, IoT, Edge Computing, Dew Computing, 5G, SAP, Web Designing, UI/ UX Design. Regards AskMahe Team askmahe.com