I had problems with google finance, hence using this to get data from yahoo finance. Hope it helps.
I’m just a need based coder, not a pro
@visuarchie , can’t thank you enough.
I have seen a smallcase called “weekend investing”, which basically uses the same model
import yfinance as yf
import pandas as pd
import csv
df = pd.read_csv(“D:/py/ind_nifty200list.csv”)##file which contains the list of socks in index
dataset = {}
for index, row in df.iterrows():
grse = yf.Ticker(row["Name"])
hist = grse.history(period="1y")
hist['ticker']=row["Name"]
dataset[row["Name"]] = hist
stock_data = pd.concat(dataset)
print(stock_data)
stock_data.to_csv(‘D:/py/out_22Jul.csv’)##output file
Subscribe To Our Free Newsletter |