pub struct DepthCache {
pub symbol: String,
pub last_update_id: u64,
pub update_time: Option<u64>,
/* private fields */
}Expand description
A local order book cache that maintains bid/ask levels.
This struct provides efficient access to order book data with sorted bids (highest first) and asks (lowest first).
Fields§
§symbol: StringTrading pair symbol.
last_update_id: u64Last update ID from the exchange.
update_time: Option<u64>Last update time.
Implementations§
Source§impl DepthCache
impl DepthCache
Sourcepub fn initialize_from_snapshot(&mut self, order_book: &OrderBook)
pub fn initialize_from_snapshot(&mut self, order_book: &OrderBook)
Initialize the cache from a REST API order book snapshot.
Sourcepub fn apply_update(&mut self, event: &DepthEvent) -> bool
pub fn apply_update(&mut self, event: &DepthEvent) -> bool
Apply a depth update event to the cache.
Returns true if the update was applied, false if it was skipped
(e.g., due to sequence issues).
Sourcepub fn best_bid(&self) -> Option<(f64, f64)>
pub fn best_bid(&self) -> Option<(f64, f64)>
Get the best bid (highest bid price and quantity).
Sourcepub fn total_bid_volume(&self) -> f64
pub fn total_bid_volume(&self) -> f64
Get the total bid volume.
Sourcepub fn total_ask_volume(&self) -> f64
pub fn total_ask_volume(&self) -> f64
Get the total ask volume.
Trait Implementations§
Source§impl Clone for DepthCache
impl Clone for DepthCache
Source§fn clone(&self) -> DepthCache
fn clone(&self) -> DepthCache
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DepthCache
impl RefUnwindSafe for DepthCache
impl Send for DepthCache
impl Sync for DepthCache
impl Unpin for DepthCache
impl UnwindSafe for DepthCache
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