pub enum MarketEvent {
Tick {
symbol: String,
ts: NaiveDateTime,
bid: f64,
ask: f64,
},
Bar {
symbol: String,
ts: NaiveDateTime,
open: f64,
high: f64,
low: f64,
close: f64,
volume: i64,
},
}Expand description
A single market data event consumed by the backtest runner.
Variants§
Implementations§
Source§impl MarketEvent
impl MarketEvent
Sourcepub fn ts(&self) -> NaiveDateTime
pub fn ts(&self) -> NaiveDateTime
Timestamp of the event.
Sourcepub fn to_quote(&self) -> PriceQuote
pub fn to_quote(&self) -> PriceQuote
Convert the event into a PriceQuote suitable for the trade engine.
- For ticks this is straightforward (bid/ask).
- For bars the close price is used for both bid and ask (zero spread approximation). A more sophisticated feed could model the spread separately.
Sourcepub fn to_valid_quote(&self) -> Option<PriceQuote>
pub fn to_valid_quote(&self) -> Option<PriceQuote>
Convert this event into a quote only when its executable bid/ask view is finite, positive, and not crossed.
Trait Implementations§
Source§impl Clone for MarketEvent
impl Clone for MarketEvent
Source§fn clone(&self) -> MarketEvent
fn clone(&self) -> MarketEvent
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 MarketEvent
impl Debug for MarketEvent
Source§impl<'de> Deserialize<'de> for MarketEvent
impl<'de> Deserialize<'de> for MarketEvent
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
Source§impl EventSourceItem for MarketEvent
impl EventSourceItem for MarketEvent
fn into_event_and_ordinal(self) -> (MarketEvent, Option<u64>)
Auto Trait Implementations§
impl Freeze for MarketEvent
impl RefUnwindSafe for MarketEvent
impl Send for MarketEvent
impl Sync for MarketEvent
impl Unpin for MarketEvent
impl UnsafeUnpin for MarketEvent
impl UnwindSafe for MarketEvent
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