Reputation: 31
I'm having an issue running a very simple script to pull in live data data from their web socket.
I wrote a simple script to connect to the websocket and get a non descriptive error with no python exception
$ python3.9 bot.py
error: invalid syntax (400)
bot.py
import traceback
from alpaca_trade_api.common import URL
from alpaca_trade_api.stream import Stream
symbol = 'BTCUSD'
ALPACA_API_KEY = "{{APIKEY}}"
ALPACA_SECRET_KEY = "{{SECRETKEY}}"
async def print_crypto_bars(t):
print('crypto bar', t)
# Initiate Class Instance
stream = Stream(key_id=ALPACA_API_KEY,
secret_key=ALPACA_SECRET_KEY,
base_url=URL('https://paper-api.alpaca.markets'),
raw_data=True)
stream.subscribe_crypto_bars(print_crypto_bars, symbol)
@stream.on_crypto_bar(symbol)
async def _(bar):
print('@on_crypto_bar', bar)
try:
stream.run()
except Exception:
traceback.print_exc()
I've found nothing online to help diagnose this with alpaca client lib
Upvotes: 0
Views: 609
Reputation: 31
I ended up creating my own client for alpaca manually to disect this non-descript issue.
I ended up finding it was the symbol
was
symbol = 'BTCUSD'
... causing "error: invalid syntax (400)"
changed to
symbol = 'BTC/USD'
Upvotes: 0