> ## 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 Closed PnL

> Query user's closed profit and loss records



## OpenAPI

````yaml /api-reference/openapi.json get /api/v1/position/closed-pnl
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/position/closed-pnl:
    get:
      tags:
        - Position
      summary: Get Closed PnL
      description: Query user's closed profit and loss records
      operationId: get_closed_pnl
      parameters:
        - name: sub_account_address
          in: query
          required: true
          schema:
            type: string
        - name: symbol
          in: query
          required: false
          schema:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/Symbol'
        - 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: Closed PnL
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetClosedPnlResponse'
      security:
        - bearer_auth: []
components:
  schemas:
    Symbol:
      type: string
      example: BTCUSDC
    GetClosedPnlResponse:
      type: object
      description: Closed PnL response.
      required:
        - list
        - next_page_cursor
      properties:
        list:
          type: array
          items:
            $ref: '#/components/schemas/ClosedPnl'
        next_page_cursor:
          type: string
    ClosedPnl:
      type: object
      description: Closed PnL entry.
      required:
        - symbol
        - order_id
        - sub_account_address
        - side
        - qty
        - order_price
        - order_type
        - exec_type
        - closed_size
        - cum_entry_value
        - avg_entry_price
        - cum_exit_value
        - avg_exit_price
        - closed_pnl
        - fill_count
        - leverage
        - open_fee
        - close_fee
        - created_time
        - updated_time
      properties:
        avg_entry_price:
          type: string
          description: Average entry price
        avg_exit_price:
          type: string
          description: Average exit price
        close_fee:
          type: string
          description: Close position trading fee
        closed_pnl:
          type: string
          description: Closed PnL
        closed_size:
          type: string
        created_time:
          type: string
          format: date-time
          example: '1672531200000'
        cum_entry_value:
          type: string
          description: Cumulated Position value
        cum_exit_value:
          type: string
          description: Cumulated exit position value
        exec_type:
          $ref: '#/components/schemas/ExecType'
        fill_count:
          type: string
          description: The number of fills in a single order
        leverage:
          type: string
          description: Leverage
        open_fee:
          type: string
          description: Open position trading fee
        order_id:
          $ref: '#/components/schemas/OrderId'
        order_price:
          type: string
        order_type:
          $ref: '#/components/schemas/OrderType'
        qty:
          type: string
        side:
          $ref: '#/components/schemas/Side'
        sub_account_address:
          type: string
        symbol:
          $ref: '#/components/schemas/Symbol'
        updated_time:
          type: string
          format: date-time
          example: '1672531200000'
    ExecType:
      type: string
      description: Execution type for trade history entries.
      enum:
        - Trade
        - AdlTrade
        - Funding
        - BustTrade
        - Delivery
        - Settle
        - BlockTrade
        - MovePosition
        - FutureSpread
    OrderId:
      type: string
      format: uuid
    OrderType:
      type: string
      description: 'Order type: Limit, Market.'
      enum:
        - Limit
        - Market
    Side:
      type: string
      description: 'Order side: buy or sell.'
      enum:
        - Sell
        - Buy
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer

````