pub struct OrderBook { /* private fields */ }Expand description
Live order book for a single symbol.
Implementations§
Source§impl OrderBook
impl OrderBook
pub fn new(symbol: impl Into<String>) -> Self
Sourcepub fn apply(&mut self, delta: BookDelta) -> Result<(), StreamError>
pub fn apply(&mut self, delta: BookDelta) -> Result<(), StreamError>
Apply an incremental delta. quantity == 0 removes the level.
Sourcepub fn reset(
&mut self,
bids: Vec<PriceLevel>,
asks: Vec<PriceLevel>,
) -> Result<(), StreamError>
pub fn reset( &mut self, bids: Vec<PriceLevel>, asks: Vec<PriceLevel>, ) -> Result<(), StreamError>
Reset the book from a full snapshot.
Sourcepub fn best_bid(&self) -> Option<PriceLevel>
pub fn best_bid(&self) -> Option<PriceLevel>
Best bid (highest).
Sourcepub fn best_ask(&self) -> Option<PriceLevel>
pub fn best_ask(&self) -> Option<PriceLevel>
Best ask (lowest).
pub fn symbol(&self) -> &str
pub fn last_sequence(&self) -> Option<u64>
Sourcepub fn top_bids(&self, n: usize) -> Vec<PriceLevel>
pub fn top_bids(&self, n: usize) -> Vec<PriceLevel>
Top N bids (descending by price).
Sourcepub fn top_asks(&self, n: usize) -> Vec<PriceLevel>
pub fn top_asks(&self, n: usize) -> Vec<PriceLevel>
Top N asks (ascending by price).
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
Mutably borrows from an owned value. Read more