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

# Ended positions

> Positions that ended in the last 48 hours, newest first: settled, or an order that the venue returned. Read a position that is still open from the chain. A page holds at most 100 rows. Page with `beforeSlot`.



## OpenAPI

````yaml /openapi/data-api.json get /v0/positions
openapi: 3.1.0
info:
  title: Rekt data API
  version: '0'
  summary: Read-only HTTP API for settled trades and ended positions.
  description: >-
    `https://data.rekt.trading` serves settled trades and ended positions. It is
    read-only and it needs no account. It sets no cookies and accepts no
    credentials. Responses carry `Access-Control-Allow-Origin: *`. Start at `GET
    /v0/health`.


    The program is the ground of truth. This API is a lagging mirror of it. Read
    live state from the chain through the SDK.


    Rules:


    - Every route answers `GET`, `HEAD` and `OPTIONS`. Any other method gets
    `405`.

    - A request URL is at most 2,048 characters. A longer one gets `414`.

    - Requests are rate-limited for each client address. `GET /v0/health` states
    the limit under `access`. A request over it gets `429` and a `Retry-After`
    header. Wait that long, then retry.

    - This API ignores a parameter that it does not know. A filter that this API
    refuses gets `400`.

    - Money amounts are decimal strings of base units of USDC (6 decimals).
    Addresses are 64 hex characters unless a field says base58. Transaction
    signatures are base58.

    - A response can hold fields that this description does not list. Ignore a
    field that you do not know.
servers:
  - url: https://data.rekt.trading
    description: The data API.
security: []
tags:
  - name: Health
    description: Freshness and limits.
  - name: Aggregates
    description: All-time totals and day series.
  - name: Trades
    description: Settled trades of the last 48 hours.
  - name: Positions
    description: Ended positions of the last 48 hours.
  - name: Minute
    description: Minute rounds of the last 48 hours.
