Closed ian-hailey closed 6 months ago
I have the same problem with get_key_statistics_data(). Tired a few of the Additional Module Methods and most of them have the same TypeError.
raceback (most recent call last):
File "
Same problem with .get_stock_quote_type_data(). Until yesterday, it worked fine. I hope it is not linked to the same issue that is impacting on some yfinance modules since October 20!
It's almost certainly related. This is change is working for me but I haven't tried all the things:
In session.py about line 133 find the line which has this and change from:
response = session.get('https://fc.yahoo.com')
to:
response = session.get('https://finance.yahoo.com/')
Thank you sylvandb. Your fix worked for .get_current_price.
Does not work for me get a 401 with finance.yahoo.com: yahoofinancials.etl.ManagedException: Server replied with server error code, HTTP 401 code while opening the url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/v?modules=defaultKeyStatistics&formatted=False&lang=en-US®ion=US&corsDomain=finance.yahoo.com&crumb=
Using get_key_statistics_data()
But with finance.yahoo.com added to response, the response of running from yahoofinancials import YahooFinancials tickers = ['AAPL', 'GOOG', 'C'] yahoo_financials = YahooFinancials(tickers, concurrent=True, max_workers=8, country="US") balance_sheet_data_qt = yahoo_financials.get_financial_stmts('quarterly', 'balance') print(balance_sheet_data_qt) Running this is way faster than with fc.yahoo.com and it works, but does not work for me when running .get_current_price and get_key_statistics_data() then i get a 401. So i guess there is some sort of authentication needed for that url.
It seems like there are some modules where the fix suggested by sylvandb works and others where it returns the error noted also by bjosun. For example, get_current_price() and get_financial_data() don't work, whereas get_financial_stmts works.
Hey all, taking care of this now.
Closing this issue with release of v1.18. Thank you everyone!
I get the following error when attempting to call many of the methods such as get_stock_earnings_data.
Calls to get_financial_stmts, get_financial_stmts and get_historical_price_data are always working.
Any ideas what could be the issue?
This test was with v1.17 on a MAC with python 3.9.
apple_earnings_data = yahoo_financials.get_stock_earnings_data()
Traceback (most recent call last): File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_exec2.py", line 3, in Exec exec(exp, global_vars, local_vars) File "", line 1, in
File "/Library/Python/3.9/site-packages/yahoofinancials-1.17-py3.9.egg/yahoofinancials/yf.py", line 121, in get_stock_earnings_data
return self.get_stock_tech_data('earnings')
File "/Library/Python/3.9/site-packages/yahoofinancials-1.17-py3.9.egg/yahoofinancials/etl.py", line 595, in get_stock_tech_data
return self.get_stock_data(tech_type=tech_type)
File "/Library/Python/3.9/site-packages/yahoofinancials-1.17-py3.9.egg/yahoofinancials/etl.py", line 565, in get_stock_data
dict_ent = self._create_dict_ent(self.ticker, statement_type, tech_type, report_name, hist_obj)
File "/Library/Python/3.9/site-packages/yahoofinancials-1.17-py3.9.egg/yahoofinancials/etl.py", line 521, in _create_dict_ent
re_data = self._get_historical_data(YAHOO_URL, r_map, tech_type, statement_type)
File "/Library/Python/3.9/site-packages/yahoofinancials-1.17-py3.9.egg/yahoofinancials/etl.py", line 248, in _get_historical_data
self._request_handler(url, config.get("response_field"))
File "/Library/Python/3.9/site-packages/yahoofinancials-1.17-py3.9.egg/yahoofinancials/etl.py", line 190, in _request_handler
cur_url += "&crumb=" + self.crumb
TypeError: can only concatenate str (not "NoneType") to str
income_statement_data_qt = yahoo_financials.get_financial_stmts('quarterly', 'income') income_statement_data_qt {'incomeStatementHistoryQuarterly': {'AAPL': [{'2023-06-30': {'basicAverageShares': 15697614000.0, .....etc