Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when calling market (aggregate) endpoint for get_beta #260

Open
nima opened this issue Feb 16, 2021 · 0 comments
Open

Crash when calling market (aggregate) endpoint for get_beta #260

nima opened this issue Feb 16, 2021 · 0 comments

Comments

@nima
Copy link

nima commented Feb 16, 2021

Summary (include Python version)

Crash when hitting the market (aggregate) endpoint, for some specific keys.

In [17]: import sys
In [18]: sys.version_info
Out[18]: sys.version_info(major=3, minor=9, micro=1, releaselevel='final', serial=0)

Date/time of issue

In [26]: datetime.datetime.now()
Out[26]: datetime.datetime(2021, 2, 15, 23, 14, 27, 323926)

Expected behavior

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'>
% pip list|grep iex
iexfinance                                        0.5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant