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

# Get portfolio analytics

> Returns allocation, per-asset performance, trading statistics, and the
24-hour change in total PnL. Contribution changes are excluded from the
24-hour figure so deposits and withdrawals do not look like performance.
Requires the `ACCOUNT_READ` scope.




## OpenAPI

````yaml /openapi.yaml get /portfolio/analytics
openapi: 3.1.0
info:
  title: PaperDrill REST API
  version: 1.0.0
  description: >
    Trade PaperDrill credit markets and read live market data.


    Prices, quantities, balances, and other decimal values are encoded as
    strings so clients do not lose precision.
servers:
  - url: https://api.paperdrill.dev/v1
    description: Production
security: []
tags:
  - name: Market data
    description: Public markets, tickers, candles, trades, and order-book snapshots.
  - name: Trading
    description: Create, inspect, and cancel orders with a scoped API key.
  - name: Account
    description: Read balances, portfolio performance, and private trade history.
  - name: Leaderboard
    description: Live public standings and your personal ranking.
  - name: Rewards
    description: >-
      Starter and daily simulated-fund credit status and claims for signed-in
      users.
paths:
  /portfolio/analytics:
    get:
      tags:
        - Account
      summary: Get portfolio analytics
      description: |
        Returns allocation, per-asset performance, trading statistics, and the
        24-hour change in total PnL. Contribution changes are excluded from the
        24-hour figure so deposits and withdrawals do not look like performance.
        Requires the `ACCOUNT_READ` scope.
      operationId: getPortfolioAnalytics
      responses:
        '200':
          description: Portfolio analytics returned successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PortfolioAnalytics'
        '503':
          $ref: '#/components/responses/PortfolioUnavailable'
        default:
          $ref: '#/components/responses/RequestError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    PortfolioAnalytics:
      type: object
      required:
        - quoteAsset
        - asOf
        - source
        - partial
        - equity
        - cash
        - positionsValue
        - costBasis
        - realizedPnl
        - unrealizedPnl
        - netContributions
        - totalPnl
        - totalPnlPercent
        - allocation
        - cashAllocationPercent
        - performance
        - bestAsset
        - worstAsset
        - trading
        - change24h
      properties:
        quoteAsset:
          type: string
        asOf:
          type: string
          format: date-time
        source:
          type: string
          enum:
            - live
            - projection
            - engine
        partial:
          type: boolean
        equity:
          $ref: '#/components/schemas/DecimalString'
        cash:
          $ref: '#/components/schemas/DecimalString'
        positionsValue:
          $ref: '#/components/schemas/DecimalString'
        costBasis:
          $ref: '#/components/schemas/NullableDecimalString'
        realizedPnl:
          $ref: '#/components/schemas/NullableSignedDecimalString'
        unrealizedPnl:
          $ref: '#/components/schemas/NullableSignedDecimalString'
        netContributions:
          $ref: '#/components/schemas/NullableDecimalString'
        totalPnl:
          $ref: '#/components/schemas/NullableSignedDecimalString'
        totalPnlPercent:
          $ref: '#/components/schemas/NullableSignedDecimalString'
        allocation:
          type: array
          description: Open positions sorted by value, largest first.
          items:
            $ref: '#/components/schemas/PortfolioAllocationEntry'
        cashAllocationPercent:
          $ref: '#/components/schemas/NullableDecimalString'
        performance:
          type: array
          description: Traded assets sorted by total PnL, best first.
          items:
            $ref: '#/components/schemas/PortfolioPerformanceEntry'
        bestAsset:
          oneOf:
            - $ref: '#/components/schemas/PortfolioPerformanceEntry'
            - type: 'null'
        worstAsset:
          oneOf:
            - $ref: '#/components/schemas/PortfolioPerformanceEntry'
            - type: 'null'
        trading:
          type: object
          required:
            - events
            - buys
            - sells
            - winningSells
            - losingSells
            - winRate
            - realizedPnl
            - firstTradeAt
            - lastTradeAt
          properties:
            events:
              type: integer
            buys:
              type: integer
            sells:
              type: integer
            winningSells:
              type: integer
            losingSells:
              type: integer
            winRate:
              $ref: '#/components/schemas/NullableDecimalString'
            realizedPnl:
              $ref: '#/components/schemas/NullableSignedDecimalString'
            firstTradeAt:
              oneOf:
                - type: string
                  format: date-time
                - type: 'null'
            lastTradeAt:
              oneOf:
                - type: string
                  format: date-time
                - type: 'null'
        change24h:
          oneOf:
            - type: object
              required:
                - from
                - change
                - changePercent
              properties:
                from:
                  type: string
                  format: date-time
                change:
                  $ref: '#/components/schemas/SignedDecimalString'
                changePercent:
                  $ref: '#/components/schemas/SignedDecimalString'
            - type: 'null'
          description: Change in total PnL over 24 hours, excluding contributions.
    DecimalString:
      type: string
      pattern: ^\d+(\.\d+)?$
      description: A non-negative decimal encoded as a string.
      example: '125.50'
    NullableDecimalString:
      oneOf:
        - $ref: '#/components/schemas/DecimalString'
        - type: 'null'
    NullableSignedDecimalString:
      oneOf:
        - $ref: '#/components/schemas/SignedDecimalString'
        - type: 'null'
    PortfolioAllocationEntry:
      type: object
      required:
        - asset
        - symbol
        - value
        - percent
      properties:
        asset:
          type: string
        symbol:
          oneOf:
            - type: string
            - type: 'null'
        value:
          $ref: '#/components/schemas/DecimalString'
        percent:
          $ref: '#/components/schemas/NullableDecimalString'
    PortfolioPerformanceEntry:
      type: object
      required:
        - asset
        - symbol
        - costBasis
        - realizedPnl
        - unrealizedPnl
        - totalPnl
        - totalPnlPercent
        - tradeCount
        - open
      properties:
        asset:
          type: string
        symbol:
          oneOf:
            - type: string
            - type: 'null'
        costBasis:
          $ref: '#/components/schemas/NullableDecimalString'
        realizedPnl:
          $ref: '#/components/schemas/NullableSignedDecimalString'
        unrealizedPnl:
          $ref: '#/components/schemas/NullableSignedDecimalString'
        totalPnl:
          $ref: '#/components/schemas/NullableSignedDecimalString'
        totalPnlPercent:
          $ref: '#/components/schemas/NullableSignedDecimalString'
        tradeCount:
          oneOf:
            - type: integer
            - type: 'null'
        open:
          type: boolean
          description: True while the position has quantity remaining.
    SignedDecimalString:
      type: string
      pattern: ^[+-]?\d+(\.\d+)?$
      description: A signed decimal encoded as a string.
      example: '+3.40'
    ApiError:
      type: object
      required:
        - error
        - requestId
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
            details:
              type: array
              items:
                $ref: '#/components/schemas/ApiErrorDetail'
        requestId:
          type: string
          format: uuid
      example:
        error:
          code: VALIDATION_ERROR
          message: Request validation failed
          details:
            - field: qty
              message: invalid decimal format
        requestId: f4c0baf4-b8d2-4c9a-a17b-c8656c4a7b0e
    ApiErrorDetail:
      type: object
      required:
        - message
      properties:
        field:
          type: string
        message:
          type: string
  responses:
    PortfolioUnavailable:
      description: Portfolio valuation is temporarily unavailable.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    RequestError:
      description: The request failed. See Errors and rate limits for recovery guidance.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: A scoped API key created in the PaperDrill dashboard.

````

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