nautilus_execution/messages/
submit_list.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 nautilus_core::{UnixNanos, UUID4};
19use nautilus_model::{
20    identifiers::{
21        ClientId, ClientOrderId, ExecAlgorithmId, InstrumentId, PositionId, StrategyId, TraderId,
22        VenueOrderId,
23    },
24    orders::OrderList,
25};
26use serde::{Deserialize, Serialize};
27
28#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
29#[serde(tag = "type")]
30pub struct SubmitOrderList {
31    pub trader_id: TraderId,
32    pub client_id: ClientId,
33    pub strategy_id: StrategyId,
34    pub instrument_id: InstrumentId,
35    pub client_order_id: ClientOrderId,
36    pub venue_order_id: VenueOrderId,
37    pub order_list: OrderList,
38    pub exec_algorith_id: Option<ExecAlgorithmId>,
39    pub position_id: Option<PositionId>,
40    pub command_id: UUID4,
41    pub ts_init: UnixNanos,
42}
43
44impl SubmitOrderList {
45    /// Creates a new [`SubmitOrderList`] instance.
46    #[allow(clippy::too_many_arguments)]
47    pub const fn new(
48        trader_id: TraderId,
49        client_id: ClientId,
50        strategy_id: StrategyId,
51        instrument_id: InstrumentId,
52        client_order_id: ClientOrderId,
53        venue_order_id: VenueOrderId,
54        order_list: OrderList,
55        exec_algorith_id: Option<ExecAlgorithmId>,
56        position_id: Option<PositionId>,
57        command_id: UUID4,
58        ts_init: UnixNanos,
59    ) -> anyhow::Result<Self> {
60        Ok(Self {
61            trader_id,
62            client_id,
63            strategy_id,
64            instrument_id,
65            client_order_id,
66            venue_order_id,
67            order_list,
68            exec_algorith_id,
69            position_id,
70            command_id,
71            ts_init,
72        })
73    }
74}
75
76impl Display for SubmitOrderList {
77    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
78        write!(
79            f,
80            "SubmitOrderList(instrument_id={}, order_list=TBD, position_id={})",
81            self.instrument_id,
82            self.position_id
83                .map_or("None".to_string(), |position_id| format!("{position_id}")),
84        )
85    }
86}
87
88////////////////////////////////////////////////////////////////////////////////
89// Tests
90////////////////////////////////////////////////////////////////////////////////
91#[cfg(test)]
92mod tests {}