ExecutionManager

Struct ExecutionManager 

Source
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

Source

pub fn new( clock: Rc<RefCell<dyn Clock>>, cache: Rc<RefCell<Cache>>, config: ExecutionManagerConfig, ) -> Self

Creates a new ExecutionManager instance.

Source

pub async fn reconcile_execution_mass_status( &mut self, mass_status: ExecutionMassStatus, ) -> Vec<OrderEventAny>

Reconciles orders and fills from a mass status report.

Source

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.

Source

pub fn check_inflight_orders(&mut self) -> Vec<OrderEventAny>

Checks inflight orders and returns events for any that need reconciliation.

Source

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.

Source

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.

Source

pub fn register_inflight(&mut self, client_order_id: ClientOrderId)

Registers an order as inflight for tracking.

Source

pub fn record_local_activity( &mut self, client_order_id: ClientOrderId, ts_event: UnixNanos, )

Records local activity for the specified order.

Source

pub fn clear_recon_tracking( &mut self, client_order_id: &ClientOrderId, drop_last_query: bool, )

Clears reconciliation tracking state for an order.

Source

pub fn claim_external_orders( &mut self, instrument_id: InstrumentId, strategy_id: StrategyId, )

Claims external orders for a specific strategy and instrument.

Source

pub fn record_position_activity( &mut self, instrument_id: InstrumentId, ts_event: UnixNanos, )

Records position activity for reconciliation tracking.

Source

pub fn is_fill_recently_processed(&self, trade_id: &TradeId) -> bool

Checks if a fill has been recently processed (for deduplication).

Source

pub fn mark_fill_processed(&mut self, trade_id: TradeId)

Marks a fill as recently processed with current timestamp.

Source

pub fn prune_recent_fills_cache(&mut self, ttl_secs: f64)

Prunes expired fills from the recent fills cache.

Default TTL is 60 seconds.

Source

pub fn purge_closed_orders(&mut self)

Purges closed orders from the cache that are older than the configured buffer.

Source

pub fn purge_closed_positions(&mut self)

Purges closed positions from the cache that are older than the configured buffer.

Source

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

Source§

fn clone(&self) -> ExecutionManager

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ExecutionManager

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

§

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> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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