nautilus_common/messages/execution/
report.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 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 nautilus_core::{Params, UUID4, UnixNanos};
19use nautilus_model::identifiers::{ClientId, ClientOrderId, InstrumentId, TraderId, Venue};
20use serde::{Deserialize, Serialize};
21
22#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
23pub struct GenerateOrderStatusReport {
24    pub command_id: UUID4,
25    pub ts_init: UnixNanos,
26    pub instrument_id: Option<InstrumentId>,
27    pub client_order_id: Option<ClientOrderId>,
28    pub venue_order_id: Option<ClientOrderId>,
29    pub params: Option<Params>,
30    pub correlation_id: Option<UUID4>,
31}
32
33impl GenerateOrderStatusReport {
34    #[must_use]
35    pub fn new(
36        command_id: UUID4,
37        ts_init: UnixNanos,
38        instrument_id: Option<InstrumentId>,
39        client_order_id: Option<ClientOrderId>,
40        venue_order_id: Option<ClientOrderId>,
41        params: Option<Params>,
42        correlation_id: Option<UUID4>,
43    ) -> Self {
44        Self {
45            command_id,
46            ts_init,
47            instrument_id,
48            client_order_id,
49            venue_order_id,
50            params,
51            correlation_id,
52        }
53    }
54}
55
56impl Display for GenerateOrderStatusReport {
57    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
58        write!(
59            f,
60            "{}(instrument_id={:?}, client_order_id={:?}, venue_order_id={:?}, command_id={})",
61            stringify!(GenerateOrderStatusReport),
62            self.instrument_id,
63            self.client_order_id,
64            self.venue_order_id,
65            self.command_id,
66        )
67    }
68}
69
70#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
71pub struct GenerateOrderStatusReports {
72    pub command_id: UUID4,
73    pub ts_init: UnixNanos,
74    pub open_only: bool,
75    pub instrument_id: Option<InstrumentId>,
76    pub start: Option<UnixNanos>,
77    pub end: Option<UnixNanos>,
78    pub params: Option<Params>,
79    pub correlation_id: Option<UUID4>,
80}
81
82impl GenerateOrderStatusReports {
83    #[allow(clippy::too_many_arguments)]
84    #[must_use]
85    pub fn new(
86        command_id: UUID4,
87        ts_init: UnixNanos,
88        open_only: bool,
89        instrument_id: Option<InstrumentId>,
90        start: Option<UnixNanos>,
91        end: Option<UnixNanos>,
92        params: Option<Params>,
93        correlation_id: Option<UUID4>,
94    ) -> Self {
95        Self {
96            command_id,
97            ts_init,
98            open_only,
99            instrument_id,
100            start,
101            end,
102            params,
103            correlation_id,
104        }
105    }
106}
107
108impl Display for GenerateOrderStatusReports {
109    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
110        write!(
111            f,
112            "{}(open_only={}, instrument_id={:?}, command_id={})",
113            stringify!(GenerateOrderStatusReports),
114            self.open_only,
115            self.instrument_id,
116            self.command_id,
117        )
118    }
119}
120
121#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
122pub struct GenerateFillReports {
123    pub command_id: UUID4,
124    pub ts_init: UnixNanos,
125    pub instrument_id: Option<InstrumentId>,
126    pub venue_order_id: Option<ClientOrderId>,
127    pub start: Option<UnixNanos>,
128    pub end: Option<UnixNanos>,
129    pub params: Option<Params>,
130    pub correlation_id: Option<UUID4>,
131}
132
133impl GenerateFillReports {
134    #[allow(clippy::too_many_arguments)]
135    #[must_use]
136    pub fn new(
137        command_id: UUID4,
138        ts_init: UnixNanos,
139        instrument_id: Option<InstrumentId>,
140        venue_order_id: Option<ClientOrderId>,
141        start: Option<UnixNanos>,
142        end: Option<UnixNanos>,
143        params: Option<Params>,
144        correlation_id: Option<UUID4>,
145    ) -> Self {
146        Self {
147            command_id,
148            ts_init,
149            instrument_id,
150            venue_order_id,
151            start,
152            end,
153            params,
154            correlation_id,
155        }
156    }
157}
158
159impl Display for GenerateFillReports {
160    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
161        write!(
162            f,
163            "{}(instrument_id={:?}, venue_order_id={:?}, command_id={})",
164            stringify!(GenerateFillReports),
165            self.instrument_id,
166            self.venue_order_id,
167            self.command_id,
168        )
169    }
170}
171
172#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
173pub struct GeneratePositionStatusReports {
174    pub command_id: UUID4,
175    pub ts_init: UnixNanos,
176    pub instrument_id: Option<InstrumentId>,
177    pub start: Option<UnixNanos>,
178    pub end: Option<UnixNanos>,
179    pub params: Option<Params>,
180    pub correlation_id: Option<UUID4>,
181}
182
183impl GeneratePositionStatusReports {
184    #[must_use]
185    pub fn new(
186        command_id: UUID4,
187        ts_init: UnixNanos,
188        instrument_id: Option<InstrumentId>,
189        start: Option<UnixNanos>,
190        end: Option<UnixNanos>,
191        params: Option<Params>,
192        correlation_id: Option<UUID4>,
193    ) -> Self {
194        Self {
195            command_id,
196            ts_init,
197            instrument_id,
198            start,
199            end,
200            params,
201            correlation_id,
202        }
203    }
204}
205
206impl Display for GeneratePositionStatusReports {
207    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
208        write!(
209            f,
210            "{}(instrument_id={:?}, command_id={})",
211            stringify!(GeneratePositionStatusReports),
212            self.instrument_id,
213            self.command_id,
214        )
215    }
216}
217
218#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
219pub struct GenerateExecutionMassStatus {
220    pub trader_id: TraderId,
221    pub client_id: ClientId,
222    pub venue: Option<Venue>,
223    pub command_id: UUID4,
224    pub ts_init: UnixNanos,
225    pub params: Option<Params>,
226    pub correlation_id: Option<UUID4>,
227}
228
229impl GenerateExecutionMassStatus {
230    #[must_use]
231    pub fn new(
232        trader_id: TraderId,
233        client_id: ClientId,
234        venue: Option<Venue>,
235        command_id: UUID4,
236        ts_init: UnixNanos,
237        params: Option<Params>,
238        correlation_id: Option<UUID4>,
239    ) -> Self {
240        Self {
241            trader_id,
242            client_id,
243            venue,
244            command_id,
245            ts_init,
246            params,
247            correlation_id,
248        }
249    }
250}
251
252impl Display for GenerateExecutionMassStatus {
253    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
254        write!(
255            f,
256            "{}(trader_id={}, client_id={}, venue={:?}, command_id={})",
257            stringify!(GenerateExecutionMassStatus),
258            self.trader_id,
259            self.client_id,
260            self.venue,
261            self.command_id,
262        )
263    }
264}