Skip to main content

Build a reliable monitoring loop

  1. Define required signals:
    • MARK_PRICE
    • ORDER_UPDATE
    • STRATEGY_UPDATE
    • TRADER_UPDATE
  2. Bootstrap baseline state from REST.
  3. Subscribe to realtime feeds with explicit filters.
  4. Persist updates with ordinal metadata.
  5. Run periodic REST reconciliation to detect missed updates.
  6. Alert on specific conditions:
    • rapid margin-fraction deterioration
    • repeated safety failures
    • liquidation or ADL events
    • sustained WebSocket reconnect loops

Persist the right ordering keys

Store enough metadata to rebuild a reliable event timeline after reconnects or worker restarts.
FieldWhy it matters
top-level ordinalpreserves message order on one live connection
globalOrdinalresumes one update family after reconnects
orderMatchOrdinalgroups multiple order outcomes from the same match
ORDER_UPDATE.ordinalorders individual outcomes within one match group
Do not compare globalOrdinal across different update families.

Reconcile WebSocket state with REST

  1. Bootstrap current orders, balances, and positions from REST before trusting live updates.
  2. Apply WebSocket messages in top-level ordinal order for that connection.
  3. On reconnect, resume one update family at a time with its own globalOrdinal.
  4. Rebuild grouped fills or liquidation outcomes with orderMatchOrdinal plus ORDER_UPDATE.ordinal.
  5. Periodically compare local balances, open orders, and strategy state against REST snapshots.

Treat these events as coupled, not isolated

TriggerMinimum interpretation
liquidationexpect both ORDER_UPDATE and STRATEGY_UPDATE effects
ADLexpect strategy-level resolution changes, not just a trade print
rejection spikesclassify by order, strategy, or trader domain before paging the wrong owner

Minimum alert set

  • Margin near maintenance threshold.
  • Order rejection spike by reason.
  • Insurance-fund-impacting liquidation outcomes.
  • Gap between local state and REST snapshot.

Next routes

Last modified on April 13, 2026