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

# Market trades

> Real-time trade updates for one Decibel market address, perp or spot (not cached, updates only). Spot BTC and perp BTC are different markets with different addresses and require separate subscriptions. Each trade row carries `asset_type`. Spot rows use `action` values `Buy` or `Sell`, leave `client_order_id` empty, and zero `realized_pnl_amount`, `realized_funding_amount`, and `fee_amount` because spot has no positions/funding and per-side fee attribution is unavailable.



## AsyncAPI

````yaml api-reference/asyncapi.json marketTrades
id: marketTrades
title: Market trades
description: >-
  Real-time trade updates for one Decibel market address, perp or spot (not
  cached, updates only). Spot BTC and perp BTC are different markets with
  different addresses and require separate subscriptions. Each trade row carries
  `asset_type`. Spot rows use `action` values `Buy` or `Sell`, leave
  `client_order_id` empty, and zero `realized_pnl_amount`,
  `realized_funding_amount`, and `fee_amount` because spot has no
  positions/funding and per-side fee attribution is unavailable.
servers:
  - id: testnet
    protocol: wss
    host: api.testnet.aptoslabs.com/decibel/ws
    bindings: []
    variables: []
address: trades:{marketAddr}
parameters:
  - id: marketAddr
    jsonSchema:
      type: string
      description: Market address (Aptos address format, e.g. 0x456...)
    description: Market address (Aptos address format, e.g. 0x456...)
    type: string
    required: true
    deprecated: false
