Configure a streaming CLI command
Use this reference when stream run needs to open a particular stream with specified subscriptions. Describe the stream, initial requests, and exit conditions in JSON. The CLI validates the configuration before creating the SDK, then opens the stream or returns a configuration error.
Choose a stream and subscriptions
The configuration selects a stream, subscriptions, and output options. For standard subscriptions, the CLI builds requests from the generated gRPC contracts.
This is the smallest valid configuration.
{
"stream": "marketdata.marketDataServerSideStream",
"subscriptions": {
"trades": [
{
"instrumentId": "BBG00QPYJ5H0"
}
]
},
"runtime": {
"format": "jsonl"
}
}
Set configuration fields
Start with stream. Provide subscriptions for the server-side market data stream, requests for the bidirectional stream, or accounts for account events.
| Field | Type | Required | Purpose |
|---|---|---|---|
stream |
string | Always | Selects the streaming API method |
subscriptions |
object | Server-side market data stream | Market data subscriptions |
requests |
object[] | Bidirectional market data stream | Static set of initial requests |
accounts |
string[] | Account streams | Account identifiers for operations and orders streams |
runtime |
object | Optional | Output and exit settings |
Supported stream values
marketdata.marketDataStreammarketdata.marketDataServerSideStreamoperations.portfolioStreamoperations.positionsStreamorders.tradesStream
marketdata.marketDataStream uses a separate requests field for its bidirectional stream. The CLI sends the configured requests first, then reads provider events.
Configuration validation rejects rawRequests for all streams.
Configure execution and output
runtime controls the output format, event count, and exit conditions.
{
"runtime": {
"format": "jsonl",
"maxEvents": 100,
"durationMs": 60000,
"idleTimeoutMs": 15000,
"includePings": false,
"includeSubscriptionEvents": true,
"raw": false
}
}
format— output format. The supported value isjsonl.maxEvents— exit after printing N events.durationMs— exit N milliseconds after the stream starts.idleTimeoutMs— exit after N milliseconds without events.includePings— includepingevents instdout.includeSubscriptionEvents— include subscription statuses instdout.raw— output the generated response without the normalized event envelope.
Subscribe to market data
subscriptions groups subscriptions by event family.
{
"stream": "marketdata.marketDataServerSideStream",
"subscriptions": {
"candles": [
{
"instrumentId": "BBG00QPYJ5H0",
"interval": "1min",
"waitingClose": false
}
],
"orderBooks": [
{
"instrumentId": "BBG00QPYJ5H0",
"depth": 10
}
],
"trades": [
{
"instrumentId": "BBG00QPYJ5H0"
}
],
"info": [
{
"instrumentId": "BBG00QPYJ5H0"
}
],
"lastPrices": [
{
"instrumentId": "BBG00QPYJ5H0"
}
]
},
"runtime": {
"format": "jsonl",
"maxEvents": 100,
"includePings": false
}
}
Subscription defaults and rules
- The CLI always subscribes using
SUBSCRIPTION_ACTION_SUBSCRIBEand rejectsactionin the configuration. - Deprecated
figifields of the generated contracts keep their protobuf defaults and are omitted during serialization. instrumentIdis required for every instrument.waitingClosedefaults tofalse.orderBooks[].depthis required and must be an integer from1to2147483647, the protobufint32range.
Use the same waitingClose value for all candle subscriptions within one request. For a server-side stream, this applies to the entire subscriptions.candles array. For a bidirectional stream, it applies to instruments in one subscribeCandles request. An omitted field counts as false.
Supported candle interval aliases
1min5min
The generated streaming SubscriptionInterval supports only one- and five-minute intervals. Other historical candle CLI aliases are unsupported here.
Choose a Market Data stream
marketdata.marketDataServerSideStream sends one initial request built from subscriptions, then reads events.
marketdata.marketDataStream is bidirectional. stream run accepts a static set of typed initial requests in the configuration. Additional requests from stdin, files, timers, and interactive input are unsupported.
Bidirectional stream configuration
{
"stream": "marketdata.marketDataStream",
"requests": [
{
"type": "subscribeTrades",
"instruments": [
{
"instrumentId": "BBG00QPYJ5H0"
}
]
},
{
"type": "getMySubscriptions"
}
],
"runtime": {
"format": "jsonl",
"maxEvents": 50
}
}
Supported request type values
subscribeCandlessubscribeOrderBooksubscribeTradessubscribeInfosubscribeLastPricegetMySubscriptions
Request entries use the same instrument fields as server-side market data subscriptions.
subscribeCandlesrequiresinstrumentIdandinterval.waitingCloseis optional.subscribeOrderBookrequiresinstrumentIdanddepth.subscribeTrades,subscribeInfo, andsubscribeLastPricerequireinstrumentId.getMySubscriptionsrejectsinstruments.
Use requests with the typed variants above to send bidirectional requests.
Subscribe to account events
Portfolio stream
{
"stream": "operations.portfolioStream",
"accounts": ["2000000000"],
"runtime": {
"format": "jsonl",
"maxEvents": 50
}
}
Positions stream
{
"stream": "operations.positionsStream",
"accounts": ["2000000000"],
"runtime": {
"format": "jsonl",
"maxEvents": 50
}
}
Order trades stream
{
"stream": "orders.tradesStream",
"accounts": ["2000000000"],
"runtime": {
"format": "jsonl",
"includePings": false
}
}
accountsmust contain at least one account ID.- The CLI passes the IDs to
accountsin the generated request. - Account streams reject
subscriptions. - Unknown fields are rejected before the SDK is created.
Validate configuration before starting
Configuration validation rejects the following.
- Unknown
streamvalues. - Missing
accountsfor account streams. - Empty
subscriptionsfor a server-side market data stream. - Missing or empty
requestsformarketdata.marketDataStream. - Unknown top-level fields.
- The unsupported
rawRequestsfield. - Unsupported
runtime.format. - Nonpositive numeric limits in
runtime. - Market Data entries without
instrumentId. - Generated enum names and aliases unsupported by the configuration converter.
The CLI validates configuration before creating TInvestNodeSDK.
Override settings on the CLI
CLI flags can override settings from runtime.
t-invest-node-sdk stream run \
--config=portfolio-stream.json \
--max-events=10 \
--include-pings
See Streaming CLI runtime settings for supported flags and boolean override rules.
Set subscriptions and account selection in the configuration file. This lets one command support multiple streams with the same set of flags.
Choose the output format
Default normalized event
{"stream":"orders.tradesStream","sequence":1,"receivedAt":"2026-06-29T12:00:00.000Z","type":"orderTrades","payload":{"orderId":"..."}}
Raw event with runtime.raw: true
{"orderTrades":{"orderId":"..."}}
By default, all streaming methods emit normalized events with a shared structure.
Run the command
- Run a streaming CLI command — look up event formats and exit codes.
- Run a CLI command — pass common arguments.