pub struct ExecutionHarness { /* private fields */ }Expand description
Engine-wired state for deterministic live execution seam tests.
Implementations§
Source§impl ExecutionHarness
impl ExecutionHarness
Sourcepub fn new(
trader_id: TraderId,
client_id: ClientId,
account_id: AccountId,
instrument: InstrumentAny,
) -> Self
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.
Sourcepub const fn clock(&self) -> &Rc<RefCell<dyn Clock>>
pub const fn clock(&self) -> &Rc<RefCell<dyn Clock>>
Returns the clock shared by the harness components.
Sourcepub const fn cache(&self) -> &Rc<RefCell<Cache>>
pub const fn cache(&self) -> &Rc<RefCell<Cache>>
Returns the cache shared by the harness components.
Sourcepub const fn risk_engine(&self) -> &Rc<RefCell<RiskEngine>>
pub const fn risk_engine(&self) -> &Rc<RefCell<RiskEngine>>
Returns the risk engine used to route trading commands.
Sourcepub const fn exec_engine(&self) -> &Rc<RefCell<ExecutionEngine>>
pub const fn exec_engine(&self) -> &Rc<RefCell<ExecutionEngine>>
Returns the execution engine containing the adapter client under test.
Sourcepub const fn account_id(&self) -> AccountId
pub const fn account_id(&self) -> AccountId
Returns the account ID used by the harness.
Sourcepub const fn instrument_id(&self) -> InstrumentId
pub const fn instrument_id(&self) -> InstrumentId
Returns the instrument ID registered in the cache.
Sourcepub fn routed(&self) -> &[RoutedKind]
pub fn routed(&self) -> &[RoutedKind]
Returns the routing kinds observed before live-runner dispatch.
Sourcepub fn assert_engine_ready(&self)
pub fn assert_engine_ready(&self)
Asserts that the execution client is registered and its engine is ready.
Sourcepub fn risk_command_count(&self) -> u64
pub fn risk_command_count(&self) -> u64
Returns the total commands received by the risk engine.
Sourcepub fn register_client(&self, client: Box<dyn ExecutionClient>) -> Result<()>
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.
Sourcepub fn submit_via_risk(&self, order: &OrderAny)
pub fn submit_via_risk(&self, order: &OrderAny)
Caches an order and sends its submission command through the risk engine.
Sourcepub fn modify_via_risk(
&self,
order: &OrderAny,
price: Option<Price>,
quantity: Option<Quantity>,
)
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.
Sourcepub fn cancel_via_execution(&self, order: &OrderAny)
pub fn cancel_via_execution(&self, order: &OrderAny)
Marks an order pending cancel and sends its cancellation through the execution engine.
Sourcepub async fn pump_until(
&mut self,
timeout: Duration,
predicate: impl Fn(&Cache) -> bool,
) -> bool
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.
Sourcepub async fn pump_until_routed(
&mut self,
timeout: Duration,
kind: RoutedKind,
) -> bool
pub async fn pump_until_routed( &mut self, timeout: Duration, kind: RoutedKind, ) -> bool
Routes emitted execution events until the expected routing kind is observed.
Sourcepub async fn pump_for(&mut self, duration: Duration)
pub async fn pump_for(&mut self, duration: Duration)
Routes every execution event received during the supplied duration.
Sourcepub fn register_exec_tester(
&self,
strategy_id: StrategyId,
order_qty: Quantity,
) -> ExecTester
pub fn register_exec_tester( &self, strategy_id: StrategyId, order_qty: Quantity, ) -> ExecTester
Registers an ExecTester against the harness clock and cache.
Sourcepub fn mark_pending_cancel(&self, order: &OrderAny)
pub fn mark_pending_cancel(&self, order: &OrderAny)
Applies a pending-cancel event to the cached order.
Sourcepub async fn reconcile_from_venue(&self) -> ExecutionMassStatus
pub async fn reconcile_from_venue(&self) -> ExecutionMassStatus
Generates and applies execution mass status from the registered adapter client.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ExecutionHarness
impl !Send for ExecutionHarness
impl !Sync for ExecutionHarness
impl !UnwindSafe for ExecutionHarness
impl Freeze for ExecutionHarness
impl Unpin for ExecutionHarness
impl UnsafeUnpin for ExecutionHarness
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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