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