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

# Get historical trades for a subaccount

> Returns a paginated history of executed trades for a single subaccount or an entire wallet (specify exactly one), with optional filters for a time window, order id, instrument name, or quote id. The response includes the trade records and pagination info with total count and page count.



## OpenAPI

````yaml /openapi.json post /private/get_trade_history
openapi: 3.1.0
info:
  title: Derive v3 API
  version: 0.2.0
  description: JSON-RPC 2.0 methods, served over WebSocket and HTTP POST.
servers:
  - url: https://api.derive.xyz/v3
    description: Production (HTTP POST base)
  - url: https://testnet.api.derive.xyz/v3
    description: Testnet (HTTP POST base)
security: []
tags:
  - name: Subaccounts
    description: >-
      List, inspect, and label subaccounts, portfolios, positions, and
      collateral.
  - name: Session Keys
    description: Register, edit, and list delegated signing keys.
  - name: Account
    description: Wallet-level account information and settings.
  - name: Orderbook
    description: Place, replace, cancel, and query orders, trigger orders, and algos.
  - name: RFQ
    description: 'Request-for-quote: send RFQs, quote, and execute block trades.'
  - name: Vault Shareholders
    description: >-
      Deposit into and withdraw from vaults, and track shares, requests, and
      performance.
  - name: Vault Curators
    description: >-
      Create and operate curated vaults: settle deposit and withdrawal requests,
      and manage vault metadata.
  - name: History
    description: >-
      Per-account historical records: orders, trades, transfers, and
      settlements.
  - name: Market Maker Protection
    description: Configure, read, and reset market-maker protection.
  - name: Transfers & Withdrawals
    description: Move collateral between subaccounts, to other wallets, and on-chain.
  - name: System
    description: Rate limits and transaction lookups.
  - name: Market Data
    description: Instruments, currencies, tickers, and market-wide feeds.
  - name: Referrals
    description: Referral codes and program performance.
  - name: Other
    description: Uncategorized.
paths:
  /private/get_trade_history:
    post:
      tags:
        - History
      summary: Get historical trades for a subaccount
      description: >-
        Returns a paginated history of executed trades for a single subaccount
        or an entire wallet (specify exactly one), with optional filters for a
        time window, order id, instrument name, or quote id. The response
        includes the trade records and pagination info with total count and page
        count.
      operationId: private_get_trade_history
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetTradeHistoryRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedTradesResult'
        default:
          description: JSON-RPC error (see Error Codes)
components:
  schemas:
    GetTradeHistoryRequest:
      type: object
      properties:
        from_timestamp:
          default: null
          type:
            - integer
            - 'null'
          format: int64
        instrument_name:
          default: null
          type:
            - string
            - 'null'
        order_id:
          default: null
          type:
            - string
            - 'null'
        page:
          default: null
          type:
            - integer
            - 'null'
          format: uint32
          minimum: 0
        page_size:
          default: null
          type:
            - integer
            - 'null'
          format: uint32
          minimum: 0
        quote_id:
          default: null
          type:
            - string
            - 'null'
        subaccount_id:
          default: null
          type:
            - integer
            - 'null'
          format: int64
        to_timestamp:
          default: null
          type:
            - integer
            - 'null'
          format: int64
        wallet:
          default: null
          type:
            - string
            - 'null'
    PaginatedTradesResult:
      type: object
      required:
        - pagination
        - subaccount_id
        - trades
      properties:
        pagination:
          $ref: '#/components/schemas/Pagination'
        subaccount_id:
          type: integer
          format: int64
        trades:
          type: array
          items:
            $ref: '#/components/schemas/TradeHistoryResponse'
    Pagination:
      description: Response envelope for paginated RPCs.
      type: object
      required:
        - count
        - num_pages
      properties:
        count:
          type: integer
          format: uint64
          minimum: 0
        num_pages:
          type: integer
          format: uint64
          minimum: 0
    TradeHistoryResponse:
      description: >-
        A trade as returned by `private/get_trade_history`. Mirrors a private
        trades subscription event, except `tx_status` is the settlement status
        (`null` until the batch settles).
      type: object
      required:
        - direction
        - expected_rebate
        - extra_fee
        - index_price
        - instrument_name
        - is_transfer
        - label
        - 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:
        direction:
          $ref: '#/components/schemas/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
        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
        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
        instrument_name:
          type: string
        is_transfer:
          type: boolean
        label:
          type: string
        liquidity_role:
          $ref: '#/components/schemas/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
        op_uuid:
          type: string
        order_id:
          type: string
        quote_id:
          description: Optional UUID v4 string
          type:
            - string
            - 'null'
          format: uuid
        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
        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
        rfq_id:
          description: Optional UUID v4 string
          type:
            - string
            - 'null'
          format: uuid
        subaccount_id:
          type: integer
          format: int64
        timestamp:
          type: integer
          format: int64
        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
        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
        trade_id:
          type: string
        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
        tx_hash:
          type:
            - string
            - 'null'
        tx_status:
          anyOf:
            - $ref: '#/components/schemas/BatchStatus'
            - type: 'null'
    Direction:
      type: string
      enum:
        - buy
        - sell
    LiquidityRole:
      type: string
      enum:
        - maker
        - taker
    BatchStatus:
      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

````

## Related topics

- [Get historical orders for a subaccount](/api-reference/history/get-historical-orders-for-a-subaccount.md)
- [Trade](/vaults/trade.md)
- [Subaccount trades](/api-reference/channels/subaccounttrades.md)
