nautilus_common/messages/execution/query.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::{
21 ClientId, ClientOrderId, InstrumentId, StrategyId, TraderId, VenueOrderId,
22};
23use serde::{Deserialize, Serialize};
24
25#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, Builder)]
26#[builder(default)]
27#[serde(tag = "type")]
28pub struct QueryOrder {
29 pub trader_id: TraderId,
30 pub client_id: ClientId,
31 pub strategy_id: StrategyId,
32 pub instrument_id: InstrumentId,
33 pub client_order_id: ClientOrderId,
34 pub venue_order_id: VenueOrderId,
35 pub command_id: UUID4,
36 pub ts_init: UnixNanos,
37}
38
39impl QueryOrder {
40 /// Creates a new [`QueryOrder`] instance.
41 ///
42 /// # Errors
43 ///
44 /// Returns an error if parameters are invalid.
45 #[allow(clippy::too_many_arguments)]
46 pub const fn new(
47 trader_id: TraderId,
48 client_id: ClientId,
49 strategy_id: StrategyId,
50 instrument_id: InstrumentId,
51 client_order_id: ClientOrderId,
52 venue_order_id: VenueOrderId,
53 command_id: UUID4,
54 ts_init: UnixNanos,
55 ) -> anyhow::Result<Self> {
56 Ok(Self {
57 trader_id,
58 client_id,
59 strategy_id,
60 instrument_id,
61 client_order_id,
62 venue_order_id,
63 command_id,
64 ts_init,
65 })
66 }
67}
68
69impl Display for QueryOrder {
70 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
71 write!(
72 f,
73 "QueryOrder(instrument_id={}, client_order_id={}, venue_order_id={})",
74 self.instrument_id, self.client_order_id, self.venue_order_id,
75 )
76 }
77}
78
79////////////////////////////////////////////////////////////////////////////////
80// Tests
81////////////////////////////////////////////////////////////////////////////////
82#[cfg(test)]
83mod tests {}