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

# Trades by instrument

> Channel name: `trades.{instrument_name}`. Public channel that streams the public trade tape for a single instrument, where {instrument_name} is the market whose fills you want to follow.



## AsyncAPI

````yaml subscriptions.asyncapi.json tradesByInstrument
id: tradesByInstrument
title: Trades by instrument
description: >-
  Channel name: `trades.{instrument_name}`. Public channel that streams the
  public trade tape for a single instrument, where {instrument_name} is the
  market whose fills you want to follow.
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_tradesByInstrument
    title: Receive_trades by instrument
    type: send
    messages:
      - &ref_6
        id: tradesByInstrumentNotification
        payload:
          - name: tradesByInstrumentNotification
            description: Pushed as a JSON array; each element has the fields below.
            type: object
            properties:
              - name: direction
                type: string
                enumValues:
                  - buy
                  - sell
                required: true
              - name: expected_rebate
                type: string
                required: true
              - name: extra_fee
                type: string
                required: true
              - name: index_price
                type: string
                required: true
              - name: instrument_name
                type: string
                required: true
              - name: liquidity_role
                type: string
                enumValues:
                  - maker
                  - taker
                required: true
              - name: mark_price
                type: string
                required: true
              - name: quote_id
                type: string
                required: false
              - name: realized_pnl
                type: string
                required: true
              - name: realized_pnl_excl_fees
                type: string
                required: true
              - name: rfq_id
                type: string
                required: false
              - name: subaccount_id
                type: integer
                required: true
              - name: timestamp
                type: integer
                required: true
              - name: trade_amount
                type: string
                required: true
              - name: trade_fee
                type: string
                required: true
              - name: trade_id
                type: string
                required: true
              - name: trade_price
                type: string
                required: true
              - name: wallet
                type: string
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - direction
            - expected_rebate
            - extra_fee
            - index_price
            - instrument_name
            - liquidity_role
            - mark_price
            - realized_pnl
            - realized_pnl_excl_fees
            - subaccount_id
            - timestamp
            - trade_amount
            - trade_fee
            - trade_id
            - trade_price
            - wallet
          properties:
            direction:
              type: string
              enum:
                - buy
                - sell
              x-parser-schema-id: Direction
            expected_rebate:
              type: string
              x-parser-schema-id: <anonymous-schema-201>
            extra_fee:
              type: string
              x-parser-schema-id: <anonymous-schema-202>
            index_price:
              type: string
              x-parser-schema-id: <anonymous-schema-203>
            instrument_name:
              type: string
              x-parser-schema-id: <anonymous-schema-204>
            liquidity_role:
              type: string
              enum:
                - maker
                - taker
              x-parser-schema-id: LiquidityRole2
            mark_price:
              type: string
              x-parser-schema-id: <anonymous-schema-205>
            quote_id:
              type: string
              nullable: true
              x-parser-schema-id: <anonymous-schema-206>
            realized_pnl:
              type: string
              x-parser-schema-id: <anonymous-schema-207>
            realized_pnl_excl_fees:
              type: string
              x-parser-schema-id: <anonymous-schema-208>
            rfq_id:
              type: string
              nullable: true
              x-parser-schema-id: <anonymous-schema-209>
            subaccount_id:
              type: integer
              format: int64
              x-parser-schema-id: <anonymous-schema-210>
            timestamp:
              type: integer
              format: int64
              x-parser-schema-id: <anonymous-schema-211>
            trade_amount:
              type: string
              x-parser-schema-id: <anonymous-schema-212>
            trade_fee:
              type: string
              x-parser-schema-id: <anonymous-schema-213>
            trade_id:
              type: string
              x-parser-schema-id: <anonymous-schema-214>
            trade_price:
              type: string
              x-parser-schema-id: <anonymous-schema-215>
            wallet:
              type: string
              x-parser-schema-id: <anonymous-schema-216>
          x-parser-schema-id: PublicTrade
        title: Trades by instrument notification
        description: Pushed as a JSON array; each element has the fields below.
        example: |-
          {
            "direction": "<string>",
            "expected_rebate": "<string>",
            "extra_fee": "<string>",
            "index_price": "<string>",
            "instrument_name": "<string>",
            "liquidity_role": "<string>",
            "mark_price": "<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>",
            "wallet": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: tradesByInstrumentNotification
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: tradesByInstrument
  - &ref_2
    id: send_subscribe_tradesByInstrument
    title: Send_subscribe_trades by instrument
    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: tradesByInstrument
securitySchemes: []

````

## Related topics

- [Trades by instrument type currency](/api-reference/channels/tradesbyinstrumenttypecurrency.md)
- [Subscriptions](/subscriptions.md)
- [Error Codes](/error-codes.md)
