Skip to main content

rust_okx/api/account/responses/
config.rs

1use serde::Deserialize;
2
3use crate::model::{InstType, NumberString, PositionSide, TradeMode};
4
5/// Account configuration.
6#[derive(Debug, Clone, Deserialize)]
7#[serde(rename_all = "camelCase")]
8#[non_exhaustive]
9pub struct AccountConfig {
10    /// Account ID.
11    #[serde(default)]
12    pub uid: String,
13    /// Account level.
14    #[serde(default)]
15    pub acct_lv: String,
16    /// Position mode.
17    #[serde(default)]
18    pub pos_mode: String,
19    /// Greeks display type.
20    #[serde(default)]
21    pub greeks_type: String,
22    /// Whether auto-borrow is enabled. OKX returns this as a JSON boolean.
23    #[serde(default)]
24    pub auto_loan: bool,
25}
26
27/// Result of setting position mode.
28#[derive(Debug, Clone, Deserialize)]
29#[serde(rename_all = "camelCase")]
30#[non_exhaustive]
31pub struct SetPositionModeResult {
32    /// Position mode.
33    #[serde(default)]
34    pub pos_mode: String,
35}
36
37/// Leverage information.
38#[derive(Debug, Clone, Deserialize)]
39#[serde(rename_all = "camelCase")]
40#[non_exhaustive]
41pub struct LeverageInfo {
42    /// Instrument ID.
43    #[serde(default)]
44    pub inst_id: String,
45    /// Margin mode.
46    pub mgn_mode: TradeMode,
47    /// Position side.
48    pub pos_side: PositionSide,
49    /// Leverage.
50    #[serde(default)]
51    pub lever: NumberString,
52}
53
54/// Maximum order size information.
55#[derive(Debug, Clone, Deserialize)]
56#[serde(rename_all = "camelCase")]
57#[non_exhaustive]
58pub struct MaxOrderSize {
59    /// Instrument ID.
60    pub inst_id: String,
61    /// Maximum buy size.
62    #[serde(default)]
63    pub max_buy: NumberString,
64    /// Maximum sell size.
65    #[serde(default)]
66    pub max_sell: NumberString,
67}
68
69/// Maximum available size information.
70#[derive(Debug, Clone, Deserialize)]
71#[serde(rename_all = "camelCase")]
72#[non_exhaustive]
73pub struct MaxAvailableSize {
74    /// Instrument ID.
75    pub inst_id: String,
76    /// Available buy size.
77    #[serde(default)]
78    pub avail_buy: NumberString,
79    /// Available sell size.
80    #[serde(default)]
81    pub avail_sell: NumberString,
82}
83
84/// Trade fee-rate information.
85#[derive(Debug, Clone, Deserialize)]
86#[serde(rename_all = "camelCase")]
87#[non_exhaustive]
88pub struct FeeRate {
89    /// Instrument type.
90    pub inst_type: InstType,
91    /// Instrument ID.
92    #[serde(default)]
93    pub inst_id: String,
94    /// Fee category.
95    #[serde(default)]
96    pub category: String,
97    /// Maker fee rate.
98    #[serde(default)]
99    pub maker: NumberString,
100    /// Taker fee rate.
101    #[serde(default)]
102    pub taker: NumberString,
103    /// Timestamp (Unix milliseconds).
104    #[serde(default)]
105    pub ts: NumberString,
106}
107
108/// Maximum withdrawal amount for a currency.
109#[derive(Debug, Clone, Deserialize)]
110#[serde(rename_all = "camelCase")]
111#[non_exhaustive]
112pub struct MaxWithdrawal {
113    /// Currency.
114    pub ccy: String,
115    /// Maximum withdrawal amount.
116    #[serde(default)]
117    pub max_wd: NumberString,
118    /// Maximum withdrawal amount excluding borrowed amount.
119    #[serde(default)]
120    pub max_wd_ex: NumberString,
121}
122
123/// Result of adding or reducing margin on a position.
124#[derive(Debug, Clone, Deserialize)]
125#[serde(rename_all = "camelCase")]
126#[non_exhaustive]
127pub struct AdjustMarginResult {
128    /// Instrument ID.
129    #[serde(default)]
130    pub inst_id: String,
131    /// Position side.
132    #[serde(default)]
133    pub pos_side: String,
134    /// Adjustment amount.
135    #[serde(default)]
136    pub amt: NumberString,
137    /// OKX adjustment type.
138    #[serde(rename = "type", default)]
139    pub adjustment_type: String,
140}
141
142/// Account-level instrument configuration.
143#[derive(Debug, Clone, Deserialize)]
144#[serde(rename_all = "camelCase")]
145#[non_exhaustive]
146pub struct AccountInstrument {
147    /// Instrument type.
148    #[serde(default)]
149    pub inst_type: String,
150    /// Instrument ID.
151    #[serde(default)]
152    pub inst_id: String,
153    /// Underlying.
154    #[serde(default)]
155    pub uly: String,
156    /// Instrument family.
157    #[serde(default)]
158    pub inst_family: String,
159    /// Base currency.
160    #[serde(default)]
161    pub base_ccy: String,
162    /// Quote currency.
163    #[serde(default)]
164    pub quote_ccy: String,
165    /// Settlement currency.
166    #[serde(default)]
167    pub settle_ccy: String,
168}
169
170/// Result of updating the greeks display type.
171#[derive(Debug, Clone, Deserialize)]
172#[serde(rename_all = "camelCase")]
173#[non_exhaustive]
174pub struct SetGreeksResult {
175    /// Greeks display type.
176    #[serde(default)]
177    pub greeks_type: String,
178}
179
180/// Result of updating isolated margin mode.
181#[derive(Debug, Clone, Deserialize)]
182#[serde(rename_all = "camelCase")]
183#[non_exhaustive]
184pub struct SetIsolatedModeResult {
185    /// Isolated margin mode.
186    #[serde(default)]
187    pub iso_mode: String,
188    /// OKX isolated-mode scope type.
189    #[serde(rename = "type", default)]
190    pub mode_type: String,
191}
192
193/// Result of updating risk offset type.
194#[derive(Debug, Clone, Deserialize)]
195#[serde(rename_all = "camelCase")]
196#[non_exhaustive]
197pub struct SetRiskOffsetTypeResult {
198    /// OKX risk offset type.
199    #[serde(rename = "type", default)]
200    pub risk_offset_type: String,
201}
202
203/// Result of updating auto loan.
204#[derive(Debug, Clone, Deserialize)]
205#[serde(rename_all = "camelCase")]
206#[non_exhaustive]
207pub struct SetAutoLoanResult {
208    /// Auto-loan setting as returned by OKX.
209    #[serde(default)]
210    pub auto_loan: String,
211}
212
213/// Result of updating account level.
214#[derive(Debug, Clone, Deserialize)]
215#[serde(rename_all = "camelCase")]
216#[non_exhaustive]
217pub struct SetAccountLevelResult {
218    /// Account level.
219    #[serde(default)]
220    pub acct_lv: String,
221}
222
223/// Result of activating option trading.
224#[derive(Debug, Clone, Deserialize)]
225#[serde(rename_all = "camelCase")]
226#[non_exhaustive]
227pub struct ActivateOptionResult {
228    /// OKX result marker, when returned.
229    #[serde(default)]
230    pub result: String,
231}