nautilus_execution/messages/
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    #[allow(clippy::too_many_arguments)]
42    pub const fn new(
43        trader_id: TraderId,
44        client_id: ClientId,
45        strategy_id: StrategyId,
46        instrument_id: InstrumentId,
47        client_order_id: ClientOrderId,
48        venue_order_id: VenueOrderId,
49        command_id: UUID4,
50        ts_init: UnixNanos,
51    ) -> anyhow::Result<Self> {
52        Ok(Self {
53            trader_id,
54            client_id,
55            strategy_id,
56            instrument_id,
57            client_order_id,
58            venue_order_id,
59            command_id,
60            ts_init,
61        })
62    }
63}
64
65impl Display for QueryOrder {
66    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
67        write!(
68            f,
69            "QueryOrder(instrument_id={}, client_order_id={}, venue_order_id={})",
70            self.instrument_id, self.client_order_id, self.venue_order_id,
71        )
72    }
73}
74
75////////////////////////////////////////////////////////////////////////////////
76// Tests
77////////////////////////////////////////////////////////////////////////////////
78#[cfg(test)]
79mod tests {}