Documentation Index
Fetch the complete documentation index at: https://docs.solanatracker.io/llms.txt
Use this file to discover all available pages before exploring further.
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.Plain terms: PnL means profit and loss. Realized PnL is from tokens already sold. Unrealized PnL is paper profit or loss on tokens still held. Cost basis is what the wallet paid for the current position.
Room Types
There are three rooms, each serving a different use case:| Room | What it emits | Use when |
|---|---|---|
pnl:{wallet}:{token} | tradeUpdate, balanceUpdate, priceUpdate for one token | You’re tracking one specific position |
pnl:{wallet} | tradeUpdate, balanceUpdate, priceUpdate for all tokens | You want live updates on every position a wallet holds |
pnl:{wallet}:summary | Total wallet PnL summary | You want aggregated wallet-level PnL totals |
PnL rooms emit
tradeUpdate on every fill and balanceUpdate on balance changes. They also emit priceUpdate events, but less frequently. Think of priceUpdate as a catch-up message for quiet positions, not as a fast price feed. For the fastest unrealized PnL ticks, pair PnL rooms with a price stream.Connecting
Room: pnl:{wallet}:{token}
Subscribe to a specific token position in a wallet. You’ll receive two message types:tradeUpdate — fires whenever a buy or sell is executed:
balanceUpdate — fires when the position value changes due to price movement (no new trade):
Subscribe example
Room: pnl:{wallet}
Subscribe to all token positions for a wallet at once. Emits the sametradeUpdate and balanceUpdate messages as above, but for every token the wallet interacts with — you don’t need to know the token addresses in advance.
Room: pnl:{wallet}:summary
Receive the wallet’s total PnL summary whenever the aggregate changes. This room returns wallet-level totals, not individual positions.Fastest Live Unrealized PnL — Combining Rooms
PnL rooms give you the official cost basis, FIFO realized PnL, and balance changes when a trade lands. FIFO means “first in, first out”: older buys are matched to sells first. PnL rooms are not designed to be a tick-by-tick price feed.priceUpdate events are throttled and only fill in for positions that have gone quiet for a while.
For a real-time portfolio UI where the unrealized PnL number updates on every price tick, combine the PnL room with a price stream:
| Stream | What it gives you |
|---|---|
pnl:{wallet} (or pnl:{wallet}:{token}) | Live cost basis, FIFO realized PnL, balance changes, trade fills |
price:aggregated:{token} | Fastest cross-pool price — best for high-liquidity tokens |
price-by-token:{token} | Price from the primary (highest-liquidity) pool — best for single-pool / low-liquidity tokens |
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)
PnL rooms emit priceUpdate as a backstop when a position’s quote hasn’t moved in a while. Treat it as a periodic refresh, not a real-time feed:
Unsubscribing
Leave any room by sending aleave message:
Choosing the Right Room
I'm tracking one specific position
I'm tracking one specific position
Use
pnl:{wallet}:{token}. Lowest noise — only fires for that token.I'm building a live portfolio dashboard
I'm building a live portfolio dashboard
Use
pnl:{wallet}. One subscription covers all positions. You get token-level detail on every update.I want a portfolio summary without per-token noise
I want a portfolio summary without per-token noise
Use
pnl:{wallet}:summary. It returns aggregated wallet-level PnL totals without per-token position rows.I want the fastest possible unrealized PnL ticks
I want the fastest possible unrealized PnL ticks
Combine
pnl:{wallet} (or pnl:{wallet}:{token}) with price:aggregated:{token} or price-by-token:{token}. PnL rooms own the cost basis and balance; price rooms drive the live tick. See Combining Rooms.Can I subscribe to multiple rooms at once?
Can I subscribe to multiple rooms at once?
Yes. Send multiple
join messages. Each room operates independently.Related Guides
PnL V2 Overview
Core PnL V2 concepts, endpoints, and how wallet indexing works.
Live Prices & Charts
price:aggregated and price-by-token rooms — pair these with PnL for live unrealized PnL.Wallet Analysis
Analyze wallet PnL, positions, trade timing, and exposure with the REST API.
Wallet Tracking
Combine live wallet activity with PnL streams for a real-time portfolio dashboard.