Skip to main content

EngineStateBuilder

Struct EngineStateBuilder 

Source
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>

Source

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.

Source

pub fn trading_state(self, value: TradingState) -> Self

Optionally provide the initial TradingState.

Defaults to TradingState::Disabled.

Source

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

Source

pub fn balances<BalanceIter, KeyedBalance>(self, balances: BalanceIter) -> Self
where 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.

Source

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§

Source§

impl<'a, GlobalData: Clone, FnInstrumentData: Clone> Clone for EngineStateBuilder<'a, GlobalData, FnInstrumentData>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, GlobalData: Debug, FnInstrumentData: Debug> Debug for EngineStateBuilder<'a, GlobalData, FnInstrumentData>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, GlobalData, FnInstrumentData> Freeze for EngineStateBuilder<'a, GlobalData, FnInstrumentData>
where GlobalData: Freeze, FnInstrumentData: Freeze,

§

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>
where GlobalData: Send, FnInstrumentData: Send,

§

impl<'a, GlobalData, FnInstrumentData> Sync for EngineStateBuilder<'a, GlobalData, FnInstrumentData>
where GlobalData: Sync, FnInstrumentData: Sync,

§

impl<'a, GlobalData, FnInstrumentData> Unpin for EngineStateBuilder<'a, GlobalData, FnInstrumentData>
where GlobalData: Unpin, FnInstrumentData: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more