HomeDocumentationAPI Reference
Log In
API Reference

(Subaccount Id) Balances

Channel Name Schema

{subaccount_id}.balances

Subscribe to changes in user's positions for a given subaccount ID.

For perpetuals, additional balance updates are emitted under the name Q-{ccy}-PERP where Q stands for "quote".
This balance is a proxy for an on-chain state of lastMarkPrice.
Because of a synchronization lag with the on-chain state, the orderbook instead keeps track of a running total cost of perpetual trades,

For example:
Q-ETH-PERP balance of $6,600 and an ETH-PERP balance of 3 means the lastMarkPrice state is estimated to be $2,200.

Channel Parameters

{/ Pandas table mapped to markdown via .to_markdown() /}

subaccount_id  integer required
Subaccount ID

Notification Data

{/ Pandas table mapped to markdown via .to_markdown() /}

channel  string required
Subscribed channel name
data  array of objects required
data[]. name  string required
Name of colletaral asset or instrument
data[]. new_balance  string required
Balance after update
data[]. previous_balance  string required
Balance before update
data[]. update_type  string required
Type of transaction
enum trade asset_deposit asset_withdrawal transfer subaccount_deposit subaccount_withdrawal liquidation liquidator onchain_drift_fix perp_settlement option_settlement interest_accrual onchain_revert double_revert

Example

Subscriptions are only available via websockets.

{request_example_javascript}
{request_example_python}

Notification messages on this channel will look like this:

{/ A pretty-formated json saved to string /}

{response_example_json}