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
910 stars 215 forks source link

Unable to get stock profile data #160

Closed nathphoenix closed 9 months ago

nathphoenix commented 10 months ago

Please this function is failing get_stock_profile_data and others when i run them.

This is the error below

HTTPSConnectionPool(host='query2.finance.yahoo.com', port=443): Max retries exceeded with url: /v6/finance/quoteSummary/googl?modules=assetProfile&formatted=False&lang=en-US&region=US&corsDomain=finance.yahoo.com (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002A2BE011000>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')))

Server replied with server error code, HTTP 404 code while opening the url: https://query1.finance.yahoo.com/v6/finance/quoteSummary/googl?modules=assetProfile&formatted=False&lang=en-US&region=US&corsDomain=finance.yahoo.com

@flipdazed @sylvandb @VKorelsky

Please what could be the possible reason

pzarfos commented 10 months ago

Are you running an ad-blocker?

I am running pi-hole and had a similar issue, which I fixed by adding the yahoo finance domain names to my ad-blocker whitelist.

more info here - https://github.com/JECSand/yahoofinancials/issues/159#issuecomment-1807168165

GerdSidan commented 10 months ago

For me getting stock profile data also does not work any longer. This simple program:

from yahoofinancials import YahooFinancials
fins = YahooFinancials('AAPL', concurrent=False, max_workers=8, country="US")
companydata = fins.get_stock_profile_data()

results in this traceback:

Traceback (most recent call last):
  File "<Path my test file>\yahoofinancials-GetProfile-SimpleTest.py", line 4, in <module>
    companydata = fins.get_stock_profile_data()
  File "<Path to my Python installation>\Python310\lib\site-packages\yahoofinancials\yf.py", line 114, in get_stock_profile_data
    self.get_stock_data(statement_type='profile', tech_type='assetProfile', report_name='assetProfile'),
  File "<Path to my Python installation>\Python310\lib\site-packages\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 "<Path to my Python installation>\Python310\lib\site-packages\yahoofinancials\etl.py", line 521, in _create_dict_ent
    re_data = self._get_historical_data(YAHOO_URL, r_map, tech_type, statement_type)
  File "<Path to my Python installation>\Python310\lib\site-packages\yahoofinancials\etl.py", line 248, in _get_historical_data
    self._request_handler(url, config.get("response_field"))
  File "<Path to my Python installation>\Python310\lib\site-packages\yahoofinancials\etl.py", line 190, in _request_handler
    cur_url += "&crumb=" + self.crumb
TypeError: can only concatenate str (not "NoneType") to str

Tested on Windows 10 with Python 3.10.1 and yahoofinancials 1.17. The error also occurs on Debian 12 with Python 3.11.2 and yahoofinancials 1.17.

JECSand commented 9 months ago

@GerdSidan Could you try that on v1.18?

JECSand commented 9 months ago

Just released v1.19 which includes a fix for this issue.