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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* 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};
/// TradeOrderBase : The base Order object for TakeProfit, StopLoss and TrailingStopLoss type of orders which are connected to a trade.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct TradeOrderBase {
/// The Order's identifier, unique within the Order's Account.
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<i32>,
/// 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 = "createTime", skip_serializing_if = "Option::is_none")]
pub create_time: Option<String>,
#[serde(rename = "state", skip_serializing_if = "Option::is_none")]
pub state: Option<models::OrderState>,
#[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
pub client_extensions: Option<Box<models::ClientExtensions>>,
/// The type of the Order.
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub r#type: Option<Type>,
/// The ID of the Trade to close when the price threshold is breached.
#[serde(rename = "tradeID", skip_serializing_if = "Option::is_none")]
pub trade_id: Option<i32>,
/// The client ID of the Trade to be closed when the price threshold is breached.
#[serde(rename = "clientTradeID", skip_serializing_if = "Option::is_none")]
pub client_trade_id: Option<String>,
#[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
pub time_in_force: Option<models::TradeOrderTimeInForce>,
/// 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 = "gtdTime", skip_serializing_if = "Option::is_none")]
pub gtd_time: Option<String>,
#[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
pub trigger_condition: Option<models::TradeOrderTriggerCondition>,
/// ID of the Transaction that filled this Order (only provided when the Order's state is FILLED)
#[serde(rename = "fillingTransactionID", skip_serializing_if = "Option::is_none")]
pub filling_transaction_id: Option<i32>,
/// 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 = "filledTime", skip_serializing_if = "Option::is_none")]
pub filled_time: Option<String>,
/// Trade ID of Trade opened when the Order was filled (only provided when the Order's state is FILLED and a Trade was opened as a result of the fill)
#[serde(rename = "tradeOpenedID", skip_serializing_if = "Option::is_none")]
pub trade_opened_id: Option<i32>,
/// Trade ID of Trade reduced when the Order was filled (only provided when the Order's state is FILLED and a Trade was reduced as a result of the fill)
#[serde(rename = "tradeReducedID", skip_serializing_if = "Option::is_none")]
pub trade_reduced_id: Option<i32>,
/// Trade IDs of Trades closed when the Order was filled (only provided when the Order's state is FILLED and one or more Trades were closed as a result of the fill)
#[serde(rename = "tradeClosedIDs", skip_serializing_if = "Option::is_none")]
pub trade_closed_ids: Option<Vec<i32>>,
/// ID of the Transaction that cancelled the Order (only provided when the Order's state is CANCELLED)
#[serde(rename = "cancellingTransactionID", skip_serializing_if = "Option::is_none")]
pub cancelling_transaction_id: Option<i32>,
/// 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 = "cancelledTime", skip_serializing_if = "Option::is_none")]
pub cancelled_time: Option<String>,
/// The ID of the Order that was replaced by this Order (only provided if this Order was created as part of a cancel/replace).
#[serde(rename = "replacesOrderID", skip_serializing_if = "Option::is_none")]
pub replaces_order_id: Option<i32>,
/// The ID of the Order that replaced this Order (only provided if this Order was cancelled as part of a cancel/replace).
#[serde(rename = "replacedByOrderID", skip_serializing_if = "Option::is_none")]
pub replaced_by_order_id: Option<i32>,
}
impl TradeOrderBase {
/// The base Order object for TakeProfit, StopLoss and TrailingStopLoss type of orders which are connected to a trade.
pub fn new() -> TradeOrderBase {
TradeOrderBase {
id: None,
create_time: None,
state: None,
client_extensions: None,
r#type: None,
trade_id: None,
client_trade_id: None,
time_in_force: None,
gtd_time: None,
trigger_condition: None,
filling_transaction_id: None,
filled_time: None,
trade_opened_id: None,
trade_reduced_id: None,
trade_closed_ids: None,
cancelling_transaction_id: None,
cancelled_time: None,
replaces_order_id: None,
replaced_by_order_id: None,
}
}
}
/// The type of the Order.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "TAKE_PROFIT")]
TakeProfit,
#[serde(rename = "STOP_LOSS")]
StopLoss,
#[serde(rename = "TRAILING_STOP_LOSS")]
TrailingStopLoss,
}
impl Default for Type {
fn default() -> Type {
Self::TakeProfit
}
}