Skip to content

BinanceTrades

Turns Binance SPOT @trade frames into the public trade tape, published as world-scoped market data on the trade topics of the openspec pubsub-topics spec ("Public trade tape"). Built on Virtufin.MarketData.DevKit.

Property Value
Project Virtufin.Worker.BinanceTrades
Worker type binancetradetape
Base class Virtufin.MarketData.DevKit.MarketDataWorkerBase
Engine application/x-dotnet-dll
Input topic act.exchange.binance.trade.update (raw frames from WebSocketManager)
Output topic <world>.exchange.binance.trade.executed.<PAIR>
ce-type com.virtufin.exchange.binance.trade.executed
Payload { trade_id, price, qty, side, trade_time }

Behaviour

  • Trades only. A frame is published when e == "trade"; SUBSCRIBE acks and other frames are skipped without an error event.
  • Once per trade. The worker remembers the last published trade id per pair, so a redelivered or replayed frame is dropped. Ids are per symbol, so the dedupe is per pair.
  • Side. side is the aggressor: m (buyer is the maker) true → sell, false → buy.
  • Envelope. exchange=binance, marketworld, marketuniverse, clocktype, eventtime = ce-time = the trade time (T); no scenario extensions.

Config (CreateWorker config, as extension attributes)

Key Default Meaning
currencypairs required Comma-separated canonical pairs, e.g. BTC_USDT,ETH_USDT (maps Binance's BTCUSDT back to BTC_USDT)
world act act or hyp.<name> (topic prefix and marketworld)
venue binance Topic segment and exchange
marketuniverse ALL marketuniverse extension
clocktype wall for act, else historical clocktype extension

Deploy

  1. Trade feed (WebSocketManager, no worker): one connection to wss://stream.binance.com:9443/stream, subscribed to <symbol>@trade for every tracked pair, publishing to act.exchange.binance.trade.update (no routing: the frame names its own symbol in s).
  2. Worker: scripts/create_worker.py with this config (one instance covers every pair; add a second only over a disjoint currencypairs list, or both would publish each trade).

Trades are the highest-rate market data in the system -- BTC alone is 10-100/s. Anything folding them should set publishintervalms/saveintervalms (see the indicator workers), and consumers should expect a bursty topic.