bindings: []
operations:
  - &ref_1
    id: receivemarketTrades
    title: Receivemarket trades
    description: >-
      Receive updates for real-time trade updates for one decibel market
      address, perp or spot (not cached, updates only). spot btc and perp btc
      are different markets with different addresses and require separate
      subscriptions. each trade row carries `asset_type`. spot rows use `action`
      values `buy` or `sell`, leave `client_order_id` empty, and zero
      `realized_pnl_amount`, `realized_funding_amount`, and `fee_amount` because
      spot has no positions/funding and per-side fee attribution is unavailable.
    type: receive
    messages:
      - &ref_2
        id: MarketTradesMessage
        payload:
          - name: MarketTradesMessage
            description: >-
              Real-time trade updates for one Decibel market address, perp or
              spot (not cached, updates only). Spot BTC and perp BTC are
              different markets with different addresses and require separate
              subscriptions. Each trade row carries `asset_type`. Spot rows use
              `action` values `Buy` or `Sell`, leave `client_order_id` empty,
              and zero `realized_pnl_amount`, `realized_funding_amount`, and
              `fee_amount` because spot has no positions/funding and per-side
              fee attribution is unavailable.
            type: object
            properties:
              - name: topic
                type: string
                required: true
              - name: trades
                type: array
                required: true
                properties:
                  - name: account
                    type: string
                    description: User's account address
                    required: true
                  - name: action
                    type: string
                    description: >-
                      Trade action type. Perp: position-centric ("OpenLong",
                      "CloseShort",

                      "Net", ...). Spot: side from this row's perspective ("Buy"
                      / "Sell").
                    required: true
                  - name: asset_type
                    type: string
                    description: >-
                      Discriminator carried on DTOs that can mix perp and spot
                      rows (markets,

                      orders, trades, bulk orders, bulk order fills, and
                      WebSocket payloads).

                      Also accepted as a query parameter on REST endpoints that
                      can filter to one

                      product.


                      Wire format is lowercase (`"perp"` / `"spot"`) and
                      accepted

                      case-insensitively on the request side via
                      [`impl_case_insensitive_deserialize`].
                    enumValues:
                      - perp
                      - spot
                    required: true
                  - name: client_order_id
                    type: string
                    description: Client-specified order ID
                    required: true
                  - name: counter_party_account
                    type: string
                    description: >-
                      Counter party account on the other leg of the fill. For
                      liquidation /

                      ADL / delisting fills this is the backstop liquidator.
                      Empty string for

                      pre-V2 historical trades that did not carry counter party
                      on-chain.
                    required: true
                  - name: fee_amount
                    type: number
                    description: >-
                      Fee paid by this row's account, normalized. Perp: always
                      in the

                      collateral asset (USDC). Spot: charged in the asset this
                      side

                      RECEIVED (protocol + builder fee combined); see
                      `fee_asset`.
                    required: true
                  - name: fee_asset
                    type: &ref_0
                      - string
                      - 'null'
                    description: >-
                      FA metadata address of the asset `fee_amount` is
                      denominated in.

                      Spot only (base asset for the buyer, quote for the
                      seller); absent

                      for perp rows, where the fee is implicitly the collateral
                      asset.
                    required: false
                  - name: is_profit
                    type: boolean
                    description: Whether trade was profitable
                    required: true
                  - name: is_rebate
                    type: boolean
                    description: Whether trade received rebate
                    required: true
                  - name: market
                    type: string
                    description: Market identifier address
                    required: true
                  - name: order_id
                    type: string
                    description: Order ID associated with trade
                    required: true
                  - name: price
                    type: number
                    description: Trade price
                    required: true
                  - name: realized_funding_amount
                    type: number
                    description: >-
                      Realized funding amount in USDC

                      - Negative value: trader PAID funding (e.g., long position
                      with positive funding rate)

                      - Positive value: trader RECEIVED funding (e.g., short
                      position with positive funding rate)

                      - Zero: no funding accrued
                    required: true
                  - name: realized_pnl_amount
                    type: number
                    description: Realized PnL amount
                    required: true
                  - name: size
                    type: number
                    description: Trade size
                    required: true
                  - name: source
                    type: string
                    description: >-
                      Trade source (e.g., "OrderFill", "MarginCall",
                      "BackStopLiquidation", "ADL", "MarketDelisted")
                    required: true
                  - name: trade_id
                    type: string
                    description: Trade ID
                    required: true
                  - name: transaction_unix_ms
                    type: integer
                    description: Transaction timestamp in milliseconds
                    required: true
                  - name: transaction_version
                    type: integer
                    description: Transaction version
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - topic
            - trades
          properties:
            topic:
              type: string
              x-parser-schema-id: <anonymous-schema-189>
            trades:
              type: array
              items:
                type: object
                required:
                  - asset_type
                  - account
                  - market
                  - action
                  - source
                  - trade_id
                  - size
                  - price
                  - is_profit
                  - realized_pnl_amount
                  - realized_funding_amount
                  - is_rebate
                  - fee_amount
                  - order_id
                  - client_order_id
                  - transaction_unix_ms
                  - transaction_version
                  - counter_party_account
                properties:
                  account:
                    type: string
                    description: User's account address
                    example: '0x1234567890abcdef1234567890abcdef12345678'
                    x-parser-schema-id: <anonymous-schema-191>
                  action:
                    type: string
                    description: >-
                      Trade action type. Perp: position-centric ("OpenLong",
                      "CloseShort",

                      "Net", ...). Spot: side from this row's perspective ("Buy"
                      / "Sell").
                    example: buy
                    x-parser-schema-id: <anonymous-schema-192>
                  asset_type:
                    type: string
                    description: >-
                      Discriminator carried on DTOs that can mix perp and spot
                      rows (markets,

                      orders, trades, bulk orders, bulk order fills, and
                      WebSocket payloads).

                      Also accepted as a query parameter on REST endpoints that
                      can filter to one

                      product.


                      Wire format is lowercase (`"perp"` / `"spot"`) and
                      accepted

                      case-insensitively on the request side via
                      [`impl_case_insensitive_deserialize`].
                    enum:
                      - perp
                      - spot
                    x-parser-schema-id: AssetType
                  client_order_id:
                    type: string
                    description: Client-specified order ID
                    example: client_order_abc
                    x-parser-schema-id: <anonymous-schema-193>
                  counter_party_account:
                    type: string
                    description: >-
                      Counter party account on the other leg of the fill. For
                      liquidation /

                      ADL / delisting fills this is the backstop liquidator.
                      Empty string for

                      pre-V2 historical trades that did not carry counter party
                      on-chain.
                    example: >-
                      0xfedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210
                    x-parser-schema-id: <anonymous-schema-194>
                  fee_amount:
                    type: number
                    format: double
                    description: >-
                      Fee paid by this row's account, normalized. Perp: always
                      in the

                      collateral asset (USDC). Spot: charged in the asset this
                      side

                      RECEIVED (protocol + builder fee combined); see
                      `fee_asset`.
                    x-parser-schema-id: <anonymous-schema-195>
                  fee_asset:
                    type: *ref_0
                    description: >-
                      FA metadata address of the asset `fee_amount` is
                      denominated in.

                      Spot only (base asset for the buyer, quote for the
                      seller); absent

                      for perp rows, where the fee is implicitly the collateral
                      asset.
                    x-parser-schema-id: <anonymous-schema-196>
                  is_profit:
                    type: boolean
                    description: Whether trade was profitable
                    x-parser-schema-id: <anonymous-schema-197>
                  is_rebate:
                    type: boolean
                    description: Whether trade received rebate
                    x-parser-schema-id: <anonymous-schema-198>
                  market:
                    type: string
                    description: Market identifier address
                    example: 0xmarket123456789abcdef
                    x-parser-schema-id: <anonymous-schema-199>
                  order_id:
                    type: string
                    description: Order ID associated with trade
                    example: '12345'
                    x-parser-schema-id: <anonymous-schema-200>
                  price:
                    type: number
                    format: double
                    description: Trade price
                    example: 50000.25
                    x-parser-schema-id: <anonymous-schema-201>
                  realized_funding_amount:
                    type: number
                    format: double
                    description: >-
                      Realized funding amount in USDC

                      - Negative value: trader PAID funding (e.g., long position
                      with positive funding rate)

                      - Positive value: trader RECEIVED funding (e.g., short
                      position with positive funding rate)

                      - Zero: no funding accrued
                    example: -15.5
                    x-parser-schema-id: <anonymous-schema-202>
                  realized_pnl_amount:
                    type: number
                    format: double
                    description: Realized PnL amount
                    x-parser-schema-id: <anonymous-schema-203>
                  size:
                    type: number
                    format: double
                    description: Trade size
                    example: 100.5
                    x-parser-schema-id: <anonymous-schema-204>
                  source:
                    type: string
                    description: >-
                      Trade source (e.g., "OrderFill", "MarginCall",
                      "BackStopLiquidation", "ADL", "MarketDelisted")
                    example: OrderFill
                    x-parser-schema-id: <anonymous-schema-205>
                  trade_id:
                    type: string
                    description: Trade ID
                    example: '3647276'
                    x-parser-schema-id: <anonymous-schema-206>
                  transaction_unix_ms:
                    type: integer
                    format: int64
                    description: Transaction timestamp in milliseconds
                    example: 1634567890000
                    x-parser-schema-id: <anonymous-schema-207>
                  transaction_version:
                    type: integer
                    format: int64
                    description: Transaction version
                    example: 3647276285
                    minimum: 0
                    x-parser-schema-id: <anonymous-schema-208>
                x-parser-schema-id: TradeDto
              x-parser-schema-id: <anonymous-schema-190>
          x-parser-schema-id: MarketTradesResponse
        title: Market trades message
        description: >-
          Real-time trade updates for one Decibel market address, perp or spot
          (not cached, updates only). Spot BTC and perp BTC are different
          markets with different addresses and require separate subscriptions.
          Each trade row carries `asset_type`. Spot rows use `action` values
          `Buy` or `Sell`, leave `client_order_id` empty, and zero
          `realized_pnl_amount`, `realized_funding_amount`, and `fee_amount`
          because spot has no positions/funding and per-side fee attribution is
          unavailable.
        example: |-
          {
            "topic": "trades:0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
            "trades": [
              {
                "asset_type": "perp",
                "account": "0x9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba",
                "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                "action": "Open Long",
                "source": "OrderFill",
                "trade_id": "3647277",
                "size": 0.8,
                "price": 50100,
                "is_profit": false,
                "realized_pnl_amount": -45.2,
                "realized_funding_amount": 5.1,
                "is_rebate": false,
                "fee_amount": 20.04,
                "order_id": "45680",
                "client_order_id": "order_123",
                "transaction_unix_ms": 1699564900000,
                "transaction_version": 3647276286,
                "counter_party_account": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
              }
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: MarketTradesMessage
          - id: x-parser-message-name
            value: MarketTradesMessage
    bindings: []
    extensions:
      - id: x-parser-unique-object-id
        value: marketTrades
sendOperations:
  - *ref_1
receiveOperations: []
sendMessages:
  - *ref_2
receiveMessages: []
extensions:
  - id: x-parser-unique-object-id
    value: marketTrades
securitySchemes: []

````