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

Alpaca broker fails to authorize and/or connect... #331

Open
andreylisovskiy opened this issue Dec 14, 2023 · 3 comments
Open

Alpaca broker fails to authorize and/or connect... #331

andreylisovskiy opened this issue Dec 14, 2023 · 3 comments

Comments

@andreylisovskiy
Copy link

andreylisovskiy commented Dec 14, 2023

I have copied initial example set up for Alpaca form "Getting Started" of Lumibot documentation. Have copied over my API and secret key, however, the connection to trading broker fails at this line of lumibot example code:
strategy = MyStrategy( broker=broker, parameters= { "symbol": "SPY" })

With this error message:
File "C:\kingston_drive\Pycharm_Projects\stocks_tensorflow\modules\lumibot_trading.py", line 67, in lumibot_example strategy = MyStrategy( File "C:\Python3_10\lib\site-packages\lumibot\strategies\_strategy.py", line 199, in __init__ self.update_broker_balances() File "C:\Python3_10\lib\site-packages\lumibot\strategies\_strategy.py", line 367, in update_broker_balances broker_balances = self.broker._get_balances_at_broker(self.quote_asset) File "C:\Python3_10\lib\site-packages\lumibot\brokers\alpaca.py", line 253, in _get_balances_at_broker response = self.api.get_account() File "C:\Python3_10\lib\site-packages\alpaca\trading\client.py", line 417, in get_account response = self.get("/account") File "C:\Python3_10\lib\site-packages\alpaca\common\rest.py", line 221, in get return self._request("GET", path, data, **kwargs) File "C:\Python3_10\lib\site-packages\alpaca\common\rest.py", line 129, in _request return self._one_request(method, url, opts, retry) File "C:\Python3_10\lib\site-packages\alpaca\common\rest.py", line 205, in _one_request raise APIError(error, http_error) alpaca.common.exceptions.APIError: {"code":40110000,"message":"request is not authorized"}

But I have zero issues accessing my paper trading account with same API and secret key using alpaca_trade_api python library like so:
api = tradeapi.rest.REST(APCA_API_KEY_ID, APCA_API_SECRET_KEY, APCA_API_BASE_URL, api_version='v2')

I do not know why lumibot method fails. Please help!

Thanks,

@grzesir
Copy link
Contributor

grzesir commented Dec 14, 2023 via email

@andreylisovskiy
Copy link
Author

That did do it! It worked! Thank you.

@grzesir
Copy link
Contributor

grzesir commented Dec 15, 2023 via email

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

2 participants