Public prints for a spot market live on client.market_data (not client.trades, which is your
private fills). No authentication is required. Call await client.wait_for_catalogs() first;
quantity decoding fails closed when the market scale is unavailable.
Methods
| Method | Summary |
|---|---|
get_trades | Recent public trades, newest first. |
subscribe_trades | Live public tape for one symbol. |
Get trades
result = await client.market_data.get_trades(symbol="BTC-USDT", limit=20)
for t in result.trades:
print(t.match_id, t.is_buy, t.price, t.qty, t.ts_ns)
# Continue with the page token when present
if result.next_page_token:
more = await client.market_data.get_trades(
symbol="BTC-USDT",
limit=20,
page_token=result.next_page_token,
)| Field | Notes |
|---|---|
symbol / symbol_id | One required |
limit | Default 100 |
start_time / end_time | Optional range, inclusive |
side | Optional aggressor: buy / sell |
page_token | Opaque cursor |
after_trade_id | Backfill cursor; see below |
To backfill trades a live stream missed, walk by trade ID instead: oldest first and gap-free. Start
from after_trade_id=0 (or the last trade ID you hold) and pass each result's next_after_trade_id to the next call. Every trade up to complete_through_trade_id is returned, across trade-ID epoch
ends (epoch_ends). When next_after_trade_id equals the ID you sent, nothing newer is available
yet; retry later with backoff. after_trade_id cannot be combined with the time range, side, or
page token.
Subscribe trades
Handshake completes before return. Consume with async for.
subscription = await client.market_data.subscribe_trades(symbol="BTC-USDT")
async with subscription:
async for trade in subscription:
print(trade.price, trade.qty, trade.is_buy)
breakMarketTrade shape
symbol_id, match_id, is_buy, price, qty, ts_ns. Result wrapper: MarketTradesResult with trades, next_page_token, complete_through_trade_id, next_after_trade_id, and epoch_ends.
is_buy is a bool from the wire is_buy / isBuy field: True when the aggressor
(taker) side is buy, False when the aggressor is sell. MarketTrade has no separate side string.
REST and realtime attach the same hydrated catalog scale to qty. The SDK does not decode public
trade quantities using a guessed scale.
Related
- User trades for your private fills
- Market data guide
- Streaming