pub struct Orderbook {
pub symbol: Symbol,
pub bids: BTreeMap<Decimal, Decimal>,
pub asks: BTreeMap<Decimal, Decimal>,
}
Expand description
Represents the current state of the orderbook, guaranteed to be accurate up to the best 100 bids and best 100 asks since the latest update. Supports efficient insertions, updates, and deletions via a BTreeMap.
Fields§
§symbol: Symbol
§bids: BTreeMap<Decimal, Decimal>
§asks: BTreeMap<Decimal, Decimal>
Implementations§
Source§impl Orderbook
impl Orderbook
pub fn new(symbol: Symbol) -> Orderbook
pub fn update(&mut self, data: &OrderbookData)
pub fn verify_checksum(&self, checksum: u32) -> bool
Sourcepub fn mid_price(&self) -> Option<Decimal>
pub fn mid_price(&self) -> Option<Decimal>
Returns the midpoint between the best bid price and best ask price. Output is not rounded to the smallest price increment.
Sourcepub fn best_bid(&self) -> Option<(Decimal, Decimal)>
pub fn best_bid(&self) -> Option<(Decimal, Decimal)>
Returns the price and quantity of the best bid (bid_price, bid_quantity)
Sourcepub fn best_ask(&self) -> Option<(Decimal, Decimal)>
pub fn best_ask(&self) -> Option<(Decimal, Decimal)>
Returns the price and quantity of the best ask (ask_price, ask_quantity)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Orderbook
impl<'de> Deserialize<'de> for Orderbook
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Orderbook
impl RefUnwindSafe for Orderbook
impl Send for Orderbook
impl Sync for Orderbook
impl Unpin 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