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, Default, Serialize, Deserialize, Builder)]
26#[builder(default)]
27#[serde(tag = "type")]
28pub struct QueryAccount {
29 pub trader_id: TraderId,
30 pub client_id: ClientId,
31 pub account_id: AccountId,
32 pub command_id: UUID4,
33 pub ts_init: UnixNanos,
34}
35
36impl QueryAccount {
37 #[allow(clippy::too_many_arguments)]
43 pub const fn new(
44 trader_id: TraderId,
45 client_id: ClientId,
46 account_id: AccountId,
47 command_id: UUID4,
48 ts_init: UnixNanos,
49 ) -> anyhow::Result<Self> {
50 Ok(Self {
51 trader_id,
52 client_id,
53 account_id,
54 command_id,
55 ts_init,
56 })
57 }
58}
59
60impl Display for QueryAccount {
61 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
62 write!(
63 f,
64 "QueryAccount(client_id={}, account_id={})",
65 self.client_id, self.account_id,
66 )
67 }
68}
69
70#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, Builder)]
71#[builder(default)]
72#[serde(tag = "type")]
73pub struct QueryOrder {
74 pub trader_id: TraderId,
75 pub client_id: ClientId,
76 pub strategy_id: StrategyId,
77 pub instrument_id: InstrumentId,
78 pub client_order_id: ClientOrderId,
79 pub venue_order_id: VenueOrderId,
80 pub command_id: UUID4,
81 pub ts_init: UnixNanos,
82}
83
84impl QueryOrder {
85 #[allow(clippy::too_many_arguments)]
91 pub const fn new(
92 trader_id: TraderId,
93 client_id: ClientId,
94 strategy_id: StrategyId,
95 instrument_id: InstrumentId,
96 client_order_id: ClientOrderId,
97 venue_order_id: VenueOrderId,
98 command_id: UUID4,
99 ts_init: UnixNanos,
100 ) -> anyhow::Result<Self> {
101 Ok(Self {
102 trader_id,
103 client_id,
104 strategy_id,
105 instrument_id,
106 client_order_id,
107 venue_order_id,
108 command_id,
109 ts_init,
110 })
111 }
112}
113
114impl Display for QueryOrder {
115 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
116 write!(
117 f,
118 "QueryOrder(instrument_id={}, client_order_id={}, venue_order_id={})",
119 self.instrument_id, self.client_order_id, self.venue_order_id,
120 )
121 }
122}
123
124#[cfg(test)]
128mod tests {}