- 
                Notifications
    You must be signed in to change notification settings 
- Fork 560
Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe.
I noticed when attempting to pull prices at 1 minute intervals between two dates that I did not have a functional API issue, but actually had a subscription limitation.
  File "/home/phanes/development/internal/proteus/proteus.py", line 28, in main
    data = api.get_bars(symbol, '1Min', start=start_date.isoformat(), end=end_date.isoformat()).df
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phanes/development/internal/proteus/.venv/lib/python3.12/site-packages/alpaca_trade_api/rest.py", line 735, in get_bars
    bars = list(self.get_bars_iter(symbol,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phanes/development/internal/proteus/.venv/lib/python3.12/site-packages/alpaca_trade_api/rest.py", line 718, in get_bars_iter
    for bar in bars:
  File "/home/phanes/development/internal/proteus/.venv/lib/python3.12/site-packages/alpaca_trade_api/rest.py", line 594, in _data_get
    resp = self.data_get(path, data=data, feed=feed,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phanes/development/internal/proteus/.venv/lib/python3.12/site-packages/alpaca_trade_api/rest.py", line 274, in data_get
    return self._request(
           ^^^^^^^^^^^^^^
  File "/home/phanes/development/internal/proteus/.venv/lib/python3.12/site-packages/alpaca_trade_api/rest.py", line 222, in _request
    return self._one_request(method, url, opts, retry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phanes/development/internal/proteus/.venv/lib/python3.12/site-packages/alpaca_trade_api/rest.py", line 248, in _one_request
    raise_api_error(resp, http_error)
  File "/home/phanes/development/internal/proteus/.venv/lib/python3.12/site-packages/alpaca_trade_api/rest.py", line 83, in raise_api_error
    raise APIError(error, http_error) from None
alpaca_trade_api.rest.APIError: subscription does not permit querying recent SIP data
It would be more readable if a special exception type for billing/account/access type errors were raised instead of a generic alpaca_trade_api.rest.APIError.  This would also add more room for nuance in error handling in consuming applications.
Describe the solution you'd like.
Can an exception type of alpaca_trade_api.rest.APISubscriptionLimitation or similar be created?
Metadata
Metadata
Assignees
Labels
No labels