JECSand / yahoofinancials

A powerful financial data module used for pulling data from Yahoo Finance. This module can pull fundamental and technical data for stocks, indexes, currencies, cryptos, ETFs, Mutual Funds, U.S. Treasuries, and commodity futures.
https://pypi.python.org/pypi/yahoofinancials
MIT License
911 stars 215 forks source link

Exemple code fails #109

Closed micksulley closed 1 year ago

micksulley commented 1 year ago

I have been using this for several years and it recently started to fail. To try to investigate I went back to the example code and that fails as well. I suspect it is the same problem as #105, but I have read through that and my skill level is not enough to figure out how to fix it. This is what I get when I run the example code

$ python3 demo.py
----------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mick/Documents/Programs/shares/DevelopmentCode/v06_5/test/yahoofinancials/demo.py", line 87, in <module>
    timeit(defaultapi, ts[0] if 1 == len(ts) else ts)
  File "/home/mick/Documents/Programs/shares/DevelopmentCode/v06_5/test/yahoofinancials/demo.py", line 68, in timeit
    f(*args)
  File "/home/mick/Documents/Programs/shares/DevelopmentCode/v06_5/test/yahoofinancials/demo.py", line 28, in defaultapi
    print(tick.get_summary_data())
  File "/home/mick/Documents/Programs/shares/DevelopmentCode/v06_5/test/yahoofinancials/yahoofinancials/__init__.py", line 627, in get_summary_data
    return self.get_clean_data(self.get_stock_tech_data('summaryDetail'), 'summaryDetail')
  File "/home/mick/Documents/Programs/shares/DevelopmentCode/v06_5/test/yahoofinancials/yahoofinancials/__init__.py", line 494, in get_stock_tech_data
    return self.get_stock_data(tech_type=tech_type)
  File "/home/mick/Documents/Programs/shares/DevelopmentCode/v06_5/test/yahoofinancials/yahoofinancials/__init__.py", line 481, in get_stock_data
    dict_ent = self._create_dict_ent(tick, statement_type, tech_type, report_name, hist_obj)
  File "/home/mick/Documents/Programs/shares/DevelopmentCode/v06_5/test/yahoofinancials/yahoofinancials/__init__.py", line 409, in _create_dict_ent
    re_data = self._scrape_data(YAHOO_URL, tech_type, statement_type)
  File "/home/mick/Documents/Programs/shares/DevelopmentCode/v06_5/test/yahoofinancials/yahoofinancials/__init__.py", line 169, in _scrape_data
    stores = data["context"]["dispatcher"]["stores"]["QuoteSummaryStore"][tech_type]
TypeError: string indices must be integers

How do I fix it? Thanks Mick

JECSand commented 1 year ago

@micksulley We just released v1.7 which implements a fix for #105. With this fix demo.py is working again. Let me know if you are still having any issues.

Thanks!

micksulley commented 1 year ago

Brilliant!! Took me a little while to figure out how to install the update but I got there and it works. Thanks so much. Mick