1use std::borrow::Cow;
2
3use serde::Serialize;
4
5use crate::model::InstType;
6
7#[derive(Debug, Clone, Serialize)]
9pub struct InstrumentsRequest<'a> {
10 #[serde(rename = "instType")]
11 inst_type: InstType,
12 #[serde(rename = "seriesId", skip_serializing_if = "Option::is_none")]
13 series_id: Option<Cow<'a, str>>,
14 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
15 inst_family: Option<Cow<'a, str>>,
16 #[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
17 inst_id: Option<Cow<'a, str>>,
18}
19
20impl<'a> InstrumentsRequest<'a> {
21 pub fn new(inst_type: InstType) -> Self {
23 Self {
24 inst_type,
25 series_id: None,
26 inst_family: None,
27 inst_id: None,
28 }
29 }
30
31 pub fn series_id(mut self, series_id: impl Into<Cow<'a, str>>) -> Self {
35 self.series_id = Some(series_id.into());
36 self
37 }
38
39 pub fn inst_family(mut self, inst_family: impl Into<Cow<'a, str>>) -> Self {
41 self.inst_family = Some(inst_family.into());
42 self
43 }
44
45 pub fn inst_id(mut self, inst_id: impl Into<Cow<'a, str>>) -> Self {
47 self.inst_id = Some(inst_id.into());
48 self
49 }
50}
51
52#[derive(Debug, Clone, Serialize)]
56pub struct InstIdRequest<'a> {
57 #[serde(rename = "instId")]
58 inst_id: Cow<'a, str>,
59}
60
61impl<'a> InstIdRequest<'a> {
62 pub fn new(inst_id: impl Into<Cow<'a, str>>) -> Self {
64 Self {
65 inst_id: inst_id.into(),
66 }
67 }
68}
69
70#[derive(Debug, Clone, Default, Serialize)]
72pub struct CurrencyRequest<'a> {
73 #[serde(skip_serializing_if = "Option::is_none")]
74 ccy: Option<Cow<'a, str>>,
75}
76
77impl<'a> CurrencyRequest<'a> {
78 pub fn new() -> Self {
80 Self::default()
81 }
82
83 pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
85 self.ccy = Some(ccy.into());
86 self
87 }
88}
89
90mod edge;
91
92pub use edge::*;
93
94#[derive(Debug, Clone, Serialize)]
96pub struct InstrumentFamilyRequest<'a> {
97 #[serde(rename = "instType")]
98 inst_type: InstType,
99 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
100 underlying: Option<Cow<'a, str>>,
101 #[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
102 inst_id: Option<Cow<'a, str>>,
103 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
104 inst_family: Option<Cow<'a, str>>,
105}
106
107impl<'a> InstrumentFamilyRequest<'a> {
108 pub fn new(inst_type: InstType) -> Self {
110 Self {
111 inst_type,
112 underlying: None,
113 inst_id: None,
114 inst_family: None,
115 }
116 }
117
118 pub fn underlying(mut self, underlying: impl Into<Cow<'a, str>>) -> Self {
120 self.underlying = Some(underlying.into());
121 self
122 }
123
124 pub fn inst_id(mut self, inst_id: impl Into<Cow<'a, str>>) -> Self {
126 self.inst_id = Some(inst_id.into());
127 self
128 }
129
130 pub fn inst_family(mut self, inst_family: impl Into<Cow<'a, str>>) -> Self {
132 self.inst_family = Some(inst_family.into());
133 self
134 }
135}
136
137#[derive(Debug, Clone, Serialize)]
139pub struct FundingRateHistoryRequest<'a> {
140 #[serde(rename = "instId")]
141 inst_id: Cow<'a, str>,
142 #[serde(skip_serializing_if = "Option::is_none")]
143 after: Option<Cow<'a, str>>,
144 #[serde(skip_serializing_if = "Option::is_none")]
145 before: Option<Cow<'a, str>>,
146 #[serde(skip_serializing_if = "Option::is_none")]
147 limit: Option<u32>,
148}
149
150impl<'a> FundingRateHistoryRequest<'a> {
151 pub fn new(inst_id: impl Into<Cow<'a, str>>) -> Self {
153 Self {
154 inst_id: inst_id.into(),
155 after: None,
156 before: None,
157 limit: None,
158 }
159 }
160
161 pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
163 self.after = Some(after.into());
164 self
165 }
166
167 pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> Self {
169 self.before = Some(before.into());
170 self
171 }
172
173 pub fn limit(mut self, limit: u32) -> Self {
175 self.limit = Some(limit);
176 self
177 }
178}
179
180#[derive(Debug, Clone, Serialize)]
182pub struct DeliveryExerciseHistoryRequest<'a> {
183 #[serde(rename = "instType")]
184 inst_type: InstType,
185 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
186 underlying: Option<Cow<'a, str>>,
187 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
188 inst_family: Option<Cow<'a, str>>,
189 #[serde(skip_serializing_if = "Option::is_none")]
190 after: Option<Cow<'a, str>>,
191 #[serde(skip_serializing_if = "Option::is_none")]
192 before: Option<Cow<'a, str>>,
193 #[serde(skip_serializing_if = "Option::is_none")]
194 limit: Option<u32>,
195}
196
197impl<'a> DeliveryExerciseHistoryRequest<'a> {
198 pub fn new(inst_type: InstType) -> Self {
200 Self {
201 inst_type,
202 underlying: None,
203 inst_family: None,
204 after: None,
205 before: None,
206 limit: None,
207 }
208 }
209
210 pub fn underlying(mut self, underlying: impl Into<Cow<'a, str>>) -> Self {
212 self.underlying = Some(underlying.into());
213 self
214 }
215
216 pub fn inst_family(mut self, inst_family: impl Into<Cow<'a, str>>) -> Self {
218 self.inst_family = Some(inst_family.into());
219 self
220 }
221
222 pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
224 self.after = Some(after.into());
225 self
226 }
227
228 pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> Self {
230 self.before = Some(before.into());
231 self
232 }
233
234 pub fn limit(mut self, limit: u32) -> Self {
236 self.limit = Some(limit);
237 self
238 }
239}
240
241#[derive(Debug, Clone, Serialize)]
243pub struct PositionTiersRequest<'a> {
244 #[serde(rename = "instType")]
245 inst_type: InstType,
246 #[serde(rename = "tdMode")]
247 td_mode: Cow<'a, str>,
248 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
249 underlying: Option<Cow<'a, str>>,
250 #[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
251 inst_id: Option<Cow<'a, str>>,
252 #[serde(skip_serializing_if = "Option::is_none")]
253 ccy: Option<Cow<'a, str>>,
254 #[serde(skip_serializing_if = "Option::is_none")]
255 tier: Option<Cow<'a, str>>,
256 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
257 inst_family: Option<Cow<'a, str>>,
258}
259
260impl<'a> PositionTiersRequest<'a> {
261 pub fn new(inst_type: InstType, td_mode: impl Into<Cow<'a, str>>) -> Self {
263 Self {
264 inst_type,
265 td_mode: td_mode.into(),
266 underlying: None,
267 inst_id: None,
268 ccy: None,
269 tier: None,
270 inst_family: None,
271 }
272 }
273
274 pub fn underlying(mut self, underlying: impl Into<Cow<'a, str>>) -> Self {
276 self.underlying = Some(underlying.into());
277 self
278 }
279
280 pub fn inst_id(mut self, inst_id: impl Into<Cow<'a, str>>) -> Self {
282 self.inst_id = Some(inst_id.into());
283 self
284 }
285
286 pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
288 self.ccy = Some(ccy.into());
289 self
290 }
291
292 pub fn tier(mut self, tier: impl Into<Cow<'a, str>>) -> Self {
294 self.tier = Some(tier.into());
295 self
296 }
297
298 pub fn inst_family(mut self, inst_family: impl Into<Cow<'a, str>>) -> Self {
300 self.inst_family = Some(inst_family.into());
301 self
302 }
303}
304
305#[derive(Debug, Clone, Serialize)]
307pub struct InsuranceFundRequest<'a> {
308 #[serde(rename = "instType")]
309 inst_type: InstType,
310 #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
311 fund_type: Option<Cow<'a, str>>,
312 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
313 underlying: Option<Cow<'a, str>>,
314 #[serde(skip_serializing_if = "Option::is_none")]
315 ccy: Option<Cow<'a, str>>,
316 #[serde(skip_serializing_if = "Option::is_none")]
317 before: Option<Cow<'a, str>>,
318 #[serde(skip_serializing_if = "Option::is_none")]
319 after: Option<Cow<'a, str>>,
320 #[serde(skip_serializing_if = "Option::is_none")]
321 limit: Option<u32>,
322 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
323 inst_family: Option<Cow<'a, str>>,
324}
325
326impl<'a> InsuranceFundRequest<'a> {
327 pub fn new(inst_type: InstType) -> Self {
329 Self {
330 inst_type,
331 fund_type: None,
332 underlying: None,
333 ccy: None,
334 before: None,
335 after: None,
336 limit: None,
337 inst_family: None,
338 }
339 }
340
341 pub fn fund_type(mut self, fund_type: impl Into<Cow<'a, str>>) -> Self {
343 self.fund_type = Some(fund_type.into());
344 self
345 }
346
347 pub fn underlying(mut self, underlying: impl Into<Cow<'a, str>>) -> Self {
349 self.underlying = Some(underlying.into());
350 self
351 }
352
353 pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
355 self.ccy = Some(ccy.into());
356 self
357 }
358
359 pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> Self {
361 self.before = Some(before.into());
362 self
363 }
364
365 pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
367 self.after = Some(after.into());
368 self
369 }
370
371 pub fn limit(mut self, limit: u32) -> Self {
373 self.limit = Some(limit);
374 self
375 }
376
377 pub fn inst_family(mut self, inst_family: impl Into<Cow<'a, str>>) -> Self {
379 self.inst_family = Some(inst_family.into());
380 self
381 }
382}
383
384#[derive(Debug, Clone, Serialize)]
386pub struct ConvertContractCoinRequest<'a> {
387 #[serde(rename = "type")]
388 conversion_type: Cow<'a, str>,
389 #[serde(rename = "instId")]
390 inst_id: Cow<'a, str>,
391 sz: Cow<'a, str>,
392 #[serde(skip_serializing_if = "Option::is_none")]
393 px: Option<Cow<'a, str>>,
394 #[serde(skip_serializing_if = "Option::is_none")]
395 unit: Option<Cow<'a, str>>,
396}
397
398impl<'a> ConvertContractCoinRequest<'a> {
399 pub fn new(
401 conversion_type: impl Into<Cow<'a, str>>,
402 inst_id: impl Into<Cow<'a, str>>,
403 sz: impl Into<Cow<'a, str>>,
404 ) -> Self {
405 Self {
406 conversion_type: conversion_type.into(),
407 inst_id: inst_id.into(),
408 sz: sz.into(),
409 px: None,
410 unit: None,
411 }
412 }
413
414 pub fn price(mut self, px: impl Into<Cow<'a, str>>) -> Self {
416 self.px = Some(px.into());
417 self
418 }
419
420 pub fn unit(mut self, unit: impl Into<Cow<'a, str>>) -> Self {
422 self.unit = Some(unit.into());
423 self
424 }
425}