rust_okx/api/public_data/
requests.rs1use serde::Serialize;
2
3use crate::model::InstType;
4
5#[derive(Debug, Clone, Serialize)]
7pub struct InstrumentsRequest<'a> {
8 #[serde(rename = "instType")]
10 pub inst_type: &'a InstType,
11 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
13 pub inst_family: Option<&'a str>,
14}
15
16#[derive(Debug, Clone, Serialize)]
20pub struct InstIdRequest<'a> {
21 #[serde(rename = "instId")]
23 pub inst_id: &'a str,
24}
25
26#[derive(Debug, Clone, Default, Serialize)]
28pub struct CurrencyRequest<'a> {
29 #[serde(skip_serializing_if = "Option::is_none")]
31 pub ccy: Option<&'a str>,
32}
33
34mod edge;
35
36pub use edge::*;
37#[derive(Debug, Clone, Serialize)]
39pub struct InstrumentFamilyRequest {
40 #[serde(rename = "instType")]
41 inst_type: InstType,
42 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
43 underlying: Option<String>,
44 #[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
45 inst_id: Option<String>,
46 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
47 inst_family: Option<String>,
48}
49
50impl InstrumentFamilyRequest {
51 pub fn new(inst_type: InstType) -> Self {
53 Self {
54 inst_type,
55 underlying: None,
56 inst_id: None,
57 inst_family: None,
58 }
59 }
60
61 pub fn underlying(mut self, underlying: impl Into<String>) -> Self {
63 self.underlying = Some(underlying.into());
64 self
65 }
66
67 pub fn inst_id(mut self, inst_id: impl Into<String>) -> Self {
69 self.inst_id = Some(inst_id.into());
70 self
71 }
72
73 pub fn inst_family(mut self, inst_family: impl Into<String>) -> Self {
75 self.inst_family = Some(inst_family.into());
76 self
77 }
78}
79
80#[derive(Debug, Clone, Serialize)]
82pub struct FundingRateHistoryRequest {
83 #[serde(rename = "instId")]
84 inst_id: String,
85 #[serde(skip_serializing_if = "Option::is_none")]
86 after: Option<String>,
87 #[serde(skip_serializing_if = "Option::is_none")]
88 before: Option<String>,
89 #[serde(skip_serializing_if = "Option::is_none")]
90 limit: Option<u32>,
91}
92
93impl FundingRateHistoryRequest {
94 pub fn new(inst_id: impl Into<String>) -> Self {
96 Self {
97 inst_id: inst_id.into(),
98 after: None,
99 before: None,
100 limit: None,
101 }
102 }
103
104 pub fn after(mut self, after: impl Into<String>) -> Self {
106 self.after = Some(after.into());
107 self
108 }
109
110 pub fn before(mut self, before: impl Into<String>) -> Self {
112 self.before = Some(before.into());
113 self
114 }
115
116 pub fn limit(mut self, limit: u32) -> Self {
118 self.limit = Some(limit);
119 self
120 }
121}
122
123#[derive(Debug, Clone, Serialize)]
125pub struct DeliveryExerciseHistoryRequest {
126 #[serde(rename = "instType")]
127 inst_type: InstType,
128 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
129 underlying: Option<String>,
130 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
131 inst_family: Option<String>,
132 #[serde(skip_serializing_if = "Option::is_none")]
133 after: Option<String>,
134 #[serde(skip_serializing_if = "Option::is_none")]
135 before: Option<String>,
136 #[serde(skip_serializing_if = "Option::is_none")]
137 limit: Option<u32>,
138}
139
140impl DeliveryExerciseHistoryRequest {
141 pub fn new(inst_type: InstType) -> Self {
143 Self {
144 inst_type,
145 underlying: None,
146 inst_family: None,
147 after: None,
148 before: None,
149 limit: None,
150 }
151 }
152
153 pub fn underlying(mut self, underlying: impl Into<String>) -> Self {
155 self.underlying = Some(underlying.into());
156 self
157 }
158
159 pub fn inst_family(mut self, inst_family: impl Into<String>) -> Self {
161 self.inst_family = Some(inst_family.into());
162 self
163 }
164
165 pub fn after(mut self, after: impl Into<String>) -> Self {
167 self.after = Some(after.into());
168 self
169 }
170
171 pub fn before(mut self, before: impl Into<String>) -> Self {
173 self.before = Some(before.into());
174 self
175 }
176
177 pub fn limit(mut self, limit: u32) -> Self {
179 self.limit = Some(limit);
180 self
181 }
182}
183
184#[derive(Debug, Clone, Serialize)]
186pub struct PositionTiersRequest {
187 #[serde(rename = "instType")]
188 inst_type: InstType,
189 #[serde(rename = "tdMode")]
190 td_mode: String,
191 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
192 underlying: Option<String>,
193 #[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
194 inst_id: Option<String>,
195 #[serde(skip_serializing_if = "Option::is_none")]
196 ccy: Option<String>,
197 #[serde(skip_serializing_if = "Option::is_none")]
198 tier: Option<String>,
199 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
200 inst_family: Option<String>,
201}
202
203impl PositionTiersRequest {
204 pub fn new(inst_type: InstType, td_mode: impl Into<String>) -> Self {
206 Self {
207 inst_type,
208 td_mode: td_mode.into(),
209 underlying: None,
210 inst_id: None,
211 ccy: None,
212 tier: None,
213 inst_family: None,
214 }
215 }
216
217 pub fn underlying(mut self, underlying: impl Into<String>) -> Self {
219 self.underlying = Some(underlying.into());
220 self
221 }
222
223 pub fn inst_id(mut self, inst_id: impl Into<String>) -> Self {
225 self.inst_id = Some(inst_id.into());
226 self
227 }
228
229 pub fn currency(mut self, ccy: impl Into<String>) -> Self {
231 self.ccy = Some(ccy.into());
232 self
233 }
234
235 pub fn tier(mut self, tier: impl Into<String>) -> Self {
237 self.tier = Some(tier.into());
238 self
239 }
240
241 pub fn inst_family(mut self, inst_family: impl Into<String>) -> Self {
243 self.inst_family = Some(inst_family.into());
244 self
245 }
246}
247
248#[derive(Debug, Clone, Serialize)]
250pub struct InsuranceFundRequest {
251 #[serde(rename = "instType")]
252 inst_type: InstType,
253 #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
254 fund_type: Option<String>,
255 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
256 underlying: Option<String>,
257 #[serde(skip_serializing_if = "Option::is_none")]
258 ccy: Option<String>,
259 #[serde(skip_serializing_if = "Option::is_none")]
260 before: Option<String>,
261 #[serde(skip_serializing_if = "Option::is_none")]
262 after: Option<String>,
263 #[serde(skip_serializing_if = "Option::is_none")]
264 limit: Option<u32>,
265 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
266 inst_family: Option<String>,
267}
268
269impl InsuranceFundRequest {
270 pub fn new(inst_type: InstType) -> Self {
272 Self {
273 inst_type,
274 fund_type: None,
275 underlying: None,
276 ccy: None,
277 before: None,
278 after: None,
279 limit: None,
280 inst_family: None,
281 }
282 }
283
284 pub fn fund_type(mut self, fund_type: impl Into<String>) -> Self {
286 self.fund_type = Some(fund_type.into());
287 self
288 }
289
290 pub fn underlying(mut self, underlying: impl Into<String>) -> Self {
292 self.underlying = Some(underlying.into());
293 self
294 }
295
296 pub fn currency(mut self, ccy: impl Into<String>) -> Self {
298 self.ccy = Some(ccy.into());
299 self
300 }
301
302 pub fn before(mut self, before: impl Into<String>) -> Self {
304 self.before = Some(before.into());
305 self
306 }
307
308 pub fn after(mut self, after: impl Into<String>) -> Self {
310 self.after = Some(after.into());
311 self
312 }
313
314 pub fn limit(mut self, limit: u32) -> Self {
316 self.limit = Some(limit);
317 self
318 }
319
320 pub fn inst_family(mut self, inst_family: impl Into<String>) -> Self {
322 self.inst_family = Some(inst_family.into());
323 self
324 }
325}
326
327#[derive(Debug, Clone, Serialize)]
329pub struct ConvertContractCoinRequest {
330 #[serde(rename = "type")]
331 conversion_type: String,
332 #[serde(rename = "instId")]
333 inst_id: String,
334 sz: String,
335 #[serde(skip_serializing_if = "Option::is_none")]
336 px: Option<String>,
337 #[serde(skip_serializing_if = "Option::is_none")]
338 unit: Option<String>,
339}
340
341impl ConvertContractCoinRequest {
342 pub fn new(
344 conversion_type: impl Into<String>,
345 inst_id: impl Into<String>,
346 sz: impl Into<String>,
347 ) -> Self {
348 Self {
349 conversion_type: conversion_type.into(),
350 inst_id: inst_id.into(),
351 sz: sz.into(),
352 px: None,
353 unit: None,
354 }
355 }
356
357 pub fn price(mut self, px: impl Into<String>) -> Self {
359 self.px = Some(px.into());
360 self
361 }
362
363 pub fn unit(mut self, unit: impl Into<String>) -> Self {
365 self.unit = Some(unit.into());
366 self
367 }
368}