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

# Get Order History

> Query order history. As order creation/cancellation is asynchronous, the data returned from this endpoint may delay.



## OpenAPI

````yaml /api-reference/openapi.json get /api/v1/order/history
openapi: 3.1.0
info:
  title: ekiden-gateway
  description: >-
    API Gateway and WebSocket proxy based on Axum and Utoipa, handling auth,
    rate limiting, and connection buffering.
  license:
    name: ''
  version: 0.1.1
servers:
  - url: https://api.ekiden.fi/
    description: Production
  - url: https://api.staging.ekiden.fi/
    description: Staging
  - url: https://api.dev.ekiden.fi/
    description: Development
  - url: http://localhost:4020/
    description: Local
security: []
paths:
  /api/v1/order/history:
    get:
      tags:
        - Trade
      summary: Get Order History
      description: >-
        Query order history. As order creation/cancellation is asynchronous, the
        data returned from this endpoint may delay.
      operationId: get_history_orders
      parameters:
        - name: sub_account_address
          in: query
          description: Trading vault address (subaccount) to query against.
          required: true
          schema:
            type: string
        - name: symbol
          in: query
          required: false
          schema:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/Symbol'
        - name: order_id
          in: query
          required: false
          schema:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/OrderId'
        - name: order_link_id
          in: query
          required: false
          schema:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/OrderLinkId'
        - name: order_filter
          in: query
          required: false
          schema:
            oneOf:
              - type: 'null'
              - 0fa20933-97b7-40e0-b8e9-dbd22753b88f
        - name: order_status
          in: query
          required: false
          schema:
            type:
              - array
              - 'null'
            items:
              $ref: '#/components/schemas/OrderStatus'
        - name: start_time
          in: query
          required: false
          schema:
            type:
              - string
              - 'null'
            format: date-time
        - name: end_time
          in: query
          required: false
          schema:
            type:
              - string
              - 'null'
            format: date-time
        - name: limit
          in: query
          required: false
          schema:
            type:
              - integer
              - 'null'
            format: int32
            minimum: 0
        - name: cursor
          in: query
          required: false
          schema:
            type:
              - string
              - 'null'
      responses:
        '200':
          description: Orders
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderListResponse'
      security:
        - bearer_auth: []
