Skip to main content

ExecutionHarness

Struct ExecutionHarness 

Source
pub struct ExecutionHarness { /* private fields */ }
Expand description

Engine-wired state for deterministic live execution seam tests.

Implementations§

Source§

impl ExecutionHarness

Source

pub fn new( trader_id: TraderId, client_id: ClientId, account_id: AccountId, instrument: InstrumentAny, ) -> Self

Creates a harness with real risk and execution engines and the supplied instrument.

Replaces the current thread’s message bus and live event senders.

Source

pub const fn clock(&self) -> &Rc<RefCell<dyn Clock>>

Returns the clock shared by the harness components.

Source

pub const fn cache(&self) -> &Rc<RefCell<Cache>>

Returns the cache shared by the harness components.

Source

pub const fn risk_engine(&self) -> &Rc<RefCell<RiskEngine>>

Returns the risk engine used to route trading commands.

Source

pub const fn exec_engine(&self) -> &Rc<RefCell<ExecutionEngine>>

Returns the execution engine containing the adapter client under test.

Source

pub const fn trader_id(&self) -> TraderId

Returns the trader ID used by the harness.

Source

pub const fn client_id(&self) -> ClientId

Returns the execution client ID used by the harness.

Source

pub const fn account_id(&self) -> AccountId

Returns the account ID used by the harness.

Source

pub const fn instrument_id(&self) -> InstrumentId

Returns the instrument ID registered in the cache.

Source

pub fn routed(&self) -> &[RoutedKind]

Returns the routing kinds observed before live-runner dispatch.

Source

pub fn assert_engine_ready(&self)

Asserts that the execution client is registered and its engine is ready.

Source

pub fn risk_command_count(&self) -> u64

Returns the total commands received by the risk engine.

Source

pub fn register_client(&self, client: Box<dyn ExecutionClient>) -> Result<()>

Registers an adapter execution client and its native venue route with the execution engine.

§Errors

Returns an error when the engine already contains the client ID or venue route.

Source

pub fn submit_via_risk(&self, order: &OrderAny)

Caches an order and sends its submission command through the risk engine.

Source

pub fn modify_via_risk( &self, order: &OrderAny, price: Option<Price>, quantity: Option<Quantity>, )

Marks an order pending update and sends its modification through the risk engine.

Source

pub fn cancel_via_execution(&self, order: &OrderAny)

Marks an order pending cancel and sends its cancellation through the execution engine.

Source

pub async fn pump_until( &mut self, timeout: Duration, predicate: impl Fn(&Cache) -> bool, ) -> bool

Routes emitted execution events until the cache predicate holds or the deadline expires.

Source

pub async fn pump_until_routed( &mut self, timeout: Duration, kind: RoutedKind, ) -> bool

Routes emitted execution events until the expected routing kind is observed.

Source

pub async fn pump_for(&mut self, duration: Duration)

Routes every execution event received during the supplied duration.

Source

pub fn register_exec_tester( &self, strategy_id: StrategyId, order_qty: Quantity, ) -> ExecTester

Registers an ExecTester against the harness clock and cache.

Source

pub fn mark_pending_cancel(&self, order: &OrderAny)

Applies a pending-cancel event to the cached order.

Source

pub async fn reconcile_from_venue(&self) -> ExecutionMassStatus

Generates and applies execution mass status from the registered adapter client.

Trait Implementations§

Source§

impl Debug for ExecutionHarness

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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
§

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

§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

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

§

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
§

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
§

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

§

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
§

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
§

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, 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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