pub struct OrderBook {
pub bids: Vec<Level>,
pub asks: Vec<Level>,
}Expand description
An order-book depth snapshot.
Bids are stored best-first (strictly descending price); asks are stored
best-first (strictly ascending price). A valid book is non-empty on both
sides and uncrossed (best_bid < best_ask).
Fields§
§bids: Vec<Level>Bid levels, best (highest price) first.
asks: Vec<Level>Ask levels, best (lowest price) first.
Implementations§
Source§impl OrderBook
impl OrderBook
Sourcepub fn new(bids: Vec<Level>, asks: Vec<Level>) -> Result<Self>
pub fn new(bids: Vec<Level>, asks: Vec<Level>) -> Result<Self>
Construct an order book, validating the level and ordering invariants.
§Errors
Returns Error::InvalidOrderBook if either side is empty, any level
has a non-finite/non-positive price or non-finite/negative size, the
bids are not strictly descending in price, the asks are not strictly
ascending in price, or the book is crossed/locked (best_bid >= best_ask).
Sourcepub const fn new_unchecked(bids: Vec<Level>, asks: Vec<Level>) -> Self
pub const fn new_unchecked(bids: Vec<Level>, asks: Vec<Level>) -> Self
Construct an order book without validation. The caller asserts that all level and ordering invariants hold.
Sourcepub fn best_bid(&self) -> Option<Level>
pub fn best_bid(&self) -> Option<Level>
The best (highest-price) bid level, or None if the bid side is empty.
Trait Implementations§
impl StructuralPartialEq for OrderBook
Auto Trait Implementations§
impl Freeze for OrderBook
impl RefUnwindSafe for OrderBook
impl Send for OrderBook
impl Sync for OrderBook
impl Unpin for OrderBook
impl UnsafeUnpin for OrderBook
impl UnwindSafe for OrderBook
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more