I am writing a for loop in Python that iterates over a list of the NASDAQ ticker symbols. Each symbol is within a column, tickers['Stock Symbol'], and I am using the yfinance package to retrieve price information. To simplify the example, let's say I just want the price date for 01-01-2018. My code then looks like:
import yfinance as yf
tickers = pd.read_csv("/nasdaq.csv")
tickerData = []
for i in range(1114):
price = yf.download(tickers[i],
start='2018-01-01',
end='2018-01-01',
progress=False)
tickerData.append(price)
The issue I have with dates I am working with is that some of the companies were not around or public on the specific date, and therefore generate an error message. I was wondering if there is a python function which will simply skip over those stocks that generate errors in this?
I am still new to Python, so I am sorry about any formatting issues here. I appreciate your feedback!