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
impl OrderManager
Sourcepub fn new(
clock: Rc<RefCell<dyn Clock>>,
cache: Rc<RefCell<Cache>>,
active_local: bool,
) -> Self
pub fn new( clock: Rc<RefCell<dyn Clock>>, cache: Rc<RefCell<Cache>>, active_local: bool, ) -> Self
Creates a new OrderManager instance.
Sourcepub fn get_submit_order_commands(&self) -> AHashMap<ClientOrderId, SubmitOrder>
pub fn get_submit_order_commands(&self) -> AHashMap<ClientOrderId, SubmitOrder>
Returns a copy of all cached submit order commands.
Sourcepub fn cache_submit_order_command(&mut self, command: SubmitOrder)
pub fn cache_submit_order_command(&mut self, command: SubmitOrder)
Caches a submit order command for later processing.
Sourcepub fn pop_submit_order_command(
&mut self,
client_order_id: ClientOrderId,
) -> Option<SubmitOrder>
pub fn pop_submit_order_command( &mut self, client_order_id: ClientOrderId, ) -> Option<SubmitOrder>
Removes and returns a cached submit order command.
Sourcepub fn cancel_order(&mut self, order: &OrderAny) -> Vec<OrderManagerAction>
pub fn cancel_order(&mut self, order: &OrderAny) -> Vec<OrderManagerAction>
Cancels an order if it’s not already pending cancellation or closed.
Sourcepub fn modify_order_quantity(
&mut self,
order: &OrderAny,
new_quantity: Quantity,
) -> Vec<OrderManagerAction>
pub fn modify_order_quantity( &mut self, order: &OrderAny, new_quantity: Quantity, ) -> Vec<OrderManagerAction>
Modifies the quantity of an existing order.
Sourcepub fn create_new_submit_order(
&mut self,
order: &OrderAny,
position_id: Option<PositionId>,
client_id: Option<ClientId>,
correlation_id: Option<UUID4>,
) -> Result<Vec<OrderManagerAction>>
pub fn create_new_submit_order( &mut self, order: &OrderAny, position_id: Option<PositionId>, client_id: Option<ClientId>, correlation_id: Option<UUID4>, ) -> Result<Vec<OrderManagerAction>>
§Errors
Returns an error if creating a new submit order fails.
Sourcepub fn should_manage_order(&self, order: &OrderAny) -> bool
pub fn should_manage_order(&self, order: &OrderAny) -> bool
Returns true if the order manager should manage the given order.
Sourcepub fn handle_event(&mut self, event: &OrderEventAny) -> Vec<OrderManagerAction>
pub fn handle_event(&mut self, event: &OrderEventAny) -> Vec<OrderManagerAction>
Handles an order event by routing it to the appropriate handler method.
Note: Only handles specific terminal/actionable events. Other events
like OrderSubmitted, OrderAccepted, etc. are no-ops for the order manager.
Sourcepub fn handle_order_rejected(
&mut self,
rejected: OrderRejected,
) -> Vec<OrderManagerAction>
pub fn handle_order_rejected( &mut self, rejected: OrderRejected, ) -> Vec<OrderManagerAction>
Handles an order rejected event and manages any contingent orders.