1use std::num::NonZeroUsize;
17
18use nautilus_core::{Params, UUID4, UnixNanos};
19use nautilus_model::{
20 data::{BarType, DataType},
21 identifiers::{ClientId, InstrumentId, OptionSeriesId, Venue},
22};
23use serde::{Deserialize, Serialize};
24
25use super::check_client_id_or_venue;
26
27#[derive(Clone, Debug, Serialize, Deserialize)]
28pub struct UnsubscribeCustomData {
29 pub client_id: Option<ClientId>,
30 pub venue: Option<Venue>,
31 pub data_type: DataType,
32 pub command_id: UUID4,
33 pub ts_init: UnixNanos,
34 pub correlation_id: Option<UUID4>,
35 pub params: Option<Params>,
36}
37
38impl UnsubscribeCustomData {
39 pub fn new(
41 client_id: Option<ClientId>,
42 venue: Option<Venue>,
43 data_type: DataType,
44 command_id: UUID4,
45 ts_init: UnixNanos,
46 correlation_id: Option<UUID4>,
47 params: Option<Params>,
48 ) -> Self {
49 check_client_id_or_venue(&client_id, &venue);
50 Self {
51 client_id,
52 venue,
53 data_type,
54 command_id,
55 ts_init,
56 correlation_id,
57 params,
58 }
59 }
60}
61
62#[derive(Clone, Debug, Serialize, Deserialize)]
63pub struct UnsubscribeInstrument {
64 pub instrument_id: InstrumentId,
65 pub client_id: Option<ClientId>,
66 pub venue: Option<Venue>,
67 pub command_id: UUID4,
68 pub ts_init: UnixNanos,
69 pub correlation_id: Option<UUID4>,
70 pub params: Option<Params>,
71}
72
73impl UnsubscribeInstrument {
74 pub fn new(
76 instrument_id: InstrumentId,
77 client_id: Option<ClientId>,
78 venue: Option<Venue>,
79 command_id: UUID4,
80 ts_init: UnixNanos,
81 correlation_id: Option<UUID4>,
82 params: Option<Params>,
83 ) -> Self {
84 check_client_id_or_venue(&client_id, &venue);
85 Self {
86 instrument_id,
87 client_id,
88 venue,
89 command_id,
90 ts_init,
91 correlation_id,
92 params,
93 }
94 }
95}
96
97#[derive(Clone, Debug, Serialize, Deserialize)]
98pub struct UnsubscribeInstruments {
99 pub client_id: Option<ClientId>,
100 pub venue: Venue,
101 pub command_id: UUID4,
102 pub ts_init: UnixNanos,
103 pub correlation_id: Option<UUID4>,
104 pub params: Option<Params>,
105}
106
107impl UnsubscribeInstruments {
108 pub fn new(
110 client_id: Option<ClientId>,
111 venue: Venue,
112 command_id: UUID4,
113 ts_init: UnixNanos,
114 correlation_id: Option<UUID4>,
115 params: Option<Params>,
116 ) -> Self {
117 Self {
118 client_id,
119 venue,
120 command_id,
121 ts_init,
122 correlation_id,
123 params,
124 }
125 }
126}
127
128#[derive(Clone, Debug, Serialize, Deserialize)]
129pub struct UnsubscribeBookDeltas {
130 pub instrument_id: InstrumentId,
131 pub client_id: Option<ClientId>,
132 pub venue: Option<Venue>,
133 pub command_id: UUID4,
134 pub ts_init: UnixNanos,
135 pub correlation_id: Option<UUID4>,
136 pub params: Option<Params>,
137}
138
139impl UnsubscribeBookDeltas {
140 pub fn new(
142 instrument_id: InstrumentId,
143 client_id: Option<ClientId>,
144 venue: Option<Venue>,
145 command_id: UUID4,
146 ts_init: UnixNanos,
147 correlation_id: Option<UUID4>,
148 params: Option<Params>,
149 ) -> Self {
150 check_client_id_or_venue(&client_id, &venue);
151 Self {
152 instrument_id,
153 client_id,
154 venue,
155 command_id,
156 ts_init,
157 correlation_id,
158 params,
159 }
160 }
161}
162
163#[derive(Clone, Debug, Serialize, Deserialize)]
164pub struct UnsubscribeBookDepth10 {
165 pub instrument_id: InstrumentId,
166 pub client_id: Option<ClientId>,
167 pub venue: Option<Venue>,
168 pub command_id: UUID4,
169 pub ts_init: UnixNanos,
170 pub correlation_id: Option<UUID4>,
171 pub params: Option<Params>,
172}
173
174impl UnsubscribeBookDepth10 {
175 pub fn new(
177 instrument_id: InstrumentId,
178 client_id: Option<ClientId>,
179 venue: Option<Venue>,
180 command_id: UUID4,
181 ts_init: UnixNanos,
182 correlation_id: Option<UUID4>,
183 params: Option<Params>,
184 ) -> Self {
185 check_client_id_or_venue(&client_id, &venue);
186 Self {
187 instrument_id,
188 client_id,
189 venue,
190 command_id,
191 ts_init,
192 correlation_id,
193 params,
194 }
195 }
196}
197
198#[derive(Clone, Debug, Serialize, Deserialize)]
199pub struct UnsubscribeBookSnapshots {
200 pub instrument_id: InstrumentId,
201 pub interval_ms: NonZeroUsize,
202 pub client_id: Option<ClientId>,
203 pub venue: Option<Venue>,
204 pub command_id: UUID4,
205 pub ts_init: UnixNanos,
206 pub correlation_id: Option<UUID4>,
207 pub params: Option<Params>,
208}
209
210impl UnsubscribeBookSnapshots {
211 #[expect(clippy::too_many_arguments)]
213 pub fn new(
214 instrument_id: InstrumentId,
215 interval_ms: NonZeroUsize,
216 client_id: Option<ClientId>,
217 venue: Option<Venue>,
218 command_id: UUID4,
219 ts_init: UnixNanos,
220 correlation_id: Option<UUID4>,
221 params: Option<Params>,
222 ) -> Self {
223 check_client_id_or_venue(&client_id, &venue);
224 Self {
225 instrument_id,
226 interval_ms,
227 client_id,
228 venue,
229 command_id,
230 ts_init,
231 correlation_id,
232 params,
233 }
234 }
235}
236
237#[derive(Clone, Debug, Serialize, Deserialize)]
238pub struct UnsubscribeQuotes {
239 pub instrument_id: InstrumentId,
240 pub client_id: Option<ClientId>,
241 pub venue: Option<Venue>,
242 pub command_id: UUID4,
243 pub ts_init: UnixNanos,
244 pub correlation_id: Option<UUID4>,
245 pub params: Option<Params>,
246}
247
248impl UnsubscribeQuotes {
249 pub fn new(
251 instrument_id: InstrumentId,
252 client_id: Option<ClientId>,
253 venue: Option<Venue>,
254 command_id: UUID4,
255 ts_init: UnixNanos,
256 correlation_id: Option<UUID4>,
257 params: Option<Params>,
258 ) -> Self {
259 check_client_id_or_venue(&client_id, &venue);
260 Self {
261 instrument_id,
262 client_id,
263 venue,
264 command_id,
265 ts_init,
266 correlation_id,
267 params,
268 }
269 }
270}
271
272#[derive(Clone, Debug, Serialize, Deserialize)]
273pub struct UnsubscribeTrades {
274 pub instrument_id: InstrumentId,
275 pub client_id: Option<ClientId>,
276 pub venue: Option<Venue>,
277 pub command_id: UUID4,
278 pub ts_init: UnixNanos,
279 pub correlation_id: Option<UUID4>,
280 pub params: Option<Params>,
281}
282
283impl UnsubscribeTrades {
284 pub fn new(
286 instrument_id: InstrumentId,
287 client_id: Option<ClientId>,
288 venue: Option<Venue>,
289 command_id: UUID4,
290 ts_init: UnixNanos,
291 correlation_id: Option<UUID4>,
292 params: Option<Params>,
293 ) -> Self {
294 check_client_id_or_venue(&client_id, &venue);
295 Self {
296 instrument_id,
297 client_id,
298 venue,
299 command_id,
300 ts_init,
301 correlation_id,
302 params,
303 }
304 }
305}
306
307#[derive(Clone, Debug, Serialize, Deserialize)]
308pub struct UnsubscribeBars {
309 pub bar_type: BarType,
310 pub client_id: Option<ClientId>,
311 pub venue: Option<Venue>,
312 pub command_id: UUID4,
313 pub ts_init: UnixNanos,
314 pub correlation_id: Option<UUID4>,
315 pub params: Option<Params>,
316}
317
318impl UnsubscribeBars {
319 pub fn new(
321 bar_type: BarType,
322 client_id: Option<ClientId>,
323 venue: Option<Venue>,
324 command_id: UUID4,
325 ts_init: UnixNanos,
326 correlation_id: Option<UUID4>,
327 params: Option<Params>,
328 ) -> Self {
329 check_client_id_or_venue(&client_id, &venue);
330 Self {
331 bar_type,
332 client_id,
333 venue,
334 command_id,
335 ts_init,
336 correlation_id,
337 params,
338 }
339 }
340}
341
342#[derive(Clone, Debug, Serialize, Deserialize)]
343pub struct UnsubscribeMarkPrices {
344 pub instrument_id: InstrumentId,
345 pub client_id: Option<ClientId>,
346 pub venue: Option<Venue>,
347 pub command_id: UUID4,
348 pub ts_init: UnixNanos,
349 pub correlation_id: Option<UUID4>,
350 pub params: Option<Params>,
351}
352
353impl UnsubscribeMarkPrices {
354 pub fn new(
356 instrument_id: InstrumentId,
357 client_id: Option<ClientId>,
358 venue: Option<Venue>,
359 command_id: UUID4,
360 ts_init: UnixNanos,
361 correlation_id: Option<UUID4>,
362 params: Option<Params>,
363 ) -> Self {
364 check_client_id_or_venue(&client_id, &venue);
365 Self {
366 instrument_id,
367 client_id,
368 venue,
369 command_id,
370 ts_init,
371 correlation_id,
372 params,
373 }
374 }
375}
376
377#[derive(Clone, Debug, Serialize, Deserialize)]
378pub struct UnsubscribeIndexPrices {
379 pub instrument_id: InstrumentId,
380 pub client_id: Option<ClientId>,
381 pub venue: Option<Venue>,
382 pub command_id: UUID4,
383 pub ts_init: UnixNanos,
384 pub correlation_id: Option<UUID4>,
385 pub params: Option<Params>,
386}
387
388impl UnsubscribeIndexPrices {
389 pub fn new(
391 instrument_id: InstrumentId,
392 client_id: Option<ClientId>,
393 venue: Option<Venue>,
394 command_id: UUID4,
395 ts_init: UnixNanos,
396 correlation_id: Option<UUID4>,
397 params: Option<Params>,
398 ) -> Self {
399 check_client_id_or_venue(&client_id, &venue);
400 Self {
401 instrument_id,
402 client_id,
403 venue,
404 command_id,
405 ts_init,
406 correlation_id,
407 params,
408 }
409 }
410}
411
412#[derive(Clone, Debug, Serialize, Deserialize)]
413pub struct UnsubscribeFundingRates {
414 pub instrument_id: InstrumentId,
415 pub client_id: Option<ClientId>,
416 pub venue: Option<Venue>,
417 pub command_id: UUID4,
418 pub ts_init: UnixNanos,
419 pub correlation_id: Option<UUID4>,
420 pub params: Option<Params>,
421}
422
423impl UnsubscribeFundingRates {
424 pub fn new(
426 instrument_id: InstrumentId,
427 client_id: Option<ClientId>,
428 venue: Option<Venue>,
429 command_id: UUID4,
430 ts_init: UnixNanos,
431 correlation_id: Option<UUID4>,
432 params: Option<Params>,
433 ) -> Self {
434 check_client_id_or_venue(&client_id, &venue);
435 Self {
436 instrument_id,
437 client_id,
438 venue,
439 command_id,
440 ts_init,
441 correlation_id,
442 params,
443 }
444 }
445}
446
447#[derive(Clone, Debug, Serialize, Deserialize)]
448pub struct UnsubscribeInstrumentStatus {
449 pub instrument_id: InstrumentId,
450 pub client_id: Option<ClientId>,
451 pub venue: Option<Venue>,
452 pub command_id: UUID4,
453 pub ts_init: UnixNanos,
454 pub correlation_id: Option<UUID4>,
455 pub params: Option<Params>,
456}
457
458impl UnsubscribeInstrumentStatus {
459 pub fn new(
461 instrument_id: InstrumentId,
462 client_id: Option<ClientId>,
463 venue: Option<Venue>,
464 command_id: UUID4,
465 ts_init: UnixNanos,
466 correlation_id: Option<UUID4>,
467 params: Option<Params>,
468 ) -> Self {
469 check_client_id_or_venue(&client_id, &venue);
470 Self {
471 instrument_id,
472 client_id,
473 venue,
474 command_id,
475 ts_init,
476 correlation_id,
477 params,
478 }
479 }
480}
481
482#[derive(Clone, Debug, Serialize, Deserialize)]
483pub struct UnsubscribeOptionGreeks {
484 pub instrument_id: InstrumentId,
485 pub client_id: Option<ClientId>,
486 pub venue: Option<Venue>,
487 pub command_id: UUID4,
488 pub ts_init: UnixNanos,
489 pub correlation_id: Option<UUID4>,
490 pub params: Option<Params>,
491}
492
493impl UnsubscribeOptionGreeks {
494 pub fn new(
496 instrument_id: InstrumentId,
497 client_id: Option<ClientId>,
498 venue: Option<Venue>,
499 command_id: UUID4,
500 ts_init: UnixNanos,
501 correlation_id: Option<UUID4>,
502 params: Option<Params>,
503 ) -> Self {
504 check_client_id_or_venue(&client_id, &venue);
505 Self {
506 instrument_id,
507 client_id,
508 venue,
509 command_id,
510 ts_init,
511 correlation_id,
512 params,
513 }
514 }
515}
516
517#[derive(Clone, Debug, Serialize, Deserialize)]
518pub struct UnsubscribeInstrumentClose {
519 pub instrument_id: InstrumentId,
520 pub client_id: Option<ClientId>,
521 pub venue: Option<Venue>,
522 pub command_id: UUID4,
523 pub ts_init: UnixNanos,
524 pub correlation_id: Option<UUID4>,
525 pub params: Option<Params>,
526}
527
528impl UnsubscribeInstrumentClose {
529 pub fn new(
531 instrument_id: InstrumentId,
532 client_id: Option<ClientId>,
533 venue: Option<Venue>,
534 command_id: UUID4,
535 ts_init: UnixNanos,
536 correlation_id: Option<UUID4>,
537 params: Option<Params>,
538 ) -> Self {
539 check_client_id_or_venue(&client_id, &venue);
540 Self {
541 instrument_id,
542 client_id,
543 venue,
544 command_id,
545 ts_init,
546 correlation_id,
547 params,
548 }
549 }
550}
551
552#[derive(Clone, Debug, Serialize, Deserialize)]
553pub struct UnsubscribeOptionChain {
554 pub series_id: OptionSeriesId,
555 pub command_id: UUID4,
556 pub ts_init: UnixNanos,
557 pub client_id: Option<ClientId>,
558 pub venue: Option<Venue>,
559}
560
561impl UnsubscribeOptionChain {
562 pub fn new(
564 series_id: OptionSeriesId,
565 command_id: UUID4,
566 ts_init: UnixNanos,
567 client_id: Option<ClientId>,
568 venue: Option<Venue>,
569 ) -> Self {
570 check_client_id_or_venue(&client_id, &venue);
571 Self {
572 series_id,
573 command_id,
574 ts_init,
575 client_id,
576 venue,
577 }
578 }
579}