AccountView
A live view of your account. Get one with ws.accountView():
const ws = await client.websocket().connect();const view = await ws.accountView({ onChange: (c) => render(c.view.state()) });view.balance?.available_balance; // "123.4500"view.openOrders; // [{id, market_id, status, price, ...}]Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
onChange |
(change: AccountChange) => void | undefined |
|
seeds |
Record<string, number> |
Join snapshots applied so far, per channel: 1 after the first seed, more after reconnects. |
ws |
STXWebSocket |
|
balance |
Record<string, any> | null |
The latest balance summary, or null before the first snapshot. |
closed |
boolean |
|
fills |
Record<string, any>[] |
Fills, newest first. |
openOrders |
Record<string, any>[] |
Open orders, newest first. |
positions |
Record<string, any>[] |
Positions, one per market. |
ready |
boolean |
True once every channel has delivered its join snapshot. |
Methods
Section titled “Methods”apply()
Section titled “apply()”apply(msg: ChannelMessage | { channel?: string; event: string; payload: any }): AccountChange | undefinedApply one channel message. The view calls this for the channels it
joined; call it yourself to feed messages from an account: channel or a
channel you joined elsewhere. Unknown events are ignored.
| Parameter | Type | Description |
|---|---|---|
msg |
ChannelMessage | { channel?: string; event: string; payload: any } |
Returns AccountChange \| undefined.
close()
Section titled “close()”close(): Promise<void>Leave the four channels. The socket stays open.
Returns Promise<void>.
state()
Section titled “state()”state(): AccountStateThe whole view as plain data.
Returns AccountState.

