nautilus_common/messages/execution/
mod.rs1pub mod cancel;
19pub mod modify;
20pub mod query;
21pub mod report;
22pub mod submit;
23
24use nautilus_core::UnixNanos;
25use nautilus_model::{
26 identifiers::{ClientId, InstrumentId},
27 reports::{ExecutionMassStatus, FillReport, OrderStatusReport, PositionStatusReport},
28};
29use strum::Display;
30
31pub use self::{
33 cancel::BatchCancelOrders, cancel::CancelAllOrders, cancel::CancelOrder, modify::ModifyOrder,
34 query::QueryAccount, query::QueryOrder, report::GenerateFillReports,
35 report::GenerateOrderStatusReport, report::GeneratePositionReports, submit::SubmitOrder,
36 submit::SubmitOrderList,
37};
38
39#[derive(Clone, Debug, Display)]
41pub enum ExecutionReport {
42 OrderStatus(Box<OrderStatusReport>),
43 Fill(Box<FillReport>),
44 Position(Box<PositionStatusReport>),
45 Mass(Box<ExecutionMassStatus>),
46}
47
48#[allow(clippy::large_enum_variant)]
50#[derive(Clone, Debug, Eq, PartialEq, Display)]
51pub enum TradingCommand {
52 SubmitOrder(SubmitOrder),
53 SubmitOrderList(SubmitOrderList),
54 ModifyOrder(ModifyOrder),
55 CancelOrder(CancelOrder),
56 CancelAllOrders(CancelAllOrders),
57 BatchCancelOrders(BatchCancelOrders),
58 QueryOrder(QueryOrder),
59 QueryAccount(QueryAccount),
60}
61
62impl TradingCommand {
63 #[must_use]
64 pub const fn client_id(&self) -> ClientId {
65 match self {
66 Self::SubmitOrder(command) => command.client_id,
67 Self::SubmitOrderList(command) => command.client_id,
68 Self::ModifyOrder(command) => command.client_id,
69 Self::CancelOrder(command) => command.client_id,
70 Self::CancelAllOrders(command) => command.client_id,
71 Self::BatchCancelOrders(command) => command.client_id,
72 Self::QueryOrder(command) => command.client_id,
73 Self::QueryAccount(command) => command.client_id,
74 }
75 }
76
77 #[must_use]
83 pub const fn instrument_id(&self) -> InstrumentId {
84 match self {
85 Self::SubmitOrder(command) => command.instrument_id,
86 Self::SubmitOrderList(command) => command.instrument_id,
87 Self::ModifyOrder(command) => command.instrument_id,
88 Self::CancelOrder(command) => command.instrument_id,
89 Self::CancelAllOrders(command) => command.instrument_id,
90 Self::BatchCancelOrders(command) => command.instrument_id,
91 Self::QueryOrder(command) => command.instrument_id,
92 Self::QueryAccount(_) => panic!("No instrument ID for command"),
93 }
94 }
95
96 #[must_use]
97 pub const fn ts_init(&self) -> UnixNanos {
98 match self {
99 Self::SubmitOrder(command) => command.ts_init,
100 Self::SubmitOrderList(command) => command.ts_init,
101 Self::ModifyOrder(command) => command.ts_init,
102 Self::CancelOrder(command) => command.ts_init,
103 Self::CancelAllOrders(command) => command.ts_init,
104 Self::BatchCancelOrders(command) => command.ts_init,
105 Self::QueryOrder(command) => command.ts_init,
106 Self::QueryAccount(command) => command.ts_init,
107 }
108 }
109}