Skip to main content

parse_book_deltas

Function parse_book_deltas 

Source
pub fn parse_book_deltas(
    book: &Book,
    instrument: &InstrumentAny,
) -> Result<Option<OrderBookDeltas>>
Expand description

Converts a full L2 book snapshot or update into deltas, taking ts_event from time_exchange and ts_init from time_coinapi.

A snapshot becomes a Clear followed by an Add per level, every delta flagged F_SNAPSHOT; an empty snapshot is a lone Clear. An update sets each listed level to its new size, and a zero size removes the level. The last delta carries F_LAST, and an update listing no levels returns None.

ยงErrors

Returns an error if a level is finer than the instrument precision, a snapshot level has zero size, or a timestamp is invalid; a single invalid level rejects the whole message.