Skip to main content

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    #[serde(default)]
17    pub average_price: f64,
18    /// Average price in USD
19    pub average_price_usd: Option<f64>,
20    /// Delta (price sensitivity) of the position
21    pub delta: Option<f64>,
22    /// Direction of the position (buy/sell/zero)
23    #[serde(default)]
24    pub direction: Direction,
25    /// Estimated liquidation price
26    pub estimated_liquidation_price: Option<f64>,
27    /// Floating profit/loss
28    pub floating_profit_loss: Option<f64>,
29    /// Floating profit/loss in USD
30    pub floating_profit_loss_usd: Option<f64>,
31    /// Gamma (delta sensitivity) of the position
32    pub gamma: Option<f64>,
33    /// Current index price
34    pub index_price: Option<f64>,
35    /// Initial margin requirement
36    pub initial_margin: Option<f64>,
37    /// Name of the instrument
38    pub instrument_name: String,
39    /// Interest value
40    pub interest_value: Option<f64>,
41    /// Instrument kind (future, option, etc.)
42    pub kind: Option<String>,
43    /// Leverage used for the position
44    pub leverage: Option<i32>,
45    /// Maintenance margin requirement
46    pub maintenance_margin: Option<f64>,
47    /// Current mark price
48    pub mark_price: Option<f64>,
49    /// Margin used by open orders
50    pub open_orders_margin: Option<f64>,
51    /// Realized funding payments
52    pub realized_funding: Option<f64>,
53    /// Realized profit/loss
54    pub realized_profit_loss: Option<f64>,
55    /// Settlement price
56    pub settlement_price: Option<f64>,
57    /// Position size
58    #[serde(default)]
59    pub size: f64,
60    /// Position size in currency units
61    pub size_currency: Option<f64>,
62    /// Theta (time decay) of the position
63    pub theta: Option<f64>,
64    /// Total profit/loss
65    pub total_profit_loss: Option<f64>,
66    /// Vega (volatility sensitivity) of the position
67    pub vega: Option<f64>,
68    /// Unrealized profit/loss
69    pub unrealized_profit_loss: Option<f64>,
70}