AlpacaTrades
Turns Alpaca crypto 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"). The same canonical contract as BinanceTrades, so a
consumer does not care which venue produced the tape.
| Property | Value |
|---|---|
| Project | Virtufin.Worker.AlpacaTrades |
| Worker type | alpacatradetape |
| Base class | Virtufin.MarketData.DevKit.MarketDataWorkerBase |
| Engine | application/x-dotnet-dll |
| Input topic | act.exchange.alpaca.trade.update (raw frames from WebSocketManager) |
| Output topic | <world>.exchange.alpaca.trade.executed.<PAIR> |
| ce-type | com.virtufin.exchange.alpaca.trade.executed |
| Payload | { trade_id, price, qty, side, trade_time } |
Behaviour
- Trades only. Only messages with
T == "t"are published; Alpaca'ssuccess/subscriptionstatus messages, errors and other channels are skipped without an error event. - Arrays, several pairs per frame. Alpaca batches messages as a JSON array; one frame can carry trades for several symbols. Each is published on its own pair's topic.
- Once per trade. The last trade id per pair is remembered, so a redelivered
or replayed frame is dropped. Alpaca's
iis per symbol, so per-pair dedupe is correct. - Side.
tksnames the aggressor:B→buy,S→sell. - Envelope.
exchange=alpaca,marketworld,marketuniverse,clocktype,eventtime=ce-time= the trade time (t, nanoseconds); no scenario extensions.
Config (CreateWorker config, as extension attributes)
| Key | Default | Meaning |
|---|---|---|
currencypairs |
required | Comma-separated canonical pairs, e.g. BTC_USD,ETH_USD (maps Alpaca's BTC/USD back to BTC_USD) |
world |
act |
act or hyp.<name> (topic prefix and marketworld) |
venue |
alpaca |
Topic segment and exchange |
marketuniverse |
ALL |
marketuniverse extension |
clocktype |
wall for act, else historical |
clocktype extension |
Deploy
- Trade feed (WebSocketManager, no worker): one connection to Alpaca's
crypto stream with a handshake that logs in and subscribes to
{"action":"subscribe","trades":["BTC/USD",…]}--AlpacaHandshakewithchannels: trades(or an in-notebook handler). The frames go toact.exchange.alpaca.trade.update; no routing is needed, because the worker reads each message'sS. - Worker:
scripts/create_worker.pywith this config (one instance covers every pair; extra instances need disjointcurrencypairslists).
Trades are the highest-rate market data in the system; anything folding them
should set publishintervalms/saveintervalms (see the indicator workers).