pub struct OrderBook {
pub symbol: String,
pub bids: BTreeMap<OrderedFloat<f64>, f64>,
pub asks: BTreeMap<OrderedFloat<f64>, f64>,
pub last_u: Option<u64>,
pub snapshot_id: Option<u64>,
pub depth: u16,
}Expand description
A sorted Binance order book (bids descending by price, asks ascending).
Values are absolute quantities (Binance-style). last_u and snapshot_id
reflect the latest applied update and the initializing REST snapshot respectively.
Most users don’t construct OrderBook directly—consume it via the
watch::Receiver<OrderBook> returned by [generate_orderbooks].
Fields§
§symbol: String§bids: BTreeMap<OrderedFloat<f64>, f64>§asks: BTreeMap<OrderedFloat<f64>, f64>§last_u: Option<u64>§snapshot_id: Option<u64>§depth: u16Implementations§
Source§impl OrderBook
impl OrderBook
pub fn new(symbol: &str) -> Self
pub async fn init_ob(symbol: &str) -> Result<OrderBook, Box<dyn Error>>
pub async fn resync_ob(&mut self) -> Result<(), Box<dyn Error>>
pub async fn get_depth_snapshot( &self, limit: u16, ) -> Result<DepthSnapshot, Box<dyn Error>>
Sourcepub fn from_snapshot(&mut self, snap: &DepthSnapshot)
pub fn from_snapshot(&mut self, snap: &DepthSnapshot)
Build a sorted book directly from a REST snapshot.
Sourcepub fn apply_update(&mut self, ev: &DepthUpdate)
pub fn apply_update(&mut self, ev: &DepthUpdate)
Apply one WS depth update (absolute quantities)
pub fn continuity_check<'a>( &mut self, du: &'a DepthUpdate, ) -> UpdateDecision<'a>
Trait Implementations§
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