pub struct Orderbook {
pub asset_id: String,
pub bids: Vec<PriceLevel>,
pub asks: Vec<PriceLevel>,
pub last_update_id: Option<u64>,
pub timestamp: Option<DateTime<Utc>>,
pub hash: Option<String>,
}Expand description
Full-depth L2 orderbook for one asset.
Fields§
§asset_id: StringThe orderable asset — Kalshi market ticker or Polymarket CTF token id (e.g. "KXBTCD-25APR1517").
bids: Vec<PriceLevel>Bid levels, sorted descending by price.
asks: Vec<PriceLevel>Ask levels, sorted ascending by price.
last_update_id: Option<u64>Monotonic sequence id from upstream; null when not provided.
timestamp: Option<DateTime<Utc>>Upstream snapshot time in UTC (e.g. "2026-04-25T12:00:00Z").
hash: Option<String>Polymarket book-state hash for replay integrity; null on Kalshi.
Implementations§
Source§impl Orderbook
impl Orderbook
pub fn best_bid(&self) -> Option<f64>
pub fn best_ask(&self) -> Option<f64>
pub fn mid_price(&self) -> Option<f64>
pub fn spread(&self) -> Option<f64>
pub fn has_data(&self) -> bool
pub fn from_rest_response( bids: &[RestPriceLevel], asks: &[RestPriceLevel], asset_id: impl Into<String>, ) -> Self
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 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