TradingStream#
- class alpaca.trading.stream.TradingStream(api_key: str, secret_key: str, paper: bool = True, raw_data: bool = False, url_override: str = None, websocket_params: Optional[Dict] = None)#
This is a WebSocket client which allows you to streaming data from your trading account.
Learn more here: https://alpaca.markets/docs/api-references/trading-api/streaming/
If using paper keys, make sure to set
paperto True when instantiating the client.- async close() None#
Closes the websocket connection.
- run() None#
Starts up the websocket connection’s event loop
- stop() None#
Stops the websocket connection.
- async stop_ws() None#
Signals websocket connection should close by adding a closing message to the stop_stream_queue
- subscribe_trade_updates(handler: Callable)#
Subscribes to trade updates for your trading account.
- Parameters:
handler (Callable) – The async handler that will receive trade update data.
- Returns:
None