deribit_http/model/
account.rs1use crate::model::response::other::AccountSummaryResponse;
7use pretty_simple_display::{DebugPretty, DisplaySimple};
8use serde::{Deserialize, Serialize};
9use serde_with::skip_serializing_none;
10
11#[skip_serializing_none]
13#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
14pub struct Subaccount {
15 pub email: String,
17 pub id: u64,
19 pub login_enabled: bool,
21 pub portfolio: Option<std::collections::HashMap<String, CurrencyPortfolio>>,
23 pub receive_notifications: bool,
25 pub system_name: String,
27 pub tif: Option<String>,
29 #[serde(rename = "type")]
31 pub subaccount_type: String,
32 pub username: String,
34 pub margin_model: Option<String>,
36 pub available_funds: Option<f64>,
38 pub disabled_trading_products: Option<Vec<String>>,
40 pub is_password: Option<bool>,
42 pub proof_id: Option<String>,
44 pub proof_id_signature: Option<String>,
46 pub security_keys_assignments: Option<Vec<serde_json::Value>>,
48 pub security_keys_enabled: Option<bool>,
50 pub trading_products_details: Option<Vec<TradingProductDetail>>,
52 pub referrals_count: Option<u64>,
54}
55
56#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
58pub struct CurrencyPortfolio {
59 pub available_funds: f64,
61 pub available_withdrawal_funds: f64,
63 pub balance: f64,
65 pub currency: String,
67 pub equity: f64,
69 pub initial_margin: f64,
71 pub locked_balance: f64,
73 pub maintenance_margin: f64,
75 pub margin_balance: f64,
77 pub spot_reserve: f64,
79 pub additional_reserve: f64,
81}
82
83#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
85pub struct TradingProductDetail {
86 pub enabled: bool,
88 pub product: String,
90 pub overwriteable: bool,
92}
93
94#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
96pub struct PortfolioInfo {
97 pub available_funds: f64,
99 pub available_withdrawal_funds: f64,
101 pub balance: f64,
103 pub currency: String,
105 pub delta_total: f64,
107 pub equity: f64,
109 pub initial_margin: f64,
111 pub maintenance_margin: f64,
113 pub margin_balance: f64,
115 pub session_rpl: f64,
117 pub session_upl: f64,
119 pub total_pl: f64,
121}
122
123#[skip_serializing_none]
125#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
126pub struct Portfolio {
127 pub currency: String,
129 pub accounts: Vec<AccountSummaryResponse>,
131 pub total_usd_value: Option<f64>,
133 pub cross_margin_enabled: bool,
135}
136
137impl Portfolio {
138 pub fn new(currency: String) -> Self {
140 Self {
141 currency,
142 accounts: Vec::new(),
143 total_usd_value: None,
144 cross_margin_enabled: false,
145 }
146 }
147
148 pub fn add_account(&mut self, account: AccountSummaryResponse) {
150 self.accounts.push(account);
151 }
152}