coinbase_advanced/models/
futures.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Deserialize)]
7pub struct FuturesPosition {
8 pub product_id: String,
10 #[serde(default)]
12 pub expiration_time: Option<String>,
13 #[serde(default)]
15 pub side: Option<String>,
16 #[serde(default)]
18 pub number_of_contracts: Option<String>,
19 #[serde(default)]
21 pub current_price: Option<String>,
22 #[serde(default)]
24 pub avg_entry_price: Option<String>,
25 #[serde(default)]
27 pub unrealized_pnl: Option<String>,
28 #[serde(default)]
30 pub daily_realized_pnl: Option<String>,
31}
32
33#[derive(Debug, Clone, Deserialize)]
35pub struct ListFuturesPositionsResponse {
36 #[serde(default)]
38 pub positions: Vec<FuturesPosition>,
39}
40
41#[derive(Debug, Clone, Deserialize)]
43pub struct GetFuturesPositionResponse {
44 pub position: FuturesPosition,
46}
47
48#[derive(Debug, Clone, Deserialize)]
50pub struct FuturesBalanceSummary {
51 #[serde(default)]
53 pub futures_buying_power: Option<String>,
54 #[serde(default)]
56 pub total_usd_balance: Option<String>,
57 #[serde(default)]
59 pub cbi_usd_balance: Option<String>,
60 #[serde(default)]
62 pub cfm_usd_balance: Option<String>,
63 #[serde(default)]
65 pub total_open_orders_hold_amount: Option<String>,
66 #[serde(default)]
68 pub unrealized_pnl: Option<String>,
69 #[serde(default)]
71 pub daily_realized_pnl: Option<String>,
72 #[serde(default)]
74 pub initial_margin: Option<String>,
75 #[serde(default)]
77 pub available_margin: Option<String>,
78 #[serde(default)]
80 pub liquidation_threshold: Option<String>,
81 #[serde(default)]
83 pub liquidation_buffer_amount: Option<String>,
84 #[serde(default)]
86 pub liquidation_buffer_percentage: Option<String>,
87}
88
89#[derive(Debug, Clone, Deserialize)]
91pub struct GetFuturesBalanceSummaryResponse {
92 pub balance_summary: FuturesBalanceSummary,
94}
95
96#[derive(Debug, Clone, Deserialize, Serialize)]
98pub struct IntradayMarginSetting {
99 #[serde(default)]
101 pub setting: Option<String>,
102}
103
104#[derive(Debug, Clone, Deserialize)]
106pub struct GetIntradayMarginSettingResponse {
107 #[serde(default)]
109 pub setting: Option<String>,
110}
111
112#[derive(Debug, Clone, Deserialize)]
114pub struct MarginWindow {
115 #[serde(default)]
117 pub margin_window_type: Option<String>,
118 #[serde(default)]
120 pub end_time: Option<String>,
121 #[serde(default)]
123 pub is_intraday_margin_killswitch_enabled: Option<bool>,
124 #[serde(default)]
126 pub is_intraday_margin_enrollment_killswitch_enabled: Option<bool>,
127}
128
129#[derive(Debug, Clone, Deserialize)]
131pub struct GetCurrentMarginWindowResponse {
132 pub margin_window: MarginWindow,
134}
135
136#[derive(Debug, Clone, Default, Serialize)]
138pub struct GetCurrentMarginWindowParams {
139 #[serde(skip_serializing_if = "Option::is_none")]
141 pub margin_profile_type: Option<String>,
142}
143
144impl GetCurrentMarginWindowParams {
145 pub fn new() -> Self {
147 Self::default()
148 }
149
150 pub fn margin_profile_type(mut self, margin_profile_type: impl Into<String>) -> Self {
152 self.margin_profile_type = Some(margin_profile_type.into());
153 self
154 }
155}
156
157#[derive(Debug, Clone, Deserialize)]
159pub struct FuturesSweep {
160 #[serde(default)]
162 pub id: Option<String>,
163 #[serde(default)]
165 pub requested_amount: Option<String>,
166 #[serde(default)]
168 pub should_sweep_all: Option<bool>,
169 #[serde(default)]
171 pub status: Option<String>,
172 #[serde(default)]
174 pub scheduled_time: Option<String>,
175}
176
177#[derive(Debug, Clone, Deserialize)]
179pub struct ListFuturesSweepsResponse {
180 #[serde(default)]
182 pub sweeps: Vec<FuturesSweep>,
183}
184
185#[derive(Debug, Clone, Serialize)]
187pub struct ScheduleFuturesSweepRequest {
188 pub usd_amount: String,
190}
191
192impl ScheduleFuturesSweepRequest {
193 pub fn new(usd_amount: impl Into<String>) -> Self {
195 Self {
196 usd_amount: usd_amount.into(),
197 }
198 }
199}
200
201#[derive(Debug, Clone, Deserialize)]
203pub struct ScheduleFuturesSweepResponse {
204 #[serde(default)]
206 pub success: bool,
207}
208
209#[derive(Debug, Clone, Serialize)]
211pub struct SetIntradayMarginSettingRequest {
212 pub setting: String,
214}
215
216impl SetIntradayMarginSettingRequest {
217 pub fn new(setting: impl Into<String>) -> Self {
219 Self {
220 setting: setting.into(),
221 }
222 }
223}