Skip to main content
Use a PnL room to keep wallet totals or token positions current after loading a REST snapshot. Add a price room when the display needs unrealized PnL updates between trades.
PnL V2 Datastream is available on Premium, Business, and Enterprise plans.
Connect to wss://datastream.solanatracker.io/{apiKey} with your Data API key.

Room types

Choose whether the display needs one position, all positions, or wallet totals:
PnL rooms report trades with tradeUpdate, balance changes with balanceUpdate, and periodic valuations with priceUpdate. Add a price stream to update unrealized PnL between position events.

Connecting

Room: pnl:{wallet}:{token}

Subscribe to one wallet-token position. Trade and balance notifications update the position; periodic priceUpdate messages refresh its price-dependent values. tradeUpdate reports a buy or sell:
balanceUpdate reports a position balance update:

Subscribe example

Room: pnl:{wallet}

Subscribe to pnl:{wallet} for updates across a wallet’s positions. You do not need a separate PnL subscription for each mint.
Use pnl:{wallet} when building a live portfolio dashboard — you only need one room subscription per wallet.

Room: pnl:{wallet}:summary

Receive the wallet’s total PnL summary whenever the aggregate changes. This room returns wallet-level totals, not individual positions.

Update unrealized PnL with price streams

Use PnL room values for cost basis, realized PnL, and token balance. A separate price stream can update the valuation between position events. To update unrealized PnL on price ticks, pair the position room with one of these price rooms: Use the PnL room as the source of truth for currentBalance and holdingCostBasis, and recompute unrealizedPnl = (currentBalance × livePrice) − holdingCostBasis whenever a price tick arrives.

Example: live unrealized PnL on a single position

Example: live unrealized PnL across an entire wallet

Subscribe to pnl:{wallet} for trade and balance updates on every position, then dynamically subscribe to a price room for each token the wallet holds.
Price streams can update often. In production, batch UI updates or throttle logs so every price tick does not flood your console or browser.
Choose a price source
  • price:aggregated:{token} — Cross-pool median price.
  • price-by-token:{token} — primary-pool price. Slightly lower latency for memecoins or anything that effectively trades on a single pool.

priceUpdate payload (PnL room)

A PnL priceUpdate is a periodic position refresh. Its cadence differs from the dedicated price streams:

Unsubscribing

Leave any room by sending a leave message:

PnL guides

Core PnL V2 concepts, endpoints, and how wallet indexing works.

Live prices

price:aggregated and price-by-token rooms — pair these with PnL for live unrealized PnL.

Wallet PnL

Analyze wallet PnL, positions, trade timing, and exposure with the REST API.

Holdings and trades

Combine live wallet activity with PnL streams for a real-time portfolio dashboard.