nautilus_common/messages/execution/
query.rs1use std::fmt::Display;
17
18use derive_builder::Builder;
19use nautilus_core::{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}
34
35impl QueryAccount {
36 #[allow(clippy::too_many_arguments)]
38 #[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 ) -> Self {
46 Self {
47 trader_id,
48 client_id,
49 account_id,
50 command_id,
51 ts_init,
52 }
53 }
54}
55
56impl Display for QueryAccount {
57 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
58 write!(
59 f,
60 "QueryAccount(client_id={:?}, account_id={})",
61 self.client_id, self.account_id,
62 )
63 }
64}
65
66#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Builder)]
67#[serde(tag = "type")]
68pub struct QueryOrder {
69 pub trader_id: TraderId,
70 pub client_id: Option<ClientId>,
71 pub strategy_id: StrategyId,
72 pub instrument_id: InstrumentId,
73 pub client_order_id: ClientOrderId,
74 pub venue_order_id: Option<VenueOrderId>,
75 pub command_id: UUID4,
76 pub ts_init: UnixNanos,
77}
78
79impl QueryOrder {
80 #[allow(clippy::too_many_arguments)]
82 #[must_use]
83 pub const fn new(
84 trader_id: TraderId,
85 client_id: Option<ClientId>,
86 strategy_id: StrategyId,
87 instrument_id: InstrumentId,
88 client_order_id: ClientOrderId,
89 venue_order_id: Option<VenueOrderId>,
90 command_id: UUID4,
91 ts_init: UnixNanos,
92 ) -> Self {
93 Self {
94 trader_id,
95 client_id,
96 strategy_id,
97 instrument_id,
98 client_order_id,
99 venue_order_id,
100 command_id,
101 ts_init,
102 }
103 }
104}
105
106impl Display for QueryOrder {
107 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
108 write!(
109 f,
110 "QueryOrder(instrument_id={}, client_order_id={}, venue_order_id={:?})",
111 self.instrument_id, self.client_order_id, self.venue_order_id,
112 )
113 }
114}
115
116#[cfg(test)]
117mod tests {}