pub async fn order_book_snapshot<M: OrderBookSource + ?Sized>(
md: &M,
id: &InstrumentId,
depth: u32,
)Expand description
REST order book: the right instrument, the asked depth, sorted best-first, not crossed.
Checks on md.order_book(id, depth):
- the call succeeds and returns [
brokapi_core::OrderBook::Snapshot] (not an increment); - the book is for the requested instrument (same [
brokapi_core::InstrumentKey]); - both sides have at least one level;
- neither side has more than
depthlevels; - bids are sorted from the highest price, asks from the lowest (equal neighbours pass);
- the best bid is strictly below the best ask.
The mock must serve both sides for id and respect depth.
§Panics
With [conformance:order_book_snapshot] <reason> when a check fails or order_book returns an error.
§Examples
brokapi_conformance::order_book_snapshot(&md, &sber, 20).await;A scenario that fails stops the test with its name and the reason. Depth 0 is something no book can satisfy, so this one panics:
ⓘ
// panics with a message that starts with [conformance:order_book_snapshot]
brokapi_conformance::order_book_snapshot(&md, &sber, 0).await;