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, GenerateExecutionMassStatusBuilder, GenerateFillReports,
39 GenerateFillReportsBuilder, GenerateOrderStatusReport, GenerateOrderStatusReportBuilder,
40 GenerateOrderStatusReports, GenerateOrderStatusReportsBuilder,
41 GeneratePositionStatusReports, GeneratePositionStatusReportsBuilder,
42 },
43 submit::{SubmitOrder, SubmitOrderList},
44};
45
46#[derive(Clone, Debug, Display)]
48pub enum ExecutionReport {
49 Order(Box<OrderStatusReport>),
50 Fill(Box<FillReport>),
51 Position(Box<PositionStatusReport>),
52 MassStatus(Box<ExecutionMassStatus>),
53}
54
55#[allow(clippy::large_enum_variant)]
57#[derive(Clone, Debug, Eq, PartialEq, Display)]
58pub enum TradingCommand {
59 SubmitOrder(SubmitOrder),
60 SubmitOrderList(SubmitOrderList),
61 ModifyOrder(ModifyOrder),
62 CancelOrder(CancelOrder),
63 CancelAllOrders(CancelAllOrders),
64 BatchCancelOrders(BatchCancelOrders),
65 QueryOrder(QueryOrder),
66 QueryAccount(QueryAccount),
67}
68
69impl TradingCommand {
70 #[must_use]
71 pub const fn client_id(&self) -> Option<ClientId> {
72 match self {
73 Self::SubmitOrder(command) => command.client_id,
74 Self::SubmitOrderList(command) => command.client_id,
75 Self::ModifyOrder(command) => command.client_id,
76 Self::CancelOrder(command) => command.client_id,
77 Self::CancelAllOrders(command) => command.client_id,
78 Self::BatchCancelOrders(command) => command.client_id,
79 Self::QueryOrder(command) => command.client_id,
80 Self::QueryAccount(command) => command.client_id,
81 }
82 }
83
84 #[must_use]
90 pub const fn instrument_id(&self) -> InstrumentId {
91 match self {
92 Self::SubmitOrder(command) => command.instrument_id,
93 Self::SubmitOrderList(command) => command.instrument_id,
94 Self::ModifyOrder(command) => command.instrument_id,
95 Self::CancelOrder(command) => command.instrument_id,
96 Self::CancelAllOrders(command) => command.instrument_id,
97 Self::BatchCancelOrders(command) => command.instrument_id,
98 Self::QueryOrder(command) => command.instrument_id,
99 Self::QueryAccount(_) => panic!("No instrument ID for command"),
100 }
101 }
102
103 #[must_use]
104 pub const fn ts_init(&self) -> UnixNanos {
105 match self {
106 Self::SubmitOrder(command) => command.ts_init,
107 Self::SubmitOrderList(command) => command.ts_init,
108 Self::ModifyOrder(command) => command.ts_init,
109 Self::CancelOrder(command) => command.ts_init,
110 Self::CancelAllOrders(command) => command.ts_init,
111 Self::BatchCancelOrders(command) => command.ts_init,
112 Self::QueryOrder(command) => command.ts_init,
113 Self::QueryAccount(command) => command.ts_init,
114 }
115 }
116
117 #[must_use]
118 pub const fn strategy_id(&self) -> Option<StrategyId> {
119 match self {
120 Self::SubmitOrder(command) => Some(command.strategy_id),
121 Self::SubmitOrderList(command) => Some(command.strategy_id),
122 Self::ModifyOrder(command) => Some(command.strategy_id),
123 Self::CancelOrder(command) => Some(command.strategy_id),
124 Self::CancelAllOrders(command) => Some(command.strategy_id),
125 Self::BatchCancelOrders(command) => Some(command.strategy_id),
126 Self::QueryOrder(command) => Some(command.strategy_id),
127 Self::QueryAccount(_) => None,
128 }
129 }
130}