1use std::num::NonZeroUsize;
17
18use nautilus_core::{Params, UUID4, UnixNanos};
19use nautilus_model::{
20 data::{BarType, DataType, option_chain::StrikeRange},
21 enums::BookType,
22 identifiers::{ClientId, InstrumentId, OptionSeriesId, Venue},
23};
24
25use super::check_client_id_or_venue;
26
27#[derive(Clone, Debug)]
28pub struct SubscribeCustomData {
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 SubscribeCustomData {
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)]
63pub struct SubscribeInstrument {
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 SubscribeInstrument {
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)]
98pub struct SubscribeInstruments {
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 SubscribeInstruments {
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)]
129pub struct SubscribeBookDeltas {
130 pub instrument_id: InstrumentId,
131 pub book_type: BookType,
132 pub client_id: Option<ClientId>,
133 pub venue: Option<Venue>,
134 pub command_id: UUID4,
135 pub ts_init: UnixNanos,
136 pub depth: Option<NonZeroUsize>,
137 pub managed: bool,
138 pub correlation_id: Option<UUID4>,
139 pub params: Option<Params>,
140}
141
142impl SubscribeBookDeltas {
143 #[expect(clippy::too_many_arguments)]
145 pub fn new(
146 instrument_id: InstrumentId,
147 book_type: BookType,
148 client_id: Option<ClientId>,
149 venue: Option<Venue>,
150 command_id: UUID4,
151 ts_init: UnixNanos,
152 depth: Option<NonZeroUsize>,
153 managed: bool,
154 correlation_id: Option<UUID4>,
155 params: Option<Params>,
156 ) -> Self {
157 check_client_id_or_venue(&client_id, &venue);
158 Self {
159 instrument_id,
160 book_type,
161 client_id,
162 venue,
163 command_id,
164 ts_init,
165 depth,
166 managed,
167 correlation_id,
168 params,
169 }
170 }
171}
172
173#[derive(Clone, Debug)]
174pub struct SubscribeBookDepth10 {
175 pub instrument_id: InstrumentId,
176 pub book_type: BookType,
177 pub client_id: Option<ClientId>,
178 pub venue: Option<Venue>,
179 pub command_id: UUID4,
180 pub ts_init: UnixNanos,
181 pub depth: Option<NonZeroUsize>,
182 pub managed: bool,
183 pub correlation_id: Option<UUID4>,
184 pub params: Option<Params>,
185}
186
187impl SubscribeBookDepth10 {
188 #[expect(clippy::too_many_arguments)]
190 pub fn new(
191 instrument_id: InstrumentId,
192 book_type: BookType,
193 client_id: Option<ClientId>,
194 venue: Option<Venue>,
195 command_id: UUID4,
196 ts_init: UnixNanos,
197 depth: Option<NonZeroUsize>,
198 managed: bool,
199 correlation_id: Option<UUID4>,
200 params: Option<Params>,
201 ) -> Self {
202 check_client_id_or_venue(&client_id, &venue);
203 Self {
204 instrument_id,
205 book_type,
206 client_id,
207 venue,
208 command_id,
209 ts_init,
210 depth,
211 managed,
212 correlation_id,
213 params,
214 }
215 }
216}
217
218#[derive(Clone, Debug)]
219pub struct SubscribeBookSnapshots {
220 pub instrument_id: InstrumentId,
221 pub book_type: BookType,
222 pub client_id: Option<ClientId>,
223 pub venue: Option<Venue>,
224 pub command_id: UUID4,
225 pub ts_init: UnixNanos,
226 pub depth: Option<NonZeroUsize>,
227 pub interval_ms: NonZeroUsize,
228 pub correlation_id: Option<UUID4>,
229 pub params: Option<Params>,
230}
231
232impl SubscribeBookSnapshots {
233 #[expect(clippy::too_many_arguments)]
235 pub fn new(
236 instrument_id: InstrumentId,
237 book_type: BookType,
238 client_id: Option<ClientId>,
239 venue: Option<Venue>,
240 command_id: UUID4,
241 ts_init: UnixNanos,
242 depth: Option<NonZeroUsize>,
243 interval_ms: NonZeroUsize,
244 correlation_id: Option<UUID4>,
245 params: Option<Params>,
246 ) -> Self {
247 check_client_id_or_venue(&client_id, &venue);
248 Self {
249 instrument_id,
250 book_type,
251 client_id,
252 venue,
253 command_id,
254 ts_init,
255 depth,
256 interval_ms,
257 correlation_id,
258 params,
259 }
260 }
261}
262
263#[derive(Clone, Debug)]
264pub struct SubscribeQuotes {
265 pub instrument_id: InstrumentId,
266 pub client_id: Option<ClientId>,
267 pub venue: Option<Venue>,
268 pub command_id: UUID4,
269 pub ts_init: UnixNanos,
270 pub correlation_id: Option<UUID4>,
271 pub params: Option<Params>,
272}
273
274impl SubscribeQuotes {
275 pub fn new(
277 instrument_id: InstrumentId,
278 client_id: Option<ClientId>,
279 venue: Option<Venue>,
280 command_id: UUID4,
281 ts_init: UnixNanos,
282 correlation_id: Option<UUID4>,
283 params: Option<Params>,
284 ) -> Self {
285 check_client_id_or_venue(&client_id, &venue);
286 Self {
287 instrument_id,
288 client_id,
289 venue,
290 command_id,
291 ts_init,
292 correlation_id,
293 params,
294 }
295 }
296}
297
298#[derive(Clone, Debug)]
299pub struct SubscribeTrades {
300 pub instrument_id: InstrumentId,
301 pub client_id: Option<ClientId>,
302 pub venue: Option<Venue>,
303 pub command_id: UUID4,
304 pub ts_init: UnixNanos,
305 pub correlation_id: Option<UUID4>,
306 pub params: Option<Params>,
307}
308
309impl SubscribeTrades {
310 pub fn new(
312 instrument_id: InstrumentId,
313 client_id: Option<ClientId>,
314 venue: Option<Venue>,
315 command_id: UUID4,
316 ts_init: UnixNanos,
317 correlation_id: Option<UUID4>,
318 params: Option<Params>,
319 ) -> Self {
320 check_client_id_or_venue(&client_id, &venue);
321 Self {
322 instrument_id,
323 client_id,
324 venue,
325 command_id,
326 ts_init,
327 correlation_id,
328 params,
329 }
330 }
331}
332
333#[derive(Clone, Debug)]
334pub struct SubscribeBars {
335 pub bar_type: BarType,
336 pub client_id: Option<ClientId>,
337 pub venue: Option<Venue>,
338 pub command_id: UUID4,
339 pub ts_init: UnixNanos,
340 pub correlation_id: Option<UUID4>,
341 pub params: Option<Params>,
342}
343
344impl SubscribeBars {
345 pub fn new(
347 bar_type: BarType,
348 client_id: Option<ClientId>,
349 venue: Option<Venue>,
350 command_id: UUID4,
351 ts_init: UnixNanos,
352 correlation_id: Option<UUID4>,
353 params: Option<Params>,
354 ) -> Self {
355 check_client_id_or_venue(&client_id, &venue);
356 Self {
357 bar_type,
358 client_id,
359 venue,
360 command_id,
361 ts_init,
362 correlation_id,
363 params,
364 }
365 }
366}
367
368#[derive(Clone, Debug)]
369pub struct SubscribeMarkPrices {
370 pub instrument_id: InstrumentId,
371 pub client_id: Option<ClientId>,
372 pub venue: Option<Venue>,
373 pub command_id: UUID4,
374 pub ts_init: UnixNanos,
375 pub correlation_id: Option<UUID4>,
376 pub params: Option<Params>,
377}
378
379impl SubscribeMarkPrices {
380 pub fn new(
382 instrument_id: InstrumentId,
383 client_id: Option<ClientId>,
384 venue: Option<Venue>,
385 command_id: UUID4,
386 ts_init: UnixNanos,
387 correlation_id: Option<UUID4>,
388 params: Option<Params>,
389 ) -> Self {
390 check_client_id_or_venue(&client_id, &venue);
391 Self {
392 instrument_id,
393 client_id,
394 venue,
395 command_id,
396 ts_init,
397 correlation_id,
398 params,
399 }
400 }
401}
402
403#[derive(Clone, Debug)]
404pub struct SubscribeIndexPrices {
405 pub instrument_id: InstrumentId,
406 pub client_id: Option<ClientId>,
407 pub venue: Option<Venue>,
408 pub command_id: UUID4,
409 pub ts_init: UnixNanos,
410 pub correlation_id: Option<UUID4>,
411 pub params: Option<Params>,
412}
413
414impl SubscribeIndexPrices {
415 pub fn new(
417 instrument_id: InstrumentId,
418 client_id: Option<ClientId>,
419 venue: Option<Venue>,
420 command_id: UUID4,
421 ts_init: UnixNanos,
422 correlation_id: Option<UUID4>,
423 params: Option<Params>,
424 ) -> Self {
425 check_client_id_or_venue(&client_id, &venue);
426 Self {
427 instrument_id,
428 client_id,
429 venue,
430 command_id,
431 ts_init,
432 correlation_id,
433 params,
434 }
435 }
436}
437
438#[derive(Clone, Debug)]
439pub struct SubscribeFundingRates {
440 pub instrument_id: InstrumentId,
441 pub client_id: Option<ClientId>,
442 pub venue: Option<Venue>,
443 pub command_id: UUID4,
444 pub ts_init: UnixNanos,
445 pub correlation_id: Option<UUID4>,
446 pub params: Option<Params>,
447}
448
449impl SubscribeFundingRates {
450 pub fn new(
452 instrument_id: InstrumentId,
453 client_id: Option<ClientId>,
454 venue: Option<Venue>,
455 command_id: UUID4,
456 ts_init: UnixNanos,
457 correlation_id: Option<UUID4>,
458 params: Option<Params>,
459 ) -> Self {
460 check_client_id_or_venue(&client_id, &venue);
461 Self {
462 instrument_id,
463 client_id,
464 venue,
465 command_id,
466 ts_init,
467 correlation_id,
468 params,
469 }
470 }
471}
472
473#[derive(Clone, Debug)]
474pub struct SubscribeInstrumentStatus {
475 pub instrument_id: InstrumentId,
476 pub client_id: Option<ClientId>,
477 pub venue: Option<Venue>,
478 pub command_id: UUID4,
479 pub ts_init: UnixNanos,
480 pub correlation_id: Option<UUID4>,
481 pub params: Option<Params>,
482}
483
484impl SubscribeInstrumentStatus {
485 pub fn new(
487 instrument_id: InstrumentId,
488 client_id: Option<ClientId>,
489 venue: Option<Venue>,
490 command_id: UUID4,
491 ts_init: UnixNanos,
492 correlation_id: Option<UUID4>,
493 params: Option<Params>,
494 ) -> Self {
495 check_client_id_or_venue(&client_id, &venue);
496 Self {
497 instrument_id,
498 client_id,
499 venue,
500 command_id,
501 ts_init,
502 correlation_id,
503 params,
504 }
505 }
506}
507
508#[derive(Clone, Debug)]
509pub struct SubscribeOptionGreeks {
510 pub instrument_id: InstrumentId,
511 pub client_id: Option<ClientId>,
512 pub venue: Option<Venue>,
513 pub command_id: UUID4,
514 pub ts_init: UnixNanos,
515 pub correlation_id: Option<UUID4>,
516 pub params: Option<Params>,
517}
518
519impl SubscribeOptionGreeks {
520 pub fn new(
522 instrument_id: InstrumentId,
523 client_id: Option<ClientId>,
524 venue: Option<Venue>,
525 command_id: UUID4,
526 ts_init: UnixNanos,
527 correlation_id: Option<UUID4>,
528 params: Option<Params>,
529 ) -> Self {
530 check_client_id_or_venue(&client_id, &venue);
531 Self {
532 instrument_id,
533 client_id,
534 venue,
535 command_id,
536 ts_init,
537 correlation_id,
538 params,
539 }
540 }
541}
542
543#[derive(Clone, Debug)]
544pub struct SubscribeInstrumentClose {
545 pub instrument_id: InstrumentId,
546 pub client_id: Option<ClientId>,
547 pub venue: Option<Venue>,
548 pub command_id: UUID4,
549 pub ts_init: UnixNanos,
550 pub correlation_id: Option<UUID4>,
551 pub params: Option<Params>,
552}
553
554impl SubscribeInstrumentClose {
555 pub fn new(
557 instrument_id: InstrumentId,
558 client_id: Option<ClientId>,
559 venue: Option<Venue>,
560 command_id: UUID4,
561 ts_init: UnixNanos,
562 correlation_id: Option<UUID4>,
563 params: Option<Params>,
564 ) -> Self {
565 check_client_id_or_venue(&client_id, &venue);
566 Self {
567 instrument_id,
568 client_id,
569 venue,
570 command_id,
571 ts_init,
572 correlation_id,
573 params,
574 }
575 }
576}
577
578#[derive(Clone, Debug)]
579pub struct SubscribeOptionChain {
580 pub series_id: OptionSeriesId,
581 pub strike_range: StrikeRange,
582 pub snapshot_interval_ms: Option<u64>,
583 pub command_id: UUID4,
584 pub ts_init: UnixNanos,
585 pub client_id: Option<ClientId>,
586 pub venue: Option<Venue>,
587 pub params: Option<Params>,
588}
589
590impl SubscribeOptionChain {
591 #[allow(clippy::too_many_arguments)]
593 pub fn new(
594 series_id: OptionSeriesId,
595 strike_range: StrikeRange,
596 snapshot_interval_ms: Option<u64>,
597 command_id: UUID4,
598 ts_init: UnixNanos,
599 client_id: Option<ClientId>,
600 venue: Option<Venue>,
601 params: Option<Params>,
602 ) -> Self {
603 check_client_id_or_venue(&client_id, &venue);
604 Self {
605 series_id,
606 strike_range,
607 snapshot_interval_ms,
608 command_id,
609 ts_init,
610 client_id,
611 venue,
612 params,
613 }
614 }
615}