It should not crash, and should behave as it does on other keys, such as price:
In [27]: x = api.iex.Stock(['AAPL', 'MSFT'])
In [28]: x.get_price()
Out[28]: {'AAPL': 135.37, 'MSFT': 244.99}
Actual behavior
In [29]: x.get_beta()
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-29-67c5fe7c40d7> in <module>
----> 1 x.get_beta()
~/rh/.venv/lib/python3.9/site-packages/iexfinance/stocks/base.py in get_beta(self)
870
871 def get_beta(self):
--> 872 return self._get_field("key_stats", "beta")
873
874 def get_short_interest(self):
~/rh/.venv/lib/python3.9/site-packages/iexfinance/stocks/base.py in _get_field(self, endpoint, field)
91 raise NotImplementedError("Endpoint %s not implemented." % endpoint)
92 if field not in data:
---> 93 raise KeyError("Field %s not found in %s." % (field, endpoint))
94 if self.output_format == "json":
95 if self.single_symbol:
KeyError: 'Field beta not found in key_stats.'
Additional Info
In [30]: x
Out[30]: Stock(symbols=AAPL,MSFT, output_format='json')
In [31]: api.iex
Out[31]: <module 'iexfinance.stocks' from '/Users/nimbler/rh/.venv/lib/python3.9/site-packages/iexfinance/stocks/__init__.py'>
Summary (include Python version)
Crash when hitting the market (aggregate) endpoint, for some specific keys.
Date/time of issue
Expected behavior
It should not crash, and should behave as it does on other keys, such as
price
:Actual behavior
Additional Info