> ## 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.

## 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);
};
```


## AsyncAPI

````yaml asyncapi/ws-subscriptions.json account-summary
id: account-summary
title: Account-summary
description: ''
servers:
  - id: production
    protocol: wss
    host: api.hotstuff.trade/ws
    bindings: []
    variables: []
  - id: testnet
    protocol: wss
    host: testnet-api.hotstuff.trade/ws
    bindings: []
    variables: []
address: /
parameters: []
bindings: []
operations:
  - &ref_14
    id: account-summary_sendSubscribe
    title: Account-summary_send subscribe
    type: receive
    messages:
      - &ref_16
        id: a_subscribeRequest
        contentType: application/json
        payload:
          - name: Subscription request
            description: Send subscribe/unsubscribe request
            type: object
            properties:
              - name: jsonrpc
                type: string
                description: JSON-RPC version
                examples: &ref_0
                  - '2.0'
                required: true
              - name: id
                type: integer
                description: Client request identifier
                examples: &ref_1
                  - 1
                required: true
              - name: method
                type: string
                description: Subscription action
                enumValues:
                  - subscribe
                  - unsubscribe
                examples: &ref_2
                  - subscribe
                required: true
              - name: params
                type: object
                description: Channel subscription parameters
                required: true
                properties:
                  - name: channel
                    type: string
                    description: Must be `account_summary`
                    examples: &ref_3
                      - account_summary
                    required: true
                  - name: user
                    type: string
                    description: 'Example: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
                    examples: &ref_4
                      - '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            jsonrpc:
              type: string
              default: '2.0'
              examples: *ref_0
              description: JSON-RPC version
              x-parser-schema-id: <anonymous-schema-2>
            id:
              type: integer
              default: 1
              examples: *ref_1
              description: Client request identifier
              x-parser-schema-id: <anonymous-schema-3>
            method:
              type: string
              enum:
                - subscribe
                - unsubscribe
              default: subscribe
              examples: *ref_2
              description: Subscription action
              x-parser-schema-id: <anonymous-schema-4>
            params:
              type: object
              properties:
                channel:
                  type: string
                  description: Must be `account_summary`
                  default: account_summary
                  examples: *ref_3
                  x-parser-schema-id: <anonymous-schema-6>
                user:
                  type: string
                  description: 'Example: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
                  default: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
                  examples: *ref_4
                  x-parser-schema-id: <anonymous-schema-7>
              required:
                - channel
                - user
              description: Channel subscription parameters
              x-parser-schema-id: <anonymous-schema-5>
          required:
            - jsonrpc
            - id
            - method
            - params
          x-parser-schema-id: <anonymous-schema-1>
        title: Subscription request
        description: Send subscribe/unsubscribe request
        example: |-
          {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "subscribe",
            "params": {
              "channel": "account_summary",
              "user": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: a_subscribeRequest
    bindings: []
    extensions: &ref_13
      - id: x-parser-unique-object-id
        value: account-summary
  - &ref_15
    id: account-summary_receiveEvent
    title: Account-summary_receive event
    type: send
    messages:
      - &ref_17
        id: event
        contentType: application/json
        payload:
          - name: Channel event
            description: Server-pushed JSON-RPC event
            type: object
            properties:
              - name: jsonrpc
                type: string
                description: '`2.0`'
                examples: &ref_5
                  - '2.0'
                required: false
              - name: method
                type: string
                description: '`event`'
                examples: &ref_6
                  - event
                required: false
              - name: params
                type: object
                required: false
                properties:
                  - name: channel
                    type: string
                    description: >-
                      returns `account_summary@<user>` when subscribed to a
                      specific user
                    examples: &ref_7
                      - >-
                        account_summary@0x42C183edba036906447372a7c81Eb89D0B9f2175
                    required: false
                  - name: data
                    type: object
                    description: user's account summary
                    required: false
                    properties:
                      - name: address
                        type: string
                        description: user's wallet address
                        examples: &ref_8
                          - '0x42C183edba036906447372a7c81Eb89D0B9f2175'
                        required: false
                      - name: margin_mode
                        type: string
                        description: one of `cross`, `isolated`
                        examples: &ref_9
                          - cross
                          - isolated
                        required: false
                      - name: multi_asset_mode
                        type: boolean
                        description: whether the user has enabled multi-asset mode
                        examples: &ref_10
                          - true
                          - false
                        required: false
                      - name: hedge_mode
                        type: boolean
                        description: whether the user has enabled hedge mode
                        examples: &ref_11
                          - true
                          - false
                        required: false
                      - name: spot_collateral
                        type: object
                        description: user's spot collateral balances
                        required: false
                        properties:
                          - name: USDC
                            type: object
                            required: false
                            properties:
                              - name: balance
                                type: number
                                required: false
                              - name: withdrawable_balance
                                type: number
                                required: false
                          - name: USDT
                            type: object
                            required: false
                            properties:
                              - name: balance
                                type: number
                                required: true
                              - name: withdrawable_balance
                                type: number
                                required: true
                      - name: collateral
                        type: object
                        description: user's derivative collateral balances
                        required: false
                        properties:
                          - name: USDC
                            type: object
                            required: false
                            properties:
                              - name: balance
                                type: number
                                required: false
                              - name: withdrawable_balance
                                type: number
                                required: false
                      - name: vault_balances
                        type: object
                        description: user's vault balances
                        required: false
                        properties:
                          - name: '0xdE66c594AF8e4AD2C62DcFadCb6714F8b176A4ef'
                            type: object
                            description: vault address
                            examples: &ref_12
                              - '0xdE66c594AF8e4AD2C62DcFadCb6714F8b176A4ef'
                            required: false
                            properties:
                              - name: withdrawable_shares
                                type: number
                                required: false
                              - name: total_shares
                                type: number
                                required: false
                              - name: amount
                                type: number
                                required: false
                      - name: staked_collateral
                        type: integer
                        description: user's staked collateral
                        required: false
                      - name: perp_positions
                        type: object
                        required: false
                        properties:
                          - name: TSLA-PERP
                            type: object
                            required: false
                            properties:
                              - name: position_type
                                type: string
                                enumValues:
                                  - oneWay
                                  - hedge
                                required: false
                              - name: legs
                                type: array
                                required: false
                                properties:
                                  - name: instrument_id
                                    type: integer
                                    required: false
                                  - name: instrument_name
                                    type: string
                                    required: false
                                  - name: side
                                    type: string
                                    description: >-
                                      side=`BOTH` represents position in one-way
                                      mode, `LONG` & `SHORT` represent position
                                      in hedge mode
                                    enumValues:
                                      - BOTH
                                      - LONG
                                      - SHORT
                                    required: false
                                  - name: size
                                    type: number
                                    description: position size
                                    required: false
                                  - name: entry_price
                                    type: number
                                    description: entry price
                                    required: false
                                  - name: leverage
                                    type: object
                                    required: false
                                    properties:
                                      - name: type
                                        type: string
                                        enumValues:
                                          - isolated
                                          - cross
                                        required: false
                                      - name: value
                                        type: integer
                                        required: false
                                  - name: position_value
                                    type: number
                                    required: false
                              - name: liquidation_price
                                type: number
                                required: false
                              - name: mm
                                type: number
                                description: maintenance margin
                                required: false
                              - name: im
                                type: number
                                description: initial margin
                                required: false
                              - name: upnl
                                type: number
                                description: position's unrealized PnL
                                required: false
                      - name: initial_margin_utilization
                        type: number
                        description: initial margin utilization for cross margin positions
                        required: false
                      - name: maintenance_margin_utilization
                        type: number
                        description: >-
                          maintenance margin utilization for cross margin
                          positions
                        required: false
                      - name: upnl
                        type: number
                        description: >-
                          account's total unrealized PnL for cross margin
                          positions
                        required: false
                      - name: total_account_equity
                        type: number
                        description: account equity
                        required: false
                      - name: margin_balance
                        type: number
                        description: account margin balance
                        required: false
                      - name: initial_margin
                        type: integer
                        description: >-
                          account's total initial margin for cross margin
                          positions
                        required: false
                      - name: maintenance_margin
                        type: integer
                        description: >-
                          account's total maintenance margin for cross margin
                          positions
                        required: false
                      - name: total_volume
                        type: integer
                        required: false
                      - name: total_pnl
                        type: number
                        required: false
                      - name: available_balance
                        type: number
                        description: account's available balance
                        required: false
                      - name: withdrawable_balance_notional
                        type: number
                        description: account's withdrawable balance in notional
                        required: false
                      - name: transfer_margin_req
                        type: integer
                        description: account's transfer margin request
                        required: false
                      - name: max_drawdown
                        type: number
                        required: false
                      - name: spot_account_equity
                        type: number
                        required: false
                      - name: derivative_account_equity
                        type: number
                        required: false
                      - name: spot_volume
                        type: integer
                        required: false
                      - name: perp_volume
                        type: integer
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            jsonrpc:
              type: string
              description: '`2.0`'
              examples: *ref_5
              x-parser-schema-id: <anonymous-schema-9>
            method:
              type: string
              description: '`event`'
              examples: *ref_6
              x-parser-schema-id: <anonymous-schema-10>
            params:
              type: object
              properties:
                channel:
                  type: string
                  description: >-
                    returns `account_summary@<user>` when subscribed to a
                    specific user
                  examples: *ref_7
                  x-parser-schema-id: <anonymous-schema-12>
                data:
                  type: object
                  description: user's account summary
                  properties:
                    address:
                      type: string
                      description: user's wallet address
                      examples: *ref_8
                      x-parser-schema-id: <anonymous-schema-14>
                    margin_mode:
                      type: string
                      description: one of `cross`, `isolated`
                      examples: *ref_9
                      x-parser-schema-id: <anonymous-schema-15>
                    multi_asset_mode:
                      type: boolean
                      description: whether the user has enabled multi-asset mode
                      examples: *ref_10
                      x-parser-schema-id: <anonymous-schema-16>
                    hedge_mode:
                      type: boolean
                      description: whether the user has enabled hedge mode
                      examples: *ref_11
                      x-parser-schema-id: <anonymous-schema-17>
                    spot_collateral:
                      type: object
                      description: user's spot collateral balances
                      properties:
                        USDC:
                          type: object
                          properties:
                            balance:
                              type: number
                              x-parser-schema-id: <anonymous-schema-20>
                            withdrawable_balance:
                              type: number
                              x-parser-schema-id: <anonymous-schema-21>
                          x-parser-schema-id: <anonymous-schema-19>
                        USDT:
                          type: object
                          properties:
                            balance:
                              type: number
                              x-parser-schema-id: <anonymous-schema-23>
                            withdrawable_balance:
                              type: number
                              x-parser-schema-id: <anonymous-schema-24>
                          required:
                            - balance
                            - withdrawable_balance
                          x-parser-schema-id: <anonymous-schema-22>
                      x-parser-schema-id: <anonymous-schema-18>
                    collateral:
                      type: object
                      description: user's derivative collateral balances
                      properties:
                        USDC:
                          type: object
                          properties:
                            balance:
                              type: number
                              x-parser-schema-id: <anonymous-schema-27>
                            withdrawable_balance:
                              type: number
                              x-parser-schema-id: <anonymous-schema-28>
                          x-parser-schema-id: <anonymous-schema-26>
                      x-parser-schema-id: <anonymous-schema-25>
                    vault_balances:
                      type: object
                      description: user's vault balances
                      properties:
                        '0xdE66c594AF8e4AD2C62DcFadCb6714F8b176A4ef':
                          type: object
                          description: vault address
                          examples: *ref_12
                          properties:
                            withdrawable_shares:
                              type: number
                              x-parser-schema-id: <anonymous-schema-31>
                            total_shares:
                              type: number
                              x-parser-schema-id: <anonymous-schema-32>
                            amount:
                              type: number
                              x-parser-schema-id: <anonymous-schema-33>
                          x-parser-schema-id: <anonymous-schema-30>
                      x-parser-schema-id: <anonymous-schema-29>
                    staked_collateral:
                      type: integer
                      description: user's staked collateral
                      x-parser-schema-id: <anonymous-schema-34>
                    perp_positions:
                      type: object
                      properties:
                        TSLA-PERP:
                          type: object
                          properties:
                            position_type:
                              type: string
                              enum:
                                - oneWay
                                - hedge
                              x-parser-schema-id: <anonymous-schema-37>
                            legs:
                              type: array
                              items:
                                type: object
                                properties:
                                  instrument_id:
                                    type: integer
                                    x-parser-schema-id: <anonymous-schema-40>
                                  instrument_name:
                                    type: string
                                    x-parser-schema-id: <anonymous-schema-41>
                                  side:
                                    type: string
                                    description: >-
                                      side=`BOTH` represents position in one-way
                                      mode, `LONG` & `SHORT` represent position
                                      in hedge mode
                                    enum:
                                      - BOTH
                                      - LONG
                                      - SHORT
                                    x-parser-schema-id: <anonymous-schema-42>
                                  size:
                                    type: number
                                    description: position size
                                    x-parser-schema-id: <anonymous-schema-43>
                                  entry_price:
                                    type: number
                                    description: entry price
                                    x-parser-schema-id: <anonymous-schema-44>
                                  leverage:
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - isolated
                                          - cross
                                        x-parser-schema-id: <anonymous-schema-46>
                                      value:
                                        type: integer
                                        x-parser-schema-id: <anonymous-schema-47>
                                    x-parser-schema-id: <anonymous-schema-45>
                                  position_value:
                                    type: number
                                    x-parser-schema-id: <anonymous-schema-48>
                                x-parser-schema-id: <anonymous-schema-39>
                              x-parser-schema-id: <anonymous-schema-38>
                            liquidation_price:
                              type: number
                              x-parser-schema-id: <anonymous-schema-49>
                            mm:
                              type: number
                              description: maintenance margin
                              x-parser-schema-id: <anonymous-schema-50>
                            im:
                              type: number
                              description: initial margin
                              x-parser-schema-id: <anonymous-schema-51>
                            upnl:
                              type: number
                              description: position's unrealized PnL
                              x-parser-schema-id: <anonymous-schema-52>
                          x-parser-schema-id: <anonymous-schema-36>
                      x-parser-schema-id: <anonymous-schema-35>
                    initial_margin_utilization:
                      type: number
                      description: initial margin utilization for cross margin positions
                      x-parser-schema-id: <anonymous-schema-53>
                    maintenance_margin_utilization:
                      type: number
                      description: >-
                        maintenance margin utilization for cross margin
                        positions
                      x-parser-schema-id: <anonymous-schema-54>
                    upnl:
                      type: number
                      description: >-
                        account's total unrealized PnL for cross margin
                        positions
                      x-parser-schema-id: <anonymous-schema-55>
                    total_account_equity:
                      type: number
                      description: account equity
                      x-parser-schema-id: <anonymous-schema-56>
                    margin_balance:
                      type: number
                      description: account margin balance
                      x-parser-schema-id: <anonymous-schema-57>
                    initial_margin:
                      type: integer
                      description: >-
                        account's total initial margin for cross margin
                        positions
                      x-parser-schema-id: <anonymous-schema-58>
                    maintenance_margin:
                      type: integer
                      description: >-
                        account's total maintenance margin for cross margin
                        positions
                      x-parser-schema-id: <anonymous-schema-59>
                    total_volume:
                      type: integer
                      x-parser-schema-id: <anonymous-schema-60>
                    total_pnl:
                      type: number
                      x-parser-schema-id: <anonymous-schema-61>
                    available_balance:
                      type: number
                      description: account's available balance
                      x-parser-schema-id: <anonymous-schema-62>
                    withdrawable_balance_notional:
                      type: number
                      description: account's withdrawable balance in notional
                      x-parser-schema-id: <anonymous-schema-63>
                    transfer_margin_req:
                      type: integer
                      description: account's transfer margin request
                      x-parser-schema-id: <anonymous-schema-64>
                    max_drawdown:
                      type: number
                      x-parser-schema-id: <anonymous-schema-65>
                    spot_account_equity:
                      type: number
                      x-parser-schema-id: <anonymous-schema-66>
                    derivative_account_equity:
                      type: number
                      x-parser-schema-id: <anonymous-schema-67>
                    spot_volume:
                      type: integer
                      x-parser-schema-id: <anonymous-schema-68>
                    perp_volume:
                      type: integer
                      x-parser-schema-id: <anonymous-schema-69>
                  x-parser-schema-id: <anonymous-schema-13>
              x-parser-schema-id: <anonymous-schema-11>
          x-parser-schema-id: <anonymous-schema-8>
        title: Channel event
        description: Server-pushed JSON-RPC event
        example: |-
          {
            "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
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: event
    bindings: []
    extensions: *ref_13
sendOperations:
  - *ref_14
receiveOperations:
  - *ref_15
sendMessages:
  - *ref_16
receiveMessages:
  - *ref_17
extensions:
  - id: x-parser-unique-object-id
    value: account-summary
securitySchemes: []

````

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