You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
api_key=""secret_key=""paper=Truetrade_client=TradingClient(api_key=api_key, secret_key=secret_key, paper=paper, url_override=trade_api_url)
symbol="BTC/USD"# 404 response. API Error thrown position=trade_client.get_open_position(symbol_or_asset_id=symbol)
# Also 404 responsetrade_client.close_position(
symbol_or_asset_id=symbol,
close_options=ClosePositionRequest(
qty="0.01",
)
)
# Change the symbol to drop / and it's okaysymbol="BTCUSD"position=trade_client.get_open_position(symbol_or_asset_id=symbol) # 200trade_client.close_position( # 200symbol_or_asset_id=symbol,
close_options=ClosePositionRequest(
qty="0.01",
)
)
# But the BTCUSD format doesn't work for historical data# APIError: {"message":"invalid symbol: BTCUSD does not match ^[A-Z]+/[A-Z]+$"}crypto_historical_data_client=CryptoHistoricalDataClient()
# get historical bars by symbol# ref. https://docs.alpaca.markets/reference/cryptobars-1now=datetime.now(ZoneInfo("America/New_York"))
req=CryptoBarsRequest(
symbol_or_symbols= [symbol],
timeframe=TimeFrame(amount=1, unit=TimeFrameUnit.Hour), # specify timeframestart=now-timedelta(days=1), # specify start datetime, default=the beginning of the current day.# end_date=None, # specify end datetime, default=nowlimit=2, # specify limit
)
crypto_historical_data_client.get_crypto_bars(req).df
Expected Behavior
Ideally you could use the same symbol string for orders, positions, and historical data. That sounds like it could be an API change, but for now it could be good to update the demo.
SDK Version I encountered this issue in
alpaca-py 0.34.0
Steps To Reproduce
Run the provided code, or:
1. Setup a fresh crypto-trading-basic.ipynb
2. Run the notebook as normal. get_open_position(symbol_or_asset_id=symbol) and trade_client.close_position(symbol_or_asset_id = symbol...) raise API errors
3. Try symbol = "BTCUSD". The notebook runs all the way until we access historical data. Then we get APIError: {"message":"invalid symbol: BTCUSD does not match ^[A-Z]+/[A-Z]+$"}
Filled out the Steps to Reproduce section?
I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.
Anything else?
No response
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Current Behavior
Expected Behavior
Ideally you could use the same symbol string for orders, positions, and historical data. That sounds like it could be an API change, but for now it could be good to update the demo.
SDK Version I encountered this issue in
alpaca-py 0.34.0
Steps To Reproduce
Filled out the Steps to Reproduce section?
Anything else?
No response
The text was updated successfully, but these errors were encountered: