from nsetools import Nse
import csv
import time
import yfinance as yf
nse = Nse()
# Open the CSV file
def stockprice():
with open('/Users/jitendersingh/Downloads/data.csv', newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
symbol = row['Symbol']
stock_data = nse.get_quote(symbol)
print(f"{stock_data['companyName']}")
current_price = str(stock_data['buyPrice1'])
if current_price == "None":
stock = yf.Ticker(""+symbol+".NS")
current_price = stock.info["regularMarketPrice"]
print("Data from Yahoo")
print(f"{symbol} current price: {current_price}")
print("---------------------------\n")
time.sleep(1)
else:
print("Data from ---------------------------------------> nsetools")
print (current_price)
print("---------------------------\n")
time.sleep(1)
for i in range (1000):
stockprice()
#Download CSV From here: https://www1.nseindia.com/live_market/dynaContent/live_watch/equities_stock_watch.htm
0 comments:
Post a Comment