pub struct EngineStateBuilder<'a, GlobalData, FnInstrumentData> { /* private fields */ }Expand description
Builder utility for an EngineState instance.
Implementations§
Source§impl<'a, GlobalData, FnInstrumentData> EngineStateBuilder<'a, GlobalData, FnInstrumentData>
impl<'a, GlobalData, FnInstrumentData> EngineStateBuilder<'a, GlobalData, FnInstrumentData>
Sourcepub fn new(
instruments: &'a IndexedInstruments,
global: GlobalData,
instrument_data_init: FnInstrumentData,
) -> Self
pub fn new( instruments: &'a IndexedInstruments, global: GlobalData, instrument_data_init: FnInstrumentData, ) -> Self
Construct a new EngineStateBuilder with a layout derived from IndexedInstruments.
Note that the rest of the EngineState data can be generated from defaults if that
is all that is needed.
Note that ConnectivityStates will be generated with
generate_empty_indexed_connectivity_states, defaulting to Health::Reconnecting.
Sourcepub fn trading_state(self, value: TradingState) -> Self
pub fn trading_state(self, value: TradingState) -> Self
Optionally provide the initial TradingState.
Defaults to TradingState::Disabled.
Sourcepub fn time_engine_start(self, value: DateTime<Utc>) -> Self
pub fn time_engine_start(self, value: DateTime<Utc>) -> Self
Optionally provide the time_engine_start.
Providing this is useful for back-test scenarios where the time should be seeded with a
“historical” clock time (eg/ from first historical MarketEvent).
Defaults to Utc::now
Sourcepub fn balances<BalanceIter, KeyedBalance>(self, balances: BalanceIter) -> Selfwhere
BalanceIter: IntoIterator<Item = KeyedBalance>,
KeyedBalance: Into<Keyed<ExchangeAsset<AssetNameInternal>, Balance>>,
pub fn balances<BalanceIter, KeyedBalance>(self, balances: BalanceIter) -> Selfwhere
BalanceIter: IntoIterator<Item = KeyedBalance>,
KeyedBalance: Into<Keyed<ExchangeAsset<AssetNameInternal>, Balance>>,
Optionally provide initial exchange asset Balances.
Useful for back-test scenarios where seeding EngineState with initial Balances is
required.
Note the internal implementation uses a HashMap, so duplicate
ExchangeAsset<AssetNameInternal> keys are overwritten.
Sourcepub fn build<InstrumentData>(self) -> EngineState<GlobalData, InstrumentData>where
FnInstrumentData: Fn(&'a Keyed<InstrumentIndex, Instrument<Keyed<ExchangeIndex, ExchangeId>, AssetIndex>>) -> InstrumentData,
pub fn build<InstrumentData>(self) -> EngineState<GlobalData, InstrumentData>where
FnInstrumentData: Fn(&'a Keyed<InstrumentIndex, Instrument<Keyed<ExchangeIndex, ExchangeId>, AssetIndex>>) -> InstrumentData,
Use the builder data to generate the associated EngineState.
If optional data is not provided (eg/ Balances), default values are used (eg/ zero Balance).
Trait Implementations§
Auto Trait Implementations§
impl<'a, GlobalData, FnInstrumentData> Freeze for EngineStateBuilder<'a, GlobalData, FnInstrumentData>
impl<'a, GlobalData, FnInstrumentData> RefUnwindSafe for EngineStateBuilder<'a, GlobalData, FnInstrumentData>where
GlobalData: RefUnwindSafe,
FnInstrumentData: RefUnwindSafe,
impl<'a, GlobalData, FnInstrumentData> Send for EngineStateBuilder<'a, GlobalData, FnInstrumentData>
impl<'a, GlobalData, FnInstrumentData> Sync for EngineStateBuilder<'a, GlobalData, FnInstrumentData>
impl<'a, GlobalData, FnInstrumentData> Unpin for EngineStateBuilder<'a, GlobalData, FnInstrumentData>
impl<'a, GlobalData, FnInstrumentData> UnsafeUnpin for EngineStateBuilder<'a, GlobalData, FnInstrumentData>where
GlobalData: UnsafeUnpin,
FnInstrumentData: UnsafeUnpin,
impl<'a, GlobalData, FnInstrumentData> UnwindSafe for EngineStateBuilder<'a, GlobalData, FnInstrumentData>where
GlobalData: UnwindSafe,
FnInstrumentData: UnwindSafe,
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
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,
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 more