pub struct MarketEvent<InstrumentKey = MarketDataInstrument, T = DataKind> {
pub time_exchange: DateTime<Utc>,
pub time_received: DateTime<Utc>,
pub exchange: ExchangeId,
pub instrument: InstrumentKey,
pub kind: T,
}Expand description
Normalised Barter MarketEvent<T> wrapping the T data variant in metadata.
Note: T can be an enum such as the DataKind if required.
See crate::subscription for all existing Barter Market event variants.
§Examples
Fields§
§time_exchange: DateTime<Utc>Exchange timestamp of the event — its position on the engine timeline.
A consuming engine treats this as the time the event occurred: the
historical/backtest clock derives “current time” from it and replays
events in time_exchange order (see rustrade’s EngineClock /
TimeExchange).
§Contract for aggregated / windowed payloads (candles, OHLCV bars)
For a point-in-time payload (e.g. PublicTrade, OrderBookL1) this is
simply the venue event time. For a payload that aggregates a time window
(a Candle), time_exchange must be the period END, i.e. the
candle’s close_time —
never the period start.
Stamping the open instant makes a completed bar enter the engine timeline
at the moment its period began, so a strategy would act on a fully-formed
bar before it could possibly exist — silent lookahead / repaint bias. This
applies to any windowed payload, including a custom T supplied by a
consumer driving the engine without this crate’s producers. The library’s
own candle producers already stamp close_time here; when wrapping a
Candle into a MarketEvent yourself, use its close_time.
time_received: DateTime<Utc>Local timestamp at which this event was received/decoded. Diagnostic only —
the engine clock and replay ordering use time_exchange.
exchange: ExchangeId§instrument: InstrumentKey§kind: TImplementations§
Source§impl<InstrumentKey, T> MarketEvent<InstrumentKey, T>
impl<InstrumentKey, T> MarketEvent<InstrumentKey, T>
pub fn map_kind<F, O>(self, op: F) -> MarketEvent<InstrumentKey, O>where
F: FnOnce(T) -> O,
Source§impl<InstrumentKey> MarketEvent<InstrumentKey, DataKind>
impl<InstrumentKey> MarketEvent<InstrumentKey, DataKind>
pub fn as_public_trade( &self, ) -> Option<MarketEvent<&InstrumentKey, &PublicTrade>>
pub fn as_order_book_l1( &self, ) -> Option<MarketEvent<&InstrumentKey, &OrderBookL1>>
pub fn as_order_book( &self, ) -> Option<MarketEvent<&InstrumentKey, &OrderBookEvent>>
pub fn as_candle(&self) -> Option<MarketEvent<&InstrumentKey, &Candle>>
pub fn as_liquidation( &self, ) -> Option<MarketEvent<&InstrumentKey, &Liquidation>>
pub fn as_option_greeks( &self, ) -> Option<MarketEvent<&InstrumentKey, &OptionGreeks>>
Trait Implementations§
Source§impl<'de, InstrumentKey, T> Deserialize<'de> for MarketEvent<InstrumentKey, T>where
InstrumentKey: Deserialize<'de>,
T: Deserialize<'de>,
impl<'de, InstrumentKey, T> Deserialize<'de> for MarketEvent<InstrumentKey, T>where
InstrumentKey: Deserialize<'de>,
T: Deserialize<'de>,
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>,
impl<InstrumentKey: Eq, T: Eq> Eq for MarketEvent<InstrumentKey, T>
Source§impl<InstrumentKey> From<(ExchangeId, InstrumentKey, BinanceOrderBookL2Snapshot)> for MarketEvent<InstrumentKey, OrderBookEvent>
impl<InstrumentKey> From<(ExchangeId, InstrumentKey, BinanceOrderBookL2Snapshot)> for MarketEvent<InstrumentKey, OrderBookEvent>
Source§fn from(
(exchange, instrument, snapshot): (ExchangeId, InstrumentKey, BinanceOrderBookL2Snapshot),
) -> Self
fn from( (exchange, instrument, snapshot): (ExchangeId, InstrumentKey, BinanceOrderBookL2Snapshot), ) -> Self
Source§impl<InstrumentKey> From<MarketEvent<InstrumentKey, Candle>> for MarketEvent<InstrumentKey, DataKind>
impl<InstrumentKey> From<MarketEvent<InstrumentKey, Candle>> for MarketEvent<InstrumentKey, DataKind>
Source§fn from(value: MarketEvent<InstrumentKey, Candle>) -> Self
fn from(value: MarketEvent<InstrumentKey, Candle>) -> Self
Source§impl<InstrumentKey> From<MarketEvent<InstrumentKey, Liquidation>> for MarketEvent<InstrumentKey, DataKind>
impl<InstrumentKey> From<MarketEvent<InstrumentKey, Liquidation>> for MarketEvent<InstrumentKey, DataKind>
Source§fn from(value: MarketEvent<InstrumentKey, Liquidation>) -> Self
fn from(value: MarketEvent<InstrumentKey, Liquidation>) -> Self
Source§impl<InstrumentKey> From<MarketEvent<InstrumentKey, OptionGreeks>> for MarketEvent<InstrumentKey, DataKind>
impl<InstrumentKey> From<MarketEvent<InstrumentKey, OptionGreeks>> for MarketEvent<InstrumentKey, DataKind>
Source§fn from(value: MarketEvent<InstrumentKey, OptionGreeks>) -> Self
fn from(value: MarketEvent<InstrumentKey, OptionGreeks>) -> Self
Source§impl<InstrumentKey> From<MarketEvent<InstrumentKey, OrderBookEvent>> for MarketEvent<InstrumentKey, DataKind>
impl<InstrumentKey> From<MarketEvent<InstrumentKey, OrderBookEvent>> for MarketEvent<InstrumentKey, DataKind>
Source§fn from(value: MarketEvent<InstrumentKey, OrderBookEvent>) -> Self
fn from(value: MarketEvent<InstrumentKey, OrderBookEvent>) -> Self
Source§impl<InstrumentKey> From<MarketEvent<InstrumentKey, OrderBookL1>> for MarketEvent<InstrumentKey, DataKind>
impl<InstrumentKey> From<MarketEvent<InstrumentKey, OrderBookL1>> for MarketEvent<InstrumentKey, DataKind>
Source§fn from(value: MarketEvent<InstrumentKey, OrderBookL1>) -> Self
fn from(value: MarketEvent<InstrumentKey, OrderBookL1>) -> Self
Source§impl<InstrumentKey> From<MarketEvent<InstrumentKey, PublicTrade>> for MarketEvent<InstrumentKey, DataKind>
impl<InstrumentKey> From<MarketEvent<InstrumentKey, PublicTrade>> for MarketEvent<InstrumentKey, DataKind>
Source§fn from(value: MarketEvent<InstrumentKey, PublicTrade>) -> Self
fn from(value: MarketEvent<InstrumentKey, PublicTrade>) -> Self
Source§impl<InstrumentKey: Ord, T: Ord> Ord for MarketEvent<InstrumentKey, T>
impl<InstrumentKey: Ord, T: Ord> Ord for MarketEvent<InstrumentKey, T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<InstrumentKey: PartialOrd, T: PartialOrd> PartialOrd for MarketEvent<InstrumentKey, T>
impl<InstrumentKey: PartialOrd, T: PartialOrd> PartialOrd for MarketEvent<InstrumentKey, T>
Source§impl<InstrumentKey, T> Serialize for MarketEvent<InstrumentKey, T>
impl<InstrumentKey, T> Serialize for MarketEvent<InstrumentKey, T>
impl<InstrumentKey: PartialEq, T: PartialEq> StructuralPartialEq for MarketEvent<InstrumentKey, T>
Auto Trait Implementations§
impl<InstrumentKey, T> Freeze for MarketEvent<InstrumentKey, T>
impl<InstrumentKey, T> RefUnwindSafe for MarketEvent<InstrumentKey, T>where
InstrumentKey: RefUnwindSafe,
T: RefUnwindSafe,
impl<InstrumentKey, T> Send for MarketEvent<InstrumentKey, T>
impl<InstrumentKey, T> Sync for MarketEvent<InstrumentKey, T>
impl<InstrumentKey, T> Unpin for MarketEvent<InstrumentKey, T>
impl<InstrumentKey, T> UnsafeUnpin for MarketEvent<InstrumentKey, T>where
InstrumentKey: UnsafeUnpin,
T: UnsafeUnpin,
impl<InstrumentKey, T> UnwindSafe for MarketEvent<InstrumentKey, T>where
InstrumentKey: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> AttachedTransformer<()> for T
impl<T> AttachedTransformer<()> for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> JsonSchemaMaybe for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.