Fetch and analyze on-chain wallet activity to compute cost basis, current position value, and distinguish between active traders and infrastructure/escrow wallets.
price: Price per share (decimal string, 0-1 range)
timestamp: Unix timestamp (seconds)
Use --limit 500 to get sufficient history. Large traders may need multiple paginated requests.
2
Filter to target market
Filter trades by condition_id to isolate activity for your market of interest:
target_condition = "0x0f49db97f71c68b1e42a6d16e3de93d85dbf7d4148e3f018eb79e88554be9f75"market_trades = [t for t in trades if t["condition_id"] == target_condition]
3
Separate BUY and SELL trades
Split trades by side:
buys = [t for t in market_trades if t["side"] == "BUY"]sells = [t for t in market_trades if t["side"] == "SELL"]
For cost-basis analysis, you’ll primarily use BUY trades.
4
Compute cost basis metrics
Calculate the wallet’s position:
# Total cost (in dollars)total_cost = sum(float(t["size"]) * float(t["price"]) for t in buys)# Total shares purchasedtotal_shares = sum(float(t["size"]) for t in buys)# Average entry priceavg_price = total_cost / total_shares if total_shares > 0 else 0# Current position (if no sells yet)shares_held = total_shares - sum(float(t["size"]) for t in sells)
This assumes all shares are still held. For partial exits, subtract SELL volumes from total_shares.
5
Calculate current value and ROI
Fetch the current market price and compute position value:
polymarket -o json markets get <market-slug>
Extract the current price (e.g., 0.28 for 28%), then:
Not all large wallets are traders. Polymarket uses infrastructure wallets for escrow, collateral management, and neg-risk CTF splits. Here’s how to identify them:
polymarket -o json data trades 0xa5Ef39C3D3e10d0B270233af41CaC69796B12966 --limit 500# Returns: []polymarket data value 0xa5Ef39C3D3e10d0B270233af41CaC69796B12966# Returns: ~$11.9B
This wallet is Polymarket’s neg-risk escrow contract, not a bettor.
Large holder ≠ big trader. Always check trade history before assuming a wallet is taking a directional bet. Infrastructure wallets can appear at the top of holder lists.
Use --limit 1000 or paginate if analyzing very active wallets. The default limit may truncate history.
To find the biggest active traders (not infrastructure), filter holders by:
Trade history is public on-chain data. You’re analyzing public addresses, which may include smart contracts, aggregators, or privacy-preserving protocols.
Partial exits are not automatically tracked. If the wallet sold some shares, you must manually subtract SELL volumes from the position.
Market makers and LPs may have high trade volumes but no directional bias. Check if BUY and SELL volumes are roughly balanced.