Skip to main content

oanda_v20_openapi/models/
position.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/// Position : The specification of a Position within an Account.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Position {
17    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
18    pub instrument: Option<models::InstrumentName>,
19    /// Profit/loss realized by the Position over the lifetime of the Account.
20    #[serde(rename = "pl", skip_serializing_if = "Option::is_none")]
21    pub pl: Option<f64>,
22    /// The unrealized profit/loss of all open Trades that contribute to this Position.
23    #[serde(rename = "unrealizedPL", skip_serializing_if = "Option::is_none")]
24    pub unrealized_pl: Option<f64>,
25    /// Margin currently used by the Position.
26    #[serde(rename = "marginUsed", skip_serializing_if = "Option::is_none")]
27    pub margin_used: Option<f64>,
28    /// Profit/loss realized by the Position since the Account's resettablePL was last reset by the client.
29    #[serde(rename = "resettablePL", skip_serializing_if = "Option::is_none")]
30    pub resettable_pl: Option<f64>,
31    /// The total amount of financing paid/collected for this instrument over the lifetime of the Account.
32    #[serde(rename = "financing", skip_serializing_if = "Option::is_none")]
33    pub financing: Option<f64>,
34    /// The total amount of commission paid for this instrument over the lifetime of the Account.
35    #[serde(rename = "commission", skip_serializing_if = "Option::is_none")]
36    pub commission: Option<f64>,
37    /// The total amount of fees charged over the lifetime of the Account for the execution of guaranteed Stop Loss Orders for this instrument.
38    #[serde(rename = "guaranteedExecutionFees", skip_serializing_if = "Option::is_none")]
39    pub guaranteed_execution_fees: Option<f64>,
40    #[serde(rename = "long", skip_serializing_if = "Option::is_none")]
41    pub long: Option<Box<models::PositionSide>>,
42    #[serde(rename = "short", skip_serializing_if = "Option::is_none")]
43    pub short: Option<Box<models::PositionSide>>,
44}
45
46impl Position {
47    /// The specification of a Position within an Account.
48    pub fn new() -> Position {
49        Position {
50            instrument: None,
51            pl: None,
52            unrealized_pl: None,
53            margin_used: None,
54            resettable_pl: None,
55            financing: None,
56            commission: None,
57            guaranteed_execution_fees: None,
58            long: None,
59            short: None,
60        }
61    }
62}
63