pub struct OrderBook {
pub instrument_name: String,
pub timestamp: i64,
pub bids: Vec<OrderBookEntry>,
pub asks: Vec<OrderBookEntry>,
pub change_id: u64,
pub prev_change_id: Option<u64>,
}Expand description
Order book data
Fields§
§instrument_name: StringInstrument name
timestamp: i64Timestamp of the order book
bids: Vec<OrderBookEntry>Bid levels (sorted by price descending)
asks: Vec<OrderBookEntry>Ask levels (sorted by price ascending)
change_id: u64Change ID for incremental updates
prev_change_id: Option<u64>Previous change ID
Implementations§
Source§impl OrderBook
impl OrderBook
Sourcepub fn new(instrument_name: String, timestamp: i64, change_id: u64) -> Self
pub fn new(instrument_name: String, timestamp: i64, change_id: u64) -> Self
Create a new empty order book
Sourcepub fn total_bid_volume(&self) -> f64
pub fn total_bid_volume(&self) -> f64
Calculate total bid volume
Sourcepub fn total_ask_volume(&self) -> f64
pub fn total_ask_volume(&self) -> f64
Calculate total ask volume
Sourcepub fn volume_at_price(&self, price: f64, is_bid: bool) -> f64
pub fn volume_at_price(&self, price: f64, is_bid: bool) -> f64
Get volume at specific price level
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