nautilus_common/messages/data/
unsubscribe.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Posei Systems Pty Ltd. All rights reserved.
3//  https://poseitrader.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 params: Option<IndexMap<String, String>>,
33}
34
35impl UnsubscribeCustomData {
36    /// Creates a new [`UnsubscribeCustomData`] instance.
37    pub fn new(
38        client_id: Option<ClientId>,
39        venue: Option<Venue>,
40        data_type: DataType,
41        command_id: UUID4,
42        ts_init: UnixNanos,
43        params: Option<IndexMap<String, String>>,
44    ) -> Self {
45        check_client_id_or_venue(&client_id, &venue);
46        Self {
47            client_id,
48            venue,
49            data_type,
50            command_id,
51            ts_init,
52            params,
53        }
54    }
55}
56
57#[derive(Clone, Debug)]
58pub struct UnsubscribeInstrument {
59    pub instrument_id: InstrumentId,
60    pub client_id: Option<ClientId>,
61    pub venue: Option<Venue>,
62    pub command_id: UUID4,
63    pub ts_init: UnixNanos,
64    pub params: Option<IndexMap<String, String>>,
65}
66
67impl UnsubscribeInstrument {
68    /// Creates a new [`UnsubscribeInstrument`] instance.
69    pub fn new(
70        instrument_id: InstrumentId,
71        client_id: Option<ClientId>,
72        venue: Option<Venue>,
73        command_id: UUID4,
74        ts_init: UnixNanos,
75        params: Option<IndexMap<String, String>>,
76    ) -> Self {
77        check_client_id_or_venue(&client_id, &venue);
78        Self {
79            instrument_id,
80            client_id,
81            venue,
82            command_id,
83            ts_init,
84            params,
85        }
86    }
87}
88
89#[derive(Clone, Debug)]
90pub struct UnsubscribeInstruments {
91    pub client_id: Option<ClientId>,
92    pub venue: Venue,
93    pub command_id: UUID4,
94    pub ts_init: UnixNanos,
95    pub params: Option<IndexMap<String, String>>,
96}
97
98impl UnsubscribeInstruments {
99    /// Creates a new [`UnsubscribeInstruments`] instance.
100    pub fn new(
101        client_id: Option<ClientId>,
102        venue: Venue,
103        command_id: UUID4,
104        ts_init: UnixNanos,
105        params: Option<IndexMap<String, String>>,
106    ) -> Self {
107        Self {
108            client_id,
109            venue,
110            command_id,
111            ts_init,
112            params,
113        }
114    }
115}
116
117#[derive(Clone, Debug)]
118pub struct UnsubscribeBookDeltas {
119    pub instrument_id: InstrumentId,
120    pub client_id: Option<ClientId>,
121    pub venue: Option<Venue>,
122    pub command_id: UUID4,
123    pub ts_init: UnixNanos,
124    pub params: Option<IndexMap<String, String>>,
125}
126
127impl UnsubscribeBookDeltas {
128    /// Creates a new [`UnsubscribeBookDeltas`] instance.
129    #[allow(clippy::too_many_arguments)]
130    pub fn new(
131        instrument_id: InstrumentId,
132        client_id: Option<ClientId>,
133        venue: Option<Venue>,
134        command_id: UUID4,
135        ts_init: UnixNanos,
136        params: Option<IndexMap<String, String>>,
137    ) -> Self {
138        check_client_id_or_venue(&client_id, &venue);
139        Self {
140            instrument_id,
141            client_id,
142            venue,
143            command_id,
144            ts_init,
145            params,
146        }
147    }
148}
149
150#[derive(Clone, Debug)]
151pub struct UnsubscribeBookDepth10 {
152    pub instrument_id: InstrumentId,
153    pub client_id: Option<ClientId>,
154    pub venue: Option<Venue>,
155    pub command_id: UUID4,
156    pub ts_init: UnixNanos,
157    pub params: Option<IndexMap<String, String>>,
158}
159
160impl UnsubscribeBookDepth10 {
161    /// Creates a new [`UnsubscribeBookDepth10`] instance.
162    #[allow(clippy::too_many_arguments)]
163    pub fn new(
164        instrument_id: InstrumentId,
165        client_id: Option<ClientId>,
166        venue: Option<Venue>,
167        command_id: UUID4,
168        ts_init: UnixNanos,
169        params: Option<IndexMap<String, String>>,
170    ) -> Self {
171        check_client_id_or_venue(&client_id, &venue);
172        Self {
173            instrument_id,
174            client_id,
175            venue,
176            command_id,
177            ts_init,
178            params,
179        }
180    }
181}
182
183#[derive(Clone, Debug)]
184pub struct UnsubscribeBookSnapshots {
185    pub instrument_id: InstrumentId,
186    pub client_id: Option<ClientId>,
187    pub venue: Option<Venue>,
188    pub command_id: UUID4,
189    pub ts_init: UnixNanos,
190    pub params: Option<IndexMap<String, String>>,
191}
192
193impl UnsubscribeBookSnapshots {
194    /// Creates a new [`UnsubscribeBookSnapshots`] instance.
195    #[allow(clippy::too_many_arguments)]
196    pub fn new(
197        instrument_id: InstrumentId,
198        client_id: Option<ClientId>,
199        venue: Option<Venue>,
200        command_id: UUID4,
201        ts_init: UnixNanos,
202        params: Option<IndexMap<String, String>>,
203    ) -> Self {
204        check_client_id_or_venue(&client_id, &venue);
205        Self {
206            instrument_id,
207            client_id,
208            venue,
209            command_id,
210            ts_init,
211            params,
212        }
213    }
214}
215
216#[derive(Clone, Debug)]
217pub struct UnsubscribeQuotes {
218    pub instrument_id: InstrumentId,
219    pub client_id: Option<ClientId>,
220    pub venue: Option<Venue>,
221    pub command_id: UUID4,
222    pub ts_init: UnixNanos,
223    pub params: Option<IndexMap<String, String>>,
224}
225
226impl UnsubscribeQuotes {
227    /// Creates a new [`UnsubscribeQuotes`] instance.
228    #[allow(clippy::too_many_arguments)]
229    pub fn new(
230        instrument_id: InstrumentId,
231        client_id: Option<ClientId>,
232        venue: Option<Venue>,
233        command_id: UUID4,
234        ts_init: UnixNanos,
235        params: Option<IndexMap<String, String>>,
236    ) -> Self {
237        check_client_id_or_venue(&client_id, &venue);
238        Self {
239            instrument_id,
240            client_id,
241            venue,
242            command_id,
243            ts_init,
244            params,
245        }
246    }
247}
248
249#[derive(Clone, Debug)]
250pub struct UnsubscribeTrades {
251    pub instrument_id: InstrumentId,
252    pub client_id: Option<ClientId>,
253    pub venue: Option<Venue>,
254    pub command_id: UUID4,
255    pub ts_init: UnixNanos,
256    pub params: Option<IndexMap<String, String>>,
257}
258
259impl UnsubscribeTrades {
260    /// Creates a new [`UnsubscribeTrades`] instance.
261    #[allow(clippy::too_many_arguments)]
262    pub fn new(
263        instrument_id: InstrumentId,
264        client_id: Option<ClientId>,
265        venue: Option<Venue>,
266        command_id: UUID4,
267        ts_init: UnixNanos,
268        params: Option<IndexMap<String, String>>,
269    ) -> Self {
270        check_client_id_or_venue(&client_id, &venue);
271        Self {
272            instrument_id,
273            client_id,
274            venue,
275            command_id,
276            ts_init,
277            params,
278        }
279    }
280}
281
282#[derive(Clone, Debug)]
283pub struct UnsubscribeBars {
284    pub bar_type: BarType,
285    pub client_id: Option<ClientId>,
286    pub venue: Option<Venue>,
287    pub command_id: UUID4,
288    pub ts_init: UnixNanos,
289    pub params: Option<IndexMap<String, String>>,
290}
291
292impl UnsubscribeBars {
293    /// Creates a new [`UnsubscribeBars`] instance.
294    #[allow(clippy::too_many_arguments)]
295    pub fn new(
296        bar_type: BarType,
297        client_id: Option<ClientId>,
298        venue: Option<Venue>,
299        command_id: UUID4,
300        ts_init: UnixNanos,
301        params: Option<IndexMap<String, String>>,
302    ) -> Self {
303        check_client_id_or_venue(&client_id, &venue);
304        Self {
305            bar_type,
306            client_id,
307            venue,
308            command_id,
309            ts_init,
310            params,
311        }
312    }
313}
314
315#[derive(Clone, Debug)]
316pub struct UnsubscribeMarkPrices {
317    pub instrument_id: InstrumentId,
318    pub client_id: Option<ClientId>,
319    pub venue: Option<Venue>,
320    pub command_id: UUID4,
321    pub ts_init: UnixNanos,
322    pub params: Option<IndexMap<String, String>>,
323}
324
325impl UnsubscribeMarkPrices {
326    /// Creates a new [`UnsubscribeMarkPrices`] instance.
327    #[allow(clippy::too_many_arguments)]
328    pub fn new(
329        instrument_id: InstrumentId,
330        client_id: Option<ClientId>,
331        venue: Option<Venue>,
332        command_id: UUID4,
333        ts_init: UnixNanos,
334        params: Option<IndexMap<String, String>>,
335    ) -> Self {
336        check_client_id_or_venue(&client_id, &venue);
337        Self {
338            instrument_id,
339            client_id,
340            venue,
341            command_id,
342            ts_init,
343            params,
344        }
345    }
346}
347
348#[derive(Clone, Debug)]
349pub struct UnsubscribeIndexPrices {
350    pub instrument_id: InstrumentId,
351    pub client_id: Option<ClientId>,
352    pub venue: Option<Venue>,
353    pub command_id: UUID4,
354    pub ts_init: UnixNanos,
355    pub params: Option<IndexMap<String, String>>,
356}
357
358impl UnsubscribeIndexPrices {
359    /// Creates a new [`UnsubscribeIndexPrices`] instance.
360    #[allow(clippy::too_many_arguments)]
361    pub fn new(
362        instrument_id: InstrumentId,
363        client_id: Option<ClientId>,
364        venue: Option<Venue>,
365        command_id: UUID4,
366        ts_init: UnixNanos,
367        params: Option<IndexMap<String, String>>,
368    ) -> Self {
369        check_client_id_or_venue(&client_id, &venue);
370        Self {
371            instrument_id,
372            client_id,
373            venue,
374            command_id,
375            ts_init,
376            params,
377        }
378    }
379}
380
381#[derive(Clone, Debug)]
382pub struct UnsubscribeInstrumentStatus {
383    pub instrument_id: InstrumentId,
384    pub client_id: Option<ClientId>,
385    pub venue: Option<Venue>,
386    pub command_id: UUID4,
387    pub ts_init: UnixNanos,
388    pub params: Option<IndexMap<String, String>>,
389}
390
391impl UnsubscribeInstrumentStatus {
392    /// Creates a new [`UnsubscribeInstrumentStatus`] 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        params: Option<IndexMap<String, String>>,
401    ) -> Self {
402        check_client_id_or_venue(&client_id, &venue);
403        Self {
404            instrument_id,
405            client_id,
406            venue,
407            command_id,
408            ts_init,
409            params,
410        }
411    }
412}
413
414#[derive(Clone, Debug)]
415pub struct UnsubscribeInstrumentClose {
416    pub instrument_id: InstrumentId,
417    pub client_id: Option<ClientId>,
418    pub venue: Option<Venue>,
419    pub command_id: UUID4,
420    pub ts_init: UnixNanos,
421    pub params: Option<IndexMap<String, String>>,
422}
423
424impl UnsubscribeInstrumentClose {
425    /// Creates a new [`UnsubscribeInstrumentClose`] instance.
426    #[allow(clippy::too_many_arguments)]
427    pub fn new(
428        instrument_id: InstrumentId,
429        client_id: Option<ClientId>,
430        venue: Option<Venue>,
431        command_id: UUID4,
432        ts_init: UnixNanos,
433        params: Option<IndexMap<String, String>>,
434    ) -> Self {
435        check_client_id_or_venue(&client_id, &venue);
436        Self {
437            instrument_id,
438            client_id,
439            venue,
440            command_id,
441            ts_init,
442            params,
443        }
444    }
445}