1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* OANDA v20 API
*
* The full OANDA v20 API Specification. This specification defines how to interact with v20 Accounts, Trades, Orders, Pricing and more.
*
* The version of the OpenAPI document: 0.2.1
* Contact: jmicoud02@gmail.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// Trade : The specification of a Trade within an Account. This includes the full representation of the Trade's dependent Orders in addition to the IDs of those Orders.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Trade {
/// The Trade's identifier, unique within the Trade's Account.
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<i32>,
#[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
pub instrument: Option<models::InstrumentName>,
/// The execution price of the Trade.
#[serde(rename = "price", skip_serializing_if = "Option::is_none")]
pub price: Option<f64>,
/// A date and time value using either RFC3339 or UNIX time representation. The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
#[serde(rename = "openTime", skip_serializing_if = "Option::is_none")]
pub open_time: Option<String>,
#[serde(rename = "state", skip_serializing_if = "Option::is_none")]
pub state: Option<models::TradeState>,
/// The initial size of the Trade. Negative values indicate a short Trade, and positive values indicate a long Trade.
#[serde(rename = "initialUnits", skip_serializing_if = "Option::is_none")]
pub initial_units: Option<f64>,
/// The margin required at the time the Trade was created. Note, this is the 'pure' margin required, it is not the 'effective' margin used that factors in the trade risk if a GSLO is attached to the trade.
#[serde(rename = "initialMarginRequired", skip_serializing_if = "Option::is_none")]
pub initial_margin_required: Option<f64>,
/// The number of units currently open for the Trade. This value is reduced to 0.0 as the Trade is closed.
#[serde(rename = "currentUnits", skip_serializing_if = "Option::is_none")]
pub current_units: Option<f64>,
/// The total profit/loss realized on the closed portion of the Trade.
#[serde(rename = "realizedPL", skip_serializing_if = "Option::is_none")]
pub realized_pl: Option<f64>,
/// The unrealized profit/loss on the open portion of the Trade.
#[serde(rename = "unrealizedPL", skip_serializing_if = "Option::is_none")]
pub unrealized_pl: Option<f64>,
/// Margin currently used by the Trade.
#[serde(rename = "marginUsed", skip_serializing_if = "Option::is_none")]
pub margin_used: Option<f64>,
/// The average closing price of the Trade. Only present if the Trade has been closed or reduced at least once.
#[serde(rename = "averageClosePrice", skip_serializing_if = "Option::is_none")]
pub average_close_price: Option<f64>,
/// The IDs of the Transactions that have closed portions of this Trade.
#[serde(rename = "closingTransactionIDs", skip_serializing_if = "Option::is_none")]
pub closing_transaction_ids: Option<Vec<i32>>,
/// The financing paid/collected for this Trade.
#[serde(rename = "financing", skip_serializing_if = "Option::is_none")]
pub financing: Option<f64>,
/// A date and time value using either RFC3339 or UNIX time representation. The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
#[serde(rename = "closeTime", skip_serializing_if = "Option::is_none")]
pub close_time: Option<String>,
#[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
pub client_extensions: Option<Box<models::ClientExtensions>>,
#[serde(rename = "takeProfitOrder", skip_serializing_if = "Option::is_none")]
pub take_profit_order: Option<Box<models::TakeProfitOrder>>,
#[serde(rename = "stopLossOrder", skip_serializing_if = "Option::is_none")]
pub stop_loss_order: Option<Box<models::StopLossOrder>>,
#[serde(rename = "trailingStopLossOrder", skip_serializing_if = "Option::is_none")]
pub trailing_stop_loss_order: Option<Box<models::TrailingStopLossOrder>>,
}
impl Trade {
/// The specification of a Trade within an Account. This includes the full representation of the Trade's dependent Orders in addition to the IDs of those Orders.
pub fn new() -> Trade {
Trade {
id: None,
instrument: None,
price: None,
open_time: None,
state: None,
initial_units: None,
initial_margin_required: None,
current_units: None,
realized_pl: None,
unrealized_pl: None,
margin_used: None,
average_close_price: None,
closing_transaction_ids: None,
financing: None,
close_time: None,
client_extensions: None,
take_profit_order: None,
stop_loss_order: None,
trailing_stop_loss_order: None,
}
}
}