pub trait ExecutionClient {
Show 31 methods
// Required methods
fn is_connected(&self) -> bool;
fn client_id(&self) -> ClientId;
fn account_id(&self) -> AccountId;
fn venue(&self) -> Venue;
fn oms_type(&self) -> OmsType;
fn get_account(&self) -> Option<AccountAny>;
fn generate_account_state(
&self,
balances: Vec<AccountBalance>,
margins: Vec<MarginBalance>,
reported: bool,
ts_event: UnixNanos,
) -> Result<()>;
fn start(&mut self) -> Result<()>;
fn stop(&mut self) -> Result<()>;
// Provided methods
fn handles_order_venue(&self, venue: Venue) -> bool { ... }
fn reset(&mut self) -> Result<()> { ... }
fn dispose(&mut self) -> Result<()> { ... }
fn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn submit_order(&self, cmd: SubmitOrder) -> Result<()> { ... }
fn submit_order_list(&self, cmd: SubmitOrderList) -> Result<()> { ... }
fn modify_order(&self, cmd: ModifyOrder) -> Result<()> { ... }
fn batch_modify_orders(&self, cmd: BatchModifyOrders) -> Result<()> { ... }
fn cancel_order(&self, cmd: CancelOrder) -> Result<()> { ... }
fn cancel_all_orders(&self, cmd: CancelAllOrders) -> Result<()> { ... }
fn batch_cancel_orders(&self, cmd: BatchCancelOrders) -> Result<()> { ... }
fn query_account(&self, cmd: QueryAccount) -> Result<()> { ... }
fn query_order(&self, cmd: QueryOrder) -> Result<()> { ... }
fn generate_order_status_report<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 GenerateOrderStatusReport,
) -> Pin<Box<dyn Future<Output = Result<Option<OrderStatusReport>>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn generate_order_status_reports<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 GenerateOrderStatusReports,
) -> Pin<Box<dyn Future<Output = Result<Vec<OrderStatusReport>>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn generate_fill_reports<'life0, 'async_trait>(
&'life0 self,
cmd: GenerateFillReports,
) -> Pin<Box<dyn Future<Output = Result<Vec<FillReport>>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn generate_position_status_reports<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 GeneratePositionStatusReports,
) -> Pin<Box<dyn Future<Output = Result<Vec<PositionStatusReport>>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn generate_mass_status<'life0, 'async_trait>(
&'life0 self,
lookback_mins: Option<u64>,
) -> Pin<Box<dyn Future<Output = Result<Option<ExecutionMassStatus>>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn register_external_order(
&self,
_client_order_id: ClientOrderId,
_venue_order_id: VenueOrderId,
_instrument_id: InstrumentId,
_strategy_id: StrategyId,
_ts_init: UnixNanos,
) { ... }
fn on_instrument(&mut self, _instrument: InstrumentAny) { ... }
fn calculate_commission(
&self,
instrument: &InstrumentAny,
last_qty: Quantity,
last_px: Price,
liquidity_side: LiquiditySide,
) -> Option<Money> { ... }
}Expand description
Defines the interface for an execution client managing order operations.
§Thread Safety
Client instances are not intended to be sent across threads. The ?Send bound
allows implementations to hold non-Send state for any Python interop.
Required Methods§
fn is_connected(&self) -> bool
fn client_id(&self) -> ClientId
fn account_id(&self) -> AccountId
fn venue(&self) -> Venue
fn oms_type(&self) -> OmsType
fn get_account(&self) -> Option<AccountAny>
Sourcefn generate_account_state(
&self,
balances: Vec<AccountBalance>,
margins: Vec<MarginBalance>,
reported: bool,
ts_event: UnixNanos,
) -> Result<()>
fn generate_account_state( &self, balances: Vec<AccountBalance>, margins: Vec<MarginBalance>, reported: bool, ts_event: UnixNanos, ) -> Result<()>
Generates and publishes the account state event.
§Errors
Returns an error if generating the account state fails.
Sourcefn stop(&mut self) -> Result<()>
fn stop(&mut self) -> Result<()>
Stops the execution client.
Implementations must be idempotent: the engine and node teardown paths
(e.g. backtest end -> reset -> dispose) may call stop() more
than once per run. Guard with an internal is_stopped check or
equivalent so repeated calls are safe.
§Errors
Returns an error if the client fails to stop.
Provided Methods§
Sourcefn handles_order_venue(&self, venue: Venue) -> bool
fn handles_order_venue(&self, venue: Venue) -> bool
Returns whether this client can execute orders for the given instrument venue.
Single-venue clients should use the default behavior. Routing brokers can override this when their client venue identifies the broker rather than the instrument’s exchange venue.
Sourcefn reset(&mut self) -> Result<()>
fn reset(&mut self) -> Result<()>
Resets the execution client to its initial state.
The default implementation is a no-op. Adapters with reconnectable state (caches, sequence counters, in-flight orders) should override this.
§Errors
Returns an error if the client fails to reset.
Sourcefn dispose(&mut self) -> Result<()>
fn dispose(&mut self) -> Result<()>
Disposes of client resources and cleans up.
The default implementation is a no-op. Adapters that hold async tasks, background threads, or external handles should override this.
§Errors
Returns an error if the client fails to dispose.
Sourcefn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn submit_order(&self, cmd: SubmitOrder) -> Result<()>
fn submit_order(&self, cmd: SubmitOrder) -> Result<()>
Submits a single order command to the execution venue.
§Errors
Returns an error if submission fails.
Sourcefn submit_order_list(&self, cmd: SubmitOrderList) -> Result<()>
fn submit_order_list(&self, cmd: SubmitOrderList) -> Result<()>
Sourcefn modify_order(&self, cmd: ModifyOrder) -> Result<()>
fn modify_order(&self, cmd: ModifyOrder) -> Result<()>
Sourcefn batch_modify_orders(&self, cmd: BatchModifyOrders) -> Result<()>
fn batch_modify_orders(&self, cmd: BatchModifyOrders) -> Result<()>
Modifies a batch of orders.
The default implementation fans out to Self::modify_order so existing execution
clients remain compatible until they add native batch support.
§Errors
Returns an error if any child modification fails.
Sourcefn cancel_order(&self, cmd: CancelOrder) -> Result<()>
fn cancel_order(&self, cmd: CancelOrder) -> Result<()>
Sourcefn cancel_all_orders(&self, cmd: CancelAllOrders) -> Result<()>
fn cancel_all_orders(&self, cmd: CancelAllOrders) -> Result<()>
Sourcefn batch_cancel_orders(&self, cmd: BatchCancelOrders) -> Result<()>
fn batch_cancel_orders(&self, cmd: BatchCancelOrders) -> Result<()>
Sourcefn query_account(&self, cmd: QueryAccount) -> Result<()>
fn query_account(&self, cmd: QueryAccount) -> Result<()>
Sourcefn query_order(&self, cmd: QueryOrder) -> Result<()>
fn query_order(&self, cmd: QueryOrder) -> Result<()>
Sourcefn generate_order_status_report<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 GenerateOrderStatusReport,
) -> Pin<Box<dyn Future<Output = Result<Option<OrderStatusReport>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn generate_order_status_report<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 GenerateOrderStatusReport,
) -> Pin<Box<dyn Future<Output = Result<Option<OrderStatusReport>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn generate_order_status_reports<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 GenerateOrderStatusReports,
) -> Pin<Box<dyn Future<Output = Result<Vec<OrderStatusReport>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn generate_order_status_reports<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 GenerateOrderStatusReports,
) -> Pin<Box<dyn Future<Output = Result<Vec<OrderStatusReport>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn generate_fill_reports<'life0, 'async_trait>(
&'life0 self,
cmd: GenerateFillReports,
) -> Pin<Box<dyn Future<Output = Result<Vec<FillReport>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate_fill_reports<'life0, 'async_trait>(
&'life0 self,
cmd: GenerateFillReports,
) -> Pin<Box<dyn Future<Output = Result<Vec<FillReport>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Generates fill reports based on execution results.
§Errors
Returns an error if fill report generation fails.
Sourcefn generate_position_status_reports<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 GeneratePositionStatusReports,
) -> Pin<Box<dyn Future<Output = Result<Vec<PositionStatusReport>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn generate_position_status_reports<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 GeneratePositionStatusReports,
) -> Pin<Box<dyn Future<Output = Result<Vec<PositionStatusReport>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn generate_mass_status<'life0, 'async_trait>(
&'life0 self,
lookback_mins: Option<u64>,
) -> Pin<Box<dyn Future<Output = Result<Option<ExecutionMassStatus>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate_mass_status<'life0, 'async_trait>(
&'life0 self,
lookback_mins: Option<u64>,
) -> Pin<Box<dyn Future<Output = Result<Option<ExecutionMassStatus>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn register_external_order(
&self,
_client_order_id: ClientOrderId,
_venue_order_id: VenueOrderId,
_instrument_id: InstrumentId,
_strategy_id: StrategyId,
_ts_init: UnixNanos,
)
fn register_external_order( &self, _client_order_id: ClientOrderId, _venue_order_id: VenueOrderId, _instrument_id: InstrumentId, _strategy_id: StrategyId, _ts_init: UnixNanos, )
Registers an external order for tracking by the execution client.
This is called after reconciliation creates an external order, allowing the execution client to track it for subsequent events (e.g., cancellations).
Sourcefn on_instrument(&mut self, _instrument: InstrumentAny)
fn on_instrument(&mut self, _instrument: InstrumentAny)
Handles an instrument update received via the message bus.
Exec clients that need live instrument updates (e.g. for internal maps) can override this to process instruments for their venue.
Sourcefn calculate_commission(
&self,
instrument: &InstrumentAny,
last_qty: Quantity,
last_px: Price,
liquidity_side: LiquiditySide,
) -> Option<Money>
fn calculate_commission( &self, instrument: &InstrumentAny, last_qty: Quantity, last_px: Price, liquidity_side: LiquiditySide, ) -> Option<Money>
Calculates the commission for a reconciliation fill.
Override this method to provide venue-specific commission logic for inferred fills generated during reconciliation.
Returns None by default, signaling callers to use their own
generic commission formula.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".