yahooquery
yahooquery copied to clipboard
stock.asset_profile doesn't work for some tickers
Describe the bug This bug is not specific to the 'assetProfile' module, I've seen it for key_stats and summary_detail as well.
To Reproduce
>>> stock = Ticker('DAR.DE')
>>> stock.asset_profile
Traceback (most recent call last):
File "/Users/samuel/Library/Python/3.9/lib/python/site-packages/yahooquery/base.py", line 1217, in _construct_data
data = json[response_field]["result"][0][addl_key]
KeyError: 'assetProfile'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/samuel/Library/Python/3.9/lib/python/site-packages/yahooquery/ticker.py", line 209, in asset_profile
return self._quote_summary(["assetProfile"])
File "/Users/samuel/Library/Python/3.9/lib/python/site-packages/yahooquery/ticker.py", line 101, in _quote_summary
data = self._get_data(key="quoteSummary", params=params, **kwargs)
File "/Users/samuel/Library/Python/3.9/lib/python/site-packages/yahooquery/base.py", line 1088, in _get_data
data = self._sync_requests(response_field, urls, params, **kwargs)
File "/Users/samuel/Library/Python/3.9/lib/python/site-packages/yahooquery/base.py", line 1185, in _sync_requests
data[symbol] = self._construct_data(json, response_field, **kwargs)
File "/Users/samuel/Library/Python/3.9/lib/python/site-packages/yahooquery/base.py", line 1224, in _construct_data
json[response_field]["result"][addl_key]
TypeError: list indices must be integers or slices, not str
Expected behavior A valid result instead of an exception.
Desktop (please complete the following information):
- OS: MacOS 13.4.1
- Version: 2.3.2
I am seeing it with recommendation_trend. It does not happen with every ticket.
Started having this issue as of this morning myself, yesterday it was working fine.
I use asset_profile to scrape the 'sector' and 'industry' information. so it basically looks like: yq.Ticker('AAPL').asset_profile['AAPL']['sector']
Yet now it gives off KeyError: 'assetProfile' and TypeError: list indices must be integers or slices, not str
Entire error looks exactly the same as OP's post.
Edit: Tried it again after a couple hours and it worked now. It seems it's an issue that can be duplicated occasionally and not persistent.
Edit: Tried it again after a couple hours and it worked now. It seems it's an issue that can be duplicated occasionally and not persistent.
It is yahoo's issue. The website somehow don't have asset profile data few hours ago.
This issue is still occurring randomly, it seems to be getting worse.