Skip to main content

bybit_api/models/
account.rs

1//! Account models.
2
3use serde::{Deserialize, Serialize};
4
5/// Wallet balance response.
6#[derive(Debug, Clone, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct WalletBalance {
9    /// List of account balances
10    pub list: Vec<AccountBalance>,
11}
12
13/// Account balance.
14#[derive(Debug, Clone, Deserialize)]
15#[serde(rename_all = "camelCase")]
16pub struct AccountBalance {
17    /// Account type
18    pub account_type: String,
19    /// Account LTV
20    #[serde(default)]
21    pub account_l_t_v: String,
22    /// Account IM rate
23    #[serde(default)]
24    pub account_i_m_rate: String,
25    /// Account MM rate
26    #[serde(default)]
27    pub account_m_m_rate: String,
28    /// Total equity
29    #[serde(default)]
30    pub total_equity: String,
31    /// Total wallet balance
32    #[serde(default)]
33    pub total_wallet_balance: String,
34    /// Total margin balance
35    #[serde(default)]
36    pub total_margin_balance: String,
37    /// Total available balance
38    #[serde(default)]
39    pub total_available_balance: String,
40    /// Total perp UPL
41    #[serde(default)]
42    pub total_perp_u_p_l: String,
43    /// Total initial margin
44    #[serde(default)]
45    pub total_initial_margin: String,
46    /// Total maintenance margin
47    #[serde(default)]
48    pub total_maintenance_margin: String,
49    /// Coin list
50    #[serde(default)]
51    pub coin: Vec<CoinBalance>,
52}
53
54/// Coin balance.
55#[derive(Debug, Clone, Deserialize)]
56#[serde(rename_all = "camelCase")]
57pub struct CoinBalance {
58    /// Coin name
59    pub coin: String,
60    /// Equity
61    #[serde(default)]
62    pub equity: String,
63    /// USD value
64    #[serde(default)]
65    pub usd_value: String,
66    /// Wallet balance
67    #[serde(default)]
68    pub wallet_balance: String,
69    /// Free amount
70    #[serde(default)]
71    pub free: String,
72    /// Locked amount
73    #[serde(default)]
74    pub locked: String,
75    /// Available to withdraw
76    #[serde(default)]
77    pub available_to_withdraw: String,
78    /// Available to borrow
79    #[serde(default)]
80    pub available_to_borrow: String,
81    /// Borrow amount
82    #[serde(default)]
83    pub borrow_amount: String,
84    /// Accrued interest
85    #[serde(default)]
86    pub accrued_interest: String,
87    /// Total order IM
88    #[serde(default)]
89    pub total_order_i_m: String,
90    /// Total position IM
91    #[serde(default)]
92    pub total_position_i_m: String,
93    /// Total position MM
94    #[serde(default)]
95    pub total_position_m_m: String,
96    /// Unrealised PnL
97    #[serde(default)]
98    pub unrealised_pnl: String,
99    /// Cumulative realised PnL
100    #[serde(default)]
101    pub cum_realised_pnl: String,
102}
103
104/// Account info response.
105#[derive(Debug, Clone, Deserialize)]
106#[serde(rename_all = "camelCase")]
107pub struct AccountInfo {
108    /// Unified margin status
109    #[serde(default)]
110    pub unified_margin_status: i32,
111    /// Margin mode
112    #[serde(default)]
113    pub margin_mode: String,
114    /// DCP status
115    #[serde(default)]
116    pub dcp_status: String,
117    /// Time window
118    #[serde(default)]
119    pub time_window: i32,
120    /// SMP group
121    #[serde(default)]
122    pub smp_group: i32,
123    /// Is master trader
124    #[serde(default)]
125    pub is_master_trader: bool,
126    /// Spot hedging status
127    #[serde(default)]
128    pub spot_hedging_status: String,
129    /// Updated time
130    #[serde(default)]
131    pub updated_time: String,
132}
133
134/// Fee rate response.
135#[derive(Debug, Clone, Deserialize)]
136#[serde(rename_all = "camelCase")]
137pub struct FeeRates {
138    /// Category
139    pub category: String,
140    /// List of fee rates
141    pub list: Vec<FeeRate>,
142}
143
144/// Fee rate.
145#[derive(Debug, Clone, Deserialize)]
146#[serde(rename_all = "camelCase")]
147pub struct FeeRate {
148    /// Symbol
149    pub symbol: String,
150    /// Base coin
151    #[serde(default)]
152    pub base_coin: String,
153    /// Taker fee rate
154    pub taker_fee_rate: String,
155    /// Maker fee rate
156    pub maker_fee_rate: String,
157}
158
159/// Transaction log response.
160#[derive(Debug, Clone, Deserialize)]
161#[serde(rename_all = "camelCase")]
162pub struct TransactionLogs {
163    /// List of transactions
164    pub list: Vec<TransactionLog>,
165    /// Next page cursor
166    #[serde(default)]
167    pub next_page_cursor: String,
168}
169
170/// Transaction log.
171#[derive(Debug, Clone, Deserialize)]
172#[serde(rename_all = "camelCase")]
173pub struct TransactionLog {
174    /// ID
175    pub id: String,
176    /// Symbol
177    #[serde(default)]
178    pub symbol: String,
179    /// Category
180    pub category: String,
181    /// Side
182    #[serde(default)]
183    pub side: String,
184    /// Transaction time
185    pub transaction_time: String,
186    /// Type
187    #[serde(rename = "type")]
188    pub tx_type: String,
189    /// Qty
190    #[serde(default)]
191    pub qty: String,
192    /// Size
193    #[serde(default)]
194    pub size: String,
195    /// Currency
196    pub currency: String,
197    /// Trade price
198    #[serde(default)]
199    pub trade_price: String,
200    /// Funding
201    #[serde(default)]
202    pub funding: String,
203    /// Fee
204    #[serde(default)]
205    pub fee: String,
206    /// Cash flow
207    #[serde(default)]
208    pub cash_flow: String,
209    /// Change
210    pub change: String,
211    /// Cash balance
212    pub cash_balance: String,
213}
214
215/// Set margin mode request.
216#[derive(Debug, Clone, Serialize)]
217#[serde(rename_all = "camelCase")]
218pub struct SetMarginModeParams {
219    /// Set margin mode
220    pub set_margin_mode: String,
221}
222
223/// Collateral info response.
224#[derive(Debug, Clone, Deserialize)]
225#[serde(rename_all = "camelCase")]
226pub struct CollateralInfo {
227    /// List of collateral info
228    pub list: Vec<Collateral>,
229}
230
231/// Collateral.
232#[derive(Debug, Clone, Deserialize)]
233#[serde(rename_all = "camelCase")]
234pub struct Collateral {
235    /// Currency
236    pub currency: String,
237    /// Hourly borrow rate
238    #[serde(default)]
239    pub hourly_borrow_rate: String,
240    /// Max borrow amount
241    #[serde(default)]
242    pub max_borrowing_amount: String,
243    /// Free borrow amount
244    #[serde(default)]
245    pub free_borrowing_amount: String,
246    /// Free borrow limit
247    #[serde(default)]
248    pub free_borrow_limit: String,
249    /// Borrow usable switch
250    #[serde(default)]
251    pub borrow_usable_switch: bool,
252    /// Collateral switch
253    #[serde(default)]
254    pub collateral_switch: bool,
255    /// Collateral ratio
256    #[serde(default)]
257    pub collateral_ratio: String,
258}
259
260/// Borrow history response.
261#[derive(Debug, Clone, Deserialize)]
262#[serde(rename_all = "camelCase")]
263pub struct BorrowHistory {
264    /// List of borrow records
265    pub list: Vec<BorrowRecord>,
266    /// Next page cursor
267    #[serde(default)]
268    pub next_page_cursor: String,
269}
270
271/// Borrow record.
272#[derive(Debug, Clone, Deserialize)]
273#[serde(rename_all = "camelCase")]
274pub struct BorrowRecord {
275    /// Currency
276    pub currency: String,
277    /// Created time
278    pub created_time: String,
279    /// Borrow cost
280    #[serde(default)]
281    pub borrow_cost: String,
282    /// Hourly borrow rate
283    #[serde(default)]
284    pub hourly_borrow_rate: String,
285    /// Interest bearing borrow size
286    #[serde(default)]
287    pub interest_bearing_borrow_size: String,
288    /// Cost exemption
289    #[serde(default)]
290    pub cost_exemption: String,
291}