> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ekiden.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Account Balance

Receive real-time updates on your account balance.

* Topic: `account_balance`
* Stream: Private (`wss://api.ekiden.fi/ws/private`)

## Authenticate

Use authentication flow described in the [Connect](./connect) page.

## Subscribe

```json theme={null}
{ "op": "subscribe", "args": ["account_balance"], "req_id": "204001" }
```

Ack:

```json theme={null}
{ "op": "subscribed", "args": ["account_balance"], "req_id": "204001" }
```

## Events

Messages arrive with `op: "event"`, `topic: "account_balance"`, and `data` is an array of `AccountBalance` objects.

Example:

```json theme={null}
{
	"op": "event",
	"topic": "account_balance",
	"server_ts_ms": 1731541800000,
	"data": [
		{
			"sub_account_address": "0xsubacct...",
			"account_type": "Trading",
			"equity": "1000000",
			"vault_balance": "1000000",
			"margin_balance": "950000",
			"available_balance": "925000",
			"accrued_interest": "0",
			"total_order_im": "25000",
			"total_position_im": "50000",
			"total_position_mm": "30000",
			"unrealised_pnl": "1000",
			"unrealized_funding": "-5",
			"realised_pnl_cum": "12345"
		}
	]
}
```

Field notes:

* All numeric values are strings to preserve precision.
* `equity` is account equity in USDC before collateral value ratio adjustments.
* `margin_balance` / `available_balance` reflect amounts available for margin after collateral value ratio adjustments.

### Fields

| Field                 | Type   | Notes                                      |
| --------------------- | ------ | ------------------------------------------ |
| sub\_account\_address | string | Sub-account address                        |
| account\_type         | string | Account type (e.g. Funding, Trading)       |
| equity                | string | Equity (USDC)                              |
| vault\_balance        | string | Vault balance (USDC)                       |
| margin\_balance       | string | Margin balance (USDC)                      |
| available\_balance    | string | Available balance for new positions (USDC) |
| accrued\_interest     | string | Accrued interest                           |
| total\_order\_im      | string | Pre-occupied margin for orders (USDC)      |
| total\_position\_im   | string | Sum of initial margin across positions     |
| total\_position\_mm   | string | Sum of maintenance margin across positions |
| unrealised\_pnl       | string | Unrealised PnL                             |
| unrealized\_funding   | string | Aggregated unrealized funding (USDC)       |
| realised\_pnl\_cum    | string | Cumulative realised PnL                    |

See schema details in [AsyncAPI](../websockets/private): `AccountBalance`.
