# Positions

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/account/futures/positions-history:
    get:
      summary: Positions
      deprecated: false
      description: >-
        Retrieves closed futures positions that were opened within a requested
        date range. Only closed positions are returned.


        **Authentication:** Bearer token; any valid API key (no specific scope
        required). This endpoint is rate-limited.


        ### P&L Calculation


        -  `closing_pnl` = profit or loss from all exit trades, based on
        notional values (exclusive of fees and funding payments)

        - `realised_pnl` = `closing_pnl` + `total_funding_payments` −
        `total_trade_fees`


        > Note: Liquidation fees are calculated at account level and are
        therefore not linked to individual positions.


        ### Instrument type


        Each position carries a `type`: `DATED_FUTURE` (with
        `contract_expiry_date` and `contract_duration`), `EQUITY_FUTURE`,
        `EQUITY_INDEX_FUTURE`, or `PERP`. Dated futures positions opened before
        2026-04-23T11:00:00Z are reported as `PERP`.


        `from`/`to` accept epoch (s, ms, µs or ns) or an ISO 8601 UTC timestamp
        ending in `Z` (or `YYYY-MM-DD`). `from` must be on or after 2024-01-01,
        not in the future, and strictly before `to`; `to` is exclusive.


        `cursor` is an opaque string. Pass the value from the previous response
        unchanged; it is `null` (or absent) on the last page. If a position's
        statistics cannot be computed it is omitted, so a page can contain fewer
        than `limit` positions while `cursor` is not `null`.


        Unknown query parameters are rejected with `400 UNEXPECTED_PARAMETERS`.


        ### Parameter Specification


        | Parameter       | Accepted Formats | Example Values |

        |-----------------|----------------|----------------|

        | `from`          | ISO 8601        | `2025-09-25T13:45:30Z` (s),
        `2025-09-25T13:45:30.123Z` (ms), `2025-09-25T13:45:30.123456Z` (us) |

        |                 | Epoch           | `1695647130` (s), `1695647130123`
        (ms), `1695647130123456` (us), `1695647130123456789` (ns) |

        |                 | Date            | `2025-09-25` |

        | `to`            | ISO 8601        | `2025-09-26T18:00:00Z` (s),
        `2025-09-26T18:00:00.456Z` (ms), `2025-09-26T18:00:00.456789Z` (us) |

        |                 | Epoch           | `1695734400` (s), `1695734400456`
        (ms), `1695734400456789` (us), `1695734400456789012` (ns) |

        |                 | Date            | `2025-09-26` |

        | `instrument_code` | String         | `BTC_USD_P` (single) |

        |                  | List           | `BTC_USD_P,ETH_USD_P`
        (comma-separated list) |

        | `order`  | String        | `DESC` or `ASC` |

        | `limit`  | Integer        | `3` |

        | `cursor`         | String         |
        `eyJlcG9jaCI6IjE3NjgzMTczNzUxMjA2MDM0ODQiLCJjcW8iOiIyMTA5NjgzNjQxNTIyNTc2In0=`
        |


        ### Parameter Constraints


        | Parameter       | Constraints |

        |-----------------|-------------------|

        | `from`          | Must be between **2024-01-01** and **present** |

        | `to`            | Must be strictly after `from`; the period between
        `from` and `to` **must not exceed 31 days** |

        | `limit`  | Integer between **1** and **10** |

        | `order`  | `DESC` or `ASC` |

        | `instrument_code` | Optional; must be valid futures market code(s) |

        | `cursor`         | Optional; string returned by previous response |


        ### Parameter Defaults


        | Parameter(s)    | Default Behaviour |

        |-----------------|-----------------|

        | `from` / `to`   | Neither provided: `from` = 7 days ago at midnight
        UTC, `to` = present time |

        | `from` / `to`   | Only `from` provided: `to` = 7 days later or present
        time, whichever is smaller |

        | `from` / `to`   | Only `to` provided: `from` = midnight UTC, 7 days
        earlier |

        | `instrument_code`| Defaults to all futures markets |

        | `limit` | Defaults to 5 |

        | `order` | Defaults to `DESC` |
      tags:
        - One Trading Public REST API/Futures
      parameters:
        - name: from
          in: query
          description: >-
            Specifies the start of the period (inclusive), matched against the
            position open time. Accepts date strings (YYYY-MM-DD), ISO 8601 UTC
            strings ending in `Z`, or numeric timestamps in seconds,
            milliseconds, microseconds or nanoseconds.
          required: false
          example: '2026-01-02'
          schema:
            type: string
        - name: to
          in: query
          description: >-
            Specifies the end of the period (exclusive). The range between start
            and end cannot exceed 31 days. Same formats as `from`.
          required: false
          example: '2026-02-01'
          schema:
            type: string
        - name: instrument_code
          in: query
          description: >-
            Instrument(s) to filter by: a single futures instrument code or a
            comma-separated list. Codes are case-insensitive; duplicates are
            rejected. Defaults to all futures markets.
          required: false
          example: ''
          schema:
            type: string
        - name: limit
          in: query
          description: Sets the maximum number of results per page, 1 to 10 (default 5).
          required: false
          example: '10'
          schema:
            type: string
        - name: cursor
          in: query
          description: >-
            Opaque pointer to the next page, taken unchanged from the `cursor`
            of the previous response.
          required: false
          example: >-
            eyJlcG9jaCI6IjE3NjgzMTczNzUxMjA2MDM0ODQiLCJjcW8iOiIyMTA5NjgzNjQxNTIyNTc2In0=
          schema:
            type: string
        - name: order
          in: query
          description: >-
            Sort order by timestamp: `ASC` or `DESC` (case-insensitive).
            Defaults to `DESC` (newest first).
          required: false
          example: DESC
          schema:
            type: string
            enum:
              - ASC
              - DESC
            default: DESC
      responses:
        '200':
          x-apidog-name: Success
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  positions:
                    type: array
                    items:
                      anyOf:
                        - $ref: '#/components/schemas/ClosedDatedFuturePosition'
                        - $ref: '#/components/schemas/ClosedPerpPosition'
                        - $ref: '#/components/schemas/ClosedEquityPerpPosition'
                  from:
                    type: string
                    description: >-
                      Start of the queried range (ISO 8601, nanosecond
                      precision).
                  to:
                    type: string
                    description: >-
                      End of the queried range, exclusive (ISO 8601, nanosecond
                      precision).
                  cursor:
                    type: string
                    description: >-
                      Opaque cursor for the next page, or `null` on the last
                      page.
                    nullable: true
                x-apidog-orders:
                  - positions
                  - from
                  - to
                  - cursor
                required:
                  - positions
                  - from
                  - to
                  - cursor
                x-apidog-ignore-properties: []
              example:
                positions:
                  - account_id: aaaba8bd-3195-4f72-87ff-98720a940f23
                    position_id: '2111199765938682'
                    instrument_code: BTC_USD_P
                    is_open: false
                    open_timestamp: '2026-01-28T08:19:25.380629346Z'
                    close_timestamp: '2026-02-13T10:27:14.886985638Z'
                    direction: LONG
                    max_position_amount: '0.01'
                    total_entry_amount: '0.01'
                    total_exit_amount: '0.01'
                    entry_trade_count: 1
                    exit_trade_count: 2
                    average_entry_price: '89075.95'
                    average_exit_price: '69107.489'
                    entry_notional: '890.7595'
                    exit_notional: '691.0749'
                    closing_pnl: '-199.6846'
                    realised_pnl: '-198.8334'
                    total_trade_fees: '0'
                    funding_payment_count: 93
                    total_funding_payments: '0.4255'
                    has_liquidation_events: false
                    type: PERP
                  - account_id: aaaba8bd-3195-4f72-87ff-98720a940f23
                    position_id: '2109683641526368'
                    instrument_code: BTC_USD_P
                    is_open: false
                    open_timestamp: '2026-01-13T15:16:26.038074298Z'
                    close_timestamp: '2026-01-13T15:16:36.081981640Z'
                    direction: SHORT
                    max_position_amount: '0.2'
                    total_entry_amount: '0.2'
                    total_exit_amount: '0.2'
                    entry_trade_count: 1
                    exit_trade_count: 1
                    average_entry_price: '92432.75'
                    average_exit_price: '92479.01'
                    entry_notional: '18486.55'
                    exit_notional: '18495.802'
                    closing_pnl: '-9.252'
                    realised_pnl: '-9.2536'
                    total_trade_fees: '0'
                    funding_payment_count: 0
                    total_funding_payments: '0'
                    has_liquidation_events: false
                    type: PERP
                from: '2026-01-01T00:00:00.000000000Z'
                to: '2026-02-01T00:00:00.000000000Z'
                cursor: >-
                  eyJlcG9jaCI6IjE3NjgzMTczNzUxMjA2MDM0ODQiLCJjcW8iOiIyMTA5NjgzNjQxNTIyNTc2In0=
          headers: {}
        '400':
          description: ''
          content:
            application/json:
              schema: &ref_0
                $ref: '#/components/schemas/ErrorResponse'
          headers: {}
          x-apidog-name: Bad Request
        '401':
          description: ''
          content:
            application/json:
              schema:
                title: ''
                type: object
                properties:
                  error:
                    type: string
                    description: Reason
                x-apidog-orders:
                  - error
                required:
                  - error
                x-apidog-ignore-properties: []
          headers: {}
          x-apidog-name: Unauthorized
        '403':
          description: ''
          content:
            application/json:
              schema:
                oneOf:
                  - *ref_0
                  - $ref: '#/components/schemas/GatewayError'
          headers: {}
          x-apidog-name: Forbidden
        '429':
          description: >-
            Rate limit exceeded. Limits are per account holder per minute: 600
            (retail), 2,000 (institutional), 10,000 (market maker).
          content:
            application/json:
              schema: *ref_0
              example:
                error: TOO_MANY_REQUESTS
                error_message: Too many requests
          headers: {}
          x-apidog-name: ''
        '500':
          description: Unexpected server error.
          content:
            application/json:
              schema: *ref_0
              example:
                error: SERVER_ERROR
                error_message: An internal server error occurred
          headers: {}
          x-apidog-name: Server Error
      security:
        - bearer: []
      x-apidog-folder: One Trading Public REST API/Futures
      x-apidog-status: developing
      x-run-in-apidog: https://app.eu.apidog.com/web/project/349694/apis/api-3928484-run
