====== Account Feed ====== [[developers:apiv2|◀ WebSocket API (V2)]] Subscribe to one or more accounts to receive their balances, positions, P&L and order status in real time. You must subscribe to an account before routing orders into it. You can auto-subscribe all accounts for your user with a single message. ===== Subscribe ===== Send [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L12|AccountSubscribe]] to subscribe an account, or all accounts: account_subscribe { subscribe: ACCOUNT_SUBSCRIBE_TYPE_ALL_UPDATES account_id: ["ACCT1", "ACCT2"] // or set subscribe_all_accounts: true upl_mode: UPL_MODE_AVERAGE // optional } Note: [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/common/enums.proto#L648|UPLMode]] allows you to save bandwidth by turning off real-time UP&L calculation and message delivery. (UP&L is updated in real-time as the market moves.) ^ Value ^ You receive ^ | ''UPL_MODE_NONE'' | Turns off UP&L calculation and message delivery | | ''UPL_MODE_AVERAGE'' | Computes UP&L as the average open price compared to the current market | The server replies with [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L18|AccountSubscribeResponse]], followed by one or more [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L161|AccountSnapshot]] messages if the subscription was successful. ===== Snapshot, then updates ===== On subscribe you receive an [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L161|AccountSnapshot]] — the current state as a bundle of messages: [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L107|AccountDetails]], [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L78|AccountUpdate]], [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L34|AccountPosition]], [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L26|AccountCurrency]], [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L29|MarketDetails]], and open-order [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/orderrouting/orderrouting.proto#L155|OrderUpdate]] messages. After the snapshot, update messages stream in real-time: ^ Message ^ Carries ^ | [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L78|AccountUpdate]] | Balance, margin (day/full/pre-trade), P&L rollups. | | [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L34|AccountPosition]] | Per-market position: buys/sells, open volume, average price, margin. | | [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L171|AccountProfit]] | Account-level UPL / RPL, working-order totals, alerting flags. | | [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/account/account.proto#L191|AccountPositionProfit]] | Per-position UPL / RPL (incl. USD-converted). | | [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/orderrouting/orderrouting.proto#L155|OrderUpdate]] | Order status updates — see [[developers:apiv2:orders|Order Routing]]. | | [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/orderrouting/orderrouting.proto#L258|OrderTrade]] | Order fills. |