Account and Order Subscriptions
Subscription calls return a uint request ID and callbacks confirm the final result asynchronously.
Subscribe Account Changes
Operation
PushClient.Subscribe. Subscription, cancellation, or subscription-state query command on an established channel. A successful write is not server confirmation.
Request
uint Subscribe(Subject subject)
uint Subscribe(Subject subject, string? account)Parameters
subject is Asset, Position, OrderStatus, or OrderTransaction; Subscribe has an optional account overload.
Asset pushes a full asset snapshot every five seconds by default. Position pushes a full position snapshot every five seconds by default. Live and paper trading accounts use the same interval. Their data arrives in the AssetChange field table, PositionChange field table, OrderStatusChange field table, or OrderTransactionChange field table, respectively.
Return
Return: uint request ID. Subscription and cancellation results arrive in the SubscribeEnd / CancelSubscribeEnd full field table.
Example
uint requestId = client.Subscribe(Subject.Asset, account);Response type
SubscribeEnd(int id, string subject, string result). See the SubscribeEnd / CancelSubscribeEnd full field table.
Data callbacks
Asset: AssetChange(AssetData) field table; Position: PositionChange(PositionData) field table; OrderStatus: OrderStatusChange(OrderStatusData) field table; OrderTransaction: OrderTransactionChange(OrderTransactionData) field table.
Callback Data Example
Asset:
{
"account": "13810712",
"currency": "USD",
"segment": "S",
"availableFunds": 2285040.55,
"netLiquidation": 2285529.37,
"buyingPower": 9140162.19,
"cashBalance": 2284275.24,
"grossPositionValue": 1143.04,
"timestamp": "1669888806020"
}Position:
{
"account": "13810712",
"symbol": "AAPL",
"identifier": "AAPL",
"market": "US",
"secType": "STK",
"positionQty": 4.0,
"averageCost": 75.0,
"latestPrice": 147.23,
"marketValue": 588.92,
"unrealizedPnl": 288.92,
"timestamp": "1669888802018"
}Order Status:
{
"id": "28875370355884032",
"account": "736845",
"symbol": "CL",
"action": "BUY",
"orderType": "LMT",
"totalQuantity": "1",
"filledQuantity": "1",
"avgFillPrice": 77.76,
"status": "Filled",
"timestamp": "1669200782221"
}Related APIs
See Callbacks and the Streaming overview.
Unsubscribe Account Changes
Operation
PushClient.CancelSubscribe. Subscription, cancellation, or subscription-state query command on an established channel. A successful write is not server confirmation.
Request
uint CancelSubscribe(Subject subject)Parameters
subject is Asset, Position, OrderStatus, or OrderTransaction; Subscribe has an optional account overload.
Return
Return: uint request ID. Subscription and cancellation results arrive in the SubscribeEnd / CancelSubscribeEnd full field table.
Example
uint requestId = client.CancelSubscribe(Subject.Asset);Response type
CancelSubscribeEnd(int id, string subject, string result). See the SubscribeEnd / CancelSubscribeEnd full field table.
Data callbacks
Before cancellation, data uses the same tables as subscription: AssetChange, PositionChange, OrderStatusChange, and OrderTransactionChange.
Related APIs
See Callbacks and the Streaming overview.
Updated about 1 month ago
