addisonlynch / iexfinance

Python SDK for IEX Cloud
https://addisonlynch.github.io/iexfinance
Apache License 2.0
648 stars 136 forks source link

Market (aggregate) endpoint `get_market_cap` is broken #261

Open nima opened 3 years ago

nima commented 3 years ago

Here's how it's expected to work:

In [9]: api.iex.Stock(['AAPL', 'MSFT']).get_price()
Out[9]: {'AAPL': 129.71, 'MSFT': 243.79}

In contrast, here's what actually happens:

In [10]: api.iex.Stock(['AAPL', 'MSFT']).get_market_cap()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-10-a10133b42a85> in <module>
----> 1 api.iex.Stock(['AAPL', 'MSFT']).get_market_cap()

~/rh/.venv/lib/python3.9/site-packages/iexfinance/stocks/base.py in get_market_cap(self)
    867 
    868     def get_market_cap(self):
--> 869         return self._get_field("quote", "marketCap")
    870 
    871     def get_beta(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 marketCap not found in quote.'