rust_okx/api/account/requests/
borrowing.rs1use serde::Serialize;
2
3use crate::model::TradeMode;
4
5#[derive(Debug, Clone, Serialize)]
7pub struct MaxLoanRequest {
8 #[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
9 inst_id: Option<String>,
10 #[serde(skip_serializing_if = "Option::is_none")]
11 ccy: Option<String>,
12 #[serde(rename = "mgnMode")]
13 mgn_mode: TradeMode,
14 #[serde(rename = "mgnCcy", skip_serializing_if = "Option::is_none")]
15 mgn_ccy: Option<String>,
16 #[serde(rename = "tradeQuoteCcy", skip_serializing_if = "Option::is_none")]
17 trade_quote_ccy: Option<String>,
18}
19
20impl MaxLoanRequest {
21 pub fn new(inst_id: impl Into<String>, mgn_mode: TradeMode) -> Self {
27 Self::by_instrument(inst_id, mgn_mode)
28 }
29
30 pub fn by_instrument(inst_id: impl Into<String>, mgn_mode: TradeMode) -> Self {
32 Self {
33 mgn_mode,
34 inst_id: Some(inst_id.into()),
35 ccy: None,
36 mgn_ccy: None,
37 trade_quote_ccy: None,
38 }
39 }
40
41 pub fn by_currency(ccy: impl Into<String>) -> Self {
43 Self {
44 mgn_mode: TradeMode::Cross,
45 inst_id: None,
46 ccy: Some(ccy.into()),
47 mgn_ccy: None,
48 trade_quote_ccy: None,
49 }
50 }
51
52 pub fn currency(mut self, ccy: impl Into<String>) -> Self {
54 self.inst_id = None;
55 self.ccy = Some(ccy.into());
56 self
57 }
58
59 pub fn margin_currency(mut self, mgn_ccy: impl Into<String>) -> Self {
61 self.mgn_ccy = Some(mgn_ccy.into());
62 self
63 }
64
65 pub fn trade_quote_currency(mut self, trade_quote_ccy: impl Into<String>) -> Self {
67 self.trade_quote_ccy = Some(trade_quote_ccy.into());
68 self
69 }
70}
71
72#[derive(Debug, Clone, Default, Serialize)]
74pub struct InterestAccruedRequest {
75 #[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
76 inst_id: Option<String>,
77 #[serde(skip_serializing_if = "Option::is_none")]
78 ccy: Option<String>,
79 #[serde(rename = "mgnMode", skip_serializing_if = "Option::is_none")]
80 mgn_mode: Option<TradeMode>,
81 #[serde(skip_serializing_if = "Option::is_none")]
82 after: Option<String>,
83 #[serde(skip_serializing_if = "Option::is_none")]
84 before: Option<String>,
85 #[serde(skip_serializing_if = "Option::is_none")]
86 limit: Option<u32>,
87}
88
89impl InterestAccruedRequest {
90 pub fn new() -> Self {
92 Self::default()
93 }
94
95 pub fn inst_id(mut self, inst_id: impl Into<String>) -> Self {
97 self.inst_id = Some(inst_id.into());
98 self
99 }
100
101 pub fn currency(mut self, ccy: impl Into<String>) -> Self {
103 self.ccy = Some(ccy.into());
104 self
105 }
106
107 pub fn margin_mode(mut self, mgn_mode: TradeMode) -> Self {
109 self.mgn_mode = Some(mgn_mode);
110 self
111 }
112
113 pub fn after(mut self, after: impl Into<String>) -> Self {
115 self.after = Some(after.into());
116 self
117 }
118
119 pub fn before(mut self, before: impl Into<String>) -> Self {
121 self.before = Some(before.into());
122 self
123 }
124
125 pub fn limit(mut self, limit: u32) -> Self {
127 self.limit = Some(limit);
128 self
129 }
130}
131
132#[derive(Debug, Clone, Serialize)]
134pub struct BorrowRepayRequest {
135 ccy: String,
136 side: String,
137 amt: String,
138 #[serde(rename = "ordId", skip_serializing_if = "Option::is_none")]
139 ord_id: Option<String>,
140}
141
142impl BorrowRepayRequest {
143 pub fn new(ccy: impl Into<String>, side: impl Into<String>, amt: impl Into<String>) -> Self {
145 Self {
146 ccy: ccy.into(),
147 side: side.into(),
148 amt: amt.into(),
149 ord_id: None,
150 }
151 }
152
153 pub fn order_id(mut self, ord_id: impl Into<String>) -> Self {
155 self.ord_id = Some(ord_id.into());
156 self
157 }
158}
159
160#[derive(Debug, Clone, Default, Serialize)]
162pub struct BorrowRepayHistoryRequest {
163 #[serde(skip_serializing_if = "Option::is_none")]
164 ccy: Option<String>,
165 #[serde(skip_serializing_if = "Option::is_none")]
166 after: Option<String>,
167 #[serde(skip_serializing_if = "Option::is_none")]
168 before: Option<String>,
169 #[serde(skip_serializing_if = "Option::is_none")]
170 limit: Option<u32>,
171}
172
173impl BorrowRepayHistoryRequest {
174 pub fn new() -> Self {
176 Self::default()
177 }
178
179 pub fn currency(mut self, ccy: impl Into<String>) -> Self {
181 self.ccy = Some(ccy.into());
182 self
183 }
184
185 pub fn after(mut self, after: impl Into<String>) -> Self {
187 self.after = Some(after.into());
188 self
189 }
190
191 pub fn before(mut self, before: impl Into<String>) -> Self {
193 self.before = Some(before.into());
194 self
195 }
196
197 pub fn limit(mut self, limit: u32) -> Self {
199 self.limit = Some(limit);
200 self
201 }
202}
203
204#[derive(Debug, Clone, Default, Serialize)]
206pub struct InterestLimitsRequest {
207 #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
208 limit_type: Option<String>,
209 #[serde(skip_serializing_if = "Option::is_none")]
210 ccy: Option<String>,
211}
212
213impl InterestLimitsRequest {
214 pub fn new() -> Self {
216 Self::default()
217 }
218
219 pub fn limit_type(mut self, limit_type: impl Into<String>) -> Self {
221 self.limit_type = Some(limit_type.into());
222 self
223 }
224
225 pub fn currency(mut self, ccy: impl Into<String>) -> Self {
227 self.ccy = Some(ccy.into());
228 self
229 }
230}