ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.89k stars 2.44k forks source link

ticker.growth_estimates error #2126

Open kschubert417 opened 1 week ago

kschubert417 commented 1 week ago

Describe bug

Yesterday (November 14, 2024) everything was running fine, this morning I have run into errors when trying to retrieve growth estimates from Microsoft (ticker MSFT).

Here is the error code:

Traceback (most recent call last):
  File "c:/python/utility-roe/web/app/functions.py", line 497, in <module>
    print(msft.growth_estimates)
  File "C:\Python37\lib\site-packages\yfinance\ticker.py", line 278, in growth_estimates
    return self.get_growth_estimates()
  File "C:\Python37\lib\site-packages\yfinance\base.py", line 308, in get_growth_estimates
    data = self._analysis.growth_estimates
  File "C:\Python37\lib\site-packages\yfinance\scrapers\analysis.py", line 225, in growth_estimates
    data_dict[period].append(item.get('growth', {}).get('raw', None))
KeyError: 'LTG'

Simple code that reproduces your problem

Here is the example from the https://pypi.org/project/yfinance/ page I am no longer able to run without error.

import yfinance as yahooFinance

msft = yahooFinance.Ticker("MSFT")
print(msft.info) # works
print(msft.growth_estimates) # where error occurs

Debug log

DEBUG    get_raw_json(): https://query2.finance.yahoo.com/v10/finance/quoteSummary/MSFT
DEBUG    Entering get()
DEBUG     Entering _make_request()
DEBUG      url=https://query2.finance.yahoo.com/v10/finance/quoteSummary/MSFT
DEBUG      params={'modules': 'earningsTrend', 'corsDomain': 'finance.yahoo.com', 'formatted': 'false', 'symbol': 'MSFT'}
DEBUG      Entering _get_cookie_and_crumb()
DEBUG       cookie_mode = 'basic'
DEBUG       Entering _get_cookie_and_crumb_basic()
DEBUG        reusing cookie
DEBUG        reusing crumb
DEBUG       Exiting _get_cookie_and_crumb_basic()
DEBUG      Exiting _get_cookie_and_crumb()
DEBUG      response code=200
DEBUG     Exiting _make_request()
DEBUG    Exiting get()
DEBUG    get_raw_json(): https://query2.finance.yahoo.com/v10/finance/quoteSummary/MSFT
DEBUG    Entering get()
DEBUG     Entering _make_request()
DEBUG      url=https://query2.finance.yahoo.com/v10/finance/quoteSummary/MSFT
DEBUG      params={'modules': 'industryTrend,sectorTrend,indexTrend', 'corsDomain': 'finance.yahoo.com', 'formatted': 'false', 'symbol': 'MSFT'}
DEBUG      Entering _get_cookie_and_crumb()
DEBUG       cookie_mode = 'basic'
DEBUG       Entering _get_cookie_and_crumb_basic()
DEBUG        reusing cookie
DEBUG        reusing crumb
DEBUG       Exiting _get_cookie_and_crumb_basic()
DEBUG      Exiting _get_cookie_and_crumb()
DEBUG      response code=200
DEBUG     Exiting _make_request()
DEBUG    Exiting get()

Bad data proof

No response

yfinance version

0.2.49

Python version

3.7

Operating system

Windows 10