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

# Subaccount trades

> Channel name: `{subaccount_id}.trades`. Private channel (requires authentication) that streams your subaccount's own trade fills as they occur, where {subaccount_id} is the numeric subaccount identifier.



## AsyncAPI

````yaml subscriptions.asyncapi.json subaccountTrades
id: subaccountTrades
title: Subaccount trades
description: >-
  Channel name: `{subaccount_id}.trades`. Private channel (requires
  authentication) that streams your subaccount's own trade fills as they occur,
  where {subaccount_id} is the numeric subaccount identifier.
servers:
  - id: production
    protocol: wss
    host: api.derive.xyz
    bindings: []
    variables: []
  - id: testnet
    protocol: wss
    host: testnet.api.derive.xyz
    bindings: []
    variables: []
address: /v3/ws
parameters: []
bindings: []
operations:
  - &ref_3
    id: receive_subaccountTrades
    title: Receive_subaccount trades
    type: send
    messages:
      - &ref_6
        id: subaccountTradesNotification
        payload:
          - name: subaccountTradesNotification
            description: Pushed as a JSON array; each element has the fields below.
            type: object
            properties:
              - name: batch_status
                type: string
                description: Settlement batch status; `null` if processed by sequencer.
                required: false
              - name: direction
                type: string
                enumValues:
                  - buy
                  - sell
                required: true
              - name: expected_rebate
                type: string
                description: >-
                  Decimal string of the human value (e.g. `"1.5"`), up to 12
                  fractional digits; a string or JSON number is accepted
                required: true
              - name: extra_fee
                type: string
                description: >-
                  Decimal string of the human value (e.g. `"1.5"`), up to 12
                  fractional digits; a string or JSON number is accepted
                required: true
              - name: index_price
                type: string
                description: >-
                  Decimal string of the human value (e.g. `"1.5"`), up to 12
                  fractional digits; a string or JSON number is accepted
                required: true
              - name: instrument_name
                type: string
                required: true
              - name: is_transfer
                type: boolean
                required: true
              - name: label
                type: string
                required: false
              - name: liquidity_role
                type: string
                enumValues:
                  - maker
                  - taker
                required: true
              - name: mark_price
                type: string
                description: >-
                  Decimal string of the human value (e.g. `"1.5"`), up to 12
                  fractional digits; a string or JSON number is accepted
                required: true
              - name: op_uuid
                type: string
                required: true
              - name: order_id
                type: string
                required: true
              - name: quote_id
                type: string
                description: Optional UUID v4 string
                required: true
              - name: realized_pnl
                type: string
                description: >-
                  Decimal string of the human value (e.g. `"1.5"`), up to 12
                  fractional digits; a string or JSON number is accepted
                required: true
              - name: realized_pnl_excl_fees
                type: string
                description: >-
                  Decimal string of the human value (e.g. `"1.5"`), up to 12
                  fractional digits; a string or JSON number is accepted
                required: true
              - name: rfq_id
                type: string
                description: Optional UUID v4 string
                required: true
              - name: subaccount_id
                type: integer
                required: true
              - name: timestamp
                type: integer
                required: true
              - name: trade_amount
                type: string
                description: >-
                  Decimal string of the human value (e.g. `"1.5"`), up to 12
                  fractional digits; a string or JSON number is accepted
                required: true
              - name: trade_fee
                type: string
                description: >-
                  Decimal string of the human value (e.g. `"1.5"`), up to 12
                  fractional digits; a string or JSON number is accepted
                required: true
              - name: trade_id
                type: string
                required: true
              - name: trade_price
                type: string
                description: >-
                  Decimal string of the human value (e.g. `"1.5"`), up to 12
                  fractional digits; a string or JSON number is accepted
                required: true
              - name: tx_hash
                type: string
                required: false
        headers: []
        jsonPayloadSchema:
          description: >-
            Info that the user expects to get delivered when requesting trade
            info.
          type: object
          required:
            - direction
            - expected_rebate
            - extra_fee
            - index_price
            - instrument_name
            - is_transfer
            - liquidity_role
            - mark_price
            - op_uuid
            - order_id
            - quote_id
            - realized_pnl
            - realized_pnl_excl_fees
            - rfq_id
            - subaccount_id
            - timestamp
            - trade_amount
            - trade_fee
            - trade_id
            - trade_price
          properties:
            batch_status:
              description: Settlement batch status; `null` if processed by sequencer.
              anyOf:
                - description: >-
                    Batch lifecycle status — the single source of lifecycle
                    truth for every operation in the batch (individual ops carry
                    no status of their own). Each stage has a healthy variant
                    and a corresponding `...Error` variant meaning that stage
                    failed. Serialized as the variant name (string) in API
                    responses.
                  type: string
                  enum:
                    - Batching
                    - Executing
                    - Proving
                    - Settling
                    - Settled
                    - BatchingError
                    - ExecutingError
                    - ProvingError
                    - SettlingError
                    - SettledError
                  x-parser-schema-id: BatchStatus
                - type: 'null'
                  x-parser-schema-id: <anonymous-schema-148>
              x-parser-schema-id: <anonymous-schema-147>
            direction:
              type: string
              enum:
                - buy
                - sell
              x-parser-schema-id: Direction
            expected_rebate:
              description: >-
                Decimal string of the human value (e.g. `"1.5"`), up to 12
                fractional digits; a string or JSON number is accepted
              type: string
              format: decimal
              x-parser-schema-id: <anonymous-schema-149>
            extra_fee:
              description: >-
                Decimal string of the human value (e.g. `"1.5"`), up to 12
                fractional digits; a string or JSON number is accepted
              type: string
              format: decimal
              x-parser-schema-id: <anonymous-schema-150>
            index_price:
              description: >-
                Decimal string of the human value (e.g. `"1.5"`), up to 12
                fractional digits; a string or JSON number is accepted
              type: string
              format: decimal
              x-parser-schema-id: <anonymous-schema-151>
            instrument_name:
              type: string
              x-parser-schema-id: <anonymous-schema-152>
            is_transfer:
              type: boolean
              x-parser-schema-id: <anonymous-schema-153>
            label:
              default: ''
              type: string
              x-parser-schema-id: <anonymous-schema-154>
            liquidity_role:
              type: string
              enum:
                - maker
                - taker
              x-parser-schema-id: LiquidityRole
            mark_price:
              description: >-
                Decimal string of the human value (e.g. `"1.5"`), up to 12
                fractional digits; a string or JSON number is accepted
              type: string
              format: decimal
              x-parser-schema-id: <anonymous-schema-155>
            op_uuid:
              type: string
              x-parser-schema-id: <anonymous-schema-156>
            order_id:
              type: string
              x-parser-schema-id: <anonymous-schema-157>
            quote_id:
              description: Optional UUID v4 string
              type: string
              format: uuid
              nullable: true
              x-parser-schema-id: <anonymous-schema-158>
            realized_pnl:
              description: >-
                Decimal string of the human value (e.g. `"1.5"`), up to 12
                fractional digits; a string or JSON number is accepted
              type: string
              format: decimal
              x-parser-schema-id: <anonymous-schema-159>
            realized_pnl_excl_fees:
              description: >-
                Decimal string of the human value (e.g. `"1.5"`), up to 12
                fractional digits; a string or JSON number is accepted
              type: string
              format: decimal
              x-parser-schema-id: <anonymous-schema-160>
            rfq_id:
              description: Optional UUID v4 string
              type: string
              format: uuid
              nullable: true
              x-parser-schema-id: <anonymous-schema-161>
            subaccount_id:
              type: integer
              format: int64
              x-parser-schema-id: <anonymous-schema-162>
            timestamp:
              type: integer
              format: int64
              x-parser-schema-id: <anonymous-schema-163>
            trade_amount:
              description: >-
                Decimal string of the human value (e.g. `"1.5"`), up to 12
                fractional digits; a string or JSON number is accepted
              type: string
              format: decimal
              x-parser-schema-id: <anonymous-schema-164>
            trade_fee:
              description: >-
                Decimal string of the human value (e.g. `"1.5"`), up to 12
                fractional digits; a string or JSON number is accepted
              type: string
              format: decimal
              x-parser-schema-id: <anonymous-schema-165>
            trade_id:
              type: string
              x-parser-schema-id: <anonymous-schema-166>
            trade_price:
              description: >-
                Decimal string of the human value (e.g. `"1.5"`), up to 12
                fractional digits; a string or JSON number is accepted
              type: string
              format: decimal
              x-parser-schema-id: <anonymous-schema-167>
            tx_hash:
              type: string
              nullable: true
              x-parser-schema-id: <anonymous-schema-168>
          x-parser-schema-id: Trade
        title: Subaccount trades notification
        description: Pushed as a JSON array; each element has the fields below.
        example: |-
          {
            "batch_status": "<string>",
            "direction": "<string>",
            "expected_rebate": "<string>",
            "extra_fee": "<string>",
            "index_price": "<string>",
            "instrument_name": "<string>",
            "is_transfer": true,
            "label": "<string>",
            "liquidity_role": "<string>",
            "mark_price": "<string>",
            "op_uuid": "<string>",
            "order_id": "<string>",
            "quote_id": "<string>",
            "realized_pnl": "<string>",
            "realized_pnl_excl_fees": "<string>",
            "rfq_id": "<string>",
            "subaccount_id": 123,
            "timestamp": 123,
            "trade_amount": "<string>",
            "trade_fee": "<string>",
            "trade_id": "<string>",
            "trade_price": "<string>",
            "tx_hash": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subaccountTradesNotification
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: subaccountTrades
  - &ref_2
    id: send_subscribe_subaccountTrades
    title: Send_subscribe_subaccount trades
    type: receive
    messages:
      - &ref_4
        id: subscribeRequest
        payload:
          - name: subscribeRequest
            description: >-
              Send to subscribe: list this channel's address (with the {param}
              segments filled, e.g. orderbook.ETH-PERP.10.20) in
              params.channels.
            type: object
            properties:
              - name: headers
                type: object
                description: Non-standard; used by `auth/login`.
                required: false
              - name: id
                type: anyOf
                required: true
              - name: method
                type: string
                description: subscribe
                required: true
              - name: params
                type: object
                description: >-
                  Params for `subscribe`. `channels` is the required list of
                  channel names to subscribe to.
                required: true
                properties:
                  - name: channels
                    type: array
                    required: true
                    properties:
                      - name: item
                        type: string
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - id
            - method
            - params
          properties:
            headers:
              description: Non-standard; used by `auth/login`.
              type: object
              additionalProperties: true
              nullable: true
              x-parser-schema-id: <anonymous-schema-16>
            id: &ref_0
              anyOf:
                - type: string
                  x-parser-schema-id: <anonymous-schema-17>
                - type: number
                  x-parser-schema-id: <anonymous-schema-18>
                - type: 'null'
                  x-parser-schema-id: <anonymous-schema-19>
              x-parser-schema-id: JsonRpcId
            method:
              type: string
              const: subscribe
              x-parser-schema-id: <anonymous-schema-20>
            params:
              description: >-
                Params for `subscribe`. `channels` is the required list of
                channel names to subscribe to.
              type: object
              required:
                - channels
              properties:
                channels:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-22>
                  x-parser-schema-id: <anonymous-schema-21>
              x-parser-schema-id: SubscribeParams
          x-parser-schema-id: <anonymous-schema-15>
        title: Subscribe request
        description: >-
          Send to subscribe: list this channel's address (with the {param}
          segments filled, e.g. orderbook.ETH-PERP.10.20) in params.channels.
        example: |-
          {
            "id": 1,
            "method": "subscribe",
            "params": {
              "channels": [
                "orderbook.ETH-PERP.10.20"
              ]
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeRequest
      - &ref_5
        id: unsubscribeRequest
        payload:
          - name: unsubscribeRequest
            description: >-
              Send to unsubscribe: list the channel addresses to drop in
              params.channels, or omit it to unsubscribe from everything.
            type: object
            properties:
              - name: headers
                type: object
                description: Non-standard; used by `auth/login`.
                required: false
              - name: id
                type: anyOf
                required: true
              - name: method
                type: string
                description: unsubscribe
                required: true
              - name: params
                type: object
                description: >-
                  Params for `unsubscribe`. `channels` is optional.


                  When omitted (or null) the connection unsubscribes from all
                  channels.
                required: true
                properties:
                  - name: channels
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - id
            - method
            - params
          properties:
            headers:
              description: Non-standard; used by `auth/login`.
              type: object
              additionalProperties: true
              nullable: true
              x-parser-schema-id: <anonymous-schema-24>
            id: *ref_0
            method:
              type: string
              const: unsubscribe
              x-parser-schema-id: <anonymous-schema-25>
            params:
              description: >-
                Params for `unsubscribe`. `channels` is optional.


                When omitted (or null) the connection unsubscribes from all
                channels.
              type: object
              properties:
                channels:
                  default: null
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-27>
                  nullable: true
                  x-parser-schema-id: <anonymous-schema-26>
              x-parser-schema-id: UnsubscribeParams
          x-parser-schema-id: <anonymous-schema-23>
        title: Unsubscribe request
        description: >-
          Send to unsubscribe: list the channel addresses to drop in
          params.channels, or omit it to unsubscribe from everything.
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribeRequest
    bindings: []
    extensions: *ref_1
sendOperations:
  - *ref_2
receiveOperations:
  - *ref_3
sendMessages:
  - *ref_4
  - *ref_5
receiveMessages:
  - *ref_6
extensions:
  - id: x-parser-unique-object-id
    value: subaccountTrades
securitySchemes: []

````

## Related topics

- [Trade](/vaults/trade.md)
- [private/get_trade_history](/api-reference/history/privateget_trade_history.md)
- [public/get_trade_history](/api-reference/market-data/publicget_trade_history.md)
