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