nautilus_common/messages/execution/
mod.rs1pub mod cancel;
19pub mod modify;
20pub mod query;
21pub mod report;
22pub mod submit;
23
24pub use nautilus_core::Params;
26use nautilus_core::UnixNanos;
27use nautilus_model::{
28 identifiers::{ClientId, InstrumentId, StrategyId},
29 reports::{ExecutionMassStatus, FillReport, OrderStatusReport, PositionStatusReport},
30};
31use strum::Display;
32
33pub use self::{
34 cancel::{BatchCancelOrders, CancelAllOrders, CancelOrder},
35 modify::ModifyOrder,
36 query::{QueryAccount, QueryOrder},
37 report::{
38 GenerateExecutionMassStatus, GenerateFillReports, GenerateOrderStatusReport,
39 GenerateOrderStatusReports, GeneratePositionStatusReports,
40 },
41 submit::{SubmitOrder, SubmitOrderList},
42};
43
44#[derive(Clone, Debug, Display)]
46pub enum ExecutionReport {
47 Order(Box<OrderStatusReport>),
48 Fill(Box<FillReport>),
49 Position(Box<PositionStatusReport>),
50 MassStatus(Box<ExecutionMassStatus>),
51}
52
53#[allow(clippy::large_enum_variant)]
55#[derive(Clone, Debug, Eq, PartialEq, Display)]
56pub enum TradingCommand {
57 SubmitOrder(SubmitOrder),
58 SubmitOrderList(SubmitOrderList),
59 ModifyOrder(ModifyOrder),
60 CancelOrder(CancelOrder),
61 CancelAllOrders(CancelAllOrders),
62 BatchCancelOrders(BatchCancelOrders),
63 QueryOrder(QueryOrder),
64 QueryAccount(QueryAccount),
65}
66
67impl TradingCommand {
68 #[must_use]
69 pub const fn client_id(&self) -> Option<ClientId> {
70 match self {
71 Self::SubmitOrder(command) => command.client_id,
72 Self::SubmitOrderList(command) => command.client_id,
73 Self::ModifyOrder(command) => command.client_id,
74 Self::CancelOrder(command) => command.client_id,
75 Self::CancelAllOrders(command) => command.client_id,
76 Self::BatchCancelOrders(command) => command.client_id,
77 Self::QueryOrder(command) => command.client_id,
78 Self::QueryAccount(command) => command.client_id,
79 }
80 }
81
82 #[must_use]
88 pub const fn instrument_id(&self) -> InstrumentId {
89 match self {
90 Self::SubmitOrder(command) => command.instrument_id,
91 Self::SubmitOrderList(command) => command.instrument_id,
92 Self::ModifyOrder(command) => command.instrument_id,
93 Self::CancelOrder(command) => command.instrument_id,
94 Self::CancelAllOrders(command) => command.instrument_id,
95 Self::BatchCancelOrders(command) => command.instrument_id,
96 Self::QueryOrder(command) => command.instrument_id,
97 Self::QueryAccount(_) => panic!("No instrument ID for command"),
98 }
99 }
100
101 #[must_use]
102 pub const fn ts_init(&self) -> UnixNanos {
103 match self {
104 Self::SubmitOrder(command) => command.ts_init,
105 Self::SubmitOrderList(command) => command.ts_init,
106 Self::ModifyOrder(command) => command.ts_init,
107 Self::CancelOrder(command) => command.ts_init,
108 Self::CancelAllOrders(command) => command.ts_init,
109 Self::BatchCancelOrders(command) => command.ts_init,
110 Self::QueryOrder(command) => command.ts_init,
111 Self::QueryAccount(command) => command.ts_init,
112 }
113 }
114
115 #[must_use]
116 pub const fn strategy_id(&self) -> Option<StrategyId> {
117 match self {
118 Self::SubmitOrder(command) => Some(command.strategy_id),
119 Self::SubmitOrderList(command) => Some(command.strategy_id),
120 Self::ModifyOrder(command) => Some(command.strategy_id),
121 Self::CancelOrder(command) => Some(command.strategy_id),
122 Self::CancelAllOrders(command) => Some(command.strategy_id),
123 Self::BatchCancelOrders(command) => Some(command.strategy_id),
124 Self::QueryOrder(command) => Some(command.strategy_id),
125 Self::QueryAccount(_) => None,
126 }
127 }
128}