pub struct ExecutionManager { /* private fields */ }Expand description
Manager for execution state.
The ExecutionManager handles:
- Startup reconciliation to align state on system start.
- Continuous reconciliation of inflight orders.
- External order discovery and claiming.
- Fill report processing and validation.
- Purging of old orders, positions, and account events.
§Thread Safety
This struct is not thread-safe and is designed for single-threaded use within
an async runtime. Internal state is managed using AHashMap without synchronization,
and the clock and cache use Rc<RefCell<>> which provide runtime borrow checking
but no thread-safety guarantees.
If concurrent access is required, this struct must be wrapped in Arc<Mutex<>> or
similar synchronization primitives. Alternatively, ensure that all methods are called
from the same thread/task in the async runtime.
Warning: Concurrent mutable access to internal AHashMaps or concurrent borrows
of RefCell contents will cause runtime panics.
Implementations§
Source§impl ExecutionManager
impl ExecutionManager
Sourcepub fn new(
clock: Rc<RefCell<dyn Clock>>,
cache: Rc<RefCell<Cache>>,
config: ExecutionManagerConfig,
) -> Self
pub fn new( clock: Rc<RefCell<dyn Clock>>, cache: Rc<RefCell<Cache>>, config: ExecutionManagerConfig, ) -> Self
Creates a new ExecutionManager instance.
Sourcepub async fn reconcile_execution_mass_status(
&mut self,
mass_status: ExecutionMassStatus,
) -> Vec<OrderEventAny>
pub async fn reconcile_execution_mass_status( &mut self, mass_status: ExecutionMassStatus, ) -> Vec<OrderEventAny>
Reconciles orders and fills from a mass status report.
Sourcepub fn reconcile_report(
&mut self,
report: ExecutionReport,
) -> Result<Vec<OrderEventAny>>
pub fn reconcile_report( &mut self, report: ExecutionReport, ) -> Result<Vec<OrderEventAny>>
Reconciles a single execution report during runtime.
§Errors
Returns an error if the average price cannot be converted to a valid Decimal.
Sourcepub fn check_inflight_orders(&mut self) -> Vec<OrderEventAny>
pub fn check_inflight_orders(&mut self) -> Vec<OrderEventAny>
Checks inflight orders and returns events for any that need reconciliation.
Sourcepub async fn check_open_orders(
&mut self,
clients: &[Rc<dyn LiveExecutionClient>],
) -> Vec<OrderEventAny>
pub async fn check_open_orders( &mut self, clients: &[Rc<dyn LiveExecutionClient>], ) -> Vec<OrderEventAny>
Checks open orders consistency between cache and venue.
This method validates that open orders in the cache match the venue’s state, comparing order status and filled quantities, and generating reconciliation events for any discrepancies detected.
§Returns
A vector of order events generated to reconcile discrepancies.
Sourcepub async fn check_positions_consistency(
&mut self,
clients: &[Rc<dyn LiveExecutionClient>],
) -> Vec<OrderEventAny>
pub async fn check_positions_consistency( &mut self, clients: &[Rc<dyn LiveExecutionClient>], ) -> Vec<OrderEventAny>
Checks position consistency between cache and venue.
This method validates that positions in the cache match the venue’s state, detecting position drift and querying for missing fills when discrepancies are found.
§Returns
A vector of fill events generated to reconcile position discrepancies.
Sourcepub fn register_inflight(&mut self, client_order_id: ClientOrderId)
pub fn register_inflight(&mut self, client_order_id: ClientOrderId)
Registers an order as inflight for tracking.
Sourcepub fn record_local_activity(
&mut self,
client_order_id: ClientOrderId,
ts_event: UnixNanos,
)
pub fn record_local_activity( &mut self, client_order_id: ClientOrderId, ts_event: UnixNanos, )
Records local activity for the specified order.
Sourcepub fn clear_recon_tracking(
&mut self,
client_order_id: &ClientOrderId,
drop_last_query: bool,
)
pub fn clear_recon_tracking( &mut self, client_order_id: &ClientOrderId, drop_last_query: bool, )
Clears reconciliation tracking state for an order.
Sourcepub fn claim_external_orders(
&mut self,
instrument_id: InstrumentId,
strategy_id: StrategyId,
)
pub fn claim_external_orders( &mut self, instrument_id: InstrumentId, strategy_id: StrategyId, )
Claims external orders for a specific strategy and instrument.
Sourcepub fn record_position_activity(
&mut self,
instrument_id: InstrumentId,
ts_event: UnixNanos,
)
pub fn record_position_activity( &mut self, instrument_id: InstrumentId, ts_event: UnixNanos, )
Records position activity for reconciliation tracking.
Sourcepub fn is_fill_recently_processed(&self, trade_id: &TradeId) -> bool
pub fn is_fill_recently_processed(&self, trade_id: &TradeId) -> bool
Checks if a fill has been recently processed (for deduplication).
Sourcepub fn mark_fill_processed(&mut self, trade_id: TradeId)
pub fn mark_fill_processed(&mut self, trade_id: TradeId)
Marks a fill as recently processed with current timestamp.
Sourcepub fn prune_recent_fills_cache(&mut self, ttl_secs: f64)
pub fn prune_recent_fills_cache(&mut self, ttl_secs: f64)
Prunes expired fills from the recent fills cache.
Default TTL is 60 seconds.
Sourcepub fn purge_closed_orders(&mut self)
pub fn purge_closed_orders(&mut self)
Purges closed orders from the cache that are older than the configured buffer.
Sourcepub fn purge_closed_positions(&mut self)
pub fn purge_closed_positions(&mut self)
Purges closed positions from the cache that are older than the configured buffer.
Sourcepub fn purge_account_events(&mut self)
pub fn purge_account_events(&mut self)
Purges old account events from the cache based on the configured lookback.
Trait Implementations§
Source§impl Clone for ExecutionManager
impl Clone for ExecutionManager
Source§fn clone(&self) -> ExecutionManager
fn clone(&self) -> ExecutionManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ExecutionManager
impl !RefUnwindSafe for ExecutionManager
impl !Send for ExecutionManager
impl !Sync for ExecutionManager
impl Unpin for ExecutionManager
impl !UnwindSafe for ExecutionManager
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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