pub struct OrderBook { /* private fields */ }Expand description
Normalised Barter OrderBook snapshot.
Implementations§
Source§impl OrderBook
impl OrderBook
Sourcepub fn new<IterBids, IterAsks, L>(
sequence: u64,
time_engine: Option<DateTime<Utc>>,
bids: IterBids,
asks: IterAsks,
) -> Self
pub fn new<IterBids, IterAsks, L>( sequence: u64, time_engine: Option<DateTime<Utc>>, bids: IterBids, asks: IterAsks, ) -> Self
Construct a new sorted OrderBook.
Note that the passed bid and asks levels do not need to be pre-sorted.
Sourcepub fn time_engine(&self) -> Option<DateTime<Utc>>
pub fn time_engine(&self) -> Option<DateTime<Utc>>
Current engine time associated with the OrderBook.
Sourcepub fn snapshot(&self, depth: usize) -> Self
pub fn snapshot(&self, depth: usize) -> Self
Generate a sorted OrderBook snapshot with a maximum depth.
Sourcepub fn update(&mut self, event: &OrderBookEvent)
pub fn update(&mut self, event: &OrderBookEvent)
Update the local OrderBook from a new OrderBookEvent.
Sourcepub fn bids(&self) -> &OrderBookSide<Bids>
pub fn bids(&self) -> &OrderBookSide<Bids>
Return a reference to this OrderBooks bids.
Sourcepub fn asks(&self) -> &OrderBookSide<Asks>
pub fn asks(&self) -> &OrderBookSide<Asks>
Return a reference to this OrderBooks asks.
Sourcepub fn mid_price(&self) -> Option<Decimal>
pub fn mid_price(&self) -> Option<Decimal>
Calculate the mid-price by taking the average of the best bid and ask prices.
See Docs: https://www.quantstart.com/articles/high-frequency-trading-ii-limit-order-book
Sourcepub fn volume_weighed_mid_price(&self) -> Option<Decimal>
pub fn volume_weighed_mid_price(&self) -> Option<Decimal>
Calculate the volume weighted mid-price (micro-price), weighing the best bid and ask prices with their associated amount.
See Docs: https://www.quantstart.com/articles/high-frequency-trading-ii-limit-order-book
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>,
impl Eq for OrderBook
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 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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