#[repr(C)]pub struct L2Book {
pub bids: [Level; 20],
pub asks: [Level; 20],
pub bid_ct: u8,
pub ask_ct: u8,
pub symbol_id: u16,
pub _pad: u32,
pub recv_ns: u64,
}Expand description
L2 order book with up to 20 levels per side. Total size: 688 bytes (fits in L1 cache).
Fields§
§bids: [Level; 20]§asks: [Level; 20]§bid_ct: u8§ask_ct: u8§symbol_id: u16§_pad: u32§recv_ns: u64Implementations§
Source§impl L2Book
impl L2Book
pub fn best_bid(&self) -> Option<&Level>
pub fn best_ask(&self) -> Option<&Level>
pub fn mid_px_1e9(&self) -> u64
Sourcepub fn spread_1e9(&self) -> u64
pub fn spread_1e9(&self) -> u64
Raw unsigned spread in 1e9 price units.
Returns 0 for crossed books (ask < bid) due to saturating_sub.
Use spread_signed_1e9() or is_crossed() for proper handling.
Sourcepub fn spread_signed_1e9(&self) -> i64
pub fn spread_signed_1e9(&self) -> i64
Signed spread in 1e9 price units. Negative = crossed book.
Sourcepub fn spread_bps(&self) -> u32
pub fn spread_bps(&self) -> u32
Spread in integer basis points (truncated).
WARNING: Returns 0 for sub-bps spreads common on liquid assets (BTC, ETH).
Use spread_bps_x1000() for milli-bps precision on liquid markets.
Sourcepub fn spread_bps_x1000(&self) -> i32
pub fn spread_bps_x1000(&self) -> i32
Spread in milli-basis-points (1 bps = 1000 milli-bps), signed. Handles sub-bps precision for liquid markets and negative values for crossed books. Uses u128 intermediate to avoid overflow on high-priced assets.
Sourcepub fn is_crossed(&self) -> bool
pub fn is_crossed(&self) -> bool
Whether the book is crossed (best bid > best ask). Common in consolidated NBBO when different venues have different prices.