Skip to content
This repository was archived by the owner on Jun 17, 2026. It is now read-only.
This repository was archived by the owner on Jun 17, 2026. It is now read-only.

Please use a billing/subscription-related exception type #756

Open

Description

@cmpunches

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions