Skip to main content

parse_runner_book_deltas

Function parse_runner_book_deltas 

Source
pub fn parse_runner_book_deltas(
    instrument_id: InstrumentId,
    rc: &RunnerChange,
    is_snapshot: bool,
    sequence: u64,
    ts_event: UnixNanos,
    ts_init: UnixNanos,
) -> Result<Option<OrderBookDeltas>>
Expand description

Parses a single runner’s book data into [OrderBookDeltas].

Handles both full image snapshots (is_snapshot = true) and delta updates.

Only processes price-keyed fields (atb/atl). Level-indexed fields (batb/batl/bdatb/bdatl) are ignored because correct delta processing requires stateful level-to-price tracking. The stream subscription should use EX_ALL_OFFERS which populates atb/atl.

Book side mapping (Betfair exchange convention):

  • atb (available to back) -> [OrderSide::Buy] (bid side)
  • atl (available to lay) -> [OrderSide::Sell] (ask side)

For snapshots: emits a Clear delta followed by Add deltas for each level. For updates: emits Update or Delete (when volume is zero) deltas.

Returns Ok(None) if the runner change contains no processable book data.

§Errors

Returns an error if price or quantity values cannot be converted.