apple_quant_algorithmic/order/state_update/
new_canceled.rs1use crate::{
2 backend::{OrderIdGenerator, OrdersBackend, RemoteOrderId},
3 instrument::InstrumentSpec,
4 order::{ActiveOrderGoals, ActiveStateGoal, DeferredOrderActions},
5 order_manager::{OrderManager, OrdersCapacitySpec},
6 timestamp::TickTimestamp,
7 volume::DirectionalExposure,
8};
9
10use super::{ApplyOrderStateUpdate, ApplyOrderStateUpdateError};
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
13pub struct NewCanceledState {
14 pub remote_order_id: RemoteOrderId,
15}
16
17impl<IS: InstrumentSpec> ApplyOrderStateUpdate<IS> for NewCanceledState {
18 async fn apply<OB: OrdersBackend<IS>, CS: OrdersCapacitySpec>(
19 self,
20 tick_timestamp: &TickTimestamp,
21 order_manager: &mut OrderManager<IS, CS>,
22 orders_backend: &mut OB,
23 order_id_generator: &mut OrderIdGenerator,
24 directional_exposure: &mut DirectionalExposure<IS>,
25 deferred_order_actions: &mut DeferredOrderActions<IS>,
26 active_order_goals: &mut ActiveOrderGoals<IS>,
27 active_state_goal: &mut ActiveStateGoal,
28 ) -> Result<(), ApplyOrderStateUpdateError>
29 where
30 IS: Send,
31 {
32 let Self { remote_order_id } = self;
33
34 let working_remote_order = order_manager
35 .working_remote_orders
36 .remove(
37 directional_exposure,
38 &remote_order_id,
39 )?;
40
41 order_manager
42 .completed_remote_orders
43 .submit::<OB>(
44 tick_timestamp,
45 working_remote_order,
46 );
47
48 Ok(())
49 }
50}