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

# All Positions

> All positions (open and closed) for a wallet or cohort, grouped by event; the nested positions field carries the per-position breakdown.



## OpenAPI

````yaml /openapi.json post /api/v1/positions/all
openapi: 3.0.3
info:
  title: DataDash Analytics API
  version: 1.0.0
servers: []
security:
  - ApiKeyAuth: []
  - BearerAuth: []
paths:
  /api/v1/positions/all:
    post:
      tags:
        - Positions
      summary: All Positions
      description: >-
        All positions (open and closed) for a wallet or cohort, grouped by
        event; the nested positions field carries the per-position breakdown.
      operationId: listPositionsAll
      requestBody:
        content:
          application/json:
            schema:
              properties:
                filter:
                  $ref: '#/components/schemas/AllPositionFilter'
                orderBy:
                  description: >-
                    Sort keys in priority order; the first is the primary sort.
                    Defaults to the table's configured ranking when omitted.
                  items:
                    properties:
                      direction:
                        default: asc
                        enum:
                          - asc
                          - desc
                        type: string
                      field:
                        enum:
                          - eventId
                          - shares
                          - avgBuyPrice
                          - exitPrice
                          - invested
                          - pnl
                          - roi
                          - marketClosed
                          - unrealizedShares
                          - unrealizedPnl
                          - positions
                        type: string
                    required:
                      - field
                    type: object
                  type: array
                page:
                  $ref: '#/components/schemas/PageInput'
                searchKey:
                  description: >-
                    Free-text search over: Event (embedding + full-text
                    relevance).
                  type: string
              required:
                - page
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/AllPositionRow'
                type: array
          description: List of All Positions rows
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            invalid request (malformed body, unknown field, or failed
            validation)
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: missing or invalid credentials
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: credentials lack access to this resource
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: internal error
components:
  schemas:
    AllPositionFilter:
      description: Filters to apply, combined with AND. Use a group for OR.
      items:
        $ref: '#/components/schemas/AllPositionFilterNode'
      minItems: 1
      type: array
    PageInput:
      properties:
        limit:
          minimum: 1
          type: integer
        offset:
          minimum: 0
          type: integer
      required:
        - limit
      type: object
    AllPositionRow:
      properties:
        avgBuyPrice:
          description: Average buying price of the shares
          format: double
          title: Avg Buy Price
          type: number
        eventId:
          description: Parent event
          format: int32
          title: Event
          type: integer
        exitPrice:
          description: Average selling price
          format: double
          title: Exit Price
          type: number
        invested:
          description: Total USD amount invested in the position.
          format: double
          title: Invested
          type: number
        marketClosed:
          description: Market Closed
          title: Market Closed
          type: boolean
        pnl:
          description: Total profit and loss
          format: double
          title: Pnl
          type: number
        positions:
          description: >
            Per-position breakdown within the event, bought, bought shares, avg
            buy price, pnl,

            realized/unrealized pnl and roi, summed across every matching wallet
            (so a position held

            by N cohort users collapses to one entry). Serialized as a JSON
            array of objects.
          items:
            properties:
              avgBuyPrice:
                format: double
                type: number
              bought:
                format: double
                type: number
              boughtShares:
                format: double
                type: number
              pnl:
                format: double
                type: number
              positionId:
                format: int32
                type: integer
              realizedPnl:
                format: double
                type: number
              roi:
                format: double
                type: number
              unrealizedPnl:
                format: double
                type: number
              unrealizedShares:
                format: double
                type: number
            type: object
          title: Positions
          type: array
        roi:
          description: Return on investment percentage
          format: double
          title: Roi
          type: number
        shares:
          description: Total shares bought
          format: double
          title: Shares
          type: number
        unrealizedPnl:
          description: Unrealized profit and loss for currently held shares
          format: double
          title: Unrealized Pnl
          type: number
        unrealizedShares:
          description: Number of currently held shares
          format: double
          title: Unrealized Shares
          type: number
      type: object
    Error:
      properties:
        code:
          description: machine-readable error code
          type: string
        message:
          description: human-readable description
          type: string
      required:
        - code
        - message
      type: object
    AllPositionFilterNode:
      description: A single condition, or a group combining conditions with AND/OR.
      oneOf:
        - $ref: '#/components/schemas/AllPositionCondition'
        - $ref: '#/components/schemas/AllPositionFilterGroup'
    AllPositionCondition:
      description: >-
        A single field condition. in/notIn take an array of values;
        matches/notMatches take one search term.
      oneOf:
        - $ref: '#/components/schemas/AllPositionNumericCondition'
        - $ref: '#/components/schemas/AllPositionIdCondition'
        - $ref: '#/components/schemas/AllPositionAddressCondition'
        - $ref: '#/components/schemas/AllPositionBooleanCondition'
    AllPositionFilterGroup:
      description: >-
        A group of conditions and nested groups, combined with the group's
        operator.
      properties:
        filters:
          items:
            oneOf:
              - $ref: '#/components/schemas/AllPositionCondition'
              - $ref: '#/components/schemas/AllPositionFilterInnerGroup'
          minItems: 1
          type: array
        operator:
          enum:
            - AND
            - OR
          type: string
      required:
        - operator
        - filters
      type: object
    AllPositionNumericCondition:
      properties:
        field:
          enum:
            - shares
            - invested
            - pnl
            - unrealizedShares
            - unrealizedPnl
            - entryPrice
            - exitPriceFilter
          type: string
        operator:
          enum:
            - eq
            - neq
            - lt
            - lte
            - gt
            - gte
          type: string
        value:
          oneOf:
            - format: double
              type: number
            - items:
                format: double
                type: number
              minItems: 1
              type: array
      required:
        - field
        - operator
        - value
      type: object
    AllPositionIdCondition:
      properties:
        field:
          enum:
            - positionId
            - marketId
            - eventId
            - tagIds
          type: string
        operator:
          enum:
            - in
            - notIn
          type: string
        value:
          oneOf:
            - format: int32
              type: integer
            - items:
                format: int32
                type: integer
              minItems: 1
              type: array
      required:
        - field
        - operator
        - value
      type: object
    AllPositionAddressCondition:
      description: inCohort/notInCohort take cohort ids instead of addresses.
      properties:
        field:
          enum:
            - userId
          type: string
        operator:
          enum:
            - in
            - notIn
            - matches
            - notMatches
            - inCohort
            - notInCohort
          type: string
        value:
          oneOf:
            - type: string
            - items:
                type: string
              minItems: 1
              type: array
      required:
        - field
        - operator
        - value
      type: object
    AllPositionBooleanCondition:
      properties:
        field:
          enum:
            - marketClosed
          type: string
        operator:
          enum:
            - eq
          type: string
        value:
          type: boolean
      required:
        - field
        - operator
        - value
      type: object
    AllPositionFilterInnerGroup:
      description: >-
        A nested group. Its members must be conditions, which bounds grouping at
        two levels.
      properties:
        filters:
          items:
            $ref: '#/components/schemas/AllPositionCondition'
          minItems: 1
          type: array
        operator:
          enum:
            - AND
            - OR
          type: string
      required:
        - operator
        - filters
      type: object
  securitySchemes:
    ApiKeyAuth:
      description: API key issued for programmatic access.
      in: header
      name: X-Api-Key
      type: apiKey
    BearerAuth:
      bearerFormat: JWT
      description: User access token.
      scheme: bearer
      type: http

````