nautilus_execution/messages/cancel_batch.rs
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// -------------------------------------------------------------------------------------------------
15
16use std::fmt::Display;
17
18use derive_builder::Builder;
19use nautilus_core::{UUID4, UnixNanos};
20use nautilus_model::identifiers::{ClientId, InstrumentId, StrategyId, TraderId};
21use serde::{Deserialize, Serialize};
22
23use super::cancel::CancelOrder;
24
25#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, Builder)]
26#[builder(default)]
27#[serde(tag = "type")]
28pub struct BatchCancelOrders {
29 pub trader_id: TraderId,
30 pub client_id: ClientId,
31 pub strategy_id: StrategyId,
32 pub instrument_id: InstrumentId,
33 pub cancels: Vec<CancelOrder>,
34 pub command_id: UUID4,
35 pub ts_init: UnixNanos,
36}
37
38impl BatchCancelOrders {
39 /// Creates a new [`BatchCancelOrders`] instance.
40 #[allow(clippy::too_many_arguments)]
41 pub const fn new(
42 trader_id: TraderId,
43 client_id: ClientId,
44 strategy_id: StrategyId,
45 instrument_id: InstrumentId,
46 cancels: Vec<CancelOrder>,
47 command_id: UUID4,
48 ts_init: UnixNanos,
49 ) -> anyhow::Result<Self> {
50 Ok(Self {
51 trader_id,
52 client_id,
53 strategy_id,
54 instrument_id,
55 cancels,
56 command_id,
57 ts_init,
58 })
59 }
60}
61
62impl Display for BatchCancelOrders {
63 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
64 write!(
65 f,
66 "BatchCancelOrders(instrument_id={}, cancels=TBD)",
67 self.instrument_id,
68 )
69 }
70}
71
72////////////////////////////////////////////////////////////////////////////////
73// Tests
74////////////////////////////////////////////////////////////////////////////////
75#[cfg(test)]
76mod tests {}