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

# account_summary

Subscribe to real-time user account summary updates. Account-specific channel.

**WebSocket URL:** `wss://api.hotstuff.trade/ws`

**Channel:** `account_summary`

## Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `jsonrpc` | string | Yes | JSON-RPC version | `"2.0"` |
| `id` | string | Yes | Request identifier for tracking | `"1"` |
| `method` | string | Yes | Action to perform | `"subscribe"` or `"unsubscribe"` |
| `channel` | string | Yes | Channel name | `"account_summary"` |
| `user` | string | Yes | User wallet address | `"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"` |

## Supported Methods

* `subscribe` - Subscribe to user account summary updates
* `unsubscribe` - Unsubscribe from user account summary updates

## Authentication

This endpoint requires a valid user wallet address to receive account-specific account summary updates.

## Example Request

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "subscribe",
  "params": {
    "channel": "account_summary",
    "user": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
  }
}
```

## Example Response

```json theme={null}
{
  "jsonrpc": "2.0",
  "method": "event",
  "params": {
    "channel": "account_summary@0x42C183edba036906447372a7c81Eb89D0B9f2175",
    "data": {
      "address": "0x42C183edba036906447372a7c81Eb89D0B9f2175",
      "margin_mode": "cross",
      "multi_asset_mode": false,
      "hedge_mode": false,
      "spot_collateral": {
        "USDC": {
          "balance": 2250.2685305,
          "withdrawable_balance": 2250.2685305
        },
        "USDT": {
          "balance": 2881.2922,
          "withdrawable_balance": 2881.2922
        }
      },
      "collateral": {
        "USDC": {
          "balance": 1577.138734,
          "withdrawable_balance": 1542.074016
        }
      },
      "vault_balances": {
        "0xdE66c594AF8e4AD2C62DcFadCb6714F8b176A4ef": {
          "withdrawable_shares": 0.000002,
          "total_shares": 0.000002,
          "amount": 1.3209
        }
      },
      "staked_collateral": 0,
      "perp_positions": {
        "TSLA-PERP": {
          "position_type": "oneWay",
          "legs": [
            {
              "instrument_id": 10,
              "instrument_name": "TSLA-PERP",
              "side": "BOTH",
              "size": 0.833,
              "entry_price": 420,
              "leverage": {
                "type": "isolated",
                "value": 10
              },
              "position_value": 349.86
            }
          ],
          "liquidation_price": 399,
          "mm": 17.571718,
          "im": 35.064718,
          "upnl": 2.74057
        }
      },
      "initial_margin_utilization": 0,
      "maintenance_margin_utilization": 0,
      "upnl": 2.74057,
      "total_account_equity": 6706.98644984,
      "margin_balance": 1542.074016,
      "initial_margin": 0,
      "maintenance_margin": 0,
      "total_volume": 21961028,
      "total_pnl": 50252.231826,
      "available_balance": 1542.074016,
      "withdrawable_balance_notional": 1542.074016,
      "transfer_margin_req": 0,
      "max_drawdown": 0.417427,
      "spot_account_equity": 5129.84771584,
      "derivative_account_equity": 1577.138734,
      "spot_volume": 3502,
      "perp_volume": 39187
    }
  }
}
```

## WebSocket Client Examples

### Python

```python theme={null}
import websocket
import json

def on_message(ws, message):
    print(f"Received: {message}")

def on_open(ws):
    subscribe_msg = {
        "jsonrpc": "2.0",
        "id": "1",
        "method": "subscribe",
        "params": {
            "channel": "account_summary",
            "user": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
        }
    }
    ws.send(json.dumps(subscribe_msg))

ws = websocket.WebSocketApp("wss://api.hotstuff.trade/ws",
                          on_message=on_message,
                          on_open=on_open)
ws.run_forever()
```

### JavaScript

```javascript theme={null}
const ws = new WebSocket("wss://api.hotstuff.trade/ws");

ws.onopen = function () {
  const subscribeMsg = {
    jsonrpc: "2.0",
    id: "1",
    method: "subscribe",
    params: {
      channel: "account_summary",
      user: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
    },
  };
  ws.send(JSON.stringify(subscribeMsg));
};

ws.onmessage = function (event) {
  console.log("Received:", event.data);
};
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.