nautilus_common/messages/execution/
query.rs1use std::fmt::Display;
17
18use derive_builder::Builder;
19use nautilus_core::{Params, UUID4, UnixNanos};
20use nautilus_model::identifiers::{
21 AccountId, ClientId, ClientOrderId, InstrumentId, StrategyId, TraderId, VenueOrderId,
22};
23use serde::{Deserialize, Serialize};
24
25#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Builder)]
26#[serde(tag = "type")]
27pub struct QueryAccount {
28 pub trader_id: TraderId,
29 pub client_id: Option<ClientId>,
30 pub account_id: AccountId,
31 pub command_id: UUID4,
32 pub ts_init: UnixNanos,
33 pub params: Option<Params>,
34}
35
36impl QueryAccount {
37 #[must_use]
39 pub const fn new(
40 trader_id: TraderId,
41 client_id: Option<ClientId>,
42 account_id: AccountId,
43 command_id: UUID4,
44 ts_init: UnixNanos,
45 params: Option<Params>,
46 ) -> Self {
47 Self {
48 trader_id,
49 client_id,
50 account_id,
51 command_id,
52 ts_init,
53 params,
54 }
55 }
56}
57
58impl Display for QueryAccount {
59 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
60 write!(
61 f,
62 "QueryAccount(client_id={:?}, account_id={})",
63 self.client_id, self.account_id,
64 )
65 }
66}
67
68#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Builder)]
69#[serde(tag = "type")]
70pub struct QueryOrder {
71 pub trader_id: TraderId,
72 pub client_id: Option<ClientId>,
73 pub strategy_id: StrategyId,
74 pub instrument_id: InstrumentId,
75 pub client_order_id: ClientOrderId,
76 pub venue_order_id: Option<VenueOrderId>,
77 pub command_id: UUID4,
78 pub ts_init: UnixNanos,
79 pub params: Option<Params>,
80}
81
82impl QueryOrder {
83 #[expect(clippy::too_many_arguments)]
85 #[must_use]
86 pub const fn new(
87 trader_id: TraderId,
88 client_id: Option<ClientId>,
89 strategy_id: StrategyId,
90 instrument_id: InstrumentId,
91 client_order_id: ClientOrderId,
92 venue_order_id: Option<VenueOrderId>,
93 command_id: UUID4,
94 ts_init: UnixNanos,
95 params: Option<Params>,
96 ) -> Self {
97 Self {
98 trader_id,
99 client_id,
100 strategy_id,
101 instrument_id,
102 client_order_id,
103 venue_order_id,
104 command_id,
105 ts_init,
106 params,
107 }
108 }
109}
110
111impl Display for QueryOrder {
112 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
113 write!(
114 f,
115 "QueryOrder(instrument_id={}, client_order_id={}, venue_order_id={:?})",
116 self.instrument_id, self.client_order_id, self.venue_order_id,
117 )
118 }
119}
120
121#[cfg(test)]
122mod tests {}