Option Market Data Websocket Stream

I’m using latest market data api for option data, this is my code for alpaca_trade_api in python, but I got an error:

data websocket error, restarting connection: server rejected WebSocket connection: HTTP 404

I’m not sure what’s wrong here, or is my subscription incorrect? If I switch to stock websocket stream, I can see live market data.

Thank you!

python
from alpaca_trade_api.stream import Stream
from alpaca_trade_api.common import URL

async def trade_update_handler(t):
    symbol = t.symbol
    price = Decimal(t.price)
    timestamp = t.timestamp
    print(symbol, price, timestamp)

async def subscribe_to_tickers(stream, tickers):
    for ticker in tickers:
        stream.subscribe_trades(trade_update_handler, ticker)
    await stream._run_forever()



account = get_market_data_account()
stream = Stream(account.api_key,
                account.secret_key,
                data_stream_url=URL('wss://stream-options.data.alpaca.markets/v1beta1'),
                data_feed='indicative')
  if loop.is_running():
      asyncio.ensure_future(subscribe_to_tickers(stream, tickers))
  else:
      loop.run_until_complete(subscribe_to_tickers(stream, tickers))

loop = asyncio.get_event_loop()

I thought the URL was:

wss://stream.data.alpaca.markets/v1beta1/{feed}

Source:

Thank you!

But I got an error: [{‘T’: ‘error’, ‘code’: 400, ‘msg’: ‘invalid syntax’}]

when I use url:

“wss://stream.data.alpaca.markets/v1beta1/indicative”

I post a message like:

{
            "action": "subscribe",
            "trades": ["SPY240522C00528000"],
}

Have you met similar error? Thank you!

Best

try to put SPY240524C00528000 - it is ending with 24 -friday, the 24th - expiration date.

still not work, same error.