Skip to content

Spec drift: polymarket_us — unrealized PnL hardcoded to 0, cashValue field available but unmapped #533

@realfishsam

Description

@realfishsam

Summary

The Polymarket US adapter returns unrealizedPnl: 0 as a hardcoded constant for all positions. The polymarket-us SDK provides a cashValue field on position objects that represents the current mark-to-market value, from which unrealized PnL can be computed. This data is available but not mapped.

Impact

MEDIUM — all Polymarket US positions show zero unrealized P&L in PMXT, making the account view misleading for active positions.

Details

  • Hardcoded value: unrealizedPnl: 0 in core/src/exchanges/polymarket_us/index.ts
  • Available data: position.cashValue from the polymarket-us SDK — the mark-to-market value of the position
  • Unrealized PnL calculation: cashValue - (avgPrice * size) or as directly provided by the SDK if it exposes a unrealizedPnl field
  • Check the polymarket-us npm package for whether it exposes unrealizedPnl directly or only cashValue

Required Fix

  1. Check the polymarket-us SDK position object for an unrealizedPnl or equivalent field
  2. If available directly, map it instead of hardcoding 0
  3. If not directly available, compute from cashValue and position cost basis (avgPrice * size)
  4. Remove the hardcoded unrealizedPnl: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    spec-driftCached OpenAPI spec out of date vs venue's live docs

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions