1use std::num::NonZeroUsize;
17
18use chrono::{DateTime, Utc};
19use nautilus_core::{Params, UUID4, UnixNanos};
20use nautilus_model::{
21 data::{BarType, DataType},
22 identifiers::{ClientId, InstrumentId, Venue},
23};
24use ustr::Ustr;
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<Params>,
38}
39
40impl RequestCustomData {
41 #[expect(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<Params>,
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<Params>,
75}
76
77impl RequestInstrument {
78 pub fn new(
80 instrument_id: InstrumentId,
81 start: Option<DateTime<Utc>>,
82 end: Option<DateTime<Utc>>,
83 client_id: Option<ClientId>,
84 request_id: UUID4,
85 ts_init: UnixNanos,
86 params: Option<Params>,
87 ) -> Self {
88 Self {
89 instrument_id,
90 start,
91 end,
92 client_id,
93 request_id,
94 ts_init,
95 params,
96 }
97 }
98}
99
100#[derive(Clone, Debug)]
101pub struct RequestInstruments {
102 pub start: Option<DateTime<Utc>>,
103 pub end: Option<DateTime<Utc>>,
104 pub client_id: Option<ClientId>,
105 pub venue: Option<Venue>,
106 pub request_id: UUID4,
107 pub ts_init: UnixNanos,
108 pub params: Option<Params>,
109}
110
111impl RequestInstruments {
112 pub fn new(
114 start: Option<DateTime<Utc>>,
115 end: Option<DateTime<Utc>>,
116 client_id: Option<ClientId>,
117 venue: Option<Venue>,
118 request_id: UUID4,
119 ts_init: UnixNanos,
120 params: Option<Params>,
121 ) -> Self {
122 check_client_id_or_venue(&client_id, &venue);
123 Self {
124 start,
125 end,
126 client_id,
127 venue,
128 request_id,
129 ts_init,
130 params,
131 }
132 }
133}
134
135#[derive(Clone, Debug)]
136pub struct RequestBookSnapshot {
137 pub instrument_id: InstrumentId,
138 pub depth: Option<NonZeroUsize>,
139 pub client_id: Option<ClientId>,
140 pub request_id: UUID4,
141 pub ts_init: UnixNanos,
142 pub params: Option<Params>,
143}
144
145impl RequestBookSnapshot {
146 pub fn new(
148 instrument_id: InstrumentId,
149 depth: Option<NonZeroUsize>,
150 client_id: Option<ClientId>,
151 request_id: UUID4,
152 ts_init: UnixNanos,
153 params: Option<Params>,
154 ) -> Self {
155 Self {
156 instrument_id,
157 depth,
158 client_id,
159 request_id,
160 ts_init,
161 params,
162 }
163 }
164}
165
166#[derive(Clone, Debug)]
167pub struct RequestQuotes {
168 pub instrument_id: InstrumentId,
169 pub start: Option<DateTime<Utc>>,
170 pub end: Option<DateTime<Utc>>,
171 pub limit: Option<NonZeroUsize>,
172 pub client_id: Option<ClientId>,
173 pub request_id: UUID4,
174 pub ts_init: UnixNanos,
175 pub params: Option<Params>,
176}
177
178impl RequestQuotes {
179 #[expect(clippy::too_many_arguments)]
181 pub fn new(
182 instrument_id: InstrumentId,
183 start: Option<DateTime<Utc>>,
184 end: Option<DateTime<Utc>>,
185 limit: Option<NonZeroUsize>,
186 client_id: Option<ClientId>,
187 request_id: UUID4,
188 ts_init: UnixNanos,
189 params: Option<Params>,
190 ) -> Self {
191 Self {
192 instrument_id,
193 start,
194 end,
195 limit,
196 client_id,
197 request_id,
198 ts_init,
199 params,
200 }
201 }
202}
203
204#[derive(Clone, Debug)]
205pub struct RequestTrades {
206 pub instrument_id: InstrumentId,
207 pub start: Option<DateTime<Utc>>,
208 pub end: Option<DateTime<Utc>>,
209 pub limit: Option<NonZeroUsize>,
210 pub client_id: Option<ClientId>,
211 pub request_id: UUID4,
212 pub ts_init: UnixNanos,
213 pub params: Option<Params>,
214}
215
216impl RequestTrades {
217 #[expect(clippy::too_many_arguments)]
219 pub fn new(
220 instrument_id: InstrumentId,
221 start: Option<DateTime<Utc>>,
222 end: Option<DateTime<Utc>>,
223 limit: Option<NonZeroUsize>,
224 client_id: Option<ClientId>,
225 request_id: UUID4,
226 ts_init: UnixNanos,
227 params: Option<Params>,
228 ) -> Self {
229 Self {
230 instrument_id,
231 start,
232 end,
233 limit,
234 client_id,
235 request_id,
236 ts_init,
237 params,
238 }
239 }
240}
241
242#[derive(Clone, Debug)]
243pub struct RequestFundingRates {
244 pub instrument_id: InstrumentId,
245 pub start: Option<DateTime<Utc>>,
246 pub end: Option<DateTime<Utc>>,
247 pub limit: Option<NonZeroUsize>,
248 pub client_id: Option<ClientId>,
249 pub request_id: UUID4,
250 pub ts_init: UnixNanos,
251 pub params: Option<Params>,
252}
253
254impl RequestFundingRates {
255 #[expect(clippy::too_many_arguments)]
257 pub fn new(
258 instrument_id: InstrumentId,
259 start: Option<DateTime<Utc>>,
260 end: Option<DateTime<Utc>>,
261 limit: Option<NonZeroUsize>,
262 client_id: Option<ClientId>,
263 request_id: UUID4,
264 ts_init: UnixNanos,
265 params: Option<Params>,
266 ) -> Self {
267 Self {
268 instrument_id,
269 start,
270 end,
271 limit,
272 client_id,
273 request_id,
274 ts_init,
275 params,
276 }
277 }
278}
279
280#[derive(Clone, Debug)]
281pub struct RequestForwardPrices {
282 pub venue: Venue,
283 pub underlying: Ustr,
284 pub instrument_id: Option<InstrumentId>,
285 pub client_id: Option<ClientId>,
286 pub request_id: UUID4,
287 pub ts_init: UnixNanos,
288 pub params: Option<Params>,
289}
290
291impl RequestForwardPrices {
292 pub fn new(
294 venue: Venue,
295 underlying: Ustr,
296 instrument_id: Option<InstrumentId>,
297 client_id: Option<ClientId>,
298 request_id: UUID4,
299 ts_init: UnixNanos,
300 params: Option<Params>,
301 ) -> Self {
302 Self {
303 venue,
304 underlying,
305 instrument_id,
306 client_id,
307 request_id,
308 ts_init,
309 params,
310 }
311 }
312}
313
314#[derive(Clone, Debug)]
315pub struct RequestBookDepth {
316 pub instrument_id: InstrumentId,
317 pub start: Option<DateTime<Utc>>,
318 pub end: Option<DateTime<Utc>>,
319 pub limit: Option<NonZeroUsize>,
320 pub depth: Option<NonZeroUsize>,
321 pub client_id: Option<ClientId>,
322 pub request_id: UUID4,
323 pub ts_init: UnixNanos,
324 pub params: Option<Params>,
325}
326
327impl RequestBookDepth {
328 #[expect(clippy::too_many_arguments)]
330 pub fn new(
331 instrument_id: InstrumentId,
332 start: Option<DateTime<Utc>>,
333 end: Option<DateTime<Utc>>,
334 limit: Option<NonZeroUsize>,
335 depth: Option<NonZeroUsize>,
336 client_id: Option<ClientId>,
337 request_id: UUID4,
338 ts_init: UnixNanos,
339 params: Option<Params>,
340 ) -> Self {
341 Self {
342 instrument_id,
343 start,
344 end,
345 limit,
346 depth,
347 client_id,
348 request_id,
349 ts_init,
350 params,
351 }
352 }
353}
354
355#[derive(Clone, Debug)]
356pub struct RequestBars {
357 pub bar_type: BarType,
358 pub start: Option<DateTime<Utc>>,
359 pub end: Option<DateTime<Utc>>,
360 pub limit: Option<NonZeroUsize>,
361 pub client_id: Option<ClientId>,
362 pub request_id: UUID4,
363 pub ts_init: UnixNanos,
364 pub params: Option<Params>,
365}
366
367impl RequestBars {
368 #[expect(clippy::too_many_arguments)]
370 pub fn new(
371 bar_type: BarType,
372 start: Option<DateTime<Utc>>,
373 end: Option<DateTime<Utc>>,
374 limit: Option<NonZeroUsize>,
375 client_id: Option<ClientId>,
376 request_id: UUID4,
377 ts_init: UnixNanos,
378 params: Option<Params>,
379 ) -> Self {
380 Self {
381 bar_type,
382 start,
383 end,
384 limit,
385 client_id,
386 request_id,
387 ts_init,
388 params,
389 }
390 }
391}