nautilus_common/messages/data/
unsubscribe.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 indexmap::IndexMap;
17use nautilus_core::{UUID4, UnixNanos};
18use nautilus_model::{
19    data::{BarType, DataType},
20    identifiers::{ClientId, InstrumentId, Venue},
21};
22
23use super::check_client_id_or_venue;
24
25#[derive(Clone, Debug)]
26pub struct UnsubscribeCustomData {
27    pub client_id: Option<ClientId>,
28    pub venue: Option<Venue>,
29    pub data_type: DataType,
30    pub command_id: UUID4,
31    pub ts_init: UnixNanos,
32    pub correlation_id: Option<UUID4>,
33    pub params: Option<IndexMap<String, String>>,
34}
35
36impl UnsubscribeCustomData {
37    /// Creates a new [`UnsubscribeCustomData`] instance.
38    #[allow(clippy::too_many_arguments)]
39    pub fn new(
40        client_id: Option<ClientId>,
41        venue: Option<Venue>,
42        data_type: DataType,
43        command_id: UUID4,
44        ts_init: UnixNanos,
45        correlation_id: Option<UUID4>,
46        params: Option<IndexMap<String, String>>,
47    ) -> Self {
48        check_client_id_or_venue(&client_id, &venue);
49        Self {
50            client_id,
51            venue,
52            data_type,
53            command_id,
54            ts_init,
55            correlation_id,
56            params,
57        }
58    }
59}
60
61#[derive(Clone, Debug)]
62pub struct UnsubscribeInstrument {
63    pub instrument_id: InstrumentId,
64    pub client_id: Option<ClientId>,
65    pub venue: Option<Venue>,
66    pub command_id: UUID4,
67    pub ts_init: UnixNanos,
68    pub correlation_id: Option<UUID4>,
69    pub params: Option<IndexMap<String, String>>,
70}
71
72impl UnsubscribeInstrument {
73    /// Creates a new [`UnsubscribeInstrument`] instance.
74    #[allow(clippy::too_many_arguments)]
75    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<IndexMap<String, String>>,
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 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<IndexMap<String, String>>,
105}
106
107impl UnsubscribeInstruments {
108    /// Creates a new [`UnsubscribeInstruments`] instance.
109    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<IndexMap<String, String>>,
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 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<IndexMap<String, String>>,
137}
138
139impl UnsubscribeBookDeltas {
140    /// Creates a new [`UnsubscribeBookDeltas`] instance.
141    #[allow(clippy::too_many_arguments)]
142    pub fn new(
143        instrument_id: InstrumentId,
144        client_id: Option<ClientId>,
145        venue: Option<Venue>,
146        command_id: UUID4,
147        ts_init: UnixNanos,
148        correlation_id: Option<UUID4>,
149        params: Option<IndexMap<String, String>>,
150    ) -> Self {
151        check_client_id_or_venue(&client_id, &venue);
152        Self {
153            instrument_id,
154            client_id,
155            venue,
156            command_id,
157            ts_init,
158            correlation_id,
159            params,
160        }
161    }
162}
163
164#[derive(Clone, Debug)]
165pub struct UnsubscribeBookDepth10 {
166    pub instrument_id: InstrumentId,
167    pub client_id: Option<ClientId>,
168    pub venue: Option<Venue>,
169    pub command_id: UUID4,
170    pub ts_init: UnixNanos,
171    pub correlation_id: Option<UUID4>,
172    pub params: Option<IndexMap<String, String>>,
173}
174
175impl UnsubscribeBookDepth10 {
176    /// Creates a new [`UnsubscribeBookDepth10`] instance.
177    #[allow(clippy::too_many_arguments)]
178    pub fn new(
179        instrument_id: InstrumentId,
180        client_id: Option<ClientId>,
181        venue: Option<Venue>,
182        command_id: UUID4,
183        ts_init: UnixNanos,
184        correlation_id: Option<UUID4>,
185        params: Option<IndexMap<String, String>>,
186    ) -> Self {
187        check_client_id_or_venue(&client_id, &venue);
188        Self {
189            instrument_id,
190            client_id,
191            venue,
192            command_id,
193            ts_init,
194            correlation_id,
195            params,
196        }
197    }
198}
199
200#[derive(Clone, Debug)]
201pub struct UnsubscribeBookSnapshots {
202    pub instrument_id: InstrumentId,
203    pub client_id: Option<ClientId>,
204    pub venue: Option<Venue>,
205    pub command_id: UUID4,
206    pub ts_init: UnixNanos,
207    pub correlation_id: Option<UUID4>,
208    pub params: Option<IndexMap<String, String>>,
209}
210
211impl UnsubscribeBookSnapshots {
212    /// Creates a new [`UnsubscribeBookSnapshots`] instance.
213    #[allow(clippy::too_many_arguments)]
214    pub fn new(
215        instrument_id: InstrumentId,
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<IndexMap<String, String>>,
222    ) -> Self {
223        check_client_id_or_venue(&client_id, &venue);
224        Self {
225            instrument_id,
226            client_id,
227            venue,
228            command_id,
229            ts_init,
230            correlation_id,
231            params,
232        }
233    }
234}
235
236#[derive(Clone, Debug)]
237pub struct UnsubscribeQuotes {
238    pub instrument_id: InstrumentId,
239    pub client_id: Option<ClientId>,
240    pub venue: Option<Venue>,
241    pub command_id: UUID4,
242    pub ts_init: UnixNanos,
243    pub correlation_id: Option<UUID4>,
244    pub params: Option<IndexMap<String, String>>,
245}
246
247impl UnsubscribeQuotes {
248    /// Creates a new [`UnsubscribeQuotes`] instance.
249    #[allow(clippy::too_many_arguments)]
250    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<IndexMap<String, String>>,
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)]
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<IndexMap<String, String>>,
281}
282
283impl UnsubscribeTrades {
284    /// Creates a new [`UnsubscribeTrades`] instance.
285    #[allow(clippy::too_many_arguments)]
286    pub fn new(
287        instrument_id: InstrumentId,
288        client_id: Option<ClientId>,
289        venue: Option<Venue>,
290        command_id: UUID4,
291        ts_init: UnixNanos,
292        correlation_id: Option<UUID4>,
293        params: Option<IndexMap<String, String>>,
294    ) -> Self {
295        check_client_id_or_venue(&client_id, &venue);
296        Self {
297            instrument_id,
298            client_id,
299            venue,
300            command_id,
301            ts_init,
302            correlation_id,
303            params,
304        }
305    }
306}
307
308#[derive(Clone, Debug)]
309pub struct UnsubscribeBars {
310    pub bar_type: BarType,
311    pub client_id: Option<ClientId>,
312    pub venue: Option<Venue>,
313    pub command_id: UUID4,
314    pub ts_init: UnixNanos,
315    pub correlation_id: Option<UUID4>,
316    pub params: Option<IndexMap<String, String>>,
317}
318
319impl UnsubscribeBars {
320    /// Creates a new [`UnsubscribeBars`] instance.
321    #[allow(clippy::too_many_arguments)]
322    pub fn new(
323        bar_type: BarType,
324        client_id: Option<ClientId>,
325        venue: Option<Venue>,
326        command_id: UUID4,
327        ts_init: UnixNanos,
328        correlation_id: Option<UUID4>,
329        params: Option<IndexMap<String, String>>,
330    ) -> Self {
331        check_client_id_or_venue(&client_id, &venue);
332        Self {
333            bar_type,
334            client_id,
335            venue,
336            command_id,
337            ts_init,
338            correlation_id,
339            params,
340        }
341    }
342}
343
344#[derive(Clone, Debug)]
345pub struct UnsubscribeMarkPrices {
346    pub instrument_id: InstrumentId,
347    pub client_id: Option<ClientId>,
348    pub venue: Option<Venue>,
349    pub command_id: UUID4,
350    pub ts_init: UnixNanos,
351    pub correlation_id: Option<UUID4>,
352    pub params: Option<IndexMap<String, String>>,
353}
354
355impl UnsubscribeMarkPrices {
356    /// Creates a new [`UnsubscribeMarkPrices`] instance.
357    #[allow(clippy::too_many_arguments)]
358    pub fn new(
359        instrument_id: InstrumentId,
360        client_id: Option<ClientId>,
361        venue: Option<Venue>,
362        command_id: UUID4,
363        ts_init: UnixNanos,
364        correlation_id: Option<UUID4>,
365        params: Option<IndexMap<String, String>>,
366    ) -> Self {
367        check_client_id_or_venue(&client_id, &venue);
368        Self {
369            instrument_id,
370            client_id,
371            venue,
372            command_id,
373            ts_init,
374            correlation_id,
375            params,
376        }
377    }
378}
379
380#[derive(Clone, Debug)]
381pub struct UnsubscribeIndexPrices {
382    pub instrument_id: InstrumentId,
383    pub client_id: Option<ClientId>,
384    pub venue: Option<Venue>,
385    pub command_id: UUID4,
386    pub ts_init: UnixNanos,
387    pub correlation_id: Option<UUID4>,
388    pub params: Option<IndexMap<String, String>>,
389}
390
391impl UnsubscribeIndexPrices {
392    /// Creates a new [`UnsubscribeIndexPrices`] instance.
393    #[allow(clippy::too_many_arguments)]
394    pub fn new(
395        instrument_id: InstrumentId,
396        client_id: Option<ClientId>,
397        venue: Option<Venue>,
398        command_id: UUID4,
399        ts_init: UnixNanos,
400        correlation_id: Option<UUID4>,
401        params: Option<IndexMap<String, String>>,
402    ) -> Self {
403        check_client_id_or_venue(&client_id, &venue);
404        Self {
405            instrument_id,
406            client_id,
407            venue,
408            command_id,
409            ts_init,
410            correlation_id,
411            params,
412        }
413    }
414}
415
416#[derive(Clone, Debug)]
417pub struct UnsubscribeFundingRates {
418    pub instrument_id: InstrumentId,
419    pub client_id: Option<ClientId>,
420    pub venue: Option<Venue>,
421    pub command_id: UUID4,
422    pub ts_init: UnixNanos,
423    pub correlation_id: Option<UUID4>,
424    pub params: Option<IndexMap<String, String>>,
425}
426
427impl UnsubscribeFundingRates {
428    /// Creates a new [`UnsubscribeFundingRates`] instance.
429    #[allow(clippy::too_many_arguments)]
430    pub fn new(
431        instrument_id: InstrumentId,
432        client_id: Option<ClientId>,
433        venue: Option<Venue>,
434        command_id: UUID4,
435        ts_init: UnixNanos,
436        correlation_id: Option<UUID4>,
437        params: Option<IndexMap<String, String>>,
438    ) -> Self {
439        check_client_id_or_venue(&client_id, &venue);
440        Self {
441            instrument_id,
442            client_id,
443            venue,
444            command_id,
445            ts_init,
446            correlation_id,
447            params,
448        }
449    }
450}
451
452#[derive(Clone, Debug)]
453pub struct UnsubscribeInstrumentStatus {
454    pub instrument_id: InstrumentId,
455    pub client_id: Option<ClientId>,
456    pub venue: Option<Venue>,
457    pub command_id: UUID4,
458    pub ts_init: UnixNanos,
459    pub correlation_id: Option<UUID4>,
460    pub params: Option<IndexMap<String, String>>,
461}
462
463impl UnsubscribeInstrumentStatus {
464    /// Creates a new [`UnsubscribeInstrumentStatus`] instance.
465    #[allow(clippy::too_many_arguments)]
466    pub fn new(
467        instrument_id: InstrumentId,
468        client_id: Option<ClientId>,
469        venue: Option<Venue>,
470        command_id: UUID4,
471        ts_init: UnixNanos,
472        correlation_id: Option<UUID4>,
473        params: Option<IndexMap<String, String>>,
474    ) -> Self {
475        check_client_id_or_venue(&client_id, &venue);
476        Self {
477            instrument_id,
478            client_id,
479            venue,
480            command_id,
481            ts_init,
482            correlation_id,
483            params,
484        }
485    }
486}
487
488#[derive(Clone, Debug)]
489pub struct UnsubscribeInstrumentClose {
490    pub instrument_id: InstrumentId,
491    pub client_id: Option<ClientId>,
492    pub venue: Option<Venue>,
493    pub command_id: UUID4,
494    pub ts_init: UnixNanos,
495    pub correlation_id: Option<UUID4>,
496    pub params: Option<IndexMap<String, String>>,
497}
498
499impl UnsubscribeInstrumentClose {
500    /// Creates a new [`UnsubscribeInstrumentClose`] instance.
501    #[allow(clippy::too_many_arguments)]
502    pub fn new(
503        instrument_id: InstrumentId,
504        client_id: Option<ClientId>,
505        venue: Option<Venue>,
506        command_id: UUID4,
507        ts_init: UnixNanos,
508        correlation_id: Option<UUID4>,
509        params: Option<IndexMap<String, String>>,
510    ) -> Self {
511        check_client_id_or_venue(&client_id, &venue);
512        Self {
513            instrument_id,
514            client_id,
515            venue,
516            command_id,
517            ts_init,
518            correlation_id,
519            params,
520        }
521    }
522}