1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3// https://nautechsystems.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
1516//! Execution specific messages such as order commands.
1718pub mod cancel;
19pub mod cancel_all;
20pub mod cancel_batch;
21pub mod modify;
22pub mod query;
23pub mod reports;
24pub mod submit;
25pub mod submit_list;
2627use nautilus_core::UnixNanos;
28use nautilus_model::identifiers::{ClientId, InstrumentId};
29use strum::Display;
3031// Re-exports
32pub use self::{
33 cancel::CancelOrder, cancel_all::CancelAllOrders, cancel_batch::BatchCancelOrders,
34 modify::ModifyOrder, query::QueryOrder, submit::SubmitOrder, submit_list::SubmitOrderList,
35};
3637// TODO
38#[allow(clippy::large_enum_variant)]
39#[derive(Clone, Debug, Eq, PartialEq, Display)]
40pub enum TradingCommand {
41 SubmitOrder(SubmitOrder),
42 SubmitOrderList(SubmitOrderList),
43 ModifyOrder(ModifyOrder),
44 CancelOrder(CancelOrder),
45 CancelAllOrders(CancelAllOrders),
46 BatchCancelOrders(BatchCancelOrders),
47 QueryOrder(QueryOrder),
48}
4950impl TradingCommand {
51#[must_use]
52pub const fn client_id(&self) -> ClientId {
53match self {
54Self::SubmitOrder(command) => command.client_id,
55Self::SubmitOrderList(command) => command.client_id,
56Self::ModifyOrder(command) => command.client_id,
57Self::CancelOrder(command) => command.client_id,
58Self::CancelAllOrders(command) => command.client_id,
59Self::BatchCancelOrders(command) => command.client_id,
60Self::QueryOrder(command) => command.client_id,
61 }
62 }
6364#[must_use]
65pub const fn instrument_id(&self) -> InstrumentId {
66match self {
67Self::SubmitOrder(command) => command.instrument_id,
68Self::SubmitOrderList(command) => command.instrument_id,
69Self::ModifyOrder(command) => command.instrument_id,
70Self::CancelOrder(command) => command.instrument_id,
71Self::CancelAllOrders(command) => command.instrument_id,
72Self::BatchCancelOrders(command) => command.instrument_id,
73Self::QueryOrder(command) => command.instrument_id,
74 }
75 }
7677#[must_use]
78pub const fn ts_init(&self) -> UnixNanos {
79match self {
80Self::SubmitOrder(command) => command.ts_init,
81Self::SubmitOrderList(command) => command.ts_init,
82Self::ModifyOrder(command) => command.ts_init,
83Self::CancelOrder(command) => command.ts_init,
84Self::CancelAllOrders(command) => command.ts_init,
85Self::BatchCancelOrders(command) => command.ts_init,
86Self::QueryOrder(command) => command.ts_init,
87 }
88 }
89}