Skip to main content
WsUpdate is a tagged enum (#[serde(tag = "kind")]) defined in engine/core/src/websocket/events.rs. Five variants. No untyped escape hatch — if you can’t handle one, that’s a bug. Every event carries paired timestamps:
  • local_ts: Instant — monotonic, captured at socket-read (Rust only)
  • local_ts_ms: u64 — wall-clock millis paired with local_ts
  • exchange_ts: Option<u64> — exchange-authoritative millis (when provided)

Snapshot

A full L2 book. Replace any cached book keyed by (market_id, asset_id). Emitted on initial subscribe and after any recovery (Clear, BookInvalidated).
FieldType
market_idstring
asset_idstring
bookArc<Orderbook>
exchange_tsu64?
local_ts_msu64
sequ64

Delta

Incremental change to an existing book. Apply in place; discard if you’ve seen a Clear / BookInvalidated for this market without a follow-up Snapshot.
FieldType
market_idstring
asset_idstring
changesChangeVec (stack-allocated up to 4)
exchange_tsu64?
local_ts_msu64
sequ64
Each PriceLevelChange is { side: Bid | Ask, price: FixedPrice, size: f64 } with absolute-replacement semantics: size > 0 sets the level; size == 0 removes it.

Clear

Per-market book invalidation, on the same stream as Snapshot/Delta. A consumer can act inline: “drop everything ≤ this seq, wait for the next Snapshot.”
FieldType
market_idstring
asset_idstring
reasonInvalidationReason
local_ts_msu64
sequ64
InvalidationReason: Reconnect, Lag, SequenceGap { expected, received }, ExchangeReset.

Trade

A public trade on a subscribed market. Not tied to a local order. ActivityTrade payload:
FieldType
market_idstring
asset_idstring
trade_idstring?
pricef64
sizef64
sidestring?
aggressor_sidestring?
outcomestring? (e.g. "Yes" / "No")
fee_rate_bpsu32? (Polymarket last_trade_price events)
exchange_ts_msu64?
source_channelCow<'static, str>

Fill

A fill on one of your orders. ActivityFill payload:
FieldType
market_idstring
asset_idstring
fill_idstring?
order_idstring?
pricef64
sizef64
sidestring?
outcomestring?
tx_hashstring?
feef64?
liquidity_roleMaker | Taker | null
exchange_ts_msu64?
source_channelCow<'static, str>

Pattern matching (Python)

Snapshot, Delta, Trade, and Fill are real classes with __match_args__:
from openpx import Snapshot, Delta, Trade, Fill

for update in ws.updates():
    match update:
        case Snapshot(market_id, asset_id, book, exchange_ts, local_ts_ms, seq):
            ...
        case Delta(market_id, asset_id, changes, exchange_ts, local_ts_ms, seq):
            ...
        case Trade(trade, local_ts_ms):
            ...
        case Fill(fill, local_ts_ms):
            ...