Skip to main content

oanda_rs/models/transaction/
order_tx.rs

1//! Order create/reject transaction subtypes and their reason enums.
2
3use serde::{Deserialize, Serialize};
4
5use crate::models::macros::string_enum;
6use crate::models::transaction::TransactionRejectReason;
7use crate::models::{
8    AccountId, ClientExtensions, DateTime, DecimalNumber, InstrumentName, LimitOrderTimeInForce,
9    MarketIfTouchedOrderTimeInForce, MarketOrderDelayedTradeClose, MarketOrderMarginCloseout,
10    MarketOrderPositionCloseout, MarketOrderTimeInForce, MarketOrderTradeClose, OrderId,
11    OrderPositionFill, OrderTriggerCondition, PriceValue, RequestId, StopLossDetails,
12    StopLossOrderTimeInForce, StopOrderTimeInForce, TakeProfitDetails, TakeProfitOrderTimeInForce,
13    TradeId, TradeState, TrailingStopLossDetails, TrailingStopLossOrderTimeInForce, TransactionId,
14};
15
16/// A MarketOrderTransaction represents the creation of a Market Order in the
17/// user's account. A Market Order is an Order that is filled immediately at the
18/// current market price. Market Orders can be specialized when they are created
19/// to accomplish a specific task: to close a Trade, to closeout a Position or
20/// to particiate in in a Margin closeout.
21#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
22#[non_exhaustive]
23pub struct MarketOrderTransaction {
24    /// The Transaction's Identifier.
25    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
26    pub id: Option<TransactionId>,
27
28    /// The date/time when the Transaction was created.
29    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
30    pub time: Option<DateTime>,
31
32    /// The ID of the user that initiated the creation of the Transaction.
33    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
34    pub user_id: Option<i64>,
35
36    /// The ID of the Account the Transaction was created for.
37    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
38    pub account_id: Option<AccountId>,
39
40    /// The ID of the "batch" that the Transaction belongs to. Transactions in
41    /// the same batch are applied to the Account simultaneously.
42    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
43    pub batch_id: Option<TransactionId>,
44
45    /// The Request ID of the request which generated the transaction.
46    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
47    pub request_id: Option<RequestId>,
48
49    // type is pinned to "MARKET_ORDER" by the enum wrapper
50    /// The Market Order's Instrument.
51    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
52    pub instrument: Option<InstrumentName>,
53
54    /// The quantity requested to be filled by the Market Order. A posititive
55    /// number of units results in a long Order, and a negative number of units
56    /// results in a short Order.
57    #[serde(rename = "units", skip_serializing_if = "Option::is_none")]
58    pub units: Option<DecimalNumber>,
59
60    /// The `timeInForce` field.
61    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
62    pub time_in_force: Option<MarketOrderTimeInForce>,
63
64    /// The worst price that the client is willing to have the Market Order
65    /// filled at.
66    #[serde(rename = "priceBound", skip_serializing_if = "Option::is_none")]
67    pub price_bound: Option<PriceValue>,
68
69    /// The `positionFill` field.
70    #[serde(rename = "positionFill", skip_serializing_if = "Option::is_none")]
71    pub position_fill: Option<OrderPositionFill>,
72
73    /// The `tradeClose` field.
74    #[serde(rename = "tradeClose", skip_serializing_if = "Option::is_none")]
75    pub trade_close: Option<MarketOrderTradeClose>,
76
77    /// The `longPositionCloseout` field.
78    #[serde(
79        rename = "longPositionCloseout",
80        skip_serializing_if = "Option::is_none"
81    )]
82    pub long_position_closeout: Option<MarketOrderPositionCloseout>,
83
84    /// The `shortPositionCloseout` field.
85    #[serde(
86        rename = "shortPositionCloseout",
87        skip_serializing_if = "Option::is_none"
88    )]
89    pub short_position_closeout: Option<MarketOrderPositionCloseout>,
90
91    /// The `marginCloseout` field.
92    #[serde(rename = "marginCloseout", skip_serializing_if = "Option::is_none")]
93    pub margin_closeout: Option<MarketOrderMarginCloseout>,
94
95    /// The `delayedTradeClose` field.
96    #[serde(rename = "delayedTradeClose", skip_serializing_if = "Option::is_none")]
97    pub delayed_trade_close: Option<MarketOrderDelayedTradeClose>,
98
99    /// The `reason` field.
100    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
101    pub reason: Option<MarketOrderReason>,
102
103    /// The `clientExtensions` field.
104    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
105    pub client_extensions: Option<ClientExtensions>,
106
107    /// The `takeProfitOnFill` field.
108    #[serde(rename = "takeProfitOnFill", skip_serializing_if = "Option::is_none")]
109    pub take_profit_on_fill: Option<TakeProfitDetails>,
110
111    /// The `stopLossOnFill` field.
112    #[serde(rename = "stopLossOnFill", skip_serializing_if = "Option::is_none")]
113    pub stop_loss_on_fill: Option<StopLossDetails>,
114
115    /// The `trailingStopLossOnFill` field.
116    #[serde(
117        rename = "trailingStopLossOnFill",
118        skip_serializing_if = "Option::is_none"
119    )]
120    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
121
122    /// The `tradeClientExtensions` field.
123    #[serde(
124        rename = "tradeClientExtensions",
125        skip_serializing_if = "Option::is_none"
126    )]
127    pub trade_client_extensions: Option<ClientExtensions>,
128}
129
130/// A MarketOrderRejectTransaction represents the rejection of the creation of a
131/// Market Order.
132#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
133#[non_exhaustive]
134pub struct MarketOrderRejectTransaction {
135    /// The Transaction's Identifier.
136    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
137    pub id: Option<TransactionId>,
138
139    /// The date/time when the Transaction was created.
140    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
141    pub time: Option<DateTime>,
142
143    /// The ID of the user that initiated the creation of the Transaction.
144    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
145    pub user_id: Option<i64>,
146
147    /// The ID of the Account the Transaction was created for.
148    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
149    pub account_id: Option<AccountId>,
150
151    /// The ID of the "batch" that the Transaction belongs to. Transactions in
152    /// the same batch are applied to the Account simultaneously.
153    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
154    pub batch_id: Option<TransactionId>,
155
156    /// The Request ID of the request which generated the transaction.
157    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
158    pub request_id: Option<RequestId>,
159
160    // type is pinned to "MARKET_ORDER_REJECT" by the enum wrapper
161    /// The Market Order's Instrument.
162    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
163    pub instrument: Option<InstrumentName>,
164
165    /// The quantity requested to be filled by the Market Order. A posititive
166    /// number of units results in a long Order, and a negative number of units
167    /// results in a short Order.
168    #[serde(rename = "units", skip_serializing_if = "Option::is_none")]
169    pub units: Option<DecimalNumber>,
170
171    /// The `timeInForce` field.
172    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
173    pub time_in_force: Option<MarketOrderTimeInForce>,
174
175    /// The worst price that the client is willing to have the Market Order
176    /// filled at.
177    #[serde(rename = "priceBound", skip_serializing_if = "Option::is_none")]
178    pub price_bound: Option<PriceValue>,
179
180    /// The `positionFill` field.
181    #[serde(rename = "positionFill", skip_serializing_if = "Option::is_none")]
182    pub position_fill: Option<OrderPositionFill>,
183
184    /// The `tradeClose` field.
185    #[serde(rename = "tradeClose", skip_serializing_if = "Option::is_none")]
186    pub trade_close: Option<MarketOrderTradeClose>,
187
188    /// The `longPositionCloseout` field.
189    #[serde(
190        rename = "longPositionCloseout",
191        skip_serializing_if = "Option::is_none"
192    )]
193    pub long_position_closeout: Option<MarketOrderPositionCloseout>,
194
195    /// The `shortPositionCloseout` field.
196    #[serde(
197        rename = "shortPositionCloseout",
198        skip_serializing_if = "Option::is_none"
199    )]
200    pub short_position_closeout: Option<MarketOrderPositionCloseout>,
201
202    /// The `marginCloseout` field.
203    #[serde(rename = "marginCloseout", skip_serializing_if = "Option::is_none")]
204    pub margin_closeout: Option<MarketOrderMarginCloseout>,
205
206    /// The `delayedTradeClose` field.
207    #[serde(rename = "delayedTradeClose", skip_serializing_if = "Option::is_none")]
208    pub delayed_trade_close: Option<MarketOrderDelayedTradeClose>,
209
210    /// The `reason` field.
211    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
212    pub reason: Option<MarketOrderReason>,
213
214    /// The `clientExtensions` field.
215    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
216    pub client_extensions: Option<ClientExtensions>,
217
218    /// The `takeProfitOnFill` field.
219    #[serde(rename = "takeProfitOnFill", skip_serializing_if = "Option::is_none")]
220    pub take_profit_on_fill: Option<TakeProfitDetails>,
221
222    /// The `stopLossOnFill` field.
223    #[serde(rename = "stopLossOnFill", skip_serializing_if = "Option::is_none")]
224    pub stop_loss_on_fill: Option<StopLossDetails>,
225
226    /// The `trailingStopLossOnFill` field.
227    #[serde(
228        rename = "trailingStopLossOnFill",
229        skip_serializing_if = "Option::is_none"
230    )]
231    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
232
233    /// The `tradeClientExtensions` field.
234    #[serde(
235        rename = "tradeClientExtensions",
236        skip_serializing_if = "Option::is_none"
237    )]
238    pub trade_client_extensions: Option<ClientExtensions>,
239
240    /// The `rejectReason` field.
241    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
242    pub reject_reason: Option<TransactionRejectReason>,
243}
244
245/// A FixedPriceOrderTransaction represents the creation of a Fixed Price Order
246/// in the user's account. A Fixed Price Order is an Order that is filled
247/// immediately at a specified price.
248#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
249#[non_exhaustive]
250pub struct FixedPriceOrderTransaction {
251    /// The Transaction's Identifier.
252    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
253    pub id: Option<TransactionId>,
254
255    /// The date/time when the Transaction was created.
256    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
257    pub time: Option<DateTime>,
258
259    /// The ID of the user that initiated the creation of the Transaction.
260    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
261    pub user_id: Option<i64>,
262
263    /// The ID of the Account the Transaction was created for.
264    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
265    pub account_id: Option<AccountId>,
266
267    /// The ID of the "batch" that the Transaction belongs to. Transactions in
268    /// the same batch are applied to the Account simultaneously.
269    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
270    pub batch_id: Option<TransactionId>,
271
272    /// The Request ID of the request which generated the transaction.
273    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
274    pub request_id: Option<RequestId>,
275
276    // type is pinned to "FIXED_PRICE_ORDER" by the enum wrapper
277    /// The Fixed Price Order's Instrument.
278    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
279    pub instrument: Option<InstrumentName>,
280
281    /// The quantity requested to be filled by the Fixed Price Order. A
282    /// posititive number of units results in a long Order, and a negative
283    /// number of units results in a short Order.
284    #[serde(rename = "units", skip_serializing_if = "Option::is_none")]
285    pub units: Option<DecimalNumber>,
286
287    /// The price specified for the Fixed Price Order. This price is the exact
288    /// price that the Fixed Price Order will be filled at.
289    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
290    pub price: Option<PriceValue>,
291
292    /// The `positionFill` field.
293    #[serde(rename = "positionFill", skip_serializing_if = "Option::is_none")]
294    pub position_fill: Option<OrderPositionFill>,
295
296    /// The `tradeState` field.
297    #[serde(rename = "tradeState", skip_serializing_if = "Option::is_none")]
298    pub trade_state: Option<TradeState>,
299
300    /// The `reason` field.
301    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
302    pub reason: Option<FixedPriceOrderReason>,
303
304    /// The `clientExtensions` field.
305    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
306    pub client_extensions: Option<ClientExtensions>,
307
308    /// The `takeProfitOnFill` field.
309    #[serde(rename = "takeProfitOnFill", skip_serializing_if = "Option::is_none")]
310    pub take_profit_on_fill: Option<TakeProfitDetails>,
311
312    /// The `stopLossOnFill` field.
313    #[serde(rename = "stopLossOnFill", skip_serializing_if = "Option::is_none")]
314    pub stop_loss_on_fill: Option<StopLossDetails>,
315
316    /// The `trailingStopLossOnFill` field.
317    #[serde(
318        rename = "trailingStopLossOnFill",
319        skip_serializing_if = "Option::is_none"
320    )]
321    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
322
323    /// The `tradeClientExtensions` field.
324    #[serde(
325        rename = "tradeClientExtensions",
326        skip_serializing_if = "Option::is_none"
327    )]
328    pub trade_client_extensions: Option<ClientExtensions>,
329}
330
331/// A LimitOrderTransaction represents the creation of a Limit Order in the
332/// user's Account.
333#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
334#[non_exhaustive]
335pub struct LimitOrderTransaction {
336    /// The Transaction's Identifier.
337    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
338    pub id: Option<TransactionId>,
339
340    /// The date/time when the Transaction was created.
341    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
342    pub time: Option<DateTime>,
343
344    /// The ID of the user that initiated the creation of the Transaction.
345    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
346    pub user_id: Option<i64>,
347
348    /// The ID of the Account the Transaction was created for.
349    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
350    pub account_id: Option<AccountId>,
351
352    /// The ID of the "batch" that the Transaction belongs to. Transactions in
353    /// the same batch are applied to the Account simultaneously.
354    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
355    pub batch_id: Option<TransactionId>,
356
357    /// The Request ID of the request which generated the transaction.
358    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
359    pub request_id: Option<RequestId>,
360
361    // type is pinned to "LIMIT_ORDER" by the enum wrapper
362    /// The Limit Order's Instrument.
363    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
364    pub instrument: Option<InstrumentName>,
365
366    /// The quantity requested to be filled by the Limit Order. A posititive
367    /// number of units results in a long Order, and a negative number of units
368    /// results in a short Order.
369    #[serde(rename = "units", skip_serializing_if = "Option::is_none")]
370    pub units: Option<DecimalNumber>,
371
372    /// The price threshold specified for the Limit Order. The Limit Order will
373    /// only be filled by a market price that is equal to or better than this
374    /// price.
375    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
376    pub price: Option<PriceValue>,
377
378    /// The `timeInForce` field.
379    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
380    pub time_in_force: Option<LimitOrderTimeInForce>,
381
382    /// The date/time when the Limit Order will be cancelled if its timeInForce
383    /// is "GTD".
384    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
385    pub gtd_time: Option<DateTime>,
386
387    /// The `positionFill` field.
388    #[serde(rename = "positionFill", skip_serializing_if = "Option::is_none")]
389    pub position_fill: Option<OrderPositionFill>,
390
391    /// The `triggerCondition` field.
392    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
393    pub trigger_condition: Option<OrderTriggerCondition>,
394
395    /// The `reason` field.
396    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
397    pub reason: Option<LimitOrderReason>,
398
399    /// The `clientExtensions` field.
400    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
401    pub client_extensions: Option<ClientExtensions>,
402
403    /// The `takeProfitOnFill` field.
404    #[serde(rename = "takeProfitOnFill", skip_serializing_if = "Option::is_none")]
405    pub take_profit_on_fill: Option<TakeProfitDetails>,
406
407    /// The `stopLossOnFill` field.
408    #[serde(rename = "stopLossOnFill", skip_serializing_if = "Option::is_none")]
409    pub stop_loss_on_fill: Option<StopLossDetails>,
410
411    /// The `trailingStopLossOnFill` field.
412    #[serde(
413        rename = "trailingStopLossOnFill",
414        skip_serializing_if = "Option::is_none"
415    )]
416    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
417
418    /// The `tradeClientExtensions` field.
419    #[serde(
420        rename = "tradeClientExtensions",
421        skip_serializing_if = "Option::is_none"
422    )]
423    pub trade_client_extensions: Option<ClientExtensions>,
424
425    /// The ID of the Order that this Order replaces (only provided if this
426    /// Order replaces an existing Order).
427    #[serde(rename = "replacesOrderID", skip_serializing_if = "Option::is_none")]
428    pub replaces_order_id: Option<OrderId>,
429
430    /// The ID of the Transaction that cancels the replaced Order (only provided
431    /// if this Order replaces an existing Order).
432    #[serde(
433        rename = "cancellingTransactionID",
434        skip_serializing_if = "Option::is_none"
435    )]
436    pub cancelling_transaction_id: Option<TransactionId>,
437
438    /// How the Order may be partially filled. Observed value: "DEFAULT_FILL".
439    /// This field is returned by the live v20 API but is not present in OANDA's
440    /// official documentation.
441    #[serde(rename = "partialFill", skip_serializing_if = "Option::is_none")]
442    pub partial_fill: Option<String>,
443}
444
445/// A LimitOrderRejectTransaction represents the rejection of the creation of a
446/// Limit Order.
447#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
448#[non_exhaustive]
449pub struct LimitOrderRejectTransaction {
450    /// The Transaction's Identifier.
451    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
452    pub id: Option<TransactionId>,
453
454    /// The date/time when the Transaction was created.
455    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
456    pub time: Option<DateTime>,
457
458    /// The ID of the user that initiated the creation of the Transaction.
459    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
460    pub user_id: Option<i64>,
461
462    /// The ID of the Account the Transaction was created for.
463    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
464    pub account_id: Option<AccountId>,
465
466    /// The ID of the "batch" that the Transaction belongs to. Transactions in
467    /// the same batch are applied to the Account simultaneously.
468    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
469    pub batch_id: Option<TransactionId>,
470
471    /// The Request ID of the request which generated the transaction.
472    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
473    pub request_id: Option<RequestId>,
474
475    // type is pinned to "LIMIT_ORDER_REJECT" by the enum wrapper
476    /// The Limit Order's Instrument.
477    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
478    pub instrument: Option<InstrumentName>,
479
480    /// The quantity requested to be filled by the Limit Order. A posititive
481    /// number of units results in a long Order, and a negative number of units
482    /// results in a short Order.
483    #[serde(rename = "units", skip_serializing_if = "Option::is_none")]
484    pub units: Option<DecimalNumber>,
485
486    /// The price threshold specified for the Limit Order. The Limit Order will
487    /// only be filled by a market price that is equal to or better than this
488    /// price.
489    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
490    pub price: Option<PriceValue>,
491
492    /// The `timeInForce` field.
493    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
494    pub time_in_force: Option<LimitOrderTimeInForce>,
495
496    /// The date/time when the Limit Order will be cancelled if its timeInForce
497    /// is "GTD".
498    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
499    pub gtd_time: Option<DateTime>,
500
501    /// The `positionFill` field.
502    #[serde(rename = "positionFill", skip_serializing_if = "Option::is_none")]
503    pub position_fill: Option<OrderPositionFill>,
504
505    /// The `triggerCondition` field.
506    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
507    pub trigger_condition: Option<OrderTriggerCondition>,
508
509    /// The `reason` field.
510    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
511    pub reason: Option<LimitOrderReason>,
512
513    /// The `clientExtensions` field.
514    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
515    pub client_extensions: Option<ClientExtensions>,
516
517    /// The `takeProfitOnFill` field.
518    #[serde(rename = "takeProfitOnFill", skip_serializing_if = "Option::is_none")]
519    pub take_profit_on_fill: Option<TakeProfitDetails>,
520
521    /// The `stopLossOnFill` field.
522    #[serde(rename = "stopLossOnFill", skip_serializing_if = "Option::is_none")]
523    pub stop_loss_on_fill: Option<StopLossDetails>,
524
525    /// The `trailingStopLossOnFill` field.
526    #[serde(
527        rename = "trailingStopLossOnFill",
528        skip_serializing_if = "Option::is_none"
529    )]
530    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
531
532    /// The `tradeClientExtensions` field.
533    #[serde(
534        rename = "tradeClientExtensions",
535        skip_serializing_if = "Option::is_none"
536    )]
537    pub trade_client_extensions: Option<ClientExtensions>,
538
539    /// The ID of the Order that this Order was intended to replace (only
540    /// provided if this Order was intended to replace an existing Order).
541    #[serde(
542        rename = "intendedReplacesOrderID",
543        skip_serializing_if = "Option::is_none"
544    )]
545    pub intended_replaces_order_id: Option<OrderId>,
546
547    /// The `rejectReason` field.
548    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
549    pub reject_reason: Option<TransactionRejectReason>,
550
551    /// How the Order may be partially filled. Observed value: "DEFAULT_FILL".
552    /// This field is returned by the live v20 API but is not present in OANDA's
553    /// official documentation.
554    #[serde(rename = "partialFill", skip_serializing_if = "Option::is_none")]
555    pub partial_fill: Option<String>,
556}
557
558/// A StopOrderTransaction represents the creation of a Stop Order in the user's
559/// Account.
560#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
561#[non_exhaustive]
562pub struct StopOrderTransaction {
563    /// The Transaction's Identifier.
564    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
565    pub id: Option<TransactionId>,
566
567    /// The date/time when the Transaction was created.
568    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
569    pub time: Option<DateTime>,
570
571    /// The ID of the user that initiated the creation of the Transaction.
572    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
573    pub user_id: Option<i64>,
574
575    /// The ID of the Account the Transaction was created for.
576    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
577    pub account_id: Option<AccountId>,
578
579    /// The ID of the "batch" that the Transaction belongs to. Transactions in
580    /// the same batch are applied to the Account simultaneously.
581    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
582    pub batch_id: Option<TransactionId>,
583
584    /// The Request ID of the request which generated the transaction.
585    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
586    pub request_id: Option<RequestId>,
587
588    // type is pinned to "STOP_ORDER" by the enum wrapper
589    /// The Stop Order's Instrument.
590    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
591    pub instrument: Option<InstrumentName>,
592
593    /// The quantity requested to be filled by the Stop Order. A posititive
594    /// number of units results in a long Order, and a negative number of units
595    /// results in a short Order.
596    #[serde(rename = "units", skip_serializing_if = "Option::is_none")]
597    pub units: Option<DecimalNumber>,
598
599    /// The price threshold specified for the Stop Order. The Stop Order will
600    /// only be filled by a market price that is equal to or worse than this
601    /// price.
602    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
603    pub price: Option<PriceValue>,
604
605    /// The worst market price that may be used to fill this Stop Order. If the
606    /// market gaps and crosses through both the price and the priceBound, the
607    /// Stop Order will be cancelled instead of being filled.
608    #[serde(rename = "priceBound", skip_serializing_if = "Option::is_none")]
609    pub price_bound: Option<PriceValue>,
610
611    /// The `timeInForce` field.
612    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
613    pub time_in_force: Option<StopOrderTimeInForce>,
614
615    /// The date/time when the Stop Order will be cancelled if its timeInForce
616    /// is "GTD".
617    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
618    pub gtd_time: Option<DateTime>,
619
620    /// The `positionFill` field.
621    #[serde(rename = "positionFill", skip_serializing_if = "Option::is_none")]
622    pub position_fill: Option<OrderPositionFill>,
623
624    /// The `triggerCondition` field.
625    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
626    pub trigger_condition: Option<OrderTriggerCondition>,
627
628    /// The `reason` field.
629    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
630    pub reason: Option<StopOrderReason>,
631
632    /// The `clientExtensions` field.
633    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
634    pub client_extensions: Option<ClientExtensions>,
635
636    /// The `takeProfitOnFill` field.
637    #[serde(rename = "takeProfitOnFill", skip_serializing_if = "Option::is_none")]
638    pub take_profit_on_fill: Option<TakeProfitDetails>,
639
640    /// The `stopLossOnFill` field.
641    #[serde(rename = "stopLossOnFill", skip_serializing_if = "Option::is_none")]
642    pub stop_loss_on_fill: Option<StopLossDetails>,
643
644    /// The `trailingStopLossOnFill` field.
645    #[serde(
646        rename = "trailingStopLossOnFill",
647        skip_serializing_if = "Option::is_none"
648    )]
649    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
650
651    /// The `tradeClientExtensions` field.
652    #[serde(
653        rename = "tradeClientExtensions",
654        skip_serializing_if = "Option::is_none"
655    )]
656    pub trade_client_extensions: Option<ClientExtensions>,
657
658    /// The ID of the Order that this Order replaces (only provided if this
659    /// Order replaces an existing Order).
660    #[serde(rename = "replacesOrderID", skip_serializing_if = "Option::is_none")]
661    pub replaces_order_id: Option<OrderId>,
662
663    /// The ID of the Transaction that cancels the replaced Order (only provided
664    /// if this Order replaces an existing Order).
665    #[serde(
666        rename = "cancellingTransactionID",
667        skip_serializing_if = "Option::is_none"
668    )]
669    pub cancelling_transaction_id: Option<TransactionId>,
670
671    /// How the Order may be partially filled. Observed value: "DEFAULT_FILL".
672    /// This field is returned by the live v20 API but is not present in OANDA's
673    /// official documentation.
674    #[serde(rename = "partialFill", skip_serializing_if = "Option::is_none")]
675    pub partial_fill: Option<String>,
676
677    /// The price trigger mode of the Order. Observed value: "TOP_OF_BOOK". This
678    /// field is returned by the live v20 API but is not present in OANDA's
679    /// official documentation.
680    #[serde(rename = "triggerMode", skip_serializing_if = "Option::is_none")]
681    pub trigger_mode: Option<String>,
682}
683
684/// A StopOrderRejectTransaction represents the rejection of the creation of a
685/// Stop Order.
686#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
687#[non_exhaustive]
688pub struct StopOrderRejectTransaction {
689    /// The Transaction's Identifier.
690    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
691    pub id: Option<TransactionId>,
692
693    /// The date/time when the Transaction was created.
694    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
695    pub time: Option<DateTime>,
696
697    /// The ID of the user that initiated the creation of the Transaction.
698    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
699    pub user_id: Option<i64>,
700
701    /// The ID of the Account the Transaction was created for.
702    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
703    pub account_id: Option<AccountId>,
704
705    /// The ID of the "batch" that the Transaction belongs to. Transactions in
706    /// the same batch are applied to the Account simultaneously.
707    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
708    pub batch_id: Option<TransactionId>,
709
710    /// The Request ID of the request which generated the transaction.
711    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
712    pub request_id: Option<RequestId>,
713
714    // type is pinned to "STOP_ORDER_REJECT" by the enum wrapper
715    /// The Stop Order's Instrument.
716    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
717    pub instrument: Option<InstrumentName>,
718
719    /// The quantity requested to be filled by the Stop Order. A posititive
720    /// number of units results in a long Order, and a negative number of units
721    /// results in a short Order.
722    #[serde(rename = "units", skip_serializing_if = "Option::is_none")]
723    pub units: Option<DecimalNumber>,
724
725    /// The price threshold specified for the Stop Order. The Stop Order will
726    /// only be filled by a market price that is equal to or worse than this
727    /// price.
728    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
729    pub price: Option<PriceValue>,
730
731    /// The worst market price that may be used to fill this Stop Order. If the
732    /// market gaps and crosses through both the price and the priceBound, the
733    /// Stop Order will be cancelled instead of being filled.
734    #[serde(rename = "priceBound", skip_serializing_if = "Option::is_none")]
735    pub price_bound: Option<PriceValue>,
736
737    /// The `timeInForce` field.
738    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
739    pub time_in_force: Option<StopOrderTimeInForce>,
740
741    /// The date/time when the Stop Order will be cancelled if its timeInForce
742    /// is "GTD".
743    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
744    pub gtd_time: Option<DateTime>,
745
746    /// The `positionFill` field.
747    #[serde(rename = "positionFill", skip_serializing_if = "Option::is_none")]
748    pub position_fill: Option<OrderPositionFill>,
749
750    /// The `triggerCondition` field.
751    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
752    pub trigger_condition: Option<OrderTriggerCondition>,
753
754    /// The `reason` field.
755    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
756    pub reason: Option<StopOrderReason>,
757
758    /// The `clientExtensions` field.
759    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
760    pub client_extensions: Option<ClientExtensions>,
761
762    /// The `takeProfitOnFill` field.
763    #[serde(rename = "takeProfitOnFill", skip_serializing_if = "Option::is_none")]
764    pub take_profit_on_fill: Option<TakeProfitDetails>,
765
766    /// The `stopLossOnFill` field.
767    #[serde(rename = "stopLossOnFill", skip_serializing_if = "Option::is_none")]
768    pub stop_loss_on_fill: Option<StopLossDetails>,
769
770    /// The `trailingStopLossOnFill` field.
771    #[serde(
772        rename = "trailingStopLossOnFill",
773        skip_serializing_if = "Option::is_none"
774    )]
775    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
776
777    /// The `tradeClientExtensions` field.
778    #[serde(
779        rename = "tradeClientExtensions",
780        skip_serializing_if = "Option::is_none"
781    )]
782    pub trade_client_extensions: Option<ClientExtensions>,
783
784    /// The ID of the Order that this Order was intended to replace (only
785    /// provided if this Order was intended to replace an existing Order).
786    #[serde(
787        rename = "intendedReplacesOrderID",
788        skip_serializing_if = "Option::is_none"
789    )]
790    pub intended_replaces_order_id: Option<OrderId>,
791
792    /// The `rejectReason` field.
793    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
794    pub reject_reason: Option<TransactionRejectReason>,
795
796    /// How the Order may be partially filled. Observed value: "DEFAULT_FILL".
797    /// This field is returned by the live v20 API but is not present in OANDA's
798    /// official documentation.
799    #[serde(rename = "partialFill", skip_serializing_if = "Option::is_none")]
800    pub partial_fill: Option<String>,
801
802    /// The price trigger mode of the Order. Observed value: "TOP_OF_BOOK". This
803    /// field is returned by the live v20 API but is not present in OANDA's
804    /// official documentation.
805    #[serde(rename = "triggerMode", skip_serializing_if = "Option::is_none")]
806    pub trigger_mode: Option<String>,
807}
808
809/// A MarketIfTouchedOrderTransaction represents the creation of a
810/// MarketIfTouched Order in the user's Account.
811#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
812#[non_exhaustive]
813pub struct MarketIfTouchedOrderTransaction {
814    /// The Transaction's Identifier.
815    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
816    pub id: Option<TransactionId>,
817
818    /// The date/time when the Transaction was created.
819    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
820    pub time: Option<DateTime>,
821
822    /// The ID of the user that initiated the creation of the Transaction.
823    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
824    pub user_id: Option<i64>,
825
826    /// The ID of the Account the Transaction was created for.
827    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
828    pub account_id: Option<AccountId>,
829
830    /// The ID of the "batch" that the Transaction belongs to. Transactions in
831    /// the same batch are applied to the Account simultaneously.
832    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
833    pub batch_id: Option<TransactionId>,
834
835    /// The Request ID of the request which generated the transaction.
836    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
837    pub request_id: Option<RequestId>,
838
839    // type is pinned to "MARKET_IF_TOUCHED_ORDER" by the enum wrapper
840    /// The MarketIfTouched Order's Instrument.
841    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
842    pub instrument: Option<InstrumentName>,
843
844    /// The quantity requested to be filled by the MarketIfTouched Order. A
845    /// posititive number of units results in a long Order, and a negative
846    /// number of units results in a short Order.
847    #[serde(rename = "units", skip_serializing_if = "Option::is_none")]
848    pub units: Option<DecimalNumber>,
849
850    /// The price threshold specified for the MarketIfTouched Order. The
851    /// MarketIfTouched Order will only be filled by a market price that crosses
852    /// this price from the direction of the market price at the time when the
853    /// Order was created (the initialMarketPrice). Depending on the value of
854    /// the Order's price and initialMarketPrice, the MarketIfTouchedOrder will
855    /// behave like a Limit or a Stop Order.
856    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
857    pub price: Option<PriceValue>,
858
859    /// The worst market price that may be used to fill this MarketIfTouched
860    /// Order.
861    #[serde(rename = "priceBound", skip_serializing_if = "Option::is_none")]
862    pub price_bound: Option<PriceValue>,
863
864    /// The `timeInForce` field.
865    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
866    pub time_in_force: Option<MarketIfTouchedOrderTimeInForce>,
867
868    /// The date/time when the MarketIfTouched Order will be cancelled if its
869    /// timeInForce is "GTD".
870    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
871    pub gtd_time: Option<DateTime>,
872
873    /// The `positionFill` field.
874    #[serde(rename = "positionFill", skip_serializing_if = "Option::is_none")]
875    pub position_fill: Option<OrderPositionFill>,
876
877    /// The `triggerCondition` field.
878    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
879    pub trigger_condition: Option<OrderTriggerCondition>,
880
881    /// The `reason` field.
882    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
883    pub reason: Option<MarketIfTouchedOrderReason>,
884
885    /// The `clientExtensions` field.
886    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
887    pub client_extensions: Option<ClientExtensions>,
888
889    /// The `takeProfitOnFill` field.
890    #[serde(rename = "takeProfitOnFill", skip_serializing_if = "Option::is_none")]
891    pub take_profit_on_fill: Option<TakeProfitDetails>,
892
893    /// The `stopLossOnFill` field.
894    #[serde(rename = "stopLossOnFill", skip_serializing_if = "Option::is_none")]
895    pub stop_loss_on_fill: Option<StopLossDetails>,
896
897    /// The `trailingStopLossOnFill` field.
898    #[serde(
899        rename = "trailingStopLossOnFill",
900        skip_serializing_if = "Option::is_none"
901    )]
902    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
903
904    /// The `tradeClientExtensions` field.
905    #[serde(
906        rename = "tradeClientExtensions",
907        skip_serializing_if = "Option::is_none"
908    )]
909    pub trade_client_extensions: Option<ClientExtensions>,
910
911    /// The ID of the Order that this Order replaces (only provided if this
912    /// Order replaces an existing Order).
913    #[serde(rename = "replacesOrderID", skip_serializing_if = "Option::is_none")]
914    pub replaces_order_id: Option<OrderId>,
915
916    /// The ID of the Transaction that cancels the replaced Order (only provided
917    /// if this Order replaces an existing Order).
918    #[serde(
919        rename = "cancellingTransactionID",
920        skip_serializing_if = "Option::is_none"
921    )]
922    pub cancelling_transaction_id: Option<TransactionId>,
923
924    /// How the Order may be partially filled. Observed value: "DEFAULT_FILL".
925    /// This field is returned by the live v20 API but is not present in OANDA's
926    /// official documentation.
927    #[serde(rename = "partialFill", skip_serializing_if = "Option::is_none")]
928    pub partial_fill: Option<String>,
929}
930
931/// A MarketIfTouchedOrderRejectTransaction represents the rejection of the
932/// creation of a MarketIfTouched Order.
933#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
934#[non_exhaustive]
935pub struct MarketIfTouchedOrderRejectTransaction {
936    /// The Transaction's Identifier.
937    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
938    pub id: Option<TransactionId>,
939
940    /// The date/time when the Transaction was created.
941    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
942    pub time: Option<DateTime>,
943
944    /// The ID of the user that initiated the creation of the Transaction.
945    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
946    pub user_id: Option<i64>,
947
948    /// The ID of the Account the Transaction was created for.
949    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
950    pub account_id: Option<AccountId>,
951
952    /// The ID of the "batch" that the Transaction belongs to. Transactions in
953    /// the same batch are applied to the Account simultaneously.
954    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
955    pub batch_id: Option<TransactionId>,
956
957    /// The Request ID of the request which generated the transaction.
958    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
959    pub request_id: Option<RequestId>,
960
961    // type is pinned to "MARKET_IF_TOUCHED_ORDER_REJECT" by the enum wrapper
962    /// The MarketIfTouched Order's Instrument.
963    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
964    pub instrument: Option<InstrumentName>,
965
966    /// The quantity requested to be filled by the MarketIfTouched Order. A
967    /// posititive number of units results in a long Order, and a negative
968    /// number of units results in a short Order.
969    #[serde(rename = "units", skip_serializing_if = "Option::is_none")]
970    pub units: Option<DecimalNumber>,
971
972    /// The price threshold specified for the MarketIfTouched Order. The
973    /// MarketIfTouched Order will only be filled by a market price that crosses
974    /// this price from the direction of the market price at the time when the
975    /// Order was created (the initialMarketPrice). Depending on the value of
976    /// the Order's price and initialMarketPrice, the MarketIfTouchedOrder will
977    /// behave like a Limit or a Stop Order.
978    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
979    pub price: Option<PriceValue>,
980
981    /// The worst market price that may be used to fill this MarketIfTouched
982    /// Order.
983    #[serde(rename = "priceBound", skip_serializing_if = "Option::is_none")]
984    pub price_bound: Option<PriceValue>,
985
986    /// The `timeInForce` field.
987    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
988    pub time_in_force: Option<MarketIfTouchedOrderTimeInForce>,
989
990    /// The date/time when the MarketIfTouched Order will be cancelled if its
991    /// timeInForce is "GTD".
992    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
993    pub gtd_time: Option<DateTime>,
994
995    /// The `positionFill` field.
996    #[serde(rename = "positionFill", skip_serializing_if = "Option::is_none")]
997    pub position_fill: Option<OrderPositionFill>,
998
999    /// The `triggerCondition` field.
1000    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
1001    pub trigger_condition: Option<OrderTriggerCondition>,
1002
1003    /// The `reason` field.
1004    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
1005    pub reason: Option<MarketIfTouchedOrderReason>,
1006
1007    /// The `clientExtensions` field.
1008    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
1009    pub client_extensions: Option<ClientExtensions>,
1010
1011    /// The `takeProfitOnFill` field.
1012    #[serde(rename = "takeProfitOnFill", skip_serializing_if = "Option::is_none")]
1013    pub take_profit_on_fill: Option<TakeProfitDetails>,
1014
1015    /// The `stopLossOnFill` field.
1016    #[serde(rename = "stopLossOnFill", skip_serializing_if = "Option::is_none")]
1017    pub stop_loss_on_fill: Option<StopLossDetails>,
1018
1019    /// The `trailingStopLossOnFill` field.
1020    #[serde(
1021        rename = "trailingStopLossOnFill",
1022        skip_serializing_if = "Option::is_none"
1023    )]
1024    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
1025
1026    /// The `tradeClientExtensions` field.
1027    #[serde(
1028        rename = "tradeClientExtensions",
1029        skip_serializing_if = "Option::is_none"
1030    )]
1031    pub trade_client_extensions: Option<ClientExtensions>,
1032
1033    /// The ID of the Order that this Order was intended to replace (only
1034    /// provided if this Order was intended to replace an existing Order).
1035    #[serde(
1036        rename = "intendedReplacesOrderID",
1037        skip_serializing_if = "Option::is_none"
1038    )]
1039    pub intended_replaces_order_id: Option<OrderId>,
1040
1041    /// The `rejectReason` field.
1042    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
1043    pub reject_reason: Option<TransactionRejectReason>,
1044
1045    /// How the Order may be partially filled. Observed value: "DEFAULT_FILL".
1046    /// This field is returned by the live v20 API but is not present in OANDA's
1047    /// official documentation.
1048    #[serde(rename = "partialFill", skip_serializing_if = "Option::is_none")]
1049    pub partial_fill: Option<String>,
1050}
1051
1052/// A TakeProfitOrderTransaction represents the creation of a TakeProfit Order
1053/// in the user's Account.
1054#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1055#[non_exhaustive]
1056pub struct TakeProfitOrderTransaction {
1057    /// The Transaction's Identifier.
1058    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
1059    pub id: Option<TransactionId>,
1060
1061    /// The date/time when the Transaction was created.
1062    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
1063    pub time: Option<DateTime>,
1064
1065    /// The ID of the user that initiated the creation of the Transaction.
1066    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
1067    pub user_id: Option<i64>,
1068
1069    /// The ID of the Account the Transaction was created for.
1070    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
1071    pub account_id: Option<AccountId>,
1072
1073    /// The ID of the "batch" that the Transaction belongs to. Transactions in
1074    /// the same batch are applied to the Account simultaneously.
1075    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
1076    pub batch_id: Option<TransactionId>,
1077
1078    /// The Request ID of the request which generated the transaction.
1079    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
1080    pub request_id: Option<RequestId>,
1081
1082    // type is pinned to "TAKE_PROFIT_ORDER" by the enum wrapper
1083    /// The ID of the Trade to close when the price threshold is breached.
1084    #[serde(rename = "tradeID", skip_serializing_if = "Option::is_none")]
1085    pub trade_id: Option<TradeId>,
1086
1087    /// The client ID of the Trade to be closed when the price threshold is
1088    /// breached.
1089    #[serde(rename = "clientTradeID", skip_serializing_if = "Option::is_none")]
1090    pub client_trade_id: Option<String>,
1091
1092    /// The price threshold specified for the TakeProfit Order. The associated
1093    /// Trade will be closed by a market price that is equal to or better than
1094    /// this threshold.
1095    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
1096    pub price: Option<PriceValue>,
1097
1098    /// The `timeInForce` field.
1099    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
1100    pub time_in_force: Option<TakeProfitOrderTimeInForce>,
1101
1102    /// The date/time when the TakeProfit Order will be cancelled if its
1103    /// timeInForce is "GTD".
1104    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
1105    pub gtd_time: Option<DateTime>,
1106
1107    /// The `triggerCondition` field.
1108    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
1109    pub trigger_condition: Option<OrderTriggerCondition>,
1110
1111    /// The `reason` field.
1112    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
1113    pub reason: Option<TakeProfitOrderReason>,
1114
1115    /// The `clientExtensions` field.
1116    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
1117    pub client_extensions: Option<ClientExtensions>,
1118
1119    /// The ID of the OrderFill Transaction that caused this Order to be created
1120    /// (only provided if this Order was created automatically when another
1121    /// Order was filled).
1122    #[serde(
1123        rename = "orderFillTransactionID",
1124        skip_serializing_if = "Option::is_none"
1125    )]
1126    pub order_fill_transaction_id: Option<TransactionId>,
1127
1128    /// The ID of the Order that this Order replaces (only provided if this
1129    /// Order replaces an existing Order).
1130    #[serde(rename = "replacesOrderID", skip_serializing_if = "Option::is_none")]
1131    pub replaces_order_id: Option<OrderId>,
1132
1133    /// The ID of the Transaction that cancels the replaced Order (only provided
1134    /// if this Order replaces an existing Order).
1135    #[serde(
1136        rename = "cancellingTransactionID",
1137        skip_serializing_if = "Option::is_none"
1138    )]
1139    pub cancelling_transaction_id: Option<TransactionId>,
1140}
1141
1142/// A TakeProfitOrderRejectTransaction represents the rejection of the creation
1143/// of a TakeProfit Order.
1144#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1145#[non_exhaustive]
1146pub struct TakeProfitOrderRejectTransaction {
1147    /// The Transaction's Identifier.
1148    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
1149    pub id: Option<TransactionId>,
1150
1151    /// The date/time when the Transaction was created.
1152    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
1153    pub time: Option<DateTime>,
1154
1155    /// The ID of the user that initiated the creation of the Transaction.
1156    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
1157    pub user_id: Option<i64>,
1158
1159    /// The ID of the Account the Transaction was created for.
1160    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
1161    pub account_id: Option<AccountId>,
1162
1163    /// The ID of the "batch" that the Transaction belongs to. Transactions in
1164    /// the same batch are applied to the Account simultaneously.
1165    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
1166    pub batch_id: Option<TransactionId>,
1167
1168    /// The Request ID of the request which generated the transaction.
1169    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
1170    pub request_id: Option<RequestId>,
1171
1172    // type is pinned to "TAKE_PROFIT_ORDER_REJECT" by the enum wrapper
1173    /// The ID of the Trade to close when the price threshold is breached.
1174    #[serde(rename = "tradeID", skip_serializing_if = "Option::is_none")]
1175    pub trade_id: Option<TradeId>,
1176
1177    /// The client ID of the Trade to be closed when the price threshold is
1178    /// breached.
1179    #[serde(rename = "clientTradeID", skip_serializing_if = "Option::is_none")]
1180    pub client_trade_id: Option<String>,
1181
1182    /// The price threshold specified for the TakeProfit Order. The associated
1183    /// Trade will be closed by a market price that is equal to or better than
1184    /// this threshold.
1185    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
1186    pub price: Option<PriceValue>,
1187
1188    /// The `timeInForce` field.
1189    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
1190    pub time_in_force: Option<TakeProfitOrderTimeInForce>,
1191
1192    /// The date/time when the TakeProfit Order will be cancelled if its
1193    /// timeInForce is "GTD".
1194    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
1195    pub gtd_time: Option<DateTime>,
1196
1197    /// The `triggerCondition` field.
1198    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
1199    pub trigger_condition: Option<OrderTriggerCondition>,
1200
1201    /// The `reason` field.
1202    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
1203    pub reason: Option<TakeProfitOrderReason>,
1204
1205    /// The `clientExtensions` field.
1206    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
1207    pub client_extensions: Option<ClientExtensions>,
1208
1209    /// The ID of the OrderFill Transaction that caused this Order to be created
1210    /// (only provided if this Order was created automatically when another
1211    /// Order was filled).
1212    #[serde(
1213        rename = "orderFillTransactionID",
1214        skip_serializing_if = "Option::is_none"
1215    )]
1216    pub order_fill_transaction_id: Option<TransactionId>,
1217
1218    /// The ID of the Order that this Order was intended to replace (only
1219    /// provided if this Order was intended to replace an existing Order).
1220    #[serde(
1221        rename = "intendedReplacesOrderID",
1222        skip_serializing_if = "Option::is_none"
1223    )]
1224    pub intended_replaces_order_id: Option<OrderId>,
1225
1226    /// The `rejectReason` field.
1227    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
1228    pub reject_reason: Option<TransactionRejectReason>,
1229}
1230
1231/// A StopLossOrderTransaction represents the creation of a StopLoss Order in
1232/// the user's Account.
1233#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1234#[non_exhaustive]
1235pub struct StopLossOrderTransaction {
1236    /// The Transaction's Identifier.
1237    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
1238    pub id: Option<TransactionId>,
1239
1240    /// The date/time when the Transaction was created.
1241    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
1242    pub time: Option<DateTime>,
1243
1244    /// The ID of the user that initiated the creation of the Transaction.
1245    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
1246    pub user_id: Option<i64>,
1247
1248    /// The ID of the Account the Transaction was created for.
1249    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
1250    pub account_id: Option<AccountId>,
1251
1252    /// The ID of the "batch" that the Transaction belongs to. Transactions in
1253    /// the same batch are applied to the Account simultaneously.
1254    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
1255    pub batch_id: Option<TransactionId>,
1256
1257    /// The Request ID of the request which generated the transaction.
1258    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
1259    pub request_id: Option<RequestId>,
1260
1261    // type is pinned to "STOP_LOSS_ORDER" by the enum wrapper
1262    /// The ID of the Trade to close when the price threshold is breached.
1263    #[serde(rename = "tradeID", skip_serializing_if = "Option::is_none")]
1264    pub trade_id: Option<TradeId>,
1265
1266    /// The client ID of the Trade to be closed when the price threshold is
1267    /// breached.
1268    #[serde(rename = "clientTradeID", skip_serializing_if = "Option::is_none")]
1269    pub client_trade_id: Option<String>,
1270
1271    /// The price threshold specified for the Stop Loss Order. If the guaranteed
1272    /// flag is false, the associated Trade will be closed by a market price
1273    /// that is equal to or worse than this threshold. If the flag is true the
1274    /// associated Trade will be closed at this price.
1275    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
1276    pub price: Option<PriceValue>,
1277
1278    /// Specifies the distance (in price units) from the Account's current price
1279    /// to use as the Stop Loss Order price. If the Trade is short the
1280    /// Instrument's bid price is used, and for long Trades the ask is used.
1281    #[serde(rename = "distance", skip_serializing_if = "Option::is_none")]
1282    pub distance: Option<DecimalNumber>,
1283
1284    /// The `timeInForce` field.
1285    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
1286    pub time_in_force: Option<StopLossOrderTimeInForce>,
1287
1288    /// The date/time when the StopLoss Order will be cancelled if its
1289    /// timeInForce is "GTD".
1290    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
1291    pub gtd_time: Option<DateTime>,
1292
1293    /// The `triggerCondition` field.
1294    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
1295    pub trigger_condition: Option<OrderTriggerCondition>,
1296
1297    /// Flag indicating that the Stop Loss Order is guaranteed. The default
1298    /// value depends on the GuaranteedStopLossOrderMode of the account, if it
1299    /// is REQUIRED, the default will be true, for DISABLED or ENABLED the
1300    /// default is false.
1301    #[serde(rename = "guaranteed", skip_serializing_if = "Option::is_none")]
1302    pub guaranteed: Option<bool>,
1303
1304    /// The fee that will be charged if the Stop Loss Order is guaranteed and
1305    /// the Order is filled at the guaranteed price. The value is determined at
1306    /// Order creation time. It is in price units and is charged for each unit
1307    /// of the Trade.
1308    #[serde(
1309        rename = "guaranteedExecutionPremium",
1310        skip_serializing_if = "Option::is_none"
1311    )]
1312    pub guaranteed_execution_premium: Option<DecimalNumber>,
1313
1314    /// The `reason` field.
1315    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
1316    pub reason: Option<StopLossOrderReason>,
1317
1318    /// The `clientExtensions` field.
1319    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
1320    pub client_extensions: Option<ClientExtensions>,
1321
1322    /// The ID of the OrderFill Transaction that caused this Order to be created
1323    /// (only provided if this Order was created automatically when another
1324    /// Order was filled).
1325    #[serde(
1326        rename = "orderFillTransactionID",
1327        skip_serializing_if = "Option::is_none"
1328    )]
1329    pub order_fill_transaction_id: Option<TransactionId>,
1330
1331    /// The ID of the Order that this Order replaces (only provided if this
1332    /// Order replaces an existing Order).
1333    #[serde(rename = "replacesOrderID", skip_serializing_if = "Option::is_none")]
1334    pub replaces_order_id: Option<OrderId>,
1335
1336    /// The ID of the Transaction that cancels the replaced Order (only provided
1337    /// if this Order replaces an existing Order).
1338    #[serde(
1339        rename = "cancellingTransactionID",
1340        skip_serializing_if = "Option::is_none"
1341    )]
1342    pub cancelling_transaction_id: Option<TransactionId>,
1343
1344    /// The price trigger mode of the Order. Observed value: "TOP_OF_BOOK". This
1345    /// field is returned by the live v20 API but is not present in OANDA's
1346    /// official documentation.
1347    #[serde(rename = "triggerMode", skip_serializing_if = "Option::is_none")]
1348    pub trigger_mode: Option<String>,
1349}
1350
1351/// A StopLossOrderRejectTransaction represents the rejection of the creation of
1352/// a StopLoss Order.
1353#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1354#[non_exhaustive]
1355pub struct StopLossOrderRejectTransaction {
1356    /// The Transaction's Identifier.
1357    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
1358    pub id: Option<TransactionId>,
1359
1360    /// The date/time when the Transaction was created.
1361    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
1362    pub time: Option<DateTime>,
1363
1364    /// The ID of the user that initiated the creation of the Transaction.
1365    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
1366    pub user_id: Option<i64>,
1367
1368    /// The ID of the Account the Transaction was created for.
1369    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
1370    pub account_id: Option<AccountId>,
1371
1372    /// The ID of the "batch" that the Transaction belongs to. Transactions in
1373    /// the same batch are applied to the Account simultaneously.
1374    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
1375    pub batch_id: Option<TransactionId>,
1376
1377    /// The Request ID of the request which generated the transaction.
1378    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
1379    pub request_id: Option<RequestId>,
1380
1381    // type is pinned to "STOP_LOSS_ORDER_REJECT" by the enum wrapper
1382    /// The ID of the Trade to close when the price threshold is breached.
1383    #[serde(rename = "tradeID", skip_serializing_if = "Option::is_none")]
1384    pub trade_id: Option<TradeId>,
1385
1386    /// The client ID of the Trade to be closed when the price threshold is
1387    /// breached.
1388    #[serde(rename = "clientTradeID", skip_serializing_if = "Option::is_none")]
1389    pub client_trade_id: Option<String>,
1390
1391    /// The price threshold specified for the Stop Loss Order. If the guaranteed
1392    /// flag is false, the associated Trade will be closed by a market price
1393    /// that is equal to or worse than this threshold. If the flag is true the
1394    /// associated Trade will be closed at this price.
1395    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
1396    pub price: Option<PriceValue>,
1397
1398    /// Specifies the distance (in price units) from the Account's current price
1399    /// to use as the Stop Loss Order price. If the Trade is short the
1400    /// Instrument's bid price is used, and for long Trades the ask is used.
1401    #[serde(rename = "distance", skip_serializing_if = "Option::is_none")]
1402    pub distance: Option<DecimalNumber>,
1403
1404    /// The `timeInForce` field.
1405    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
1406    pub time_in_force: Option<StopLossOrderTimeInForce>,
1407
1408    /// The date/time when the StopLoss Order will be cancelled if its
1409    /// timeInForce is "GTD".
1410    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
1411    pub gtd_time: Option<DateTime>,
1412
1413    /// The `triggerCondition` field.
1414    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
1415    pub trigger_condition: Option<OrderTriggerCondition>,
1416
1417    /// Flag indicating that the Stop Loss Order is guaranteed. The default
1418    /// value depends on the GuaranteedStopLossOrderMode of the account, if it
1419    /// is REQUIRED, the default will be true, for DISABLED or ENABLED the
1420    /// default is false.
1421    #[serde(rename = "guaranteed", skip_serializing_if = "Option::is_none")]
1422    pub guaranteed: Option<bool>,
1423
1424    /// The `reason` field.
1425    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
1426    pub reason: Option<StopLossOrderReason>,
1427
1428    /// The `clientExtensions` field.
1429    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
1430    pub client_extensions: Option<ClientExtensions>,
1431
1432    /// The ID of the OrderFill Transaction that caused this Order to be created
1433    /// (only provided if this Order was created automatically when another
1434    /// Order was filled).
1435    #[serde(
1436        rename = "orderFillTransactionID",
1437        skip_serializing_if = "Option::is_none"
1438    )]
1439    pub order_fill_transaction_id: Option<TransactionId>,
1440
1441    /// The ID of the Order that this Order was intended to replace (only
1442    /// provided if this Order was intended to replace an existing Order).
1443    #[serde(
1444        rename = "intendedReplacesOrderID",
1445        skip_serializing_if = "Option::is_none"
1446    )]
1447    pub intended_replaces_order_id: Option<OrderId>,
1448
1449    /// The `rejectReason` field.
1450    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
1451    pub reject_reason: Option<TransactionRejectReason>,
1452
1453    /// The price trigger mode of the Order. Observed value: "TOP_OF_BOOK". This
1454    /// field is returned by the live v20 API but is not present in OANDA's
1455    /// official documentation.
1456    #[serde(rename = "triggerMode", skip_serializing_if = "Option::is_none")]
1457    pub trigger_mode: Option<String>,
1458}
1459
1460/// A TrailingStopLossOrderTransaction represents the creation of a
1461/// TrailingStopLoss Order in the user's Account.
1462#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1463#[non_exhaustive]
1464pub struct TrailingStopLossOrderTransaction {
1465    /// The Transaction's Identifier.
1466    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
1467    pub id: Option<TransactionId>,
1468
1469    /// The date/time when the Transaction was created.
1470    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
1471    pub time: Option<DateTime>,
1472
1473    /// The ID of the user that initiated the creation of the Transaction.
1474    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
1475    pub user_id: Option<i64>,
1476
1477    /// The ID of the Account the Transaction was created for.
1478    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
1479    pub account_id: Option<AccountId>,
1480
1481    /// The ID of the "batch" that the Transaction belongs to. Transactions in
1482    /// the same batch are applied to the Account simultaneously.
1483    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
1484    pub batch_id: Option<TransactionId>,
1485
1486    /// The Request ID of the request which generated the transaction.
1487    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
1488    pub request_id: Option<RequestId>,
1489
1490    // type is pinned to "TRAILING_STOP_LOSS_ORDER" by the enum wrapper
1491    /// The ID of the Trade to close when the price threshold is breached.
1492    #[serde(rename = "tradeID", skip_serializing_if = "Option::is_none")]
1493    pub trade_id: Option<TradeId>,
1494
1495    /// The client ID of the Trade to be closed when the price threshold is
1496    /// breached.
1497    #[serde(rename = "clientTradeID", skip_serializing_if = "Option::is_none")]
1498    pub client_trade_id: Option<String>,
1499
1500    /// The price distance (in price units) specified for the TrailingStopLoss
1501    /// Order.
1502    #[serde(rename = "distance", skip_serializing_if = "Option::is_none")]
1503    pub distance: Option<DecimalNumber>,
1504
1505    /// The `timeInForce` field.
1506    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
1507    pub time_in_force: Option<TrailingStopLossOrderTimeInForce>,
1508
1509    /// The date/time when the StopLoss Order will be cancelled if its
1510    /// timeInForce is "GTD".
1511    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
1512    pub gtd_time: Option<DateTime>,
1513
1514    /// The `triggerCondition` field.
1515    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
1516    pub trigger_condition: Option<OrderTriggerCondition>,
1517
1518    /// The `reason` field.
1519    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
1520    pub reason: Option<TrailingStopLossOrderReason>,
1521
1522    /// The `clientExtensions` field.
1523    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
1524    pub client_extensions: Option<ClientExtensions>,
1525
1526    /// The ID of the OrderFill Transaction that caused this Order to be created
1527    /// (only provided if this Order was created automatically when another
1528    /// Order was filled).
1529    #[serde(
1530        rename = "orderFillTransactionID",
1531        skip_serializing_if = "Option::is_none"
1532    )]
1533    pub order_fill_transaction_id: Option<TransactionId>,
1534
1535    /// The ID of the Order that this Order replaces (only provided if this
1536    /// Order replaces an existing Order).
1537    #[serde(rename = "replacesOrderID", skip_serializing_if = "Option::is_none")]
1538    pub replaces_order_id: Option<OrderId>,
1539
1540    /// The ID of the Transaction that cancels the replaced Order (only provided
1541    /// if this Order replaces an existing Order).
1542    #[serde(
1543        rename = "cancellingTransactionID",
1544        skip_serializing_if = "Option::is_none"
1545    )]
1546    pub cancelling_transaction_id: Option<TransactionId>,
1547}
1548
1549/// A TrailingStopLossOrderRejectTransaction represents the rejection of the
1550/// creation of a TrailingStopLoss Order.
1551#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1552#[non_exhaustive]
1553pub struct TrailingStopLossOrderRejectTransaction {
1554    /// The Transaction's Identifier.
1555    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
1556    pub id: Option<TransactionId>,
1557
1558    /// The date/time when the Transaction was created.
1559    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
1560    pub time: Option<DateTime>,
1561
1562    /// The ID of the user that initiated the creation of the Transaction.
1563    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
1564    pub user_id: Option<i64>,
1565
1566    /// The ID of the Account the Transaction was created for.
1567    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
1568    pub account_id: Option<AccountId>,
1569
1570    /// The ID of the "batch" that the Transaction belongs to. Transactions in
1571    /// the same batch are applied to the Account simultaneously.
1572    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
1573    pub batch_id: Option<TransactionId>,
1574
1575    /// The Request ID of the request which generated the transaction.
1576    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
1577    pub request_id: Option<RequestId>,
1578
1579    // type is pinned to "TRAILING_STOP_LOSS_ORDER_REJECT" by the enum wrapper
1580    /// The ID of the Trade to close when the price threshold is breached.
1581    #[serde(rename = "tradeID", skip_serializing_if = "Option::is_none")]
1582    pub trade_id: Option<TradeId>,
1583
1584    /// The client ID of the Trade to be closed when the price threshold is
1585    /// breached.
1586    #[serde(rename = "clientTradeID", skip_serializing_if = "Option::is_none")]
1587    pub client_trade_id: Option<String>,
1588
1589    /// The price distance (in price units) specified for the TrailingStopLoss
1590    /// Order.
1591    #[serde(rename = "distance", skip_serializing_if = "Option::is_none")]
1592    pub distance: Option<DecimalNumber>,
1593
1594    /// The `timeInForce` field.
1595    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
1596    pub time_in_force: Option<TrailingStopLossOrderTimeInForce>,
1597
1598    /// The date/time when the StopLoss Order will be cancelled if its
1599    /// timeInForce is "GTD".
1600    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
1601    pub gtd_time: Option<DateTime>,
1602
1603    /// The `triggerCondition` field.
1604    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
1605    pub trigger_condition: Option<OrderTriggerCondition>,
1606
1607    /// The `reason` field.
1608    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
1609    pub reason: Option<TrailingStopLossOrderReason>,
1610
1611    /// The `clientExtensions` field.
1612    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
1613    pub client_extensions: Option<ClientExtensions>,
1614
1615    /// The ID of the OrderFill Transaction that caused this Order to be created
1616    /// (only provided if this Order was created automatically when another
1617    /// Order was filled).
1618    #[serde(
1619        rename = "orderFillTransactionID",
1620        skip_serializing_if = "Option::is_none"
1621    )]
1622    pub order_fill_transaction_id: Option<TransactionId>,
1623
1624    /// The ID of the Order that this Order was intended to replace (only
1625    /// provided if this Order was intended to replace an existing Order).
1626    #[serde(
1627        rename = "intendedReplacesOrderID",
1628        skip_serializing_if = "Option::is_none"
1629    )]
1630    pub intended_replaces_order_id: Option<OrderId>,
1631
1632    /// The `rejectReason` field.
1633    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
1634    pub reject_reason: Option<TransactionRejectReason>,
1635}
1636
1637string_enum! {
1638    /// The reason that the Market Order was created
1639    pub enum MarketOrderReason {
1640        ClientOrder => "CLIENT_ORDER",
1641        TradeClose => "TRADE_CLOSE",
1642        PositionCloseout => "POSITION_CLOSEOUT",
1643        MarginCloseout => "MARGIN_CLOSEOUT",
1644        DelayedTradeClose => "DELAYED_TRADE_CLOSE",
1645    }
1646}
1647
1648string_enum! {
1649    /// The reason that the Fixed Price Order was created
1650    pub enum FixedPriceOrderReason {
1651        PlatformAccountMigration => "PLATFORM_ACCOUNT_MIGRATION",
1652    }
1653}
1654
1655string_enum! {
1656    /// The reason that the Limit Order was initiated
1657    pub enum LimitOrderReason {
1658        ClientOrder => "CLIENT_ORDER",
1659        Replacement => "REPLACEMENT",
1660    }
1661}
1662
1663string_enum! {
1664    /// The reason that the Stop Order was initiated
1665    pub enum StopOrderReason {
1666        ClientOrder => "CLIENT_ORDER",
1667        Replacement => "REPLACEMENT",
1668    }
1669}
1670
1671string_enum! {
1672    /// The reason that the Market-if-touched Order was initiated
1673    pub enum MarketIfTouchedOrderReason {
1674        ClientOrder => "CLIENT_ORDER",
1675        Replacement => "REPLACEMENT",
1676    }
1677}
1678
1679string_enum! {
1680    /// The reason that the Take Profit Order was initiated
1681    pub enum TakeProfitOrderReason {
1682        ClientOrder => "CLIENT_ORDER",
1683        Replacement => "REPLACEMENT",
1684        OnFill => "ON_FILL",
1685    }
1686}
1687
1688string_enum! {
1689    /// The reason that the Stop Loss Order was initiated
1690    pub enum StopLossOrderReason {
1691        ClientOrder => "CLIENT_ORDER",
1692        Replacement => "REPLACEMENT",
1693        OnFill => "ON_FILL",
1694    }
1695}
1696
1697string_enum! {
1698    /// The reason that the Trailing Stop Loss Order was initiated
1699    pub enum TrailingStopLossOrderReason {
1700        ClientOrder => "CLIENT_ORDER",
1701        Replacement => "REPLACEMENT",
1702        OnFill => "ON_FILL",
1703    }
1704}