pub struct QuoteEvent {
pub exchange: ExchangeId,
pub instrument: InstrumentId,
pub bid: Price,
pub ask: Price,
pub ts: i64,
}Expand description
Quote update (bid/ask)
Fields§
§exchange: ExchangeIdExchange that produced the quote.
instrument: InstrumentIdInstrument whose book changed.
bid: PriceBest bid price.
ask: PriceBest ask price.
ts: i64Event timestamp in milliseconds since the Unix epoch.
Implementations§
Source§impl QuoteEvent
impl QuoteEvent
Sourcepub fn mid(&self) -> Price
pub fn mid(&self) -> Price
Return the arithmetic midpoint between bid and ask.
§Example
use bot_core::{ExchangeId, InstrumentId, Price, QuoteEvent};
use rust_decimal::Decimal;
let quote = QuoteEvent {
exchange: ExchangeId::new("hyperliquid"),
instrument: InstrumentId::new("ETH-PERP"),
bid: Price::new(Decimal::new(2_000, 0)),
ask: Price::new(Decimal::new(2_002, 0)),
ts: 1,
};
assert_eq!(quote.mid().value(), Decimal::new(2_001, 0));Trait Implementations§
Source§impl Clone for QuoteEvent
impl Clone for QuoteEvent
Source§fn clone(&self) -> QuoteEvent
fn clone(&self) -> QuoteEvent
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QuoteEvent
impl Debug for QuoteEvent
Source§impl<'de> Deserialize<'de> for QuoteEvent
impl<'de> Deserialize<'de> for QuoteEvent
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 QuoteEvent
impl RefUnwindSafe for QuoteEvent
impl Send for QuoteEvent
impl Sync for QuoteEvent
impl Unpin for QuoteEvent
impl UnsafeUnpin for QuoteEvent
impl UnwindSafe for QuoteEvent
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