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

# Closed Positions

> Read closed-position history, not currently open positions.

Read closed-position history, not currently open positions. This is an unsigned `POST /account` query with
`type: "positions"`, not a separate endpoint.

## Query target

Use a master, sub-account, or physical isolated-account public key.

`openTime` and `closeTime` are nanosecond timestamps; `averageEntryTime` is not exposed. For current positions and margin, use [Account Snapshot](https://docs.bulk.trade/api-reference/account/snapshot.md).

## Pagination

Rows are newest-first. Start with optional inclusive `startSlot` and `endSlot`
bounds and `limit` (1–5000; default 5000). Continue with `page.nextCursor`,
keeping `user` and `type` unchanged; you may change `limit` but must omit slot
bounds. Stop when `hasMore` is false. Newer events need a new first-page request.

HTTP `206` can carry partial or unknown coverage. Neither an empty page nor
`hasMore: false` proves complete history. On `409`, preserve the coverage gap;
on `410`, restart and deduplicate; on `503`, back off and retry. See the shared
[history rules](https://docs.bulk.trade/api-reference/getAccount.md#history-queries) for errors and coverage.


## OpenAPI

````yaml api-reference/account/openapi-closed-positions.yaml POST /account
openapi: 3.0.3
info:
  title: Bulk Trade API - Closed Positions
  version: 1.0.0
servers:
  - url: https://mainnet-api1.bulk.trade/api/v1
    description: Mainnet
  - url: https://exchange-api.bulk.trade/api/v1
    description: Testnet
security: []
paths:
  /account:
    post:
      summary: Closed Positions
      description: >-
        Read closed-position history, not currently open positions. No signature
        required. Use a master, sub-account, or physical isolated-account public
        key. First-page slot bounds are inclusive. A continuation keeps type and
        user, uses the returned cursor, and cannot include slot bounds.
      operationId: queryAccountPositions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - type
                - user
              not:
                anyOf:
                  - required:
                      - cursor
                      - startSlot
                  - required:
                      - cursor
                      - endSlot
              properties:
                type:
                  type: string
                  enum:
                    - positions
                  default: positions
                user:
                  type: string
                  description: >-
                    Paste the account public key (base58). No account is
                    selected for you.
                limit:
                  type: integer
                  minimum: 1
                  maximum: 5000
                  default: 5000
                  description: Optional page size for history queries
                  example: 2
                startSlot:
                  type: integer
                  format: int64
                  minimum: 0
                  description: >-
                    Optional inclusive lower slot bound for the first history
                    page
                endSlot:
                  type: integer
                  format: int64
                  minimum: 0
                  description: >-
                    Optional inclusive upper slot bound for the first history
                    page
                cursor:
                  type: string
                  description: >-
                    Opaque history continuation; cannot be combined with slot
                    bounds
            example:
              type: positions
              user: ''
              limit: 2
      responses:
        '200':
          description: >-
            Typed history page; inspect page coverage independently of
            pagination; illustrative example, not live data for the supplied
            account
          content:
            application/json:
              example:
                data: []
                page:
                  nextCursor: null
                  hasMore: false
                  asOfSlot: 13000
                  startSlot: 12000
                  endSlot: 13000
                  coverage: complete
              schema:
                type: object
                required:
                  - data
                  - page
                properties:
                  data:
                    type: array
                    items:
                      allOf:
                        - type: object
                          description: Closed position history record
                          required:
                            - owner
                            - symbol
                            - quantity
                            - maxQuantity
                            - totalVolume
                            - avgOpenPrice
                            - avgClosePrice
                            - realizedPnl
                            - fees
                            - funding
                            - openTime
                            - closeTime
                            - closeReason
                            - closeSlot
                            - sequence
                            - iso
                          properties:
                            owner:
                              type: string
                              description: Owner public key (base58)
                            symbol:
                              type: string
                              description: Market symbol
                            quantity:
                              type: number
                              description: >-
                                Closed position size (signed; long=positive,
                                short=negative)
                            maxQuantity:
                              type: number
                              description: >-
                                Legacy alias of quantity (kept for backward
                                compatibility)
                            totalVolume:
                              type: number
                              description: Total traded volume over position lifetime
                            avgOpenPrice:
                              type: number
                              description: Volume-weighted average entry price
                            avgClosePrice:
                              type: number
                              description: Volume-weighted average exit price
                            realizedPnl:
                              type: number
                              description: Total realized profit/loss
                            fees:
                              type: number
                              description: Total fees paid
                            funding:
                              type: number
                              description: >-
                                Total funding payments (positive=received,
                                negative=paid)
                            openTime:
                              type: integer
                              format: int64
                              description: Position open timestamp (nanoseconds)
                            closeTime:
                              type: integer
                              format: int64
                              description: Position close timestamp (nanoseconds)
                            closeReason:
                              type: string
                              description: Reason for position closure
                              enum:
                                - normal
                                - liquidation
                                - adl
                                - liquidation_sweep
                            closeSlot:
                              type: integer
                              format: int64
                              description: Slot in which the position closed
                            sequence:
                              type: integer
                              format: int64
                              description: Event sequence inside closeSlot
                            iso:
                              type: boolean
                              description: >-
                                `true` if this row belongs to a per-instrument
                                isolated account, otherwise `false`
                            isoPubkey:
                              type: string
                              nullable: true
                              description: >-
                                Present only when `iso=true`; isolated-lane
                                account pubkey (base58)
                        - type: object
                          required:
                            - owner
                            - symbol
                            - quantity
                            - maxQuantity
                            - totalVolume
                            - avgOpenPrice
                            - avgClosePrice
                            - realizedPnl
                            - fees
                            - funding
                            - openTime
                            - closeTime
                            - closeReason
                            - iso
                            - closeSlot
                            - sequence
                  page:
                    type: object
                    required:
                      - nextCursor
                      - hasMore
                      - asOfSlot
                      - startSlot
                      - endSlot
                      - coverage
                    properties:
                      nextCursor:
                        type: string
                        nullable: true
                        description: >-
                          Opaque exclusive continuation; null exactly when
                          hasMore is false
                      hasMore:
                        type: boolean
                      asOfSlot:
                        type: integer
                        format: int64
                        minimum: 0
                      startSlot:
                        type: integer
                        format: int64
                        minimum: 0
                      endSlot:
                        type: integer
                        format: int64
                        minimum: 0
                      coverage:
                        type: string
                        enum:
                          - complete
                          - partial
                          - unknown
                        description: >-
                          Coverage of the effective inclusive range. Backfill
                          proof is fixed at its inclusive cutoff and is not
                          advanced by newer live rows.
                      minAvailableSlot:
                        type: integer
                        format: int64
                        minimum: 0
                        description: >-
                          Earliest authoritative slot for this direct or
                          aggregate history scope; primary and parent-alias
                          retention floors are independent. Omitted when
                          unknown.
        '206':
          description: >-
            Incomplete history page when partial reads are enabled; inspect page
            coverage
          headers:
            X-Bulk-History-Status:
              description: Coverage status
              schema:
                type: string
                enum:
                  - partial
                  - unknown
            X-Bulk-History-Min-Available-Slot:
              description: Earliest authoritative available slot; omitted when unknown
              schema:
                type: integer
                format: int64
                minimum: 0
          content:
            application/json:
              schema:
                $ref: 4d8c9bb7-740b-4aed-b9c5-908e54511978
        '400':
          description: >-
            Invalid current-state request or malformed history query, limit,
            slot range, or cursor
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: object
                    required:
                      - code
                      - message
                    properties:
                      code:
                        type: string
                        enum:
                          - INVALID_HISTORY_QUERY
                          - INVALID_HISTORY_LIMIT
                          - INVALID_SLOT_RANGE
                          - CURSOR_INVALID
                          - ACCOUNT_NOT_FOUND
                          - HISTORY_NOT_COVERED
                          - CURSOR_EXPIRED
                          - HISTORY_STATE_NOT_READY
                          - HISTORY_BUSY
                          - HISTORY_STORAGE_ERROR
                      message:
                        type: string
        '404':
          description: >-
            The current-state account or history scope was not found. History
            requests return the structured error envelope when a JSON body is
            present.
          content:
            application/json:
              schema:
                $ref: 08bd669e-28d3-4599-95a2-c87886c4d865
        '408':
          description: >-
            Response timeout (60 seconds for orders, 5 seconds for current-state
            snapshot requests). An order may still execute; reconcile before
            submitting a replacement.
        '409':
          description: Strict coverage cannot satisfy the requested history range
          content:
            application/json:
              schema:
                $ref: 08bd669e-28d3-4599-95a2-c87886c4d865
        '410':
          description: >-
            History scope, coverage, backfill, or retention changed after cursor
            issuance
          content:
            application/json:
              schema:
                $ref: 08bd669e-28d3-4599-95a2-c87886c4d865
        '429':
          description: >-
            Request or action rate limit reached. Back off before retrying; the
            body may be plain text or empty.
        '500':
          description: >-
            Current-state request failure or history storage/decoding failure.
            History requests return the structured error envelope when a JSON
            body is present.
          content:
            application/json:
              schema:
                $ref: 08bd669e-28d3-4599-95a2-c87886c4d865
        '503':
          description: >-
            History state is not ready, bounded read capacity is saturated, or
            the API is locked
          content:
            application/json:
              schema:
                oneOf:
                  - 3e86799f-072e-4cdc-9a52-ec3ab5a34027
                  - type: object
                    required:
                      - code
                      - error
                    properties:
                      code:
                        type: string
                        enum:
                          - API_LOCKED
                      error:
                        type: string
      security: []

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.