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

# Wallet P&L

> Get profit and loss for a wallet in USD. Supports time-windowed P&L with ?period=1d|7d|30d|1y plus tag, category, market, event, and condition filters.

Returns P\&L data for a wallet in USD. Without a time parameter, it returns the wallet's current all-time P\&L. With `period`, `after`, or `before`, it returns this boundary calculation across all matching positions:

```text theme={null}
time-window realized P&L = realized state at or before `before`
                         - realized state immediately before `after`
```

Both boundaries are inclusive. A state change timestamped exactly at `after` or `before` is included.

> [!NOTE]
>
> **Owner addresses.** Pass an owner EOA as the wallet address and the response combines the EOA's Polymarket wallets (Safe, proxy, deposit wallets) that have data for this endpoint. Passing a Safe, proxy or deposit wallet returns just that wallet, as before. Combined responses list the combined wallets in `wallets`. See [Owner addresses](https://docs.polynode.dev/data/overview.md#owner-addresses).

## Fees and accounting scope

For **standard spot market positions**, realized and unrealized P\&L exclude
separately reported trader-paid fees, rebates, and rewards. `net_realized_pnl`
means the combined realized gains and losses, not an after-fee return.
Use [Fees Paid](https://docs.polynode.dev/data/wallets/fees-paid.md), [Rebates](https://docs.polynode.dev/data/wallets/rebates.md), and
the optional [Wallet Summary accounting fields](https://docs.polynode.dev/data/wallets/summary.md) when
you need those separate amounts.

`include_combos=true` adds a component with different fee treatment:
[Combo P\&L](https://docs.polynode.dev/data/combos/leaderboard.md) includes each signed order's recorded
exchange fill fee in its cost basis or sale proceeds. That does not make the
standard spot component fee-inclusive. Perps has its own endpoint accounting
model; do not infer its fee or funding treatment from either component.

## Time-window behavior

The two modes have different counting semantics: all-time `wins` and `losses` are current position counts; time-windowed `wins`, `losses`, and the legacy `events` field count positions whose realized state changed. Time-windowed responses declare `count_type: "positions_changed"`. Do not compare the counts directly.

> [!WARNING]
>
> Time-windowed P\&L is a **realized-state change**, not a historical snapshot of the all-time leaderboard. It captures realized changes reflected by sells, merges, redemptions, and timestamped corrections. A buy-and-hold position can therefore contribute `0` to a window even if terminal treatment makes the resolved position profitable in current all-time P\&L. For the same reason, an `after=1&before=now` result is not expected to equal the all-time response or leaderboard total.

The boundary calculation uses Polynode's recovered Polymarket weighted-average-cost state. The difference is scope and timing, not a simpler cost-basis formula: all-time P\&L uses the current recovered portfolio state, including terminal treatment for resolved holdings and current unrealized P\&L, while a time window reports only the change in realized state across its boundaries.

> [!NOTE]
>
> Wallet P\&L supports focused market filters such as `category`, `tags`/`tag_slug`, `market`/`market_slug`, `event_slug`, and `condition_id`. For leaderboard views, use one primary filter dimension per request.

## Request

```
GET /v3/wallets/{address}/pnl
```

### Query parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `period` | string | -- | Time window: `1d`, `7d`, `30d`, `1y` |
| `after` | integer | -- | Start timestamp (Unix seconds). Time-windowed queries clamp values below `1` to `1`. |
| `before` | integer | -- | End timestamp (Unix seconds) |
| `category` | string | -- | Filter to one market category, case-insensitive |
| `tags` | string | -- | Comma-separated tag slugs to filter by, case-insensitive (e.g. `politics,crypto`, `nfl`, `Iran`) |
| `tag_slug` | string | -- | Alias for a single `tags` value |
| `market` | string | -- | Filter by condition ID or market slug |
| `market_slug` | string | -- | Filter by market slug |
| `event_slug` | string | -- | Filter by parent event slug |
| `condition_id` | string | -- | Filter by market condition ID |
| `include_unrealized` | string | `false` | Set to `true` to add current unrealized P\&L to the realized event-window result. This is the current value, not the change between the two requested boundaries. Only applies to time-filtered queries. |
| `include_combos` | boolean | `false` | Add combo position P\&L to all-time wallet P\&L. If the wallet has no combo exposure, the response remains 200 with a zero combo contribution. |

## Examples

### All-time P\&L

```bash theme={null}
curl https://api.polynode.dev/v3/wallets/0x56687bf447db6ffa42ffe2204a05edaa20f55839/pnl
```

### All-time P\&L including combos

```bash theme={null}
curl "https://api.polynode.dev/v3/wallets/0x63613e3b96f418332d43cd2af8dc321014d15907/pnl?include_combos=true"
```

```json theme={null}
{
  "address": "0x63613e3b96f418332d43cd2af8dc321014d15907",
  "net_realized_pnl": 113.510513,
  "realized_pnl": 113.510513,
  "gross_profit": 184.901354,
  "gross_loss": -71.390841,
  "unrealized_pnl": 0.0,
  "total_pnl": 113.510513,
  "position_count": 21496,
  "open_positions": 1495,
  "total_volume": 129.837476,
  "include_combos": true,
  "included_position_types": ["market", "combo"],
  "combo_pnl": {
    "position_type": "combo",
    "included": true,
    "realized_pnl": 113.510513,
    "unrealized_pnl": 0.0,
    "total_pnl": 113.510513,
    "position_count": 21492,
    "open_positions": 1495
  }
}
```

For time-windowed or tag-filtered P\&L, the response stays successful. If combo P\&L cannot be safely added to that filtered view, `combo_pnl.included` is `false` and the standard market P\&L fields remain unchanged.

```json theme={null}
{
  "address": "0x56687bf447db6ffa42ffe2204a05edaa20f55839",
  "net_realized_pnl": 22053845.825455,
  "gross_profit": 22057977.181649,
  "gross_loss": -4131.356194,
  "unrealized_pnl": 0.000688755,
  "total_pnl": 22053845.826143753,
  "position_count": 22,
  "open_positions": 1,
  "total_volume": 43013258.515682,
  "wins": 18,
  "losses": 4,
  "elapsed_ms": 41
}
```

### 30-day P\&L

```bash theme={null}
curl https://api.polynode.dev/v3/wallets/0xbddf61af533ff524d27154e589d2d7a81510c684/pnl?period=30d
```

```json theme={null}
{
  "address": "0xbddf61af533ff524d27154e589d2d7a81510c684",
  "realized_pnl": 1815261.28,
  "gross_profit": 1918402.27,
  "gross_loss": -103140.98,
  "wins": 33039,
  "losses": 58867,
  "events": 91906,
  "count_type": "positions_changed",
  "source": "recovered_realized_boundaries",
  "period": "30d",
  "after": 1776134996,
  "before": 1778726996,
  "elapsed_ms": 5902
}
```

### Filtered P\&L

```bash theme={null}
curl "https://api.polynode.dev/v3/wallets/0x952d11ebff81d6bd3185e608ed3515b94618ab8a/pnl?category=crypto"
curl "https://api.polynode.dev/v3/wallets/0x952d11ebff81d6bd3185e608ed3515b94618ab8a/pnl?tag_slug=us-election&period=30d"
curl "https://api.polynode.dev/v3/wallets/0x952d11ebff81d6bd3185e608ed3515b94618ab8a/pnl?market_slug=will-donald-trump-win-the-popular-vote-in-the-2024-presidential-election"
curl "https://api.polynode.dev/v3/wallets/0x952d11ebff81d6bd3185e608ed3515b94618ab8a/pnl?event_slug=presidential-election-popular-vote-winner-2024"
```

### 30-day P\&L with unrealized

Pass `include_unrealized=true` to add current unrealized P\&L to the realized-state change. This does not turn the response into a historical portfolio-value change between `after` and `before`.

```bash theme={null}
curl https://api.polynode.dev/v3/wallets/0xbddf61af533ff524d27154e589d2d7a81510c684/pnl?period=30d&include_unrealized=true
```

```json theme={null}
{
  "address": "0xbddf61af533ff524d27154e589d2d7a81510c684",
  "realized_pnl": 1815261.28,
  "gross_profit": 1918402.27,
  "gross_loss": -103140.98,
  "unrealized_pnl": 14714.71,
  "total_pnl": 1829975.99,
  "open_positions_at_date": 363,
  "wins": 33039,
  "losses": 58867,
  "events": 91906,
  "count_type": "positions_changed",
  "source": "recovered_realized_boundaries",
  "period": "30d",
  "after": 1776135002,
  "before": 1778727002,
  "elapsed_ms": 3803
}
```

## Response fields (all-time)

| Field | Type | Description |
| - | - | - |
| `net_realized_pnl` | number | Net realized P\&L (USD) |
| `gross_profit` | number | Sum of winning positions (USD) |
| `gross_loss` | number | Sum of losing positions (USD, negative) |
| `unrealized_pnl` | number | Paper P\&L from open positions (USD) |
| `total_pnl` | number | `net_realized_pnl + unrealized_pnl` (USD) |
| `wins` | integer | Winning position count |
| `losses` | integer | Losing position count |
| `position_count` | integer | Total positions |
| `open_positions` | integer | Currently held positions |
| `total_volume` | number | Total volume traded (USD) |
| `include_combos` | boolean | Present when `include_combos=true` was requested |
| `included_position_types` | array | Position families included in aggregate totals |
| `combo_pnl` | object | Combo-only contribution to the aggregate response |

## Response fields (with period)

| Field | Type | Description |
| - | - | - |
| `realized_pnl` | number | Weighted-average-cost realized state at `before` minus the state immediately before `after` (USD) |
| `gross_profit` | number | Sum of positive changed-position deltas in the window (USD) |
| `gross_loss` | number | Sum of negative changed-position deltas in the window (USD, negative) |
| `wins` | integer | Positions with a positive realized-state delta |
| `losses` | integer | Positions with a negative realized-state delta |
| `events` | integer | Legacy field name; total positions with a nonzero realized-state delta |
| `count_type` | string | `positions_changed` for time-windowed queries |
| `period` | string | The requested period |
| `after` | integer | Start timestamp (Unix seconds) |
| `before` | integer | End timestamp (Unix seconds) |
| `source` | string | Dataset label for time-windowed queries; currently `recovered_realized_boundaries` |

### Additional fields (with `include_unrealized=true`)

| Field | Type | Description |
| - | - | - |
| `unrealized_pnl` | number | Current unrealized P\&L for open positions (USD), not the change in unrealized P\&L between the requested boundaries. |
| `total_pnl` | number | `realized_pnl + unrealized_pnl` (USD) |
| `open_positions_at_date` | integer | Current open position count returned with the unrealized P\&L estimate |

### Owner address fields

Present only when you pass an owner EOA. See [Owner addresses](https://docs.polynode.dev/data/overview.md#owner-addresses).

| Field | Type | Description |
| - | - | - |
| `wallets` | array | The combined wallets, in a fixed order, each `{wallet, type}` with `type` one of `eoa`, `safe`, `proxy`, or `deposit_wallet` |

Totals and counts are summed across the combined wallets. With `period`, `after`, or `before`, every wallet uses the same window, and `address` stays the address you passed. With `include_combos=true`, `combo_pnl` is included only when it is available for every combined wallet; otherwise the response covers market positions only. A wallet whose P\&L is not loaded yet is left out of the combination and of `wallets`.

## Errors

| HTTP | Error | When |
| - | - | - |
| `400` | Invalid request | The wallet address, period, filter, or boundary is invalid |
| `503` | `time_filtered_pnl_unavailable` | The selected wallet and window exceed the serving deadline. Retry with a narrower window. The response includes `reason: "query_timeout"`. |


## OpenAPI

````yaml GET /v3/wallets/{address}/pnl
openapi: 3.1.0
info:
  title: PolyNode API
  description: >-
    Real-time Polymarket data API with decoded mempool settlements, OHLCV
    candles, and full Polygon JSON-RPC proxy.
  contact:
    name: PolyNode
    url: https://polynode.dev
  license:
    name: ''
  version: 2.0.0
servers:
  - url: https://api.polynode.dev
    description: Production
security:
  - api_key: []
paths:
  /v3/wallets/{address}/pnl:
    get:
      tags:
        - V3 Wallets
      summary: Wallet P&L
      description: >-
        Get wallet profit and loss. Default/all-time mode returns current
        portfolio P&L. Time-windowed mode returns weighted-average-cost realized
        state at the inclusive end boundary minus realized state immediately
        before the inclusive start boundary; it is not a historical
        all-time-portfolio snapshot. For standard spot market positions, P&L
        excludes separately reported trader-paid fees, rebates, and rewards;
        net_realized_pnl means combined realized gains and losses, not an
        after-fee return. Optional Combo P&L includes its own recorded exchange
        fill fee; this does not change the standard spot component.
      operationId: v3_wallet_pnl
      parameters:
        - name: address
          in: path
          required: true
          schema:
            type: string
          description: >-
            Wallet address, or an owner EOA to combine every Polymarket wallet
            it owns
        - name: period
          in: query
          schema:
            type: string
            enum:
              - 1d
              - 7d
              - 30d
              - 1y
          description: Time window shortcut
        - name: after
          in: query
          schema:
            type: integer
          description: >-
            Inclusive Unix timestamp lower bound; the realized-state baseline is
            taken immediately before this timestamp
        - name: before
          in: query
          schema:
            type: integer
          description: Inclusive Unix timestamp upper bound
        - name: include_unrealized
          in: query
          schema:
            type: boolean
            default: false
          description: >-
            Add current unrealized P&L to the time-windowed realized-state
            change; this is not the unrealized-P&L change between the requested
            boundaries
      responses:
        '200':
          description: Wallet P&L
          content:
            application/json:
              schema:
                type: object
                description: >-
                  Owner-address responses add the optional fields below. See the
                  page for the full response.
                properties:
                  wallets:
                    type: array
                    description: >-
                      Present only when you pass an owner EOA: the combined
                      wallets, in a fixed order.
                    items:
                      $ref: '#/components/schemas/OwnerWallet'
        '400':
          description: Invalid wallet address or query parameter
        '401':
          description: Unauthorized
        '503':
          description: >-
            Time-filtered P&L exceeded the serving deadline; retry a narrower
            window (`time_filtered_pnl_unavailable`, reason `query_timeout`)
      security:
        - api_key: []
components:
  schemas:
    OwnerWallet:
      type: object
      description: One wallet combined into an owner-address response.
      required:
        - wallet
        - type
      properties:
        wallet:
          type: string
          description: Wallet address, lowercased
        type:
          type: string
          enum:
            - eoa
            - safe
            - proxy
            - deposit_wallet
          description: Wallet type
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: x-api-key

````

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