Build a reliable monitoring loop
- Define required signals:
MARK_PRICEORDER_UPDATESTRATEGY_UPDATETRADER_UPDATE
- Bootstrap baseline state from REST.
- Subscribe to realtime feeds with explicit filters.
- Persist updates with ordinal metadata.
- Run periodic REST reconciliation to detect missed updates.
- 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.| Field | Why it matters |
|---|---|
top-level ordinal | preserves message order on one live connection |
globalOrdinal | resumes one update family after reconnects |
orderMatchOrdinal | groups multiple order outcomes from the same match |
ORDER_UPDATE.ordinal | orders individual outcomes within one match group |
globalOrdinal across different update families.
Reconcile WebSocket state with REST
- Bootstrap current orders, balances, and positions from REST before trusting live updates.
- Apply WebSocket messages in top-level
ordinalorder for that connection. - On reconnect, resume one update family at a time with its own
globalOrdinal. - Rebuild grouped fills or liquidation outcomes with
orderMatchOrdinalplusORDER_UPDATE.ordinal. - Periodically compare local balances, open orders, and strategy state against REST snapshots.
Treat these events as coupled, not isolated
| Trigger | Minimum interpretation |
|---|---|
| liquidation | expect both ORDER_UPDATE and STRATEGY_UPDATE effects |
| ADL | expect strategy-level resolution changes, not just a trade print |
| rejection spikes | classify 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.