Skip to main content
The trades channel streams every public trade for a contract — regardless of which account was involved. Each push message contains an array of one or more trade objects, all of which executed in the same block. If you only care about fills from your own account, use the userFills channel instead.

Subscribing

Replace "1" with the numeric contract ID whose trade stream you want to receive.

Push message format

Multiple trade objects may appear in the data array when several trades execute within the same block. Process them in array order.

Trade object fields

string
Contract ID. Matches the asset in your subscription.
string
Trade execution price (raw string). Apply the contract’s decimal precision before displaying to users.
string
Trade size (raw string). This is the notional quantity that changed hands at px.
string
Indicates which side initiated the trade. "B" means the buyer was the aggressor (taker); "S" means the seller was the aggressor (taker).
number
Globally unique trade ID assigned on-chain. Use this to deduplicate trades if you receive the same block’s data from multiple sources.
number
Reserved field; currently 0. Use the outer ts field on the envelope for event timing.

Outer envelope fields

number
Server send timestamp in Unix milliseconds. Use this as the authoritative timestamp for all trades in the data array.

Building a trade history feed

1

Subscribe to receive the live stream

Send the subscribe message. The server starts pushing trades from the moment of subscription. There is no backfill on subscribe.
2

Bootstrap history from candleSnapshot

To display historical trades or fill in chart data, call the REST candleSnapshot endpoint before or alongside subscribing. This gives you aggregated OHLCV history, and the WebSocket stream picks up from the current point in time.
3

Deduplicate using tid

If you consume trades from multiple sources (e.g., a REST snapshot and the WebSocket stream), use the tid field as the unique key to avoid counting the same trade twice.
The trades channel pushes from subscription time only — there is no historical backfill. Use candleSnapshot via the REST API to retrieve historical OHLCV data for chart initialisation.
To build a volume-weighted average price (VWAP) over a rolling window, accumulate px × sz from incoming trade messages, divide by the rolling total sz, and reset the window at your chosen interval.