Struct OrderManager

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

Manages the lifecycle and state of orders with contingency handling.

The order manager is responsible for managing local order state, handling contingent orders (OTO, OCO, OUO), and coordinating with emulation and execution systems. It tracks order commands and manages complex order relationships for advanced order types.

Implementations§

Source§

impl OrderManager

Source

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

Creates a new OrderManager instance.

Source

pub fn get_submit_order_commands(&self) -> HashMap<ClientOrderId, SubmitOrder>

Returns a copy of all cached submit order commands.

Source

pub fn cache_submit_order_command(&mut self, command: SubmitOrder)

Caches a submit order command for later processing.

Source

pub fn pop_submit_order_command( &mut self, client_order_id: ClientOrderId, ) -> Option<SubmitOrder>

Removes and returns a cached submit order command.

Source

pub fn reset(&mut self)

Resets the order manager by clearing all cached commands.

Source

pub fn cancel_order(&mut self, order: &OrderAny)

Cancels an order if it’s not already pending cancellation or closed.

Source

pub const fn modify_order_quantity( &mut self, order: &mut OrderAny, new_quantity: Quantity, )

Modifies the quantity of an existing order.

Source

pub fn create_new_submit_order( &mut self, order: &OrderAny, position_id: Option<PositionId>, client_id: Option<ClientId>, ) -> Result<()>

§Errors

Returns an error if creating a new submit order fails.

Source

pub fn should_manage_order(&self, order: &OrderAny) -> bool

Returns true if the order manager should manage the given order.

Source

pub fn handle_event(&mut self, event: OrderEventAny)

Handles an order event by routing it to the appropriate handler method.

Source

pub fn handle_order_rejected(&mut self, rejected: OrderRejected)

Handles an order rejected event and manages any contingent orders.

Source

pub fn handle_order_canceled(&mut self, canceled: OrderCanceled)

Source

pub fn handle_order_expired(&mut self, expired: OrderExpired)

Source

pub fn handle_order_updated(&mut self, updated: OrderUpdated)

Source

pub fn handle_order_filled(&mut self, filled: OrderFilled)

§Panics

Panics if the OTO child order cannot be found for the given client order ID.

Source

pub fn handle_contingencies(&mut self, order: OrderAny)

§Panics

Panics if a contingent order cannot be found for the given client order ID.

Source

pub fn handle_contingencies_update(&mut self, order: OrderAny)

§Panics

Panics if an OCO contingent order cannot be found for the given client order ID.

Source

pub fn handle_position_event(&mut self, _event: OrderEventAny)

Source

pub fn send_emulator_command(&self, command: TradingCommand)

Source

pub fn send_algo_command( &self, command: SubmitOrder, exec_algorithm_id: ExecAlgorithmId, )

Source

pub fn send_risk_command(&self, command: TradingCommand)

Source

pub fn send_exec_command(&self, command: TradingCommand)

Source

pub fn send_risk_event(&self, event: OrderEventAny)

Source

pub fn send_exec_event(&self, event: OrderEventAny)

Trait Implementations§

Source§

impl Debug for OrderManager

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