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) -> HashMap<ClientOrderId, SubmitOrder>
pub fn get_submit_order_commands(&self) -> HashMap<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)
pub fn cancel_order(&mut self, order: &OrderAny)
Cancels an order if it’s not already pending cancellation or closed.
Sourcepub const fn modify_order_quantity(
&mut self,
order: &mut OrderAny,
new_quantity: Quantity,
)
pub const fn modify_order_quantity( &mut self, order: &mut OrderAny, new_quantity: Quantity, )
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>,
) -> Result<()>
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.
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)
pub fn handle_event(&mut self, event: OrderEventAny)
Handles an order event by routing it to the appropriate handler method.
Sourcepub fn handle_order_rejected(&mut self, rejected: OrderRejected)
pub fn handle_order_rejected(&mut self, rejected: OrderRejected)
Handles an order rejected event and manages any contingent orders.
pub fn handle_order_canceled(&mut self, canceled: OrderCanceled)
pub fn handle_order_expired(&mut self, expired: OrderExpired)
pub fn handle_order_updated(&mut self, updated: OrderUpdated)
Sourcepub fn handle_order_filled(&mut self, filled: OrderFilled)
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.
Sourcepub fn handle_contingencies(&mut self, order: OrderAny)
pub fn handle_contingencies(&mut self, order: OrderAny)
§Panics
Panics if a contingent order cannot be found for the given client order ID.
Sourcepub fn handle_contingencies_update(&mut self, order: OrderAny)
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.