PnL V2 Datastream is available on Premium, Business, and Enterprise plans.
Connect to
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; periodicpriceUpdate messages refresh its price-dependent values.
tradeUpdate reports a buy or sell:
balanceUpdate reports a position balance update:
Subscribe example
Room: pnl:{wallet}
Subscribe topnl:{wallet} for updates across a wallet’s positions. You do not need a separate PnL subscription for each mint.
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 topnl:{wallet} for trade and balance updates on every position, then dynamically subscribe to a price room for each token the wallet holds.
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 aleave message:
Related guides
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.