yahooquery icon indicating copy to clipboard operation
yahooquery copied to clipboard

stock.asset_profile doesn't work for some tickers

Open portefeuille opened this issue 1 year ago • 4 comments

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

portefeuille avatar Jul 17 '23 16:07 portefeuille

I am seeing it with recommendation_trend. It does not happen with every ticket.

habeebalaidroos avatar Jul 18 '23 03:07 habeebalaidroos

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.

EmirEgilli avatar Aug 03 '23 07:08 EmirEgilli

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.

KenLee12323 avatar Aug 03 '23 12:08 KenLee12323

This issue is still occurring randomly, it seems to be getting worse.

leoalonso3053 avatar Oct 16 '23 00:10 leoalonso3053