For the complete documentation index, see llms.txt. This page is also available as Markdown.

Streaming

Stream live LTP, quotes, market depth, and order updates from the OpenAlgo WebSocket server as NDJSON

openalgo stream connects to the OpenAlgo WebSocket server, authenticates with the API key, subscribes, and prints every message as one JSON object per line (NDJSON) on stdout. When the stream ends it unsubscribes and closes the connection.

Command
Streams

stream ltp

Last traded price ticks

stream quote

Quote ticks: OHLC, LTP, volume, and average price

stream depth

Market depth (order book) ticks

stream orders

Order status updates for the account

Symbols

Market data streams take symbols in one of two forms:

Flag
Form
Example

--symbols

Comma-separated EXCHANGE:SYMBOL list

--symbols NSE:RELIANCE,NSE:SBIN,NSE_INDEX:NIFTY

--symbol with --exchange

A single symbol

--symbol RELIANCE --exchange NSE

--exchange also applies to bare symbols in --symbols. stream depth accepts --depth for the number of order book levels (5, 20, 30, or 50, broker dependent; default 5).

stream orders takes no symbols. It reports status updates for orders on the account; the mode field says whether an update is live or analyze (analyzer mode).

Ending a Stream

Flag
Effect

(none)

Run until Ctrl-C

--count N

Exit after N data messages

--duration 30s

Exit after a duration such as 30s or 5m

--raw

Also print control messages (auth, subscribe, and unsubscribe acknowledgements)

Always bound a stream with --count or --duration in automation and agent sessions, so the command returns.

Examples

--jq is applied to each message, so the output stays NDJSON:

Two quote ticks streamed as NDJSON and shaped with --jq

NDJSON pipes directly into other tools:

Message Shapes

Run --schema on any stream command to print its message shape without connecting:

Market data messages have type, symbol, exchange, mode (1 LTP, 2 quote, 3 depth), broker, and a data object whose exact fields depend on the broker. Order updates have type order_update, orderid, symbol, exchange, action, quantity, price, order_status, filled_quantity, average_price, rejection_reason, and related fields.

WebSocket URL

The WebSocket URL is derived from the REST host:

Host
WebSocket URL

http://127.0.0.1:5000

ws://127.0.0.1:8765

http://127.0.0.1:5001 (second instance)

ws://127.0.0.1:8766

https://algo.example.com

wss://algo.example.com/ws

Additional instances keep the same port offset. See Multiple OpenAlgo Instances.

Override the derived URL when your deployment differs:

Credentials from
Override

A profile

openalgo profile login --ws-url wss://ws.example.com, stored as ws_url in the profile file

OPENALGO_API_KEY

OPENALGO_WS_URL=wss://ws.example.com

With profile credentials OPENALGO_WS_URL is ignored, so an environment variable can never redirect a stored key to another server.

Diagnostics

Flag
Shows on stderr

--verbose

The WebSocket URL and connect time

--debug

Every frame sent and received, with the API key redacted

openalgo doctor prints the WebSocket URL the active profile resolves to.

See WebSockets for the underlying protocol.

Last updated

Was this helpful?