alpacahq / alpaca-py

The Official Python SDK for Alpaca API
https://alpaca.markets/sdks/python/getting_started.html
Apache License 2.0
605 stars 149 forks source link

request is not authorized #519

Closed maxpy closed 4 weeks ago

maxpy commented 1 month ago
from alpaca.trading.client import TradingClient
from alpaca.trading.requests import GetAssetsRequest
from alpaca.trading.enums import AssetClass

trading_client = TradingClient(apiKey, secret)

search_params = GetAssetsRequest(asset_class=AssetClass.US_EQUITY)

assets = trading_client.get_all_assets(search_params)
assets
# search for crypto assets

get : APIError: {"code":40110000,"message":"request is not authorized"}

why?

hiohiohio commented 4 weeks ago

@maxpy Do you use an api key for live account? if so, could you please try to set paper=False for the TradingClient? Default value of the paper parameter is True.

trading_client = TradingClient(apiKey, secret, paper=False)