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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* 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.1.0
* Contact: jmicoud02@gmail.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// StopLossOrder : A StopLossOrder is an order that is linked to an open Trade and created with a price threshold. The Order will be filled (closing the Trade) by the first price that is equal to or worse than the threshold. A StopLossOrder cannot be used to open a new Position.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct StopLossOrder {
/// 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>,
/// The price threshold specified for the Stop Loss Order. If the guaranteed flag is false, the associated Trade will be closed by a market price that is equal to or worse than this threshold. If the flag is true the associated Trade will be closed at this price.
#[serde(rename = "price", skip_serializing_if = "Option::is_none")]
pub price: Option<f64>,
/// The premium that will be charged if the Stop Loss Order is guaranteed and the Order is filled at the guaranteed price. It is in price units and is charged for each unit of the Trade.
#[serde(rename = "guaranteedExecutionPremium", skip_serializing_if = "Option::is_none")]
pub guaranteed_execution_premium: Option<f64>,
/// Specifies the distance (in price units) from the Account's current price to use as the Stop Loss Order price. If the Trade is short the Instrument's bid price is used, and for long Trades the ask is used.
#[serde(rename = "distance", skip_serializing_if = "Option::is_none")]
pub distance: Option<f64>,
/// Flag indicating that the Stop Loss Order is guaranteed. The default value depends on the GuaranteedStopLossOrderMode of the account, if it is REQUIRED, the default will be true, for DISABLED or ENABLED the default is false.
#[serde(rename = "guaranteed", skip_serializing_if = "Option::is_none")]
pub guaranteed: Option<bool>,
}
impl StopLossOrder {
/// A StopLossOrder is an order that is linked to an open Trade and created with a price threshold. The Order will be filled (closing the Trade) by the first price that is equal to or worse than the threshold. A StopLossOrder cannot be used to open a new Position.
pub fn new() -> StopLossOrder {
StopLossOrder {
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,
price: None,
guaranteed_execution_premium: None,
distance: None,
guaranteed: 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
}
}