Checks if the WebSocket connection is currently open.
true if the connection is open, false otherwise.
Checks if the WebSocket connection is subscribed to the specified stream.
The name of the WebSocket stream to check.
true if the connection is subscribed to the stream, false otherwise.
Removes an event listener for the specified WebSocket event.
The WebSocket event to stop listening for, such as 'open', 'message', 'error', 'close', 'ping', or 'pong'.
The callback function that was previously added as the event listener.
Adds an event listener for the specified WebSocket event.
The WebSocket event to listen for, such as 'open', 'message', 'error', 'close', 'ping', or 'pong'.
The callback function to be executed when the event is triggered. The function can accept any number of arguments.
Real-time push of the user's order updates. Option orders are pushed on orderReportV2, not on orderReport.
orderReportV2 carries both US stock and US stock option orders; tell them apart with the ac field. To process option orders only, subscribe to orderReportV2 and handle events where ac = us_option.
A push is sent once when an open order changes (x = ORDER_UPDATE) and once when it reaches a terminal state (x = ORDER_TERMINAL). Pushes are best-effort: a failed push is not retried, events while the listenKey is invalid are not replayed, and an order never pushed in an open state (e.g. rejected immediately) may not get a terminal push. After reconnecting, call Current Open Option Orders for a full snapshot first. Fill-level details are not pushed; use Option Order Detail or Option Trade History.
For expiration-day auto-liquidation orders by the broker (o = market), p, b, q, tc, u, ct, sp and ed may be null; get contract details from Option Exchange Info by os.
Prerequisite: obtain a listenKey via the Listen Key endpoint first.
Request parameters.
Subscribes to one or multiple WebSocket streams Handles both single and pool modes
Single stream name or array of stream names to subscribe to
Optionalid: string
Optional subscription ID
void
Unsubscribes from one or multiple WebSocket streams Handles both single and pool modes
Single stream name or array of stream names to unsubscribe from
Optionalid: string
Optional unsubscription ID
void
Disconnects from the WebSocket server. If there is no active connection, a warning is logged. Otherwise, all connections in the connection pool are closed gracefully, and a message is logged indicating that the connection has been disconnected.