components:
  schemas:
    Symbol:
      type: string
      example: BTCUSDC
    OrderId:
      type: string
      format: uuid
    OrderLinkId:
      type: string
    OrderStatus:
      type: string
      enum:
        - New
        - PartiallyFilled
        - Untriggered
        - CancelRequested
        - Rejected
        - PartiallyFilledCanceled
        - Filled
        - Canceled
        - Triggered
        - Deactivated
        - Expired
    OrderListResponse:
      type: object
      description: Response for order list and order history requests.
      required:
        - list
        - next_page_cursor
      properties:
        list:
          type: array
          items:
            $ref: '#/components/schemas/Order'
        next_page_cursor:
          type: string
    Order:
      type: object
      description: Summary information about an order.
      required:
        - order_id
        - symbol
        - sub_account_address
        - price
        - qty
        - side
        - margin_mode
        - order_status
        - avg_price
        - leaves_qty
        - leaves_value
        - cum_exec_qty
        - cum_exec_value
        - cum_exec_fee
        - time_in_force
        - order_type
        - last_price_on_created
        - post_only
        - reduce_only
        - close_on_trigger
        - created_time
        - updated_time
      properties:
        avg_price:
          type: string
          description: >-
            Average price at which part (or all) of the order has been executed
            (i.e. filled)
        cancel_type:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/CancelType'
        close_on_trigger:
          type: boolean
        closed_pnl:
          type:
            - string
            - 'null'
          description: |-
            Closed profit and loss for each close position order.
            Valid only in order WebSocket
        create_type:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/CreateType'
        created_time:
          type: string
          format: date-time
          example: '1672531200000'
        cum_exec_fee:
          type: string
          description: >-
            Cumulative executed trading fee: the total fees charged so far for
            the executed portion of this order
        cum_exec_qty:
          type: string
          description: |-
            Cumulative executed quantity: total amount of the order
            that has already been filled/executed so far
        cum_exec_value:
          type: string
          description: >-
            Cumulative executed value: the total value corresponding to the part
            of

            the order that has already been filled. Basically: how much worth in
            total has been executed so far
        expire_time:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            Expiration time for orders with a time-in-force of Good-Til-Date
            (GTD)
          example: '1672531200000'
        last_price_on_created:
          type: string
          description: Last price at the time the order was created
        leaves_qty:
          type: string
          description: Remaining quantity from the order that has not yet been executed
        leaves_value:
          type: string
          description: >-
            Estimated value of the remaining quantity (leavesQty)

            that remains unfilled. Basically: how much the unfilled portion is
            “worth”
        margin_mode:
          $ref: '#/components/schemas/MarginMode'
        order_id:
          $ref: '#/components/schemas/OrderId'
        order_link_id:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/OrderLinkId'
        order_status:
          $ref: '#/components/schemas/OrderStatus'
        order_type:
          $ref: '#/components/schemas/OrderType'
          description: >-
            Order type. Market, Limit. For TP/SL orders, is the order type after
            the order was triggered
        post_only:
          type: boolean
        price:
          type: string
        qty:
          type: string
        reduce_only:
          type: boolean
        reject_reason:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/RejectReason'
        side:
          $ref: '#/components/schemas/Side'
        stop_order_type:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/StopOrderType'
              description: Stop order type. For example, Stop Market or Stop Limit.
        sub_account_address:
          type: string
        symbol:
          $ref: '#/components/schemas/Symbol'
        time_in_force:
          $ref: '#/components/schemas/TimeInForce'
        tpsl:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TpSl'
              description: Take Profit / Stop Loss details if set
        trigger:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/ConditionalOrder'
              description: Conditional order details if this is a conditional order
        updated_time:
          type: string
          format: date-time
          example: '1672531200000'
    CancelType:
      type: string
      description: Reason/Source of the order cancellation.
      enum:
        - CancelByUser
        - CancelByAdmin
        - CancelBySystem
        - CancelByReduceOnly
        - CancelByPrepareLiq
        - CancelAllBeforeLiq
        - CancelByPrepareAdl
        - CancelAllBeforeAdl
        - CancelBySettle
        - CancelByTpSlTsClear
        - CancelBySmp
        - CancelByDcp
        - CancelByRebalance
        - CancelByOcoTpCanceledBySlTriggered
        - CancelByOcoSlCanceledByTpTriggered
    CreateType:
      type: string
      enum:
        - CreateByUser
        - CreateByFutureSpread
        - CreateByAdminClosing
        - CreateBySettle
        - CreateByStopOrder
        - CreateByTakeProfit
        - CreateByPartialTakeProfit
        - CreateByStopLoss
        - CreateByPartialStopLoss
        - CreateByTrailingStop
        - CreateByTrailingProfit
        - CreateByLiq
        - CreateByTakeOverPassThrough
        - CreateByAdlPassThrough
        - CreateByBlockPassThrough
        - CreateByBlockTradeMovePositionPassThrough
        - CreateByClosing
        - CreateByFGridBot
        - CloseByFGridBot
        - CreateByTWAP
        - CreateByTVSignal
        - CreateByMmRateClose
        - CreateByMartingaleBot
        - CloseByMartingaleBot
        - CreateByIceBerg
        - CreateByArbitrage
        - CreateByDdh
        - CreateByBboOrder
    MarginMode:
      type: string
      enum:
        - Cross
        - Isolated
    OrderType:
      type: string
      description: 'Order type: Limit, Market.'
      enum:
        - Limit
        - Market
    RejectReason:
      type: string
      enum:
        - EcNoError
        - EcOthers
        - EcInsufficientFunds
        - EcUnknownMessageType
        - EcMissingClOrdId
        - EcMissingOrigClOrdId
        - EcClOrdIdOrigClOrdIdAreTheSame
        - EcDuplicatedClOrdId
        - EcOrigClOrdIdDoesNotExist
        - EcTooLateToCancel
        - EcUnknownOrderType
        - EcUnknownSide
        - EcUnknownTimeInForce
        - EcWronglyRouted
        - EcMarketOrderPriceIsNotZero
        - EcLimitOrderInvalidPrice
        - EcNoEnoughQtyToFill
        - EcNoImmediateQtyToFill
        - EcPerCancelRequest
        - EcMarketOrderCannotBePostOnly
        - EcPostOnlyWillTakeLiquidity
        - EcReduceOnlyNoPosition
        - EcReduceOnlyWouldIncreasePosition
        - EcReduceOnlyExceedsPosition
        - EcReduceOnlyMode
        - EcTradingHalted
        - EcCancelReplaceOrder
        - EcInvalidSymbolStatus
        - EcCancelForNoFullFill
        - EcBySelfMatch
        - EcInCallAuctionStatus
        - EcQtyCannotBeZero
        - EcMarketOrderNoSupportTif
        - EcReachMaxTradeNum
        - EcInvalidPriceScale
        - EcBitIndexInvalid
        - EcStopBySelfMatch
        - EcInvalidSmpType
        - EcCancelByMmp
        - EcInvalidUserType
        - EcInvalidMirrorOid
        - EcInvalidMirrorUid
        - EcEcInvalidQty
        - EcInvalidAmount
        - EcLoadOrderCancel
        - EcMarketQuoteNoSuppSell
        - EcDisorderOrderId
        - EcInvalidBaseValue
        - EcLoadOrderCanMatch
        - EcSecurityStatusFail
        - EcReachRiskPriceLimit
        - EcOrderNotExist
        - EcCancelByOrderValueZero
        - EcCancelByMatchValueZero
        - EcReachMarketPriceLimit
    Side:
      type: string
      description: 'Order side: buy or sell.'
      enum:
        - Sell
        - Buy
    StopOrderType:
      type: string
      enum:
        - TakeProfit
        - StopLoss
        - TrailingStop
        - Stop
        - PartialTakeProfit
        - PartialStopLoss
        - TpslOrder
        - OcoOrder
        - MmRateClose
        - BidirectionalTpslOrder
    TimeInForce:
      oneOf:
        - type: string
          description: Good Till Cancel
          enum:
            - GTC
        - type: string
          description: Immediate or Cancel
          enum:
            - IOC
        - type: string
          description: Fill or Kill
          enum:
            - FOK
        - type: object
          description: Good Till Date
          required:
            - GTD
          properties:
            GTD:
              type: integer
              format: int64
              description: Good Till Date
              minimum: 0
        - type: string
          description: Good For Day
          enum:
            - Day
      description: Time in Force instructions.
    TpSl:
      type: object
      required:
        - mode
      properties:
        mode:
          $ref: '#/components/schemas/TpSlMode'
        stop_loss:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TpSlSpec'
        take_profit:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TpSlSpec'
    ConditionalOrder:
      type: object
      required:
        - trigger_price
        - trigger_direction
        - trigger_by
      properties:
        trigger_by:
          $ref: '#/components/schemas/TriggerBy'
          description: Last Price, Mark Price, or Index Price.
        trigger_direction:
          $ref: '#/components/schemas/TriggerDirection'
          description: Up or Down.
        trigger_price:
          type: string
          description: The price level that activates the order.
    TpSlMode:
      type: string
      enum:
        - Full
        - Partial
    TpSlSpec:
      oneOf:
        - type: object
          required:
            - market
          properties:
            market:
              type: object
              required:
                - trigger_price
                - trigger_by
              properties:
                trigger_by:
                  $ref: '#/components/schemas/TriggerBy'
                trigger_price:
                  type: string
        - type: object
          required:
            - limit
          properties:
            limit:
              type: object
              required:
                - trigger_price
                - limit_price
                - trigger_by
              properties:
                limit_price:
                  type: string
                trigger_by:
                  $ref: '#/components/schemas/TriggerBy'
                trigger_price:
                  type: string
    TriggerBy:
      type: string
      enum:
        - LastPrice
        - IndexPrice
        - MarkPrice
    TriggerDirection:
      type: string
      enum:
        - Up
        - Down
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer

````