atreadw1492 / yahoo_fin

Scrape stock price history from new (Spring 2017) Yahoo Finance layout
MIT License
286 stars 125 forks source link

Cash flow and income statements are not available for some tickers #73

Closed climb4hope closed 1 year ago

climb4hope commented 2 years ago

The cash flow or incomeStatementHistory are not available for some tickers. Example: In [20]: si.get_income_statement("IWF")

KeyError Traceback (most recent call last)

in ----> 1 si.get_income_statement("IWF") /Library/Python/3.8/site-packages/yahoo_fin/stock_info.py in get_income_statement(ticker, yearly) 420 421 if yearly: --> 422 temp = json_info["incomeStatementHistory"]["incomeStatementHistory"] 423 else: 424 temp = json_info["incomeStatementHistoryQuarterly"]["incomeStatementHistory"] KeyError: 'incomeStatementHistory' Would be nice to add a key check or catch it with exception and assign to None or something to handle gracefully Encountered when running a script to download a list of tickers