pub struct OrderBook {
pub symbol: String,
pub bids: Vec<OrderBookEntry>,
pub asks: Vec<OrderBookEntry>,
pub timestamp: DateTime<Utc>,
}Expand description
Order book (market depth).
Fields§
§symbol: StringTrading symbol.
bids: Vec<OrderBookEntry>Bid levels (buyers), sorted from highest to lowest price.
asks: Vec<OrderBookEntry>Ask levels (sellers), sorted from lowest to highest price.
timestamp: DateTime<Utc>Timestamp.
Implementations§
Source§impl OrderBook
impl OrderBook
Sourcepub fn with_levels(
symbol: impl Into<String>,
bids: Vec<OrderBookEntry>,
asks: Vec<OrderBookEntry>,
) -> Self
pub fn with_levels( symbol: impl Into<String>, bids: Vec<OrderBookEntry>, asks: Vec<OrderBookEntry>, ) -> Self
Creates an order book with the given levels.
Sourcepub fn best_bid(&self) -> Option<&OrderBookEntry>
pub fn best_bid(&self) -> Option<&OrderBookEntry>
Returns the best bid (highest buy price).
Sourcepub fn best_ask(&self) -> Option<&OrderBookEntry>
pub fn best_ask(&self) -> Option<&OrderBookEntry>
Returns the best ask (lowest sell price).
Sourcepub fn best_bid_price(&self) -> Option<Decimal>
pub fn best_bid_price(&self) -> Option<Decimal>
Returns the best bid price.
Sourcepub fn best_ask_price(&self) -> Option<Decimal>
pub fn best_ask_price(&self) -> Option<Decimal>
Returns the best ask price.
Sourcepub fn bid_depth(&self, levels: usize) -> u64
pub fn bid_depth(&self, levels: usize) -> u64
Returns the total bid depth up to the given level count.
Sourcepub fn ask_depth(&self, levels: usize) -> u64
pub fn ask_depth(&self, levels: usize) -> u64
Returns the total ask depth up to the given level count.
Sourcepub fn bid_levels(&self) -> usize
pub fn bid_levels(&self) -> usize
Returns the number of bid levels.
Sourcepub fn ask_levels(&self) -> usize
pub fn ask_levels(&self) -> usize
Returns the number of ask levels.
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
impl StructuralPartialEq for OrderBook
Auto Trait Implementations§
impl Forget for OrderBook
impl Freeze for OrderBook
impl Move 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