rust_okx/api/public_data/
requests.rs1use serde::Serialize;
2
3use crate::model::{InstType, RequestParams};
4
5#[derive(Debug, Clone, Serialize)]
7pub struct InstrumentFamilyRequest {
8 #[serde(rename = "instType")]
9 inst_type: InstType,
10 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
11 underlying: Option<String>,
12 #[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
13 inst_id: Option<String>,
14 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
15 inst_family: Option<String>,
16}
17
18impl InstrumentFamilyRequest {
19 pub fn new(inst_type: InstType) -> Self {
21 Self {
22 inst_type,
23 underlying: None,
24 inst_id: None,
25 inst_family: None,
26 }
27 }
28
29 pub fn underlying(mut self, underlying: impl Into<String>) -> Self {
31 self.underlying = Some(underlying.into());
32 self
33 }
34
35 pub fn inst_id(mut self, inst_id: impl Into<String>) -> Self {
37 self.inst_id = Some(inst_id.into());
38 self
39 }
40
41 pub fn inst_family(mut self, inst_family: impl Into<String>) -> Self {
43 self.inst_family = Some(inst_family.into());
44 self
45 }
46}
47
48#[derive(Debug, Clone, Serialize)]
50pub struct FundingRateHistoryRequest {
51 #[serde(rename = "instId")]
52 inst_id: String,
53 #[serde(skip_serializing_if = "Option::is_none")]
54 after: Option<String>,
55 #[serde(skip_serializing_if = "Option::is_none")]
56 before: Option<String>,
57 #[serde(skip_serializing_if = "Option::is_none")]
58 limit: Option<u32>,
59}
60
61impl FundingRateHistoryRequest {
62 pub fn new(inst_id: impl Into<String>) -> Self {
64 Self {
65 inst_id: inst_id.into(),
66 after: None,
67 before: None,
68 limit: None,
69 }
70 }
71
72 pub fn after(mut self, after: impl Into<String>) -> Self {
74 self.after = Some(after.into());
75 self
76 }
77
78 pub fn before(mut self, before: impl Into<String>) -> Self {
80 self.before = Some(before.into());
81 self
82 }
83
84 pub fn limit(mut self, limit: u32) -> Self {
86 self.limit = Some(limit);
87 self
88 }
89}
90
91#[derive(Debug, Clone, Serialize)]
93pub struct DeliveryExerciseHistoryRequest {
94 #[serde(rename = "instType")]
95 inst_type: InstType,
96 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
97 underlying: Option<String>,
98 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
99 inst_family: Option<String>,
100 #[serde(skip_serializing_if = "Option::is_none")]
101 after: Option<String>,
102 #[serde(skip_serializing_if = "Option::is_none")]
103 before: Option<String>,
104 #[serde(skip_serializing_if = "Option::is_none")]
105 limit: Option<u32>,
106}
107
108impl DeliveryExerciseHistoryRequest {
109 pub fn new(inst_type: InstType) -> Self {
111 Self {
112 inst_type,
113 underlying: None,
114 inst_family: None,
115 after: None,
116 before: None,
117 limit: None,
118 }
119 }
120
121 pub fn underlying(mut self, underlying: impl Into<String>) -> Self {
123 self.underlying = Some(underlying.into());
124 self
125 }
126
127 pub fn inst_family(mut self, inst_family: impl Into<String>) -> Self {
129 self.inst_family = Some(inst_family.into());
130 self
131 }
132
133 pub fn after(mut self, after: impl Into<String>) -> Self {
135 self.after = Some(after.into());
136 self
137 }
138
139 pub fn before(mut self, before: impl Into<String>) -> Self {
141 self.before = Some(before.into());
142 self
143 }
144
145 pub fn limit(mut self, limit: u32) -> Self {
147 self.limit = Some(limit);
148 self
149 }
150}
151
152#[derive(Debug, Clone, Serialize)]
154pub struct PositionTiersRequest {
155 #[serde(rename = "instType")]
156 inst_type: InstType,
157 #[serde(rename = "tdMode")]
158 td_mode: String,
159 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
160 underlying: Option<String>,
161 #[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
162 inst_id: Option<String>,
163 #[serde(skip_serializing_if = "Option::is_none")]
164 ccy: Option<String>,
165 #[serde(skip_serializing_if = "Option::is_none")]
166 tier: Option<String>,
167 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
168 inst_family: Option<String>,
169}
170
171impl PositionTiersRequest {
172 pub fn new(inst_type: InstType, td_mode: impl Into<String>) -> Self {
174 Self {
175 inst_type,
176 td_mode: td_mode.into(),
177 underlying: None,
178 inst_id: None,
179 ccy: None,
180 tier: None,
181 inst_family: None,
182 }
183 }
184
185 pub fn underlying(mut self, underlying: impl Into<String>) -> Self {
187 self.underlying = Some(underlying.into());
188 self
189 }
190
191 pub fn inst_id(mut self, inst_id: impl Into<String>) -> Self {
193 self.inst_id = Some(inst_id.into());
194 self
195 }
196
197 pub fn currency(mut self, ccy: impl Into<String>) -> Self {
199 self.ccy = Some(ccy.into());
200 self
201 }
202
203 pub fn tier(mut self, tier: impl Into<String>) -> Self {
205 self.tier = Some(tier.into());
206 self
207 }
208
209 pub fn inst_family(mut self, inst_family: impl Into<String>) -> Self {
211 self.inst_family = Some(inst_family.into());
212 self
213 }
214}
215
216#[derive(Debug, Clone, Serialize)]
218pub struct InsuranceFundRequest {
219 #[serde(rename = "instType")]
220 inst_type: InstType,
221 #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
222 fund_type: Option<String>,
223 #[serde(rename = "uly", skip_serializing_if = "Option::is_none")]
224 underlying: Option<String>,
225 #[serde(skip_serializing_if = "Option::is_none")]
226 ccy: Option<String>,
227 #[serde(skip_serializing_if = "Option::is_none")]
228 before: Option<String>,
229 #[serde(skip_serializing_if = "Option::is_none")]
230 after: Option<String>,
231 #[serde(skip_serializing_if = "Option::is_none")]
232 limit: Option<u32>,
233 #[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
234 inst_family: Option<String>,
235}
236
237impl InsuranceFundRequest {
238 pub fn new(inst_type: InstType) -> Self {
240 Self {
241 inst_type,
242 fund_type: None,
243 underlying: None,
244 ccy: None,
245 before: None,
246 after: None,
247 limit: None,
248 inst_family: None,
249 }
250 }
251
252 pub fn fund_type(mut self, fund_type: impl Into<String>) -> Self {
254 self.fund_type = Some(fund_type.into());
255 self
256 }
257
258 pub fn underlying(mut self, underlying: impl Into<String>) -> Self {
260 self.underlying = Some(underlying.into());
261 self
262 }
263
264 pub fn currency(mut self, ccy: impl Into<String>) -> Self {
266 self.ccy = Some(ccy.into());
267 self
268 }
269
270 pub fn before(mut self, before: impl Into<String>) -> Self {
272 self.before = Some(before.into());
273 self
274 }
275
276 pub fn after(mut self, after: impl Into<String>) -> Self {
278 self.after = Some(after.into());
279 self
280 }
281
282 pub fn limit(mut self, limit: u32) -> Self {
284 self.limit = Some(limit);
285 self
286 }
287
288 pub fn inst_family(mut self, inst_family: impl Into<String>) -> Self {
290 self.inst_family = Some(inst_family.into());
291 self
292 }
293}
294
295#[derive(Debug, Clone, Serialize)]
297pub struct ConvertContractCoinRequest {
298 #[serde(rename = "type")]
299 conversion_type: String,
300 #[serde(rename = "instId")]
301 inst_id: String,
302 sz: String,
303 #[serde(skip_serializing_if = "Option::is_none")]
304 px: Option<String>,
305 #[serde(skip_serializing_if = "Option::is_none")]
306 unit: Option<String>,
307}
308
309impl ConvertContractCoinRequest {
310 pub fn new(
312 conversion_type: impl Into<String>,
313 inst_id: impl Into<String>,
314 sz: impl Into<String>,
315 ) -> Self {
316 Self {
317 conversion_type: conversion_type.into(),
318 inst_id: inst_id.into(),
319 sz: sz.into(),
320 px: None,
321 unit: None,
322 }
323 }
324
325 pub fn price(mut self, px: impl Into<String>) -> Self {
327 self.px = Some(px.into());
328 self
329 }
330
331 pub fn unit(mut self, unit: impl Into<String>) -> Self {
333 self.unit = Some(unit.into());
334 self
335 }
336}
337
338pub type OptionSummaryRequest = RequestParams;
340
341pub type InterestRateLoanQuotaRequest = RequestParams;
343
344pub type VipInterestRateLoanQuotaRequest = RequestParams;
346
347pub type InstrumentTickBandsRequest = RequestParams;
349
350pub type PublicOptionTradesRequest = RequestParams;
352
353pub type MarketDataHistoryRequest = RequestParams;