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::identifiers::{ClientId, InstrumentId};
26use strum::Display;
27
28pub use self::{
30 cancel::BatchCancelOrders, cancel::CancelAllOrders, cancel::CancelOrder, modify::ModifyOrder,
31 query::QueryAccount, query::QueryOrder, report::GenerateFillReports,
32 report::GenerateOrderStatusReport, report::GeneratePositionReports, submit::SubmitOrder,
33 submit::SubmitOrderList,
34};
35
36#[allow(clippy::large_enum_variant)]
38#[derive(Clone, Debug, Eq, PartialEq, Display)]
39pub enum TradingCommand {
40 SubmitOrder(SubmitOrder),
41 SubmitOrderList(SubmitOrderList),
42 ModifyOrder(ModifyOrder),
43 CancelOrder(CancelOrder),
44 CancelAllOrders(CancelAllOrders),
45 BatchCancelOrders(BatchCancelOrders),
46 QueryOrder(QueryOrder),
47 QueryAccount(QueryAccount),
48}
49
50impl TradingCommand {
51 #[must_use]
52 pub const fn client_id(&self) -> ClientId {
53 match self {
54 Self::SubmitOrder(command) => command.client_id,
55 Self::SubmitOrderList(command) => command.client_id,
56 Self::ModifyOrder(command) => command.client_id,
57 Self::CancelOrder(command) => command.client_id,
58 Self::CancelAllOrders(command) => command.client_id,
59 Self::BatchCancelOrders(command) => command.client_id,
60 Self::QueryOrder(command) => command.client_id,
61 Self::QueryAccount(command) => command.client_id,
62 }
63 }
64
65 #[must_use]
66 pub const fn instrument_id(&self) -> InstrumentId {
67 match self {
68 Self::SubmitOrder(command) => command.instrument_id,
69 Self::SubmitOrderList(command) => command.instrument_id,
70 Self::ModifyOrder(command) => command.instrument_id,
71 Self::CancelOrder(command) => command.instrument_id,
72 Self::CancelAllOrders(command) => command.instrument_id,
73 Self::BatchCancelOrders(command) => command.instrument_id,
74 Self::QueryOrder(command) => command.instrument_id,
75 Self::QueryAccount(_) => panic!("No instrument ID for command"),
76 }
77 }
78
79 #[must_use]
80 pub const fn ts_init(&self) -> UnixNanos {
81 match self {
82 Self::SubmitOrder(command) => command.ts_init,
83 Self::SubmitOrderList(command) => command.ts_init,
84 Self::ModifyOrder(command) => command.ts_init,
85 Self::CancelOrder(command) => command.ts_init,
86 Self::CancelAllOrders(command) => command.ts_init,
87 Self::BatchCancelOrders(command) => command.ts_init,
88 Self::QueryOrder(command) => command.ts_init,
89 Self::QueryAccount(command) => command.ts_init,
90 }
91 }
92}