alpacahq/alpaca-backtrader-api

Informing user about subscription

brianhumphreys opened this issue · 2 comments

Hey Alpaca Team,
Not a big issue here but would be nice as an addition to new users. When running the example code, I got the following error message with no other context.

Traceback (most recent call last):
  File "/Users/brianhumphreys/.pyenv/versions/3.7.3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/Users/brianhumphreys/.pyenv/versions/3.7.3/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/brianhumphreys/.pyenv/versions/3.7.3/lib/python3.7/site-packages/alpaca_backtrader_api/alpacastore.py", line 430, in _t_candles
    ].dropna(subset=['high'])
  File "/Users/brianhumphreys/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pandas/util/_decorators.py", line 311, in wrapper
    return func(*args, **kwargs)
  File "/Users/brianhumphreys/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pandas/core/frame.py", line 5953, in dropna
    raise KeyError(list(np.compress(check, subset)))
KeyError: ['high']

I had to fork and investigate to figure out that I was getting an error message:
{'code': 42210000, 'message': 'your subscription does not permit querying data from the past 15 minutes'}

when attempting to hit the endpoint https://data.alpaca.markets/stocks/AAPL/bars.

It would be nice to bubble this error up to inform the user without requiring them to investigate. Also, it would be helpful to just mention the required subscription tier in the README.md :)

How did you get it to display the underlying error message?

The error message originates from the alpaca-trade-api package in the rest.py file line 621 (for alpaca-trade-api version 1.4.3). You can view the exact line using this link.