1use std::{any::Any, sync::Arc};
17
18use indexmap::IndexMap;
19use nautilus_core::{UUID4, UnixNanos};
20use nautilus_model::{
21 data::{Bar, BarType, DataType, QuoteTick, TradeTick},
22 identifiers::{ClientId, InstrumentId, Venue},
23 instruments::InstrumentAny,
24 orderbook::OrderBook,
25};
26
27use super::Payload;
28
29#[derive(Clone, Debug)]
30pub struct CustomDataResponse {
31 pub correlation_id: UUID4,
32 pub client_id: ClientId,
33 pub venue: Option<Venue>,
34 pub data_type: DataType,
35 pub data: Payload,
36 pub start: Option<UnixNanos>,
37 pub end: Option<UnixNanos>,
38 pub ts_init: UnixNanos,
39 pub params: Option<IndexMap<String, String>>,
40}
41
42impl CustomDataResponse {
43 #[allow(clippy::too_many_arguments)]
45 pub fn new<T: Any + Send + Sync>(
46 correlation_id: UUID4,
47 client_id: ClientId,
48 venue: Option<Venue>,
49 data_type: DataType,
50 data: T,
51 start: Option<UnixNanos>,
52 end: Option<UnixNanos>,
53 ts_init: UnixNanos,
54 params: Option<IndexMap<String, String>>,
55 ) -> Self {
56 Self {
57 correlation_id,
58 client_id,
59 venue,
60 data_type,
61 data: Arc::new(data),
62 start,
63 end,
64 ts_init,
65 params,
66 }
67 }
68
69 pub fn as_any(&self) -> &dyn Any {
71 self
72 }
73}
74
75#[derive(Clone, Debug)]
76pub struct InstrumentResponse {
77 pub correlation_id: UUID4,
78 pub client_id: ClientId,
79 pub instrument_id: InstrumentId,
80 pub data: InstrumentAny,
81 pub start: Option<UnixNanos>,
82 pub end: Option<UnixNanos>,
83 pub ts_init: UnixNanos,
84 pub params: Option<IndexMap<String, String>>,
85}
86
87impl InstrumentResponse {
88 pub fn as_any(&self) -> &dyn Any {
90 self
91 }
92
93 #[allow(clippy::too_many_arguments)]
95 pub fn new(
96 correlation_id: UUID4,
97 client_id: ClientId,
98 instrument_id: InstrumentId,
99 data: InstrumentAny,
100 start: Option<UnixNanos>,
101 end: Option<UnixNanos>,
102 ts_init: UnixNanos,
103 params: Option<IndexMap<String, String>>,
104 ) -> Self {
105 Self {
106 correlation_id,
107 client_id,
108 instrument_id,
109 data,
110 start,
111 end,
112 ts_init,
113 params,
114 }
115 }
116}
117
118#[derive(Clone, Debug)]
119pub struct InstrumentsResponse {
120 pub correlation_id: UUID4,
121 pub client_id: ClientId,
122 pub venue: Venue,
123 pub data: Vec<InstrumentAny>,
124 pub start: Option<UnixNanos>,
125 pub end: Option<UnixNanos>,
126 pub ts_init: UnixNanos,
127 pub params: Option<IndexMap<String, String>>,
128}
129
130impl InstrumentsResponse {
131 pub fn as_any(&self) -> &dyn Any {
133 self
134 }
135
136 #[allow(clippy::too_many_arguments)]
138 pub fn new(
139 correlation_id: UUID4,
140 client_id: ClientId,
141 venue: Venue,
142 data: Vec<InstrumentAny>,
143 start: Option<UnixNanos>,
144 end: Option<UnixNanos>,
145 ts_init: UnixNanos,
146 params: Option<IndexMap<String, String>>,
147 ) -> Self {
148 Self {
149 correlation_id,
150 client_id,
151 venue,
152 data,
153 start,
154 end,
155 ts_init,
156 params,
157 }
158 }
159}
160
161#[derive(Clone, Debug)]
162pub struct BookResponse {
163 pub correlation_id: UUID4,
164 pub client_id: ClientId,
165 pub instrument_id: InstrumentId,
166 pub data: OrderBook,
167 pub start: Option<UnixNanos>,
168 pub end: Option<UnixNanos>,
169 pub ts_init: UnixNanos,
170 pub params: Option<IndexMap<String, String>>,
171}
172
173impl BookResponse {
174 pub fn as_any(&self) -> &dyn Any {
176 self
177 }
178
179 #[allow(clippy::too_many_arguments)]
181 pub fn new(
182 correlation_id: UUID4,
183 client_id: ClientId,
184 instrument_id: InstrumentId,
185 data: OrderBook,
186 start: Option<UnixNanos>,
187 end: Option<UnixNanos>,
188 ts_init: UnixNanos,
189 params: Option<IndexMap<String, String>>,
190 ) -> Self {
191 Self {
192 correlation_id,
193 client_id,
194 instrument_id,
195 data,
196 start,
197 end,
198 ts_init,
199 params,
200 }
201 }
202}
203
204#[derive(Clone, Debug)]
205pub struct QuotesResponse {
206 pub correlation_id: UUID4,
207 pub client_id: ClientId,
208 pub instrument_id: InstrumentId,
209 pub data: Vec<QuoteTick>,
210 pub start: Option<UnixNanos>,
211 pub end: Option<UnixNanos>,
212 pub ts_init: UnixNanos,
213 pub params: Option<IndexMap<String, String>>,
214}
215
216impl QuotesResponse {
217 pub fn as_any(&self) -> &dyn Any {
219 self
220 }
221
222 #[allow(clippy::too_many_arguments)]
224 pub fn new(
225 correlation_id: UUID4,
226 client_id: ClientId,
227 instrument_id: InstrumentId,
228 data: Vec<QuoteTick>,
229 start: Option<UnixNanos>,
230 end: Option<UnixNanos>,
231 ts_init: UnixNanos,
232 params: Option<IndexMap<String, String>>,
233 ) -> Self {
234 Self {
235 correlation_id,
236 client_id,
237 instrument_id,
238 data,
239 start,
240 end,
241 ts_init,
242 params,
243 }
244 }
245}
246
247#[derive(Clone, Debug)]
248pub struct TradesResponse {
249 pub correlation_id: UUID4,
250 pub client_id: ClientId,
251 pub instrument_id: InstrumentId,
252 pub data: Vec<TradeTick>,
253 pub start: Option<UnixNanos>,
254 pub end: Option<UnixNanos>,
255 pub ts_init: UnixNanos,
256 pub params: Option<IndexMap<String, String>>,
257}
258
259impl TradesResponse {
260 pub fn as_any(&self) -> &dyn Any {
262 self
263 }
264
265 #[allow(clippy::too_many_arguments)]
267 pub fn new(
268 correlation_id: UUID4,
269 client_id: ClientId,
270 instrument_id: InstrumentId,
271 data: Vec<TradeTick>,
272 start: Option<UnixNanos>,
273 end: Option<UnixNanos>,
274 ts_init: UnixNanos,
275 params: Option<IndexMap<String, String>>,
276 ) -> Self {
277 Self {
278 correlation_id,
279 client_id,
280 instrument_id,
281 data,
282 start,
283 end,
284 ts_init,
285 params,
286 }
287 }
288}
289
290#[derive(Clone, Debug)]
291pub struct BarsResponse {
292 pub correlation_id: UUID4,
293 pub client_id: ClientId,
294 pub bar_type: BarType,
295 pub data: Vec<Bar>,
296 pub ts_init: UnixNanos,
297 pub start: Option<UnixNanos>,
298 pub end: Option<UnixNanos>,
299 pub params: Option<IndexMap<String, String>>,
300}
301
302impl BarsResponse {
303 pub fn as_any(&self) -> &dyn Any {
305 self
306 }
307
308 #[allow(clippy::too_many_arguments)]
310 pub fn new(
311 correlation_id: UUID4,
312 client_id: ClientId,
313 bar_type: BarType,
314 data: Vec<Bar>,
315 start: Option<UnixNanos>,
316 end: Option<UnixNanos>,
317 ts_init: UnixNanos,
318 params: Option<IndexMap<String, String>>,
319 ) -> Self {
320 Self {
321 correlation_id,
322 client_id,
323 bar_type,
324 data,
325 start,
326 end,
327 ts_init,
328 params,
329 }
330 }
331}