paths:
  /v0/positions:
    get:
      tags:
        - Positions
      summary: Ended positions
      description: >-
        Positions that ended in the last 48 hours, newest first: settled, or an
        order that the venue returned. Read a position that is still open from
        the chain. A page holds at most 100 rows. Page with `beforeSlot`.
      operationId: listPositions
      parameters:
        - $ref: '#/components/parameters/owner'
        - $ref: '#/components/parameters/market'
        - name: phase
          in: query
          required: false
          description: Return only the positions in this phase. Any other phase gets `400`.
          schema:
            type: string
            enum:
              - settled
              - voided
        - name: signature
          in: query
          required: false
          description: >-
            Return only the position that this transaction touched. Give the
            signature in base58.
          schema:
            type: string
        - $ref: '#/components/parameters/beforeSlot'
        - $ref: '#/components/parameters/limit50'
      responses:
        '200':
          description: A page of ended positions.
          headers:
            Cache-Control:
              description: '`public, max-age=5`.'
              schema:
                type: string
            Warning:
              description: >-
                Present only when `asOf.stale` is true. It states that the
                archive is stale.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PositionsResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '414':
          $ref: '#/components/responses/UriTooLong'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  parameters:
    owner:
      name: owner
      in: query
      required: false
      description: >-
        Return only the rows of this wallet. Give the wallet as base58 or as 64
        hex characters. Any other value matches nothing: the page is empty and
        `filters.owner` repeats the value.
      schema:
        type: string
    market:
      name: market
      in: query
      required: false
      description: >-
        Return only the rows of this market. Give the market account address as
        64 hex characters.
      schema:
        type: string
    beforeSlot:
      name: beforeSlot
      in: query
      required: false
      description: >-
        Return only the rows before this slot. To get the next page, send
        `nextBeforeSlot` from the previous page. Unit: slots.
      schema:
        type: integer
        minimum: 0
    limit50:
      name: limit
      in: query
      required: false
      description: >-
        The number of rows in the page. The server reads a value above 100 as
        100.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 50
  schemas:
    PositionsResponse:
      type: object
      description: A page of positions that have ended, newest first.
      properties:
        asOf:
          $ref: '#/components/schemas/AsOf'
        tier:
          type: string
          description: >-
            The access tier that answered. It is `public` for a caller without a
            key.
          enum:
            - public
        window:
          $ref: '#/components/schemas/Window'
        note:
          type: string
          description: >-
            A statement, in words: the phase is the last one that the archive
            saw.
        filters:
          type: object
          description: >-
            The filters of this request, as sent. A filter that was not sent is
            null.
          properties:
            owner:
              type:
                - string
                - 'null'
              description: The `owner` filter.
            market:
              type:
                - string
                - 'null'
              description: The `market` filter.
            phase:
              type:
                - string
                - 'null'
              description: The `phase` filter.
            signature:
              type:
                - string
                - 'null'
              description: The `signature` filter.
            beforeSlot:
              type:
                - string
                - 'null'
              description: The `beforeSlot` filter, as sent.
            limit:
              type: integer
              description: 'The page size that applied. Unit: rows.'
        sampleSize:
          type: integer
          description: 'The number of rows in this page. Unit: rows.'
        totalMatching:
          type: integer
          description: 'The number of rows in the window that match the filters. Unit: rows.'
        nextBeforeSlot:
          type:
            - integer
            - 'null'
          description: >-
            Send this value as `beforeSlot` to get the next page. Null on the
            last page. Unit: slots.
        positions:
          type: array
          description: The positions, newest first.
          items:
            $ref: '#/components/schemas/PositionRow'
      required:
        - asOf
        - tier
        - window
        - filters
        - sampleSize
        - totalMatching
        - nextBeforeSlot
        - positions
    AsOf:
      type: object
      description: How fresh the archive is at the time of this response.
      properties:
        generatedAt:
          type: string
          description: The time the server made this response, in UTC (ISO 8601).
          format: date-time
        archiveTailSlot:
          type:
            - integer
            - 'null'
          description: >-
            The slot of the newest transaction in the archive. Unit: slots. Null
            when the archive is empty.
        archiveTailAt:
          type:
            - string
            - 'null'
          description: >-
            The block time of the newest transaction in the archive, in UTC (ISO
            8601). Null when the archive is empty.
          format: date-time
        stale:
          type: boolean
          description: >-
            True when the archive has not moved for longer than its freshness
            limit. The server still sends a stale response, with a `Warning`
            header.
        staleReason:
          type:
            - string
            - 'null'
          description: Why the archive is stale, in words. Null when `stale` is false.
        entryFeeBasis:
          type: string
          description: >-
            How the entry fees in the rows were found. `observed` means each fee
            is the fee that the trade paid. Only the routes whose rows carry an
            entry fee send this field.
          enum:
            - observed
      required:
        - generatedAt
        - archiveTailSlot
        - archiveTailAt
        - stale
        - staleReason
    Window:
      type: object
      description: The time window of a per-transaction route.
      properties:
        hours:
          type: integer
          description: 'The length of the window. Unit: hours.'
          examples:
            - 48
        since:
          type: string
          description: >-
            The start of the window, in UTC (ISO 8601). The route does not send
            rows before this time.
          format: date-time
        rule:
          type: string
          description: The window rule, in words.
      required:
        - hours
        - since
        - rule
    PositionRow:
      type: object
      description: One position that has ended, with every step that the archive saw.
      properties:
        owner:
          type: string
          description: The wallet that owns the position, as 64 hex characters.
          pattern: ^[0-9a-f]{64}$
        market:
          type: string
          description: The market account address, as 64 hex characters.
          pattern: ^[0-9a-f]{64}$
        seq:
          type: string
          description: The position number of this owner, as a decimal string.
          pattern: ^[0-9]+$
        direction:
          type:
            - string
            - 'null'
          description: The side of the position.
          enum:
            - long
            - short
            - null
        tier:
          type:
            - string
            - 'null'
          description: The leverage tier, as a decimal string (`1000` is 1000x).
          pattern: ^[0-9]+$
        stake:
          type:
            - string
            - 'null'
          pattern: ^[0-9]+$
          description: >-
            The stake committed at the open. Unit: base units of USDC (6
            decimals), as a decimal string.
        phase:
          type: string
          description: >-
            The last phase that the archive saw. `settled`: the position
            settled. `voided`: the venue returned the order.
          enum:
            - settled
            - voided
        priceKind:
          type:
            - string
            - 'null'
          description: The name of the price source of the market.
        phaseAt:
          type:
            - integer
            - 'null'
          description: 'The time the position entered its phase. Unit: Unix seconds.'
        phaseSlot:
          type:
            - integer
            - 'null'
          description: 'The slot where the position entered its phase. Unit: slots.'
        slot:
          type: integer
          description: >-
            The slot of the newest event of the position. Unit: slots. Pages are
            in this order, newest first.
        endedAt:
          type:
            - integer
            - 'null'
          description: >-
            The time the position ended. Unit: Unix seconds. The 48-hour window
            counts from this time.
        commit:
          type:
            - object
            - 'null'
          description: The open transaction. Null when the archive began after it.
          properties:
            signature:
              type: string
              description: The signature of the open transaction, in base58.
            slot:
              type: integer
              description: 'The slot of the open transaction. Unit: slots.'
            blockTime:
              type:
                - integer
                - 'null'
              description: 'The block time of the open transaction. Unit: Unix seconds.'
        entry:
          type:
            - object
            - 'null'
          description: >-
            The entry price that the fill wrote. Null when the order was not
            filled.
          properties:
            price:
              type: string
              description: >-
                The price of the first fill, as a decimal string. Apply `expo`
                to read it.
              pattern: ^[0-9]+$
            expo:
              type:
                - integer
                - 'null'
              description: The price exponent. The price is `price × 10^expo`.
            fee:
              type:
                - string
                - 'null'
              pattern: ^[0-9]+$
              description: >-
                The entry fee. Null when it is not known. Unit: base units of
                USDC (6 decimals), as a decimal string.
            tick:
              description: >-
                The tick that priced the fill. Null when the price source states
                no tick.
              anyOf:
                - $ref: '#/components/schemas/Tick'
                - type: 'null'
            fill:
              type:
                - object
                - 'null'
              description: The fill transaction.
              properties:
                slot:
                  type: integer
                  description: 'The slot of the fill transaction. Unit: slots.'
                blockTime:
                  type:
                    - integer
                    - 'null'
                  description: 'The block time of the fill transaction. Unit: Unix seconds.'
        voided:
          type:
            - object
            - 'null'
          description: How the venue returned the order. Null when the order was filled.
          properties:
            reason:
              type: string
              description: Why the venue returned the order, as a short code.
            text:
              type: string
              description: Why the venue returned the order, in words.
            refundTotal:
              type: string
              pattern: ^[0-9]+$
              description: >-
                The amount that the venue returned. Unit: base units of USDC (6
                decimals), as a decimal string.
            feeKept:
              type: string
              pattern: ^[0-9]+$
              description: >-
                The fee that the venue kept. Unit: base units of USDC (6
                decimals), as a decimal string.
            feeRefunded:
              type: string
              pattern: ^[0-9]+$
              description: >-
                The fee that the venue returned. Unit: base units of USDC (6
                decimals), as a decimal string.
            delivered:
              type: boolean
              description: >-
                True when the refund reached the wallet. False when the program
                set it aside.
            balanced:
              type: boolean
              description: >-
                True when the refund and the kept fee add up to the amount that
                was committed.
            slot:
              type: integer
              description: >-
                The slot of the transaction that returned the order. Unit:
                slots.
            blockTime:
              type:
                - integer
                - 'null'
              description: 'The block time of that transaction. Unit: Unix seconds.'
            tick:
              description: The tick that proved the return. Null when no tick proved it.
              anyOf:
                - $ref: '#/components/schemas/Tick'
                - type: 'null'
        adds:
          type: array
          description: Each add to the position, oldest first.
          items:
            type: object
            description: One add.
            properties:
              addedCollateral:
                type: string
                pattern: ^[0-9]+$
                description: >-
                  The collateral that the add committed. Unit: base units of
                  USDC (6 decimals), as a decimal string.
              totalDebit:
                type:
                  - string
                  - 'null'
                pattern: ^[0-9]+$
                description: >-
                  The total amount that the add took from the wallet. Unit: base
                  units of USDC (6 decimals), as a decimal string.
              fee:
                type:
                  - string
                  - 'null'
                pattern: ^[0-9]+$
                description: >-
                  The entry fee of the add. Unit: base units of USDC (6
                  decimals), as a decimal string.
              phase:
                type: string
                description: >-
                  Where the add stands: `add-pending`, `live` (it joined the
                  position) or `reversed`.
                enum:
                  - add-pending
                  - live
                  - reversed
              commit:
                type:
                  - object
                  - 'null'
                description: The add transaction.
                properties:
                  signature:
                    type: string
                    description: The signature of the add transaction, in base58.
                  slot:
                    type: integer
                    description: 'The slot of the add transaction. Unit: slots.'
                  blockTime:
                    type:
                      - integer
                      - 'null'
                    description: 'The block time of the add transaction. Unit: Unix seconds.'
              filled:
                type:
                  - object
                  - 'null'
                description: The fill of the add. Null when the add was not filled.
                properties:
                  entryPrice:
                    type: string
                    description: >-
                      The entry price of the position after the add, as a
                      decimal string.
                    pattern: ^[0-9]+$
                  entryPriceBefore:
                    type: string
                    description: >-
                      The entry price of the position before the add, as a
                      decimal string.
                    pattern: ^[0-9]+$
                  slot:
                    type: integer
                    description: 'The slot of the fill of the add. Unit: slots.'
                  blockTime:
                    type:
                      - integer
                      - 'null'
                    description: 'The block time of the fill of the add. Unit: Unix seconds.'
              reversed:
                type:
                  - object
                  - 'null'
                description: >-
                  How the venue returned the add. Null when the add was not
                  returned.
                properties:
                  reason:
                    type: string
                    description: Why the venue returned the order, as a short code.
                  text:
                    type: string
                    description: Why the venue returned the order, in words.
                  refundTotal:
                    type: string
                    pattern: ^[0-9]+$
                    description: >-
                      The amount that the venue returned. Unit: base units of
                      USDC (6 decimals), as a decimal string.
                  feeKept:
                    type: string
                    pattern: ^[0-9]+$
                    description: >-
                      The fee that the venue kept. Unit: base units of USDC (6
                      decimals), as a decimal string.
                  feeRefunded:
                    type: string
                    pattern: ^[0-9]+$
                    description: >-
                      The fee that the venue returned. Unit: base units of USDC
                      (6 decimals), as a decimal string.
                  delivered:
                    type: boolean
                    description: >-
                      True when the refund reached the wallet. False when the
                      program set it aside.
                  balanced:
                    type: boolean
                    description: >-
                      True when the refund and the kept fee add up to the amount
                      that was committed.
                  slot:
                    type: integer
                    description: >-
                      The slot of the transaction that returned the order. Unit:
                      slots.
                  blockTime:
                    type:
                      - integer
                      - 'null'
                    description: 'The block time of that transaction. Unit: Unix seconds.'
        exit:
          type:
            - object
            - 'null'
          description: The close request or the expiry mark. Null when there was none.
          properties:
            kind:
              type: string
              description: 'The step: `close-requested` or `expiry-marked`.'
              enum:
                - close-requested
                - expiry-marked
            reason:
              type: string
              description: >-
                The close reason of the step: `voluntary`, `userExpiry` or
                `tenorExpiry`.
            clockS:
              type:
                - string
                - 'null'
              description: >-
                The chain clock when the program recorded the step. Unit: Unix
                seconds, as a decimal string. Null on markets that use a target
                slot.
              pattern: ^[0-9]+$
            slot:
              type: integer
              description: 'The slot of the step. Unit: slots.'
            blockTime:
              type:
                - integer
                - 'null'
              description: 'The block time of the step. Unit: Unix seconds.'
        stamp:
          type:
            - object
            - 'null'
          description: >-
            The level stamp: the barrier or the target that the price reached.
            Null when there was none.
          properties:
            level:
              type: string
              description: 'The level that the price reached: `knockout` or `takeProfit`.'
              enum:
                - knockout
                - takeProfit
            price:
              type: string
              description: The price that reached the level, as a decimal string.
              pattern: ^[0-9]+$
            beforeAdd:
              type: boolean
              description: True when the price reached the level before an add filled.
            tick:
              description: >-
                The tick that proved the stamp. Null when the price source
                states no tick.
              anyOf:
                - $ref: '#/components/schemas/Tick'
                - type: 'null'
            slot:
              type: integer
              description: 'The slot of the stamp. Unit: slots.'
            blockTime:
              type:
                - integer
                - 'null'
              description: 'The block time of the stamp. Unit: Unix seconds.'
        settlement:
          type:
            - object
            - 'null'
          description: The settlement. Null when the position did not settle.
          properties:
            settledAt:
              type:
                - integer
                - 'null'
              description: 'The block time of the settle transaction. Unit: Unix seconds.'
            reason:
              type:
                - string
                - 'null'
              description: Why the position closed. See `reason` on a trade row.
            stake:
              type: string
              pattern: ^[0-9]+$
              description: >-
                The stake of the position. Unit: base units of USDC (6
                decimals), as a decimal string.
            payoutTrader:
              type: string
              pattern: ^[0-9]+$
              description: >-
                The amount that the settlement paid the trader. Unit: base units
                of USDC (6 decimals), as a decimal string.
            verified:
              type: boolean
              description: >-
                True when the replayed engine gave the same payouts as the
                program.
            tick:
              description: >-
                The tick that priced the settlement. Null when the price source
                states no tick.
              anyOf:
                - $ref: '#/components/schemas/Tick'
                - type: 'null'
            receipt:
              $ref: '#/components/schemas/Receipt'
            slot:
              type: integer
              description: 'The slot of the settle transaction. Unit: slots.'
            blockTime:
              type:
                - integer
                - 'null'
              description: 'The block time of the settle transaction. Unit: Unix seconds.'
        feeTerms:
          type: object
          description: The fee terms that applied at the close.
          properties:
            closed:
              type: object
              description: The fee terms at the close.
              properties:
                applied:
                  type: boolean
                  description: >-
                    True when the fee terms of the position applied at the
                    close.
                haircut:
                  type: string
                  pattern: ^[0-9]+$
                  description: >-
                    The part of the gain that the fee terms withheld. Unit: base
                    units of USDC (6 decimals), as a decimal string.
                exitFeeTotal:
                  type: string
                  pattern: ^[0-9]+$
                  description: >-
                    The exit fee that the close charged. Unit: base units of
                    USDC (6 decimals), as a decimal string.
      required:
        - owner
        - market
        - seq
        - phase
        - slot
    Error:
      type: object
      description: A refused request.
      properties:
        error:
          type: string
          description: What is wrong, in words.
        retryAfterSeconds:
          type: integer
          description: 'On `429` only: wait this long, then retry. Unit: seconds.'
        routes:
          type: array
          items:
            type: string
          description: 'On `404` for an unknown route only: the routes that this API serves.'
      required:
        - error
    Tick:
      type: object
      description: >-
        The price tick that priced this step, when the price source of the
        market states one.
      properties:
        role:
          type: string
          description: >-
            What the tick priced: `fill`, `void-proof`, `window`, `level`,
            `add-fill` or `reverse-proof`. `unknown` is a role that this server
            cannot name.
        tickUs:
          type: string
          description: >-
            The time of the tick. Unit: microseconds since the Unix epoch, as a
            decimal string.
          pattern: ^[0-9]+$
        targetUs:
          type:
            - string
            - 'null'
          description: >-
            The time that the request asked for. Unit: microseconds since the
            Unix epoch, as a decimal string. Null when the step asked for no
            time.
          pattern: ^[0-9]+$
        channel:
          type: integer
          description: The channel number of the tick.
        session:
          type: integer
          description: The market session code of the tick. 0 is the regular session.
        updateAgeUs:
          type: string
          description: >-
            The age of the tick content when the program read it. Unit:
            microseconds, as a decimal string.
          pattern: ^[0-9]+$
        slot:
          type: string
          description: >-
            The slot where the instruction that read the tick landed. Unit:
            slots, as a decimal string.
          pattern: ^[0-9]+$
    Receipt:
      type: object
      description: The receipt that the program wrote for this settlement.
      properties:
        exitFeeTotal:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The exit fee that the settlement charged. Unit: base units of USDC
            (6 decimals), as a decimal string.
        lossTaxTotal:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The loss tax that the settlement charged. Unit: base units of USDC
            (6 decimals), as a decimal string.
        payoutTrader:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The amount that the settlement paid the trader. Unit: base units of
            USDC (6 decimals), as a decimal string.
        priceKind:
          type:
            - string
            - 'null'
          description: >-
            The name of the price source that priced the settlement. Null when
            no price priced it.
        tick:
          description: >-
            The tick that priced the settlement. Null when the price source
            states no tick.
          anyOf:
            - $ref: '#/components/schemas/Tick'
            - type: 'null'
  responses:
    BadRequest:
      description: >-
        The request used a filter that this API refuses, or the path, the
        signature or `phase` is not valid. Fix the request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UriTooLong:
      description: The request URL is longer than 2,048 characters. Shorten it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    TooManyRequests:
      description: >-
        Too many requests. Wait `Retry-After` seconds, then retry. `GET
        /v0/health` states the limit under `access`.
      headers:
        Retry-After:
          description: 'Wait this long before you retry. Unit: seconds.'
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServerError:
      description: The server could not answer. Retry later.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'

````

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