Skip to navigation

Account balances

A pool's latest readout

URL — No public environment serves this socket yet.

Topic accountBalance

Request parameters

ParameterTypeRequiredDescription
opstringYessubscribe
reqIdstringYesEchoed byte-exact on the answer. Printable ASCII, escape-free; anything else answers MALFORMED.
paramsobjectYes
> topicsarray of stringsYesaccountBalance

Response parameters

ParameterTypeRequiredDescription
opstringYesOne of subscribe, unsubscribe.
reqIdstringYesEchoed byte-exact on the answer. Printable ASCII, escape-free; anything else answers MALFORMED.
successbooleanYestrue

Push data parameters

Every amount is required money: a zero balance is a measurement, so “0.00000000” is a value and never a null. available is what the venue would let move; held is margin, pending withdrawals and freezes. Needs accounts:read, or any accounts capability (1.7.0): a balance is the account’s.

What the image holds. The latest reading for every (accountId, wallet, assetId) pair this member has seen for the organization — one row per pair, not a history. Rows appear as connectors report them, so an image is what has been reported, never a list of assets the venue supports.

How a row leaves. It does not. A pool that empties is reported as zero, which is a measurement and stays in your map; it never vanishes, and its absence would mean “never reported”, which is a different thing. A row for an account whose own status has moved on is still served — read the account’s state from the account channel, not from a balance’s presence.

Three clocks, and the one to age is not on this lane. observedAtNs is the platform’s time of the reading, moved by every change and by every heartbeat restatement while the connector serves the key; venueUpdatedAtNs is the venue’s own stamp on the state it reported, which can move without the holding moving. Neither says whether the account is being read now: that is the HTTP lane’s readAtNs on the account row (trading-gateway 0.49.0). Age that, and nothing here.

ParameterTypeRequiredDescription
eventstringYesaccountBalance
msgTypestringYesaccountBalance
topicstringYesaccountBalance
seqstringYesThe stream position, as a decimal string — an int64 a JSON number would truncate.
seqTsstringYesThe stream timestamp, epoch-ns as a decimal string.
isSnapshotbooleanYesOne of true, false.
snapshotIdstringNoPresent on a snapshot part only, and the same on every part of one image; the next image of any topic carries a different one. Opaque — compare it for equality and nothing else. It is not a sequence, a version or a timestamp, and its shape may change; a client that ordered by it would be relying on how a member happens to mint it. Use it to keep two images apart. A repeat subscribe re-pushes the image — that is the resync, and there is no separate op — so a client can start image N+1 while N is still arriving, and without a name on each part it cannot tell which last: true closes which, nor stop a straggling part of N landing in the map N+1 just cleared. Discard any part whose snapshotId is not the one you are currently applying.
partintegerNoPresent on a snapshot part only; 1-based.
lastbooleanNoPresent on a snapshot part only. The image is complete when true — including for an empty channel, which is still one part.
dataarray of objectsYesOne wallet’s latest readout, keyed by (accountId, wallet, assetId) — the three together are the upsert key, none alone (5.0.0; the pair without the wallet before it). What an account owns in an asset is the sum of its wallets; what it can trade is the venue’s order wallet alone.
> accountIdintegerYes
> accountstring, nullableYes
> walletstringYesThe wallet inside the venue account the reading is of, as the venue names it — trading and funding at OKX, unified at Bybit, spot at Binance. The value set is the venues’ own, open-ended: render it, never predict it.
> credentialIdintegerYesThe account’s own reading key — the key the reading was taken through.
> assetIdintegerYes
> assetstring, nullableYes
> totalstringYesRequired money at the scale this reading itself states, trailing zeros kept — not the asset’s canonical scale, which can differ and is never consulted here. Two assets in one frame routinely carry different digit counts, and so can two readings of the same asset. Parse the decimal; do not predict its length. A zero balance is a MEASUREMENT, so “0.00000000” is a value and never a null.
> availablestringYesWhat the venue would let move.
> heldstringYesMargin, pending withdrawals and freezes.
> venueUpdatedAtNsstring, nullableYesThe venue’s own stamp on the balance (venueTsNs until 4.0.0), as it stood at the latest observation of the pool: the holding’s change time where the venue stamps that (OKX), the account’s update time where it stamps that (Binance), the answer’s time where it stamps only that (Bybit); null where the venue stated none. The venue’s word about the state it reported, never freshness on this platform — it can move without the holding moving, and a restatement carries the latest observation’s stamp. The clock to age for an account is on the HTTP lane: the account row’s readAtNs.
> venueRevisionstring, nullableYes
> observedAtNsstringYesThe platform time of the reading: moved by every change and by every restatement on the connector’s heartbeat for as long as the connector serves the key, the venue answering or not. The row’s clock, not the account’s freshness.