Skip to main content

oanda_v20_openapi/models/
calculated_position_state.rs

1/*
2 * OANDA v20 API
3 *
4 * The full OANDA v20 API Specification. This specification defines how to interact with v20 Accounts, Trades, Orders, Pricing and more.
5 *
6 * The version of the OpenAPI document: 0.2.1
7 * Contact: jmicoud02@gmail.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// CalculatedPositionState : The dynamic (calculated) state of a Position
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct CalculatedPositionState {
17    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
18    pub instrument: Option<models::InstrumentName>,
19    /// The Position's net unrealized profit/loss
20    #[serde(rename = "netUnrealizedPL", skip_serializing_if = "Option::is_none")]
21    pub net_unrealized_pl: Option<f64>,
22    /// The unrealized profit/loss of the Position's long open Trades
23    #[serde(rename = "longUnrealizedPL", skip_serializing_if = "Option::is_none")]
24    pub long_unrealized_pl: Option<f64>,
25    /// The unrealized profit/loss of the Position's short open Trades
26    #[serde(rename = "shortUnrealizedPL", skip_serializing_if = "Option::is_none")]
27    pub short_unrealized_pl: Option<f64>,
28    /// Margin currently used by the Position.
29    #[serde(rename = "marginUsed", skip_serializing_if = "Option::is_none")]
30    pub margin_used: Option<f64>,
31}
32
33impl CalculatedPositionState {
34    /// The dynamic (calculated) state of a Position
35    pub fn new() -> CalculatedPositionState {
36        CalculatedPositionState {
37            instrument: None,
38            net_unrealized_pl: None,
39            long_unrealized_pl: None,
40            short_unrealized_pl: None,
41            margin_used: None,
42        }
43    }
44}
45