pub struct EngineState<GlobalData, InstrumentData> {
pub trading: TradingState,
pub global: GlobalData,
pub connectivity: ConnectivityStates,
pub assets: AssetStates,
pub instruments: InstrumentStates<InstrumentData, ExchangeIndex, AssetIndex, InstrumentIndex>,
}Expand description
Algorithmic trading Engine state.
Fields§
§trading: TradingStateCurrent TradingState of the Engine.
global: GlobalDataConfigurable GlobalData state.
connectivity: ConnectivityStatesGlobal connection Health, and health of the market data and
account connections for each exchange.
assets: AssetStatesState of every asset (eg/ “btc”, “usdt”, etc.) being tracked by the Engine.
instruments: InstrumentStates<InstrumentData, ExchangeIndex, AssetIndex, InstrumentIndex>State of every instrument (eg/ “okx_spot_btc_usdt”, “bybit_perpetual_btc_usdt”, etc.)
being tracked by the Engine.
Implementations§
Source§impl<GlobalData, InstrumentData> EngineState<GlobalData, InstrumentData>
impl<GlobalData, InstrumentData> EngineState<GlobalData, InstrumentData>
pub const fn new( trading: TradingState, global: GlobalData, connectivity: ConnectivityStates, assets: AssetStates, instruments: InstrumentStates<InstrumentData, ExchangeIndex, AssetIndex, InstrumentIndex>, ) -> EngineState<GlobalData, InstrumentData>
Source§impl<GlobalData, InstrumentData> EngineState<GlobalData, InstrumentData>
impl<GlobalData, InstrumentData> EngineState<GlobalData, InstrumentData>
Sourcepub fn builder<FnInstrumentData>(
instruments: &IndexedInstruments,
global: GlobalData,
instrument_data_init: FnInstrumentData,
) -> EngineStateBuilder<'_, GlobalData, FnInstrumentData>where
FnInstrumentData: Fn(&Keyed<InstrumentIndex, Instrument<Keyed<ExchangeIndex, ExchangeId>, AssetIndex>>) -> InstrumentData,
pub fn builder<FnInstrumentData>(
instruments: &IndexedInstruments,
global: GlobalData,
instrument_data_init: FnInstrumentData,
) -> EngineStateBuilder<'_, GlobalData, FnInstrumentData>where
FnInstrumentData: Fn(&Keyed<InstrumentIndex, Instrument<Keyed<ExchangeIndex, ExchangeId>, AssetIndex>>) -> InstrumentData,
Construct an EngineStateBuilder to assist with EngineState initialisation.
Sourcepub fn update_from_account(
&mut self,
event: &AccountEvent,
) -> Option<PositionExited<QuoteAsset>>where
GlobalData: for<'a> Processor<&'a AccountEvent>,
InstrumentData: for<'a> Processor<&'a AccountEvent>,
pub fn update_from_account(
&mut self,
event: &AccountEvent,
) -> Option<PositionExited<QuoteAsset>>where
GlobalData: for<'a> Processor<&'a AccountEvent>,
InstrumentData: for<'a> Processor<&'a AccountEvent>,
Updates the internal state from an AccountEvent.
If the AccountEvent results in a new PositionExited, that is returned.
This method:
- Sets the account
ConnectivityStatetoHealth::Healthyif it was not previously. - Updates the
GlobalDatawith theAccountEvent. - Updates the associated
AssetStatesandInstrumentStateswith theAccountEvent.
Sourcepub fn update_from_market(
&mut self,
event: &MarketEvent<InstrumentIndex, InstrumentData::MarketEventKind>,
)where
GlobalData: for<'a> Processor<&'a MarketEvent<InstrumentIndex, InstrumentData::MarketEventKind>>,
InstrumentData: InstrumentDataState,
pub fn update_from_market(
&mut self,
event: &MarketEvent<InstrumentIndex, InstrumentData::MarketEventKind>,
)where
GlobalData: for<'a> Processor<&'a MarketEvent<InstrumentIndex, InstrumentData::MarketEventKind>>,
InstrumentData: InstrumentDataState,
Updates the internal state from a MarketEvent.
This method:
- Sets the market data
ConnectivityStatetoHealth::Healthyif it was not previously. - Updates the
GlobalDatawith theMarketEvent. - Updates the associated
InstrumentDataStatewith theMarketEvent.
Trait Implementations§
Source§impl<GlobalData: Clone, InstrumentData: Clone> Clone for EngineState<GlobalData, InstrumentData>
impl<GlobalData: Clone, InstrumentData: Clone> Clone for EngineState<GlobalData, InstrumentData>
Source§impl<GlobalData: Debug, InstrumentData: Debug> Debug for EngineState<GlobalData, InstrumentData>
impl<GlobalData: Debug, InstrumentData: Debug> Debug for EngineState<GlobalData, InstrumentData>
Source§impl<'de, GlobalData, InstrumentData> Deserialize<'de> for EngineState<GlobalData, InstrumentData>where
GlobalData: Deserialize<'de>,
InstrumentData: Deserialize<'de>,
impl<'de, GlobalData, InstrumentData> Deserialize<'de> for EngineState<GlobalData, InstrumentData>where
GlobalData: Deserialize<'de>,
InstrumentData: 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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<GlobalData, InstrumentData> From<&EngineState<GlobalData, InstrumentData>> for FnvHashMap<ExchangeId, UnindexedAccountSnapshot>
impl<GlobalData, InstrumentData> From<&EngineState<GlobalData, InstrumentData>> for FnvHashMap<ExchangeId, UnindexedAccountSnapshot>
Source§fn from(value: &EngineState<GlobalData, InstrumentData>) -> Self
fn from(value: &EngineState<GlobalData, InstrumentData>) -> Self
Converts to this type from the input type.
Source§impl<GlobalData, InstrumentData> InFlightRequestRecorder for EngineState<GlobalData, InstrumentData>
impl<GlobalData, InstrumentData> InFlightRequestRecorder for EngineState<GlobalData, InstrumentData>
fn record_in_flight_cancel( &mut self, request: &OrderRequestCancel<ExchangeIndex, InstrumentIndex>, )
fn record_in_flight_open( &mut self, request: &OrderRequestOpen<ExchangeIndex, InstrumentIndex>, )
fn record_in_flight_cancels<'a>(
&mut self,
requests: impl IntoIterator<Item = &'a OrderRequestCancel<ExchangeKey, InstrumentKey>>,
)where
ExchangeKey: 'a,
InstrumentKey: 'a,
fn record_in_flight_opens<'a>(
&mut self,
requests: impl IntoIterator<Item = &'a OrderRequestOpen<ExchangeKey, InstrumentKey>>,
)where
ExchangeKey: 'a,
InstrumentKey: 'a,
Source§impl<GlobalData: PartialEq, InstrumentData: PartialEq> PartialEq for EngineState<GlobalData, InstrumentData>
impl<GlobalData: PartialEq, InstrumentData: PartialEq> PartialEq for EngineState<GlobalData, InstrumentData>
Source§impl<GlobalData, InstrumentData> Serialize for EngineState<GlobalData, InstrumentData>
impl<GlobalData, InstrumentData> Serialize for EngineState<GlobalData, InstrumentData>
impl<GlobalData: PartialEq, InstrumentData: PartialEq> StructuralPartialEq for EngineState<GlobalData, InstrumentData>
Auto Trait Implementations§
impl<GlobalData, InstrumentData> Freeze for EngineState<GlobalData, InstrumentData>
impl<GlobalData, InstrumentData> RefUnwindSafe for EngineState<GlobalData, InstrumentData>
impl<GlobalData, InstrumentData> Send for EngineState<GlobalData, InstrumentData>
impl<GlobalData, InstrumentData> Sync for EngineState<GlobalData, InstrumentData>
impl<GlobalData, InstrumentData> Unpin for EngineState<GlobalData, InstrumentData>
impl<GlobalData, InstrumentData> UnsafeUnpin for EngineState<GlobalData, InstrumentData>
impl<GlobalData, InstrumentData> UnwindSafe for EngineState<GlobalData, InstrumentData>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
Converts
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> ⓘ
Converts
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 more