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

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

Open
1 task done
cmpunches opened this issue Mar 24, 2024 · 0 comments
Open
1 task done

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

cmpunches opened this issue Mar 24, 2024 · 0 comments

Comments

@cmpunches
Copy link

cmpunches commented Mar 24, 2024

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?

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