Skip to main content
Refer to Websocket for establishing the websocket connection.

Params

Positions Snapshots

Upon subscription, the account_positions websocket immediately returns a snapshot of all current positions, then begins streaming all changes made to an account’s positions in a best effort picture of current state.

We recommend using account_positions for initialization, and account_trades, to construct up-to-date positions state.
Every account_positions message is a complete replacement — replace your whole local array on each message rather than merging. A closed position is dropped (there is no zero row or deletion marker), and an empty data: [] array means the account is flat. Each message carries a Last ID (li) on every row and one on the envelope for the whole position set. On (re)subscription, use the initialization snapshot as your baseline, then apply later snapshots with an equal or newer envelope li and discard older ones.

Stream

FieldTypeDescription
’s’stringSymbol
’d’stringPosition side (bid, ask)
‘a’decimal stringPosition amount
’p’decimal stringAverage entry price
’m’decimal stringPosition margin
’f’decimal stringPosition funding fee
’i’boolIs position isolated?
‘l’decimal stringLiquidation price in USD (null if not applicable)
‘t’numberTimestamp in milliseconds
’li’ (row)number or nullLast ID — sequence number for this (account, symbol) position. null if the engine has not touched the row yet.
‘li’ (envelope)numberLast ID — sequence number for the account’s whole position set. Advances on every change, including closes and empty snapshots.