Skip to main content

parse_ws_order_report

Function parse_ws_order_report 

Source
pub fn parse_ws_order_report(
    ws_order: &DydxWsOrderSubaccountMessageContents,
    instrument_cache: &InstrumentCache,
    order_contexts: &DashMap<u32, OrderContext>,
    encoder: &ClientOrderIdEncoder,
    account_id: AccountId,
    ts_init: UnixNanos,
) -> Result<OrderStatusReport>
Expand description

Parses a WebSocket order update into an OrderStatusReport.

Converts the WebSocket order format to the HTTP Order format, then delegates to the existing HTTP parser for consistency.

§Arguments

  • ws_order - The WebSocket order message to parse
  • instrument_cache - Cache for looking up instruments by clob_pair_id
  • order_contexts - Map of dYdX u32 client IDs to order contexts
  • encoder - Bidirectional encoder for ClientOrderId ↔ u32 mapping
  • account_id - Account ID for the report
  • ts_init - Timestamp for initialization

§Errors

Returns an error if:

  • clob_pair_id cannot be parsed from string.
  • Instrument lookup fails for the clob_pair_id.
  • Field parsing fails (price, size, etc.).
  • HTTP parser fails.