deribit_http/model/
position.rs

1/******************************************************************************
2   Author: Joaquín Béjar García
3   Email: jb@taunais.com
4   Date: 15/9/25
5******************************************************************************/
6use crate::model::types::Direction;
7use pretty_simple_display::{DebugPretty, DisplaySimple};
8use serde::{Deserialize, Serialize};
9use serde_with::skip_serializing_none;
10
11/// Position structure
12#[skip_serializing_none]
13#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
14pub struct Position {
15    /// Average price of the position
16    pub average_price: f64,
17    /// Average price in USD
18    pub average_price_usd: Option<f64>,
19    /// Delta (price sensitivity) of the position
20    pub delta: Option<f64>,
21    /// Direction of the position (buy/sell)
22    pub direction: Direction,
23    /// Estimated liquidation price
24    pub estimated_liquidation_price: Option<f64>,
25    /// Floating profit/loss
26    pub floating_profit_loss: Option<f64>,
27    /// Floating profit/loss in USD
28    pub floating_profit_loss_usd: Option<f64>,
29    /// Gamma (delta sensitivity) of the position
30    pub gamma: Option<f64>,
31    /// Current index price
32    pub index_price: Option<f64>,
33    /// Initial margin requirement
34    pub initial_margin: Option<f64>,
35    /// Name of the instrument
36    pub instrument_name: String,
37    /// Interest value
38    pub interest_value: Option<f64>,
39    /// Instrument kind (future, option, etc.)
40    pub kind: Option<String>,
41    /// Leverage used for the position
42    pub leverage: Option<i32>,
43    /// Maintenance margin requirement
44    pub maintenance_margin: Option<f64>,
45    /// Current mark price
46    pub mark_price: Option<f64>,
47    /// Margin used by open orders
48    pub open_orders_margin: Option<f64>,
49    /// Realized funding payments
50    pub realized_funding: Option<f64>,
51    /// Realized profit/loss
52    pub realized_profit_loss: Option<f64>,
53    /// Settlement price
54    pub settlement_price: Option<f64>,
55    /// Position size
56    pub size: f64,
57    /// Position size in currency units
58    pub size_currency: Option<f64>,
59    /// Theta (time decay) of the position
60    pub theta: Option<f64>,
61    /// Total profit/loss
62    pub total_profit_loss: Option<f64>,
63    /// Vega (volatility sensitivity) of the position
64    pub vega: Option<f64>,
65    /// Unrealized profit/loss
66    pub unrealized_profit_loss: Option<f64>,
67}