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