components:
  schemas:
    ClosedEquityPerpPosition:
      type: object
      properties:
        position_id: &ref_1
          type: string
          description: Unique identifier for the position (numeric string).
        account_id: &ref_2
          type: string
          format: uuid
          description: The account ID the position belongs to
        instrument_code: &ref_3
          type: string
          description: Instrument code of the futures market.
        open_timestamp: &ref_4
          type: string
          description: When the position was opened (ISO 8601, nanosecond precision)
        close_timestamp: &ref_5
          type: string
          description: When the position was closed (ISO 8601, nanosecond precision).
        direction: &ref_6
          type: string
          enum:
            - LONG
            - SHORT
          description: Position direction.
        total_entry_amount: &ref_7
          type: string
          description: Total entry trade amount in base currency
        total_exit_amount: &ref_8
          type: string
          description: Total exit trade amount in base currency
        is_open: &ref_9
          type: boolean
          description: >-
            Whether the position is currently open. Always `false`: only closed
            positions are returned.
        entry_trade_count: &ref_10
          type: integer
          description: Number of entry trades
        exit_trade_count: &ref_11
          type: integer
          description: Number of exit trades
        average_entry_price: &ref_12
          type: string
          description: Volume weighted average entry price
        average_exit_price: &ref_13
          type: string
          description: Volume weighted average exit price
          nullable: true
        total_trade_fees: &ref_14
          type: string
          description: Total trading fees for entry and exit trades
        total_funding_payments: &ref_15
          type: string
          description: >-
            Sum of funding payments received (positive) or paid (negative) while
            the position was open.
        closing_pnl: &ref_16
          type: string
          description: >-
            Profit or loss from the position’s trades, excluding fees and
            funding payments.
        realised_pnl: &ref_17
          type: string
          description: >-
            Net profit or loss: `closing_pnl` + `total_funding_payments` −
            `total_trade_fees`.
        has_liquidation_events: &ref_18
          type: boolean
          description: Whether the position has any liquidation trades
        max_position_amount: &ref_19
          type: string
          description: >-
            Largest absolute position size reached while the position was open,
            in base currency.
        entry_notional: &ref_20
          type: string
          description: >-
            Total notional value of the entry trades, in the settlement
            currency.
        exit_notional: &ref_21
          type: string
          description: Total notional value of the exit trades, in the settlement currency.
        funding_payment_count: &ref_22
          type: integer
          description: Number of funding payments applied to the position.
      x-apidog-orders:
        - 01KPZRWJ4GYS94MNEDV1ACPCTP
      x-apidog-refs:
        01KPZRWJ4GYS94MNEDV1ACPCTP: &ref_23
          $ref: '#/components/schemas/ClosedPosition'
      x-apidog-folder: ''
      required:
        - position_id
        - account_id
        - instrument_code
        - open_timestamp
        - close_timestamp
        - direction
        - total_entry_amount
        - total_exit_amount
        - is_open
        - entry_trade_count
        - exit_trade_count
        - average_entry_price
        - average_exit_price
        - total_trade_fees
        - total_funding_payments
        - closing_pnl
        - realised_pnl
        - has_liquidation_events
        - max_position_amount
        - entry_notional
        - exit_notional
        - funding_payment_count
      x-apidog-ignore-properties:
        - position_id
        - account_id
        - instrument_code
        - open_timestamp
        - close_timestamp
        - direction
        - total_entry_amount
        - total_exit_amount
        - is_open
        - entry_trade_count
        - exit_trade_count
        - average_entry_price
        - average_exit_price
        - total_trade_fees
        - total_funding_payments
        - closing_pnl
        - realised_pnl
        - has_liquidation_events
        - max_position_amount
        - entry_notional
        - exit_notional
        - funding_payment_count
    ClosedPosition:
      type: object
      properties:
        position_id: *ref_1
        account_id: *ref_2
        instrument_code: *ref_3
        open_timestamp: *ref_4
        close_timestamp: *ref_5
        direction: *ref_6
        total_entry_amount: *ref_7
        total_exit_amount: *ref_8
        is_open: *ref_9
        entry_trade_count: *ref_10
        exit_trade_count: *ref_11
        average_entry_price: *ref_12
        average_exit_price: *ref_13
        total_trade_fees: *ref_14
        total_funding_payments: *ref_15
        closing_pnl: *ref_16
        realised_pnl: *ref_17
        has_liquidation_events: *ref_18
        max_position_amount: *ref_19
        entry_notional: *ref_20
        exit_notional: *ref_21
        funding_payment_count: *ref_22
      x-apidog-orders:
        - position_id
        - account_id
        - instrument_code
        - open_timestamp
        - close_timestamp
        - direction
        - total_entry_amount
        - total_exit_amount
        - is_open
        - entry_trade_count
        - exit_trade_count
        - average_entry_price
        - average_exit_price
        - total_trade_fees
        - total_funding_payments
        - closing_pnl
        - realised_pnl
        - has_liquidation_events
        - max_position_amount
        - entry_notional
        - exit_notional
        - funding_payment_count
      required:
        - position_id
        - account_id
        - instrument_code
        - open_timestamp
        - close_timestamp
        - direction
        - total_entry_amount
        - total_exit_amount
        - is_open
        - entry_trade_count
        - exit_trade_count
        - average_entry_price
        - average_exit_price
        - total_trade_fees
        - total_funding_payments
        - closing_pnl
        - realised_pnl
        - has_liquidation_events
        - max_position_amount
        - entry_notional
        - exit_notional
        - funding_payment_count
      x-apidog-folder: ''
      x-apidog-ignore-properties: []
    ClosedPerpPosition:
      type: object
      properties:
        position_id: *ref_1
        account_id: *ref_2
        instrument_code: *ref_3
        open_timestamp: *ref_4
        close_timestamp: *ref_5
        direction: *ref_6
        total_entry_amount: *ref_7
        total_exit_amount: *ref_8
        is_open: *ref_9
        entry_trade_count: *ref_10
        exit_trade_count: *ref_11
        average_entry_price: *ref_12
        average_exit_price: *ref_13
        total_trade_fees: *ref_14
        total_funding_payments: *ref_15
        closing_pnl: *ref_16
        realised_pnl: *ref_17
        has_liquidation_events: *ref_18
        max_position_amount: *ref_19
        entry_notional: *ref_20
        exit_notional: *ref_21
        funding_payment_count: *ref_22
        type: &ref_24
          type: string
          const: PERP
          description: >-
            Instrument type. `PERP` for perpetual markets, and for dated futures
            positions opened before 2026-04-23T11:00:00Z, which keep the legacy
            `PERP` classification.
      x-apidog-orders:
        - 01KPZQPY9WRENCWGJW95N5A91T
        - 01KPZRNEADHQHMXPPQ8ST5C50Q
      x-apidog-refs:
        01KPZQPY9WRENCWGJW95N5A91T: *ref_23
        01KPZRNEADHQHMXPPQ8ST5C50Q:
          $ref: '#/components/schemas/PerpPositionFields'
      x-apidog-folder: ''
      required:
        - position_id
        - account_id
        - instrument_code
        - open_timestamp
        - close_timestamp
        - direction
        - total_entry_amount
        - total_exit_amount
        - is_open
        - entry_trade_count
        - exit_trade_count
        - average_entry_price
        - average_exit_price
        - total_trade_fees
        - total_funding_payments
        - closing_pnl
        - realised_pnl
        - has_liquidation_events
        - max_position_amount
        - entry_notional
        - exit_notional
        - funding_payment_count
        - type
      x-apidog-ignore-properties:
        - position_id
        - account_id
        - instrument_code
        - open_timestamp
        - close_timestamp
        - direction
        - total_entry_amount
        - total_exit_amount
        - is_open
        - entry_trade_count
        - exit_trade_count
        - average_entry_price
        - average_exit_price
        - total_trade_fees
        - total_funding_payments
        - closing_pnl
        - realised_pnl
        - has_liquidation_events
        - max_position_amount
        - entry_notional
        - exit_notional
        - funding_payment_count
        - type
    PerpPositionFields:
      type: object
      properties:
        type: *ref_24
      x-apidog-orders:
        - type
      required:
        - type
      x-apidog-folder: ''
      x-apidog-ignore-properties: []
    ClosedDatedFuturePosition:
      type: object
      properties:
        position_id: *ref_1
        account_id: *ref_2
        instrument_code: *ref_3
        open_timestamp: *ref_4
        close_timestamp: *ref_5
        direction: *ref_6
        total_entry_amount: *ref_7
        total_exit_amount: *ref_8
        is_open: *ref_9
        entry_trade_count: *ref_10
        exit_trade_count: *ref_11
        average_entry_price: *ref_12
        average_exit_price: *ref_13
        total_trade_fees: *ref_14
        total_funding_payments: *ref_15
        closing_pnl: *ref_16
        realised_pnl: *ref_17
        has_liquidation_events: *ref_18
        max_position_amount: *ref_19
        entry_notional: *ref_20
        exit_notional: *ref_21
        funding_payment_count: *ref_22
        type: &ref_25
          type: string
          description: >-
            Instrument type, always `DATED_FUTURE` (positions opened on or after
            2026-04-23T11:00:00Z).
          const: DATED_FUTURE
        contract_duration: &ref_26
          type: string
          description: Contract duration (e.g., 5Y for five years).
        contract_expiry_date: &ref_27
          type: string
          description: Expiry date of the dated futures contract (YYYY-MM-DD).
      x-apidog-orders:
        - 01KPZP8FY93PJNJFH67SX6DMRE
        - 01KPZPMZ94SQ1YV6YT4DZ1V0J5
      x-apidog-refs:
        01KPZP8FY93PJNJFH67SX6DMRE: *ref_23
        01KPZPMZ94SQ1YV6YT4DZ1V0J5:
          $ref: '#/components/schemas/DatedFuturePositionFields'
      x-apidog-folder: ''
      required:
        - position_id
        - account_id
        - instrument_code
        - open_timestamp
        - close_timestamp
        - direction
        - total_entry_amount
        - total_exit_amount
        - is_open
        - entry_trade_count
        - exit_trade_count
        - average_entry_price
        - average_exit_price
        - total_trade_fees
        - total_funding_payments
        - closing_pnl
        - realised_pnl
        - has_liquidation_events
        - max_position_amount
        - entry_notional
        - exit_notional
        - funding_payment_count
        - type
        - contract_duration
        - contract_expiry_date
      x-apidog-ignore-properties:
        - position_id
        - account_id
        - instrument_code
        - open_timestamp
        - close_timestamp
        - direction
        - total_entry_amount
        - total_exit_amount
        - is_open
        - entry_trade_count
        - exit_trade_count
        - average_entry_price
        - average_exit_price
        - total_trade_fees
        - total_funding_payments
        - closing_pnl
        - realised_pnl
        - has_liquidation_events
        - max_position_amount
        - entry_notional
        - exit_notional
        - funding_payment_count
        - type
        - contract_duration
        - contract_expiry_date
    DatedFuturePositionFields:
      type: object
      properties:
        type: *ref_25
        contract_duration: *ref_26
        contract_expiry_date: *ref_27
      x-apidog-orders:
        - type
        - contract_duration
        - contract_expiry_date
      required:
        - type
        - contract_duration
        - contract_expiry_date
      x-apidog-folder: ''
      x-apidog-ignore-properties: []
    ErrorResponse:
      type: object
      description: >-
        Error body. `error` is a machine-readable code (e.g.
        `INVALID_INSTRUMENT_CODE`) on most endpoints; a few older endpoints
        return a human-readable message in `error` instead and omit
        `error_message`.
      properties:
        error:
          type: string
          description: Error code (or, on older endpoints, a human-readable message).
        error_message:
          type: string
          description: >-
            Human-readable detail. Present on endpoints that return an error
            code in `error`.
      required:
        - error
      x-apidog-orders:
        - error
        - error_message
      x-apidog-folder: ''
      x-apidog-ignore-properties: []
    GatewayError:
      type: object
      description: >-
        Returned by the API gateway itself when the bearer token is missing,
        invalid, expired or revoked, or the calling IP is not on the API key's
        allowlist.
      properties:
        message:
          type: string
          enum:
            - Forbidden
            - Unauthorized
      required:
        - message
      x-apidog-orders:
        - message
      x-apidog-folder: ''
      x-apidog-ignore-properties: []
  securitySchemes:
    bearerAuth:
      type: bearer
      scheme: bearer
      description: >-
        API key issued to the account holder, sent as `Authorization: Bearer
        <token>`. The key must hold the `SUBACCOUNT_TRANSFER` scope.
    bearer:
      type: http
      scheme: bearer
servers:
  - url: https://api.onetrading.com/fast
    description: Production Env
security: []

```