oanda_v20_openapi/models/trade_order_base.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/// TradeOrderBase : The base Order object for TakeProfit, StopLoss and TrailingStopLoss type of orders which are connected to a trade.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct TradeOrderBase {
17 /// The Order's identifier, unique within the Order's Account.
18 #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
19 pub id: Option<i32>,
20 /// 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).
21 #[serde(rename = "createTime", skip_serializing_if = "Option::is_none")]
22 pub create_time: Option<String>,
23 #[serde(rename = "state", skip_serializing_if = "Option::is_none")]
24 pub state: Option<models::OrderState>,
25 #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
26 pub client_extensions: Option<Box<models::ClientExtensions>>,
27 /// The type of the Order.
28 #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
29 pub r#type: Option<Type>,
30 /// The ID of the Trade to close when the price threshold is breached.
31 #[serde(rename = "tradeID", skip_serializing_if = "Option::is_none")]
32 pub trade_id: Option<i32>,
33 /// The client ID of the Trade to be closed when the price threshold is breached.
34 #[serde(rename = "clientTradeID", skip_serializing_if = "Option::is_none")]
35 pub client_trade_id: Option<String>,
36 #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
37 pub time_in_force: Option<models::TradeOrderTimeInForce>,
38 /// 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).
39 #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
40 pub gtd_time: Option<String>,
41 #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
42 pub trigger_condition: Option<models::TradeOrderTriggerCondition>,
43 /// ID of the Transaction that filled this Order (only provided when the Order's state is FILLED)
44 #[serde(rename = "fillingTransactionID", skip_serializing_if = "Option::is_none")]
45 pub filling_transaction_id: Option<i32>,
46 /// 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).
47 #[serde(rename = "filledTime", skip_serializing_if = "Option::is_none")]
48 pub filled_time: Option<String>,
49 /// 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)
50 #[serde(rename = "tradeOpenedID", skip_serializing_if = "Option::is_none")]
51 pub trade_opened_id: Option<i32>,
52 /// 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)
53 #[serde(rename = "tradeReducedID", skip_serializing_if = "Option::is_none")]
54 pub trade_reduced_id: Option<i32>,
55 /// 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)
56 #[serde(rename = "tradeClosedIDs", skip_serializing_if = "Option::is_none")]
57 pub trade_closed_ids: Option<Vec<i32>>,
58 /// ID of the Transaction that cancelled the Order (only provided when the Order's state is CANCELLED)
59 #[serde(rename = "cancellingTransactionID", skip_serializing_if = "Option::is_none")]
60 pub cancelling_transaction_id: Option<i32>,
61 /// 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).
62 #[serde(rename = "cancelledTime", skip_serializing_if = "Option::is_none")]
63 pub cancelled_time: Option<String>,
64 /// The ID of the Order that was replaced by this Order (only provided if this Order was created as part of a cancel/replace).
65 #[serde(rename = "replacesOrderID", skip_serializing_if = "Option::is_none")]
66 pub replaces_order_id: Option<i32>,
67 /// The ID of the Order that replaced this Order (only provided if this Order was cancelled as part of a cancel/replace).
68 #[serde(rename = "replacedByOrderID", skip_serializing_if = "Option::is_none")]
69 pub replaced_by_order_id: Option<i32>,
70}
71
72impl TradeOrderBase {
73 /// The base Order object for TakeProfit, StopLoss and TrailingStopLoss type of orders which are connected to a trade.
74 pub fn new() -> TradeOrderBase {
75 TradeOrderBase {
76 id: None,
77 create_time: None,
78 state: None,
79 client_extensions: None,
80 r#type: None,
81 trade_id: None,
82 client_trade_id: None,
83 time_in_force: None,
84 gtd_time: None,
85 trigger_condition: None,
86 filling_transaction_id: None,
87 filled_time: None,
88 trade_opened_id: None,
89 trade_reduced_id: None,
90 trade_closed_ids: None,
91 cancelling_transaction_id: None,
92 cancelled_time: None,
93 replaces_order_id: None,
94 replaced_by_order_id: None,
95 }
96 }
97}
98/// The type of the Order.
99#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
100pub enum Type {
101 #[serde(rename = "TAKE_PROFIT")]
102 TakeProfit,
103 #[serde(rename = "STOP_LOSS")]
104 StopLoss,
105 #[serde(rename = "TRAILING_STOP_LOSS")]
106 TrailingStopLoss,
107}
108
109impl Default for Type {
110 fn default() -> Type {
111 Self::TakeProfit
112 }
113}
114