Skip to main content

oanda_client/models/
transaction.rs

1//! OANDA v20 transaction definitions.
2// Shared imports vary by definition family; unused ones are deliberately allowed.
3#[allow(unused_imports)]
4use super::*;
5#[allow(unused_imports)]
6use crate::ids::*;
7#[allow(unused_imports)]
8use crate::timestamp::Timestamp;
9#[allow(unused_imports)]
10use rust_decimal::Decimal;
11#[allow(unused_imports)]
12use serde::{Deserialize, Serialize};
13
14/// A CreateTransaction represents the creation of an Account.
15#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
16#[serde(rename_all = "camelCase")]
17pub struct CreateTransaction {
18    /// The Transaction’s Identifier.
19    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
20    pub id: Option<TransactionID>,
21    /// The date/time when the Transaction was created.
22    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
23    pub time: Option<Timestamp>,
24    /// The ID of the user that initiated the creation of the Transaction.
25    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
26    pub user_id: Option<i64>,
27    /// The ID of the Account the Transaction was created for.
28    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
29    pub account_id: Option<AccountID>,
30    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
31    /// Account simultaneously.
32    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
33    pub batch_id: Option<TransactionID>,
34    /// The Request ID of the request which generated the transaction.
35    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
36    pub request_id: Option<RequestID>,
37    /// The Type of the Transaction. Always set to “CREATE” in a CreateTransaction.
38    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
39    pub r#type: Option<TransactionType>,
40    /// The ID of the Division that the Account is in
41    #[serde(
42        rename = "divisionID",
43        default,
44        skip_serializing_if = "Option::is_none"
45    )]
46    pub division_id: Option<i64>,
47    /// The ID of the Site that the Account was created at
48    #[serde(rename = "siteID", default, skip_serializing_if = "Option::is_none")]
49    pub site_id: Option<i64>,
50    /// The ID of the user that the Account was created for
51    #[serde(
52        rename = "accountUserID",
53        default,
54        skip_serializing_if = "Option::is_none"
55    )]
56    pub account_user_id: Option<i64>,
57    /// The number of the Account within the site/division/user
58    #[serde(
59        rename = "accountNumber",
60        default,
61        skip_serializing_if = "Option::is_none"
62    )]
63    pub account_number: Option<i64>,
64    /// The home currency of the Account
65    #[serde(
66        rename = "homeCurrency",
67        default,
68        skip_serializing_if = "Option::is_none"
69    )]
70    pub home_currency: Option<Currency>,
71}
72
73/// A CloseTransaction represents the closing of an Account.
74#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
75#[serde(rename_all = "camelCase")]
76pub struct CloseTransaction {
77    /// The Transaction’s Identifier.
78    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
79    pub id: Option<TransactionID>,
80    /// The date/time when the Transaction was created.
81    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
82    pub time: Option<Timestamp>,
83    /// The ID of the user that initiated the creation of the Transaction.
84    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
85    pub user_id: Option<i64>,
86    /// The ID of the Account the Transaction was created for.
87    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
88    pub account_id: Option<AccountID>,
89    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
90    /// Account simultaneously.
91    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
92    pub batch_id: Option<TransactionID>,
93    /// The Request ID of the request which generated the transaction.
94    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
95    pub request_id: Option<RequestID>,
96    /// The Type of the Transaction. Always set to “CLOSE” in a CloseTransaction.
97    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
98    pub r#type: Option<TransactionType>,
99}
100
101/// A ReopenTransaction represents the re-opening of a closed Account.
102#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
103#[serde(rename_all = "camelCase")]
104pub struct ReopenTransaction {
105    /// The Transaction’s Identifier.
106    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
107    pub id: Option<TransactionID>,
108    /// The date/time when the Transaction was created.
109    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
110    pub time: Option<Timestamp>,
111    /// The ID of the user that initiated the creation of the Transaction.
112    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
113    pub user_id: Option<i64>,
114    /// The ID of the Account the Transaction was created for.
115    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
116    pub account_id: Option<AccountID>,
117    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
118    /// Account simultaneously.
119    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
120    pub batch_id: Option<TransactionID>,
121    /// The Request ID of the request which generated the transaction.
122    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
123    pub request_id: Option<RequestID>,
124    /// The Type of the Transaction. Always set to “REOPEN” in a ReopenTransaction.
125    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
126    pub r#type: Option<TransactionType>,
127}
128
129/// A ClientConfigureTransaction represents the configuration of an Account by a client.
130#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
131#[serde(rename_all = "camelCase")]
132pub struct ClientConfigureTransaction {
133    /// The Transaction’s Identifier.
134    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
135    pub id: Option<TransactionID>,
136    /// The date/time when the Transaction was created.
137    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
138    pub time: Option<Timestamp>,
139    /// The ID of the user that initiated the creation of the Transaction.
140    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
141    pub user_id: Option<i64>,
142    /// The ID of the Account the Transaction was created for.
143    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
144    pub account_id: Option<AccountID>,
145    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
146    /// Account simultaneously.
147    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
148    pub batch_id: Option<TransactionID>,
149    /// The Request ID of the request which generated the transaction.
150    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
151    pub request_id: Option<RequestID>,
152    /// The Type of the Transaction. Always set to “CLIENT_CONFIGURE” in a ClientConfigureTransaction.
153    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
154    pub r#type: Option<TransactionType>,
155    /// The client-provided alias for the Account.
156    #[serde(rename = "alias", default, skip_serializing_if = "Option::is_none")]
157    pub alias: Option<String>,
158    /// The margin rate override for the Account.
159    #[serde(
160        rename = "marginRate",
161        default,
162        skip_serializing_if = "Option::is_none"
163    )]
164    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
165    pub margin_rate: Option<Decimal>,
166}
167
168/// A ClientConfigureRejectTransaction represents the rejection of configuration of an Account by a client.
169#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
170#[serde(rename_all = "camelCase")]
171pub struct ClientConfigureRejectTransaction {
172    /// The Transaction’s Identifier.
173    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
174    pub id: Option<TransactionID>,
175    /// The date/time when the Transaction was created.
176    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
177    pub time: Option<Timestamp>,
178    /// The ID of the user that initiated the creation of the Transaction.
179    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
180    pub user_id: Option<i64>,
181    /// The ID of the Account the Transaction was created for.
182    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
183    pub account_id: Option<AccountID>,
184    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
185    /// Account simultaneously.
186    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
187    pub batch_id: Option<TransactionID>,
188    /// The Request ID of the request which generated the transaction.
189    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
190    pub request_id: Option<RequestID>,
191    /// The Type of the Transaction. Always set to “CLIENT_CONFIGURE_REJECT” in a
192    /// ClientConfigureRejectTransaction.
193    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
194    pub r#type: Option<TransactionType>,
195    /// The client-provided alias for the Account.
196    #[serde(rename = "alias", default, skip_serializing_if = "Option::is_none")]
197    pub alias: Option<String>,
198    /// The margin rate override for the Account.
199    #[serde(
200        rename = "marginRate",
201        default,
202        skip_serializing_if = "Option::is_none"
203    )]
204    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
205    pub margin_rate: Option<Decimal>,
206    /// The reason that the Reject Transaction was created
207    #[serde(
208        rename = "rejectReason",
209        default,
210        skip_serializing_if = "Option::is_none"
211    )]
212    pub reject_reason: Option<TransactionRejectReason>,
213}
214
215/// A TransferFundsTransaction represents the transfer of funds in/out of an Account.
216#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
217#[serde(rename_all = "camelCase")]
218pub struct TransferFundsTransaction {
219    /// The Transaction’s Identifier.
220    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
221    pub id: Option<TransactionID>,
222    /// The date/time when the Transaction was created.
223    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
224    pub time: Option<Timestamp>,
225    /// The ID of the user that initiated the creation of the Transaction.
226    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
227    pub user_id: Option<i64>,
228    /// The ID of the Account the Transaction was created for.
229    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
230    pub account_id: Option<AccountID>,
231    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
232    /// Account simultaneously.
233    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
234    pub batch_id: Option<TransactionID>,
235    /// The Request ID of the request which generated the transaction.
236    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
237    pub request_id: Option<RequestID>,
238    /// The Type of the Transaction. Always set to “TRANSFER_FUNDS” in a TransferFundsTransaction.
239    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
240    pub r#type: Option<TransactionType>,
241    /// The amount to deposit/withdraw from the Account in the Account’s home currency. A positive value
242    /// indicates a deposit, a negative value indicates a withdrawal.
243    #[serde(rename = "amount", default, skip_serializing_if = "Option::is_none")]
244    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
245    pub amount: Option<Decimal>,
246    /// The reason that an Account is being funded.
247    #[serde(
248        rename = "fundingReason",
249        default,
250        skip_serializing_if = "Option::is_none"
251    )]
252    pub funding_reason: Option<FundingReason>,
253    /// An optional comment that may be attached to a fund transfer for audit purposes
254    #[serde(rename = "comment", default, skip_serializing_if = "Option::is_none")]
255    pub comment: Option<String>,
256    /// The Account’s balance after funds are transferred.
257    #[serde(
258        rename = "accountBalance",
259        default,
260        skip_serializing_if = "Option::is_none"
261    )]
262    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
263    pub account_balance: Option<Decimal>,
264}
265
266/// A TransferFundsRejectTransaction represents the rejection of the transfer of funds in/out of an Account.
267#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
268#[serde(rename_all = "camelCase")]
269pub struct TransferFundsRejectTransaction {
270    /// The Transaction’s Identifier.
271    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
272    pub id: Option<TransactionID>,
273    /// The date/time when the Transaction was created.
274    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
275    pub time: Option<Timestamp>,
276    /// The ID of the user that initiated the creation of the Transaction.
277    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
278    pub user_id: Option<i64>,
279    /// The ID of the Account the Transaction was created for.
280    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
281    pub account_id: Option<AccountID>,
282    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
283    /// Account simultaneously.
284    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
285    pub batch_id: Option<TransactionID>,
286    /// The Request ID of the request which generated the transaction.
287    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
288    pub request_id: Option<RequestID>,
289    /// The Type of the Transaction. Always set to “TRANSFER_FUNDS_REJECT” in a TransferFundsRejectTransaction.
290    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
291    pub r#type: Option<TransactionType>,
292    /// The amount to deposit/withdraw from the Account in the Account’s home currency. A positive value
293    /// indicates a deposit, a negative value indicates a withdrawal.
294    #[serde(rename = "amount", default, skip_serializing_if = "Option::is_none")]
295    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
296    pub amount: Option<Decimal>,
297    /// The reason that an Account is being funded.
298    #[serde(
299        rename = "fundingReason",
300        default,
301        skip_serializing_if = "Option::is_none"
302    )]
303    pub funding_reason: Option<FundingReason>,
304    /// An optional comment that may be attached to a fund transfer for audit purposes
305    #[serde(rename = "comment", default, skip_serializing_if = "Option::is_none")]
306    pub comment: Option<String>,
307    /// The reason that the Reject Transaction was created
308    #[serde(
309        rename = "rejectReason",
310        default,
311        skip_serializing_if = "Option::is_none"
312    )]
313    pub reject_reason: Option<TransactionRejectReason>,
314}
315
316/// A MarketOrderTransaction represents the creation of a Market Order in the user’s account. A Market Order
317/// is an Order that is filled immediately at the current market price. Market Orders can be specialized
318/// when they are created to accomplish a specific task: to close a Trade, to closeout a Position or to
319/// participate in a Margin closeout.
320#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
321#[serde(rename_all = "camelCase")]
322pub struct MarketOrderTransaction {
323    /// The Transaction’s Identifier.
324    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
325    pub id: Option<TransactionID>,
326    /// The date/time when the Transaction was created.
327    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
328    pub time: Option<Timestamp>,
329    /// The ID of the user that initiated the creation of the Transaction.
330    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
331    pub user_id: Option<i64>,
332    /// The ID of the Account the Transaction was created for.
333    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
334    pub account_id: Option<AccountID>,
335    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
336    /// Account simultaneously.
337    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
338    pub batch_id: Option<TransactionID>,
339    /// The Request ID of the request which generated the transaction.
340    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
341    pub request_id: Option<RequestID>,
342    /// The Type of the Transaction. Always set to “MARKET_ORDER” in a MarketOrderTransaction.
343    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
344    pub r#type: Option<TransactionType>,
345    /// The Market Order’s Instrument.
346    #[serde(rename = "instrument")]
347    pub instrument: InstrumentName,
348    /// The quantity requested to be filled by the Market Order. A positive number of units results in a long
349    /// Order, and a negative number of units results in a short Order.
350    #[serde(rename = "units")]
351    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
352    pub units: Decimal,
353    /// The time-in-force requested for the Market Order. Restricted to FOK or IOC for a MarketOrder.
354    #[serde(rename = "timeInForce")]
355    pub time_in_force: TimeInForce,
356    /// The worst price that the client is willing to have the Market Order filled at.
357    #[serde(
358        rename = "priceBound",
359        default,
360        skip_serializing_if = "Option::is_none"
361    )]
362    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
363    pub price_bound: Option<Decimal>,
364    /// Specification of how Positions in the Account are modified when the Order is filled.
365    #[serde(rename = "positionFill")]
366    pub position_fill: OrderPositionFill,
367    /// Details of the Trade requested to be closed, only provided when the Market Order is being used to
368    /// explicitly close a Trade.
369    #[serde(
370        rename = "tradeClose",
371        default,
372        skip_serializing_if = "Option::is_none"
373    )]
374    pub trade_close: Option<MarketOrderTradeClose>,
375    /// Details of the long Position requested to be closed out, only provided when a Market Order is being used
376    /// to explicitly closeout a long Position.
377    #[serde(
378        rename = "longPositionCloseout",
379        default,
380        skip_serializing_if = "Option::is_none"
381    )]
382    pub long_position_closeout: Option<MarketOrderPositionCloseout>,
383    /// Details of the short Position requested to be closed out, only provided when a Market Order is being
384    /// used to explicitly closeout a short Position.
385    #[serde(
386        rename = "shortPositionCloseout",
387        default,
388        skip_serializing_if = "Option::is_none"
389    )]
390    pub short_position_closeout: Option<MarketOrderPositionCloseout>,
391    /// Details of the Margin Closeout that this Market Order was created for
392    #[serde(
393        rename = "marginCloseout",
394        default,
395        skip_serializing_if = "Option::is_none"
396    )]
397    pub margin_closeout: Option<MarketOrderMarginCloseout>,
398    /// Details of the delayed Trade close that this Market Order was created for
399    #[serde(
400        rename = "delayedTradeClose",
401        default,
402        skip_serializing_if = "Option::is_none"
403    )]
404    pub delayed_trade_close: Option<MarketOrderDelayedTradeClose>,
405    /// The reason that the Market Order was created
406    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
407    pub reason: Option<MarketOrderReason>,
408    /// Client Extensions to add to the Order (only provided if the Order is being created with client
409    /// extensions).
410    #[serde(
411        rename = "clientExtensions",
412        default,
413        skip_serializing_if = "Option::is_none"
414    )]
415    pub client_extensions: Option<ClientExtensions>,
416    /// The specification of the Take Profit Order that should be created for a Trade opened when the Order is
417    /// filled (if such a Trade is created).
418    #[serde(
419        rename = "takeProfitOnFill",
420        default,
421        skip_serializing_if = "Option::is_none"
422    )]
423    pub take_profit_on_fill: Option<TakeProfitDetails>,
424    /// The specification of the Stop Loss Order that should be created for a Trade opened when the Order is
425    /// filled (if such a Trade is created).
426    #[serde(
427        rename = "stopLossOnFill",
428        default,
429        skip_serializing_if = "Option::is_none"
430    )]
431    pub stop_loss_on_fill: Option<StopLossDetails>,
432    /// The specification of the Trailing Stop Loss Order that should be created for a Trade that is opened when
433    /// the Order is filled (if such a Trade is created).
434    #[serde(
435        rename = "trailingStopLossOnFill",
436        default,
437        skip_serializing_if = "Option::is_none"
438    )]
439    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
440    /// The specification of the Guaranteed Stop Loss Order that should be created for a Trade that is opened
441    /// when the Order is filled (if such a Trade is created).
442    #[serde(
443        rename = "guaranteedStopLossOnFill",
444        default,
445        skip_serializing_if = "Option::is_none"
446    )]
447    pub guaranteed_stop_loss_on_fill: Option<GuaranteedStopLossDetails>,
448    /// Client Extensions to add to the Trade created when the Order is filled (if such a Trade is created). Do
449    /// not set, modify, delete tradeClientExtensions if your account is associated with MT4.
450    #[serde(
451        rename = "tradeClientExtensions",
452        default,
453        skip_serializing_if = "Option::is_none"
454    )]
455    pub trade_client_extensions: Option<ClientExtensions>,
456}
457
458/// A MarketOrderRejectTransaction represents the rejection of the creation of a Market Order.
459#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
460#[serde(rename_all = "camelCase")]
461pub struct MarketOrderRejectTransaction {
462    /// The Transaction’s Identifier.
463    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
464    pub id: Option<TransactionID>,
465    /// The date/time when the Transaction was created.
466    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
467    pub time: Option<Timestamp>,
468    /// The ID of the user that initiated the creation of the Transaction.
469    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
470    pub user_id: Option<i64>,
471    /// The ID of the Account the Transaction was created for.
472    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
473    pub account_id: Option<AccountID>,
474    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
475    /// Account simultaneously.
476    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
477    pub batch_id: Option<TransactionID>,
478    /// The Request ID of the request which generated the transaction.
479    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
480    pub request_id: Option<RequestID>,
481    /// The Type of the Transaction. Always set to “MARKET_ORDER_REJECT” in a MarketOrderRejectTransaction.
482    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
483    pub r#type: Option<TransactionType>,
484    /// The Market Order’s Instrument.
485    #[serde(rename = "instrument")]
486    pub instrument: InstrumentName,
487    /// The quantity requested to be filled by the Market Order. A positive number of units results in a long
488    /// Order, and a negative number of units results in a short Order.
489    #[serde(rename = "units")]
490    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
491    pub units: Decimal,
492    /// The time-in-force requested for the Market Order. Restricted to FOK or IOC for a MarketOrder.
493    #[serde(rename = "timeInForce")]
494    pub time_in_force: TimeInForce,
495    /// The worst price that the client is willing to have the Market Order filled at.
496    #[serde(
497        rename = "priceBound",
498        default,
499        skip_serializing_if = "Option::is_none"
500    )]
501    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
502    pub price_bound: Option<Decimal>,
503    /// Specification of how Positions in the Account are modified when the Order is filled.
504    #[serde(rename = "positionFill")]
505    pub position_fill: OrderPositionFill,
506    /// Details of the Trade requested to be closed, only provided when the Market Order is being used to
507    /// explicitly close a Trade.
508    #[serde(
509        rename = "tradeClose",
510        default,
511        skip_serializing_if = "Option::is_none"
512    )]
513    pub trade_close: Option<MarketOrderTradeClose>,
514    /// Details of the long Position requested to be closed out, only provided when a Market Order is being used
515    /// to explicitly closeout a long Position.
516    #[serde(
517        rename = "longPositionCloseout",
518        default,
519        skip_serializing_if = "Option::is_none"
520    )]
521    pub long_position_closeout: Option<MarketOrderPositionCloseout>,
522    /// Details of the short Position requested to be closed out, only provided when a Market Order is being
523    /// used to explicitly closeout a short Position.
524    #[serde(
525        rename = "shortPositionCloseout",
526        default,
527        skip_serializing_if = "Option::is_none"
528    )]
529    pub short_position_closeout: Option<MarketOrderPositionCloseout>,
530    /// Details of the Margin Closeout that this Market Order was created for
531    #[serde(
532        rename = "marginCloseout",
533        default,
534        skip_serializing_if = "Option::is_none"
535    )]
536    pub margin_closeout: Option<MarketOrderMarginCloseout>,
537    /// Details of the delayed Trade close that this Market Order was created for
538    #[serde(
539        rename = "delayedTradeClose",
540        default,
541        skip_serializing_if = "Option::is_none"
542    )]
543    pub delayed_trade_close: Option<MarketOrderDelayedTradeClose>,
544    /// The reason that the Market Order was created
545    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
546    pub reason: Option<MarketOrderReason>,
547    /// Client Extensions to add to the Order (only provided if the Order is being created with client
548    /// extensions).
549    #[serde(
550        rename = "clientExtensions",
551        default,
552        skip_serializing_if = "Option::is_none"
553    )]
554    pub client_extensions: Option<ClientExtensions>,
555    /// The specification of the Take Profit Order that should be created for a Trade opened when the Order is
556    /// filled (if such a Trade is created).
557    #[serde(
558        rename = "takeProfitOnFill",
559        default,
560        skip_serializing_if = "Option::is_none"
561    )]
562    pub take_profit_on_fill: Option<TakeProfitDetails>,
563    /// The specification of the Stop Loss Order that should be created for a Trade opened when the Order is
564    /// filled (if such a Trade is created).
565    #[serde(
566        rename = "stopLossOnFill",
567        default,
568        skip_serializing_if = "Option::is_none"
569    )]
570    pub stop_loss_on_fill: Option<StopLossDetails>,
571    /// The specification of the Trailing Stop Loss Order that should be created for a Trade that is opened when
572    /// the Order is filled (if such a Trade is created).
573    #[serde(
574        rename = "trailingStopLossOnFill",
575        default,
576        skip_serializing_if = "Option::is_none"
577    )]
578    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
579    /// The specification of the Guaranteed Stop Loss Order that should be created for a Trade that is opened
580    /// when the Order is filled (if such a Trade is created).
581    #[serde(
582        rename = "guaranteedStopLossOnFill",
583        default,
584        skip_serializing_if = "Option::is_none"
585    )]
586    pub guaranteed_stop_loss_on_fill: Option<GuaranteedStopLossDetails>,
587    /// Client Extensions to add to the Trade created when the Order is filled (if such a Trade is created). Do
588    /// not set, modify, delete tradeClientExtensions if your account is associated with MT4.
589    #[serde(
590        rename = "tradeClientExtensions",
591        default,
592        skip_serializing_if = "Option::is_none"
593    )]
594    pub trade_client_extensions: Option<ClientExtensions>,
595    /// The reason that the Reject Transaction was created
596    #[serde(
597        rename = "rejectReason",
598        default,
599        skip_serializing_if = "Option::is_none"
600    )]
601    pub reject_reason: Option<TransactionRejectReason>,
602}
603
604/// A FixedPriceOrderTransaction represents the creation of a Fixed Price Order in the user’s account. A
605/// Fixed Price Order is an Order that is filled immediately at a specified price.
606#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
607#[serde(rename_all = "camelCase")]
608pub struct FixedPriceOrderTransaction {
609    /// The Transaction’s Identifier.
610    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
611    pub id: Option<TransactionID>,
612    /// The date/time when the Transaction was created.
613    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
614    pub time: Option<Timestamp>,
615    /// The ID of the user that initiated the creation of the Transaction.
616    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
617    pub user_id: Option<i64>,
618    /// The ID of the Account the Transaction was created for.
619    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
620    pub account_id: Option<AccountID>,
621    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
622    /// Account simultaneously.
623    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
624    pub batch_id: Option<TransactionID>,
625    /// The Request ID of the request which generated the transaction.
626    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
627    pub request_id: Option<RequestID>,
628    /// The Type of the Transaction. Always set to “FIXED_PRICE_ORDER” in a FixedPriceOrderTransaction.
629    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
630    pub r#type: Option<TransactionType>,
631    /// The Fixed Price Order’s Instrument.
632    #[serde(rename = "instrument")]
633    pub instrument: InstrumentName,
634    /// The quantity requested to be filled by the Fixed Price Order. A positive number of units results in a
635    /// long Order, and a negative number of units results in a short Order.
636    #[serde(rename = "units")]
637    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
638    pub units: Decimal,
639    /// The price specified for the Fixed Price Order. This price is the exact price that the Fixed Price Order
640    /// will be filled at.
641    #[serde(rename = "price")]
642    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
643    pub price: Decimal,
644    /// Specification of how Positions in the Account are modified when the Order is filled.
645    #[serde(rename = "positionFill")]
646    pub position_fill: OrderPositionFill,
647    /// The state that the trade resulting from the Fixed Price Order should be set to.
648    #[serde(rename = "tradeState")]
649    pub trade_state: String,
650    /// The reason that the Fixed Price Order was created
651    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
652    pub reason: Option<FixedPriceOrderReason>,
653    /// The client extensions for the Fixed Price Order.
654    #[serde(
655        rename = "clientExtensions",
656        default,
657        skip_serializing_if = "Option::is_none"
658    )]
659    pub client_extensions: Option<ClientExtensions>,
660    /// The specification of the Take Profit Order that should be created for a Trade opened when the Order is
661    /// filled (if such a Trade is created).
662    #[serde(
663        rename = "takeProfitOnFill",
664        default,
665        skip_serializing_if = "Option::is_none"
666    )]
667    pub take_profit_on_fill: Option<TakeProfitDetails>,
668    /// The specification of the Stop Loss Order that should be created for a Trade opened when the Order is
669    /// filled (if such a Trade is created).
670    #[serde(
671        rename = "stopLossOnFill",
672        default,
673        skip_serializing_if = "Option::is_none"
674    )]
675    pub stop_loss_on_fill: Option<StopLossDetails>,
676    /// The specification of the Trailing Stop Loss Order that should be created for a Trade that is opened when
677    /// the Order is filled (if such a Trade is created).
678    #[serde(
679        rename = "trailingStopLossOnFill",
680        default,
681        skip_serializing_if = "Option::is_none"
682    )]
683    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
684    /// The specification of the Guaranteed Stop Loss Order that should be created for a Trade that is opened
685    /// when the Order is filled (if such a Trade is created).
686    #[serde(
687        rename = "guaranteedStopLossOnFill",
688        default,
689        skip_serializing_if = "Option::is_none"
690    )]
691    pub guaranteed_stop_loss_on_fill: Option<GuaranteedStopLossDetails>,
692    /// Client Extensions to add to the Trade created when the Order is filled (if such a Trade is created). Do
693    /// not set, modify, delete tradeClientExtensions if your account is associated with MT4.
694    #[serde(
695        rename = "tradeClientExtensions",
696        default,
697        skip_serializing_if = "Option::is_none"
698    )]
699    pub trade_client_extensions: Option<ClientExtensions>,
700}
701
702/// A LimitOrderTransaction represents the creation of a Limit Order in the user’s Account.
703#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
704#[serde(rename_all = "camelCase")]
705pub struct LimitOrderTransaction {
706    /// The Transaction’s Identifier.
707    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
708    pub id: Option<TransactionID>,
709    /// The date/time when the Transaction was created.
710    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
711    pub time: Option<Timestamp>,
712    /// The ID of the user that initiated the creation of the Transaction.
713    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
714    pub user_id: Option<i64>,
715    /// The ID of the Account the Transaction was created for.
716    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
717    pub account_id: Option<AccountID>,
718    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
719    /// Account simultaneously.
720    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
721    pub batch_id: Option<TransactionID>,
722    /// The Request ID of the request which generated the transaction.
723    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
724    pub request_id: Option<RequestID>,
725    /// The Type of the Transaction. Always set to “LIMIT_ORDER” in a LimitOrderTransaction.
726    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
727    pub r#type: Option<TransactionType>,
728    /// The Limit Order’s Instrument.
729    #[serde(rename = "instrument")]
730    pub instrument: InstrumentName,
731    /// The quantity requested to be filled by the Limit Order. A positive number of units results in a long
732    /// Order, and a negative number of units results in a short Order.
733    #[serde(rename = "units")]
734    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
735    pub units: Decimal,
736    /// The price threshold specified for the Limit Order. The Limit Order will only be filled by a market price
737    /// that is equal to or better than this price.
738    #[serde(rename = "price")]
739    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
740    pub price: Decimal,
741    /// The time-in-force requested for the Limit Order.
742    #[serde(rename = "timeInForce")]
743    pub time_in_force: TimeInForce,
744    /// The date/time when the Limit Order will be cancelled if its timeInForce is “GTD”.
745    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
746    pub gtd_time: Option<Timestamp>,
747    /// Specification of how Positions in the Account are modified when the Order is filled.
748    #[serde(rename = "positionFill")]
749    pub position_fill: OrderPositionFill,
750    /// Specification of which price component should be used when determining if an Order should be triggered
751    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
752    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
753    /// filled using their default price component. This feature is only provided through the REST API. Clients
754    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
755    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
756    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
757    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
758    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
759    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
760    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
761    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
762    #[serde(rename = "triggerCondition")]
763    pub trigger_condition: OrderTriggerCondition,
764    /// The reason that the Limit Order was initiated
765    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
766    pub reason: Option<LimitOrderReason>,
767    /// Client Extensions to add to the Order (only provided if the Order is being created with client
768    /// extensions).
769    #[serde(
770        rename = "clientExtensions",
771        default,
772        skip_serializing_if = "Option::is_none"
773    )]
774    pub client_extensions: Option<ClientExtensions>,
775    /// The specification of the Take Profit Order that should be created for a Trade opened when the Order is
776    /// filled (if such a Trade is created).
777    #[serde(
778        rename = "takeProfitOnFill",
779        default,
780        skip_serializing_if = "Option::is_none"
781    )]
782    pub take_profit_on_fill: Option<TakeProfitDetails>,
783    /// The specification of the Stop Loss Order that should be created for a Trade opened when the Order is
784    /// filled (if such a Trade is created).
785    #[serde(
786        rename = "stopLossOnFill",
787        default,
788        skip_serializing_if = "Option::is_none"
789    )]
790    pub stop_loss_on_fill: Option<StopLossDetails>,
791    /// The specification of the Trailing Stop Loss Order that should be created for a Trade that is opened when
792    /// the Order is filled (if such a Trade is created).
793    #[serde(
794        rename = "trailingStopLossOnFill",
795        default,
796        skip_serializing_if = "Option::is_none"
797    )]
798    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
799    /// The specification of the Guaranteed Stop Loss Order that should be created for a Trade that is opened
800    /// when the Order is filled (if such a Trade is created).
801    #[serde(
802        rename = "guaranteedStopLossOnFill",
803        default,
804        skip_serializing_if = "Option::is_none"
805    )]
806    pub guaranteed_stop_loss_on_fill: Option<GuaranteedStopLossDetails>,
807    /// Client Extensions to add to the Trade created when the Order is filled (if such a Trade is created). Do
808    /// not set, modify, delete tradeClientExtensions if your account is associated with MT4.
809    #[serde(
810        rename = "tradeClientExtensions",
811        default,
812        skip_serializing_if = "Option::is_none"
813    )]
814    pub trade_client_extensions: Option<ClientExtensions>,
815    /// The ID of the Order that this Order replaces (only provided if this Order replaces an existing Order).
816    #[serde(
817        rename = "replacesOrderID",
818        default,
819        skip_serializing_if = "Option::is_none"
820    )]
821    pub replaces_order_id: Option<OrderID>,
822    /// The ID of the Transaction that cancels the replaced Order (only provided if this Order replaces an
823    /// existing Order).
824    #[serde(
825        rename = "cancellingTransactionID",
826        default,
827        skip_serializing_if = "Option::is_none"
828    )]
829    pub cancelling_transaction_id: Option<TransactionID>,
830}
831
832/// A LimitOrderRejectTransaction represents the rejection of the creation of a Limit Order.
833#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
834#[serde(rename_all = "camelCase")]
835pub struct LimitOrderRejectTransaction {
836    /// The Transaction’s Identifier.
837    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
838    pub id: Option<TransactionID>,
839    /// The date/time when the Transaction was created.
840    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
841    pub time: Option<Timestamp>,
842    /// The ID of the user that initiated the creation of the Transaction.
843    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
844    pub user_id: Option<i64>,
845    /// The ID of the Account the Transaction was created for.
846    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
847    pub account_id: Option<AccountID>,
848    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
849    /// Account simultaneously.
850    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
851    pub batch_id: Option<TransactionID>,
852    /// The Request ID of the request which generated the transaction.
853    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
854    pub request_id: Option<RequestID>,
855    /// The Type of the Transaction. Always set to “LIMIT_ORDER_REJECT” in a LimitOrderRejectTransaction.
856    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
857    pub r#type: Option<TransactionType>,
858    /// The Limit Order’s Instrument.
859    #[serde(rename = "instrument")]
860    pub instrument: InstrumentName,
861    /// The quantity requested to be filled by the Limit Order. A positive number of units results in a long
862    /// Order, and a negative number of units results in a short Order.
863    #[serde(rename = "units")]
864    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
865    pub units: Decimal,
866    /// The price threshold specified for the Limit Order. The Limit Order will only be filled by a market price
867    /// that is equal to or better than this price.
868    #[serde(rename = "price")]
869    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
870    pub price: Decimal,
871    /// The time-in-force requested for the Limit Order.
872    #[serde(rename = "timeInForce")]
873    pub time_in_force: TimeInForce,
874    /// The date/time when the Limit Order will be cancelled if its timeInForce is “GTD”.
875    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
876    pub gtd_time: Option<Timestamp>,
877    /// Specification of how Positions in the Account are modified when the Order is filled.
878    #[serde(rename = "positionFill")]
879    pub position_fill: OrderPositionFill,
880    /// Specification of which price component should be used when determining if an Order should be triggered
881    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
882    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
883    /// filled using their default price component. This feature is only provided through the REST API. Clients
884    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
885    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
886    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
887    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
888    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
889    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
890    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
891    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
892    #[serde(rename = "triggerCondition")]
893    pub trigger_condition: OrderTriggerCondition,
894    /// The reason that the Limit Order was initiated
895    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
896    pub reason: Option<LimitOrderReason>,
897    /// Client Extensions to add to the Order (only provided if the Order is being created with client
898    /// extensions).
899    #[serde(
900        rename = "clientExtensions",
901        default,
902        skip_serializing_if = "Option::is_none"
903    )]
904    pub client_extensions: Option<ClientExtensions>,
905    /// The specification of the Take Profit Order that should be created for a Trade opened when the Order is
906    /// filled (if such a Trade is created).
907    #[serde(
908        rename = "takeProfitOnFill",
909        default,
910        skip_serializing_if = "Option::is_none"
911    )]
912    pub take_profit_on_fill: Option<TakeProfitDetails>,
913    /// The specification of the Stop Loss Order that should be created for a Trade opened when the Order is
914    /// filled (if such a Trade is created).
915    #[serde(
916        rename = "stopLossOnFill",
917        default,
918        skip_serializing_if = "Option::is_none"
919    )]
920    pub stop_loss_on_fill: Option<StopLossDetails>,
921    /// The specification of the Trailing Stop Loss Order that should be created for a Trade that is opened when
922    /// the Order is filled (if such a Trade is created).
923    #[serde(
924        rename = "trailingStopLossOnFill",
925        default,
926        skip_serializing_if = "Option::is_none"
927    )]
928    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
929    /// The specification of the Guaranteed Stop Loss Order that should be created for a Trade that is opened
930    /// when the Order is filled (if such a Trade is created).
931    #[serde(
932        rename = "guaranteedStopLossOnFill",
933        default,
934        skip_serializing_if = "Option::is_none"
935    )]
936    pub guaranteed_stop_loss_on_fill: Option<GuaranteedStopLossDetails>,
937    /// Client Extensions to add to the Trade created when the Order is filled (if such a Trade is created). Do
938    /// not set, modify, delete tradeClientExtensions if your account is associated with MT4.
939    #[serde(
940        rename = "tradeClientExtensions",
941        default,
942        skip_serializing_if = "Option::is_none"
943    )]
944    pub trade_client_extensions: Option<ClientExtensions>,
945    /// The ID of the Order that this Order was intended to replace (only provided if this Order was intended to
946    /// replace an existing Order).
947    #[serde(
948        rename = "intendedReplacesOrderID",
949        default,
950        skip_serializing_if = "Option::is_none"
951    )]
952    pub intended_replaces_order_id: Option<OrderID>,
953    /// The reason that the Reject Transaction was created
954    #[serde(
955        rename = "rejectReason",
956        default,
957        skip_serializing_if = "Option::is_none"
958    )]
959    pub reject_reason: Option<TransactionRejectReason>,
960}
961
962/// A StopOrderTransaction represents the creation of a Stop Order in the user’s Account.
963#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
964#[serde(rename_all = "camelCase")]
965pub struct StopOrderTransaction {
966    /// The Transaction’s Identifier.
967    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
968    pub id: Option<TransactionID>,
969    /// The date/time when the Transaction was created.
970    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
971    pub time: Option<Timestamp>,
972    /// The ID of the user that initiated the creation of the Transaction.
973    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
974    pub user_id: Option<i64>,
975    /// The ID of the Account the Transaction was created for.
976    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
977    pub account_id: Option<AccountID>,
978    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
979    /// Account simultaneously.
980    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
981    pub batch_id: Option<TransactionID>,
982    /// The Request ID of the request which generated the transaction.
983    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
984    pub request_id: Option<RequestID>,
985    /// The Type of the Transaction. Always set to “STOP_ORDER” in a StopOrderTransaction.
986    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
987    pub r#type: Option<TransactionType>,
988    /// The Stop Order’s Instrument.
989    #[serde(rename = "instrument")]
990    pub instrument: InstrumentName,
991    /// The quantity requested to be filled by the Stop Order. A positive number of units results in a long
992    /// Order, and a negative number of units results in a short Order.
993    #[serde(rename = "units")]
994    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
995    pub units: Decimal,
996    /// The price threshold specified for the Stop Order. The Stop Order will only be filled by a market price
997    /// that is equal to or worse than this price.
998    #[serde(rename = "price")]
999    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1000    pub price: Decimal,
1001    /// The worst market price that may be used to fill this Stop Order. If the market gaps and crosses through
1002    /// both the price and the priceBound, the Stop Order will be cancelled instead of being filled.
1003    #[serde(
1004        rename = "priceBound",
1005        default,
1006        skip_serializing_if = "Option::is_none"
1007    )]
1008    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1009    pub price_bound: Option<Decimal>,
1010    /// The time-in-force requested for the Stop Order.
1011    #[serde(rename = "timeInForce")]
1012    pub time_in_force: TimeInForce,
1013    /// The date/time when the Stop Order will be cancelled if its timeInForce is “GTD”.
1014    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
1015    pub gtd_time: Option<Timestamp>,
1016    /// Specification of how Positions in the Account are modified when the Order is filled.
1017    #[serde(rename = "positionFill")]
1018    pub position_fill: OrderPositionFill,
1019    /// Specification of which price component should be used when determining if an Order should be triggered
1020    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
1021    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
1022    /// filled using their default price component. This feature is only provided through the REST API. Clients
1023    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
1024    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
1025    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
1026    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
1027    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
1028    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
1029    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
1030    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
1031    #[serde(rename = "triggerCondition")]
1032    pub trigger_condition: OrderTriggerCondition,
1033    /// The reason that the Stop Order was initiated
1034    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
1035    pub reason: Option<StopOrderReason>,
1036    /// Client Extensions to add to the Order (only provided if the Order is being created with client
1037    /// extensions).
1038    #[serde(
1039        rename = "clientExtensions",
1040        default,
1041        skip_serializing_if = "Option::is_none"
1042    )]
1043    pub client_extensions: Option<ClientExtensions>,
1044    /// The specification of the Take Profit Order that should be created for a Trade opened when the Order is
1045    /// filled (if such a Trade is created).
1046    #[serde(
1047        rename = "takeProfitOnFill",
1048        default,
1049        skip_serializing_if = "Option::is_none"
1050    )]
1051    pub take_profit_on_fill: Option<TakeProfitDetails>,
1052    /// The specification of the Stop Loss Order that should be created for a Trade opened when the Order is
1053    /// filled (if such a Trade is created).
1054    #[serde(
1055        rename = "stopLossOnFill",
1056        default,
1057        skip_serializing_if = "Option::is_none"
1058    )]
1059    pub stop_loss_on_fill: Option<StopLossDetails>,
1060    /// The specification of the Trailing Stop Loss Order that should be created for a Trade that is opened when
1061    /// the Order is filled (if such a Trade is created).
1062    #[serde(
1063        rename = "trailingStopLossOnFill",
1064        default,
1065        skip_serializing_if = "Option::is_none"
1066    )]
1067    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
1068    /// The specification of the Guaranteed Stop Loss Order that should be created for a Trade that is opened
1069    /// when the Order is filled (if such a Trade is created).
1070    #[serde(
1071        rename = "guaranteedStopLossOnFill",
1072        default,
1073        skip_serializing_if = "Option::is_none"
1074    )]
1075    pub guaranteed_stop_loss_on_fill: Option<GuaranteedStopLossDetails>,
1076    /// Client Extensions to add to the Trade created when the Order is filled (if such a Trade is created). Do
1077    /// not set, modify, delete tradeClientExtensions if your account is associated with MT4.
1078    #[serde(
1079        rename = "tradeClientExtensions",
1080        default,
1081        skip_serializing_if = "Option::is_none"
1082    )]
1083    pub trade_client_extensions: Option<ClientExtensions>,
1084    /// The ID of the Order that this Order replaces (only provided if this Order replaces an existing Order).
1085    #[serde(
1086        rename = "replacesOrderID",
1087        default,
1088        skip_serializing_if = "Option::is_none"
1089    )]
1090    pub replaces_order_id: Option<OrderID>,
1091    /// The ID of the Transaction that cancels the replaced Order (only provided if this Order replaces an
1092    /// existing Order).
1093    #[serde(
1094        rename = "cancellingTransactionID",
1095        default,
1096        skip_serializing_if = "Option::is_none"
1097    )]
1098    pub cancelling_transaction_id: Option<TransactionID>,
1099}
1100
1101/// A StopOrderRejectTransaction represents the rejection of the creation of a Stop Order.
1102#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1103#[serde(rename_all = "camelCase")]
1104pub struct StopOrderRejectTransaction {
1105    /// The Transaction’s Identifier.
1106    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
1107    pub id: Option<TransactionID>,
1108    /// The date/time when the Transaction was created.
1109    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
1110    pub time: Option<Timestamp>,
1111    /// The ID of the user that initiated the creation of the Transaction.
1112    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
1113    pub user_id: Option<i64>,
1114    /// The ID of the Account the Transaction was created for.
1115    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
1116    pub account_id: Option<AccountID>,
1117    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
1118    /// Account simultaneously.
1119    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
1120    pub batch_id: Option<TransactionID>,
1121    /// The Request ID of the request which generated the transaction.
1122    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
1123    pub request_id: Option<RequestID>,
1124    /// The Type of the Transaction. Always set to “STOP_ORDER_REJECT” in a StopOrderRejectTransaction.
1125    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
1126    pub r#type: Option<TransactionType>,
1127    /// The Stop Order’s Instrument.
1128    #[serde(rename = "instrument")]
1129    pub instrument: InstrumentName,
1130    /// The quantity requested to be filled by the Stop Order. A positive number of units results in a long
1131    /// Order, and a negative number of units results in a short Order.
1132    #[serde(rename = "units")]
1133    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1134    pub units: Decimal,
1135    /// The price threshold specified for the Stop Order. The Stop Order will only be filled by a market price
1136    /// that is equal to or worse than this price.
1137    #[serde(rename = "price")]
1138    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1139    pub price: Decimal,
1140    /// The worst market price that may be used to fill this Stop Order. If the market gaps and crosses through
1141    /// both the price and the priceBound, the Stop Order will be cancelled instead of being filled.
1142    #[serde(
1143        rename = "priceBound",
1144        default,
1145        skip_serializing_if = "Option::is_none"
1146    )]
1147    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1148    pub price_bound: Option<Decimal>,
1149    /// The time-in-force requested for the Stop Order.
1150    #[serde(rename = "timeInForce")]
1151    pub time_in_force: TimeInForce,
1152    /// The date/time when the Stop Order will be cancelled if its timeInForce is “GTD”.
1153    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
1154    pub gtd_time: Option<Timestamp>,
1155    /// Specification of how Positions in the Account are modified when the Order is filled.
1156    #[serde(rename = "positionFill")]
1157    pub position_fill: OrderPositionFill,
1158    /// Specification of which price component should be used when determining if an Order should be triggered
1159    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
1160    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
1161    /// filled using their default price component. This feature is only provided through the REST API. Clients
1162    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
1163    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
1164    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
1165    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
1166    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
1167    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
1168    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
1169    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
1170    #[serde(rename = "triggerCondition")]
1171    pub trigger_condition: OrderTriggerCondition,
1172    /// The reason that the Stop Order was initiated
1173    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
1174    pub reason: Option<StopOrderReason>,
1175    /// Client Extensions to add to the Order (only provided if the Order is being created with client
1176    /// extensions).
1177    #[serde(
1178        rename = "clientExtensions",
1179        default,
1180        skip_serializing_if = "Option::is_none"
1181    )]
1182    pub client_extensions: Option<ClientExtensions>,
1183    /// The specification of the Take Profit Order that should be created for a Trade opened when the Order is
1184    /// filled (if such a Trade is created).
1185    #[serde(
1186        rename = "takeProfitOnFill",
1187        default,
1188        skip_serializing_if = "Option::is_none"
1189    )]
1190    pub take_profit_on_fill: Option<TakeProfitDetails>,
1191    /// The specification of the Stop Loss Order that should be created for a Trade opened when the Order is
1192    /// filled (if such a Trade is created).
1193    #[serde(
1194        rename = "stopLossOnFill",
1195        default,
1196        skip_serializing_if = "Option::is_none"
1197    )]
1198    pub stop_loss_on_fill: Option<StopLossDetails>,
1199    /// The specification of the Trailing Stop Loss Order that should be created for a Trade that is opened when
1200    /// the Order is filled (if such a Trade is created).
1201    #[serde(
1202        rename = "trailingStopLossOnFill",
1203        default,
1204        skip_serializing_if = "Option::is_none"
1205    )]
1206    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
1207    /// The specification of the Guaranteed Stop Loss Order that should be created for a Trade that is opened
1208    /// when the Order is filled (if such a Trade is created).
1209    #[serde(
1210        rename = "guaranteedStopLossOnFill",
1211        default,
1212        skip_serializing_if = "Option::is_none"
1213    )]
1214    pub guaranteed_stop_loss_on_fill: Option<GuaranteedStopLossDetails>,
1215    /// Client Extensions to add to the Trade created when the Order is filled (if such a Trade is created). Do
1216    /// not set, modify, delete tradeClientExtensions if your account is associated with MT4.
1217    #[serde(
1218        rename = "tradeClientExtensions",
1219        default,
1220        skip_serializing_if = "Option::is_none"
1221    )]
1222    pub trade_client_extensions: Option<ClientExtensions>,
1223    /// The ID of the Order that this Order was intended to replace (only provided if this Order was intended to
1224    /// replace an existing Order).
1225    #[serde(
1226        rename = "intendedReplacesOrderID",
1227        default,
1228        skip_serializing_if = "Option::is_none"
1229    )]
1230    pub intended_replaces_order_id: Option<OrderID>,
1231    /// The reason that the Reject Transaction was created
1232    #[serde(
1233        rename = "rejectReason",
1234        default,
1235        skip_serializing_if = "Option::is_none"
1236    )]
1237    pub reject_reason: Option<TransactionRejectReason>,
1238}
1239
1240/// A MarketIfTouchedOrderTransaction represents the creation of a MarketIfTouched Order in the user’s
1241/// Account.
1242#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1243#[serde(rename_all = "camelCase")]
1244pub struct MarketIfTouchedOrderTransaction {
1245    /// The Transaction’s Identifier.
1246    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
1247    pub id: Option<TransactionID>,
1248    /// The date/time when the Transaction was created.
1249    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
1250    pub time: Option<Timestamp>,
1251    /// The ID of the user that initiated the creation of the Transaction.
1252    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
1253    pub user_id: Option<i64>,
1254    /// The ID of the Account the Transaction was created for.
1255    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
1256    pub account_id: Option<AccountID>,
1257    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
1258    /// Account simultaneously.
1259    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
1260    pub batch_id: Option<TransactionID>,
1261    /// The Request ID of the request which generated the transaction.
1262    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
1263    pub request_id: Option<RequestID>,
1264    /// The Type of the Transaction. Always set to “MARKET_IF_TOUCHED_ORDER” in a
1265    /// MarketIfTouchedOrderTransaction.
1266    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
1267    pub r#type: Option<TransactionType>,
1268    /// The MarketIfTouched Order’s Instrument.
1269    #[serde(rename = "instrument")]
1270    pub instrument: InstrumentName,
1271    /// The quantity requested to be filled by the MarketIfTouched Order. A positive number of units results in
1272    /// a long Order, and a negative number of units results in a short Order.
1273    #[serde(rename = "units")]
1274    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1275    pub units: Decimal,
1276    /// The price threshold specified for the MarketIfTouched Order. The MarketIfTouched Order will only be
1277    /// filled by a market price that crosses this price from the direction of the market price at the time when
1278    /// the Order was created (the initialMarketPrice). Depending on the value of the Order’s price and
1279    /// initialMarketPrice, the MarketIfTouchedOrder will behave like a Limit or a Stop Order.
1280    #[serde(rename = "price")]
1281    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1282    pub price: Decimal,
1283    /// The worst market price that may be used to fill this MarketIfTouched Order.
1284    #[serde(
1285        rename = "priceBound",
1286        default,
1287        skip_serializing_if = "Option::is_none"
1288    )]
1289    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1290    pub price_bound: Option<Decimal>,
1291    /// The time-in-force requested for the MarketIfTouched Order. Restricted to “GTC”, “GFD” and “GTD” for
1292    /// MarketIfTouched Orders.
1293    #[serde(rename = "timeInForce")]
1294    pub time_in_force: TimeInForce,
1295    /// The date/time when the MarketIfTouched Order will be cancelled if its timeInForce is “GTD”.
1296    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
1297    pub gtd_time: Option<Timestamp>,
1298    /// Specification of how Positions in the Account are modified when the Order is filled.
1299    #[serde(rename = "positionFill")]
1300    pub position_fill: OrderPositionFill,
1301    /// Specification of which price component should be used when determining if an Order should be triggered
1302    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
1303    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
1304    /// filled using their default price component. This feature is only provided through the REST API. Clients
1305    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
1306    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
1307    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
1308    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
1309    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
1310    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
1311    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
1312    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
1313    #[serde(rename = "triggerCondition")]
1314    pub trigger_condition: OrderTriggerCondition,
1315    /// The reason that the Market-if-touched Order was initiated
1316    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
1317    pub reason: Option<MarketIfTouchedOrderReason>,
1318    /// Client Extensions to add to the Order (only provided if the Order is being created with client
1319    /// extensions).
1320    #[serde(
1321        rename = "clientExtensions",
1322        default,
1323        skip_serializing_if = "Option::is_none"
1324    )]
1325    pub client_extensions: Option<ClientExtensions>,
1326    /// The specification of the Take Profit Order that should be created for a Trade opened when the Order is
1327    /// filled (if such a Trade is created).
1328    #[serde(
1329        rename = "takeProfitOnFill",
1330        default,
1331        skip_serializing_if = "Option::is_none"
1332    )]
1333    pub take_profit_on_fill: Option<TakeProfitDetails>,
1334    /// The specification of the Stop Loss Order that should be created for a Trade opened when the Order is
1335    /// filled (if such a Trade is created).
1336    #[serde(
1337        rename = "stopLossOnFill",
1338        default,
1339        skip_serializing_if = "Option::is_none"
1340    )]
1341    pub stop_loss_on_fill: Option<StopLossDetails>,
1342    /// The specification of the Trailing Stop Loss Order that should be created for a Trade that is opened when
1343    /// the Order is filled (if such a Trade is created).
1344    #[serde(
1345        rename = "trailingStopLossOnFill",
1346        default,
1347        skip_serializing_if = "Option::is_none"
1348    )]
1349    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
1350    /// The specification of the Guaranteed Stop Loss Order that should be created for a Trade that is opened
1351    /// when the Order is filled (if such a Trade is created).
1352    #[serde(
1353        rename = "guaranteedStopLossOnFill",
1354        default,
1355        skip_serializing_if = "Option::is_none"
1356    )]
1357    pub guaranteed_stop_loss_on_fill: Option<GuaranteedStopLossDetails>,
1358    /// Client Extensions to add to the Trade created when the Order is filled (if such a Trade is created). Do
1359    /// not set, modify, delete tradeClientExtensions if your account is associated with MT4.
1360    #[serde(
1361        rename = "tradeClientExtensions",
1362        default,
1363        skip_serializing_if = "Option::is_none"
1364    )]
1365    pub trade_client_extensions: Option<ClientExtensions>,
1366    /// The ID of the Order that this Order replaces (only provided if this Order replaces an existing Order).
1367    #[serde(
1368        rename = "replacesOrderID",
1369        default,
1370        skip_serializing_if = "Option::is_none"
1371    )]
1372    pub replaces_order_id: Option<OrderID>,
1373    /// The ID of the Transaction that cancels the replaced Order (only provided if this Order replaces an
1374    /// existing Order).
1375    #[serde(
1376        rename = "cancellingTransactionID",
1377        default,
1378        skip_serializing_if = "Option::is_none"
1379    )]
1380    pub cancelling_transaction_id: Option<TransactionID>,
1381}
1382
1383/// A MarketIfTouchedOrderRejectTransaction represents the rejection of the creation of a MarketIfTouched
1384/// Order.
1385#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1386#[serde(rename_all = "camelCase")]
1387pub struct MarketIfTouchedOrderRejectTransaction {
1388    /// The Transaction’s Identifier.
1389    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
1390    pub id: Option<TransactionID>,
1391    /// The date/time when the Transaction was created.
1392    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
1393    pub time: Option<Timestamp>,
1394    /// The ID of the user that initiated the creation of the Transaction.
1395    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
1396    pub user_id: Option<i64>,
1397    /// The ID of the Account the Transaction was created for.
1398    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
1399    pub account_id: Option<AccountID>,
1400    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
1401    /// Account simultaneously.
1402    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
1403    pub batch_id: Option<TransactionID>,
1404    /// The Request ID of the request which generated the transaction.
1405    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
1406    pub request_id: Option<RequestID>,
1407    /// The Type of the Transaction. Always set to “MARKET_IF_TOUCHED_ORDER_REJECT” in a
1408    /// MarketIfTouchedOrderRejectTransaction.
1409    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
1410    pub r#type: Option<TransactionType>,
1411    /// The MarketIfTouched Order’s Instrument.
1412    #[serde(rename = "instrument")]
1413    pub instrument: InstrumentName,
1414    /// The quantity requested to be filled by the MarketIfTouched Order. A positive number of units results in
1415    /// a long Order, and a negative number of units results in a short Order.
1416    #[serde(rename = "units")]
1417    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1418    pub units: Decimal,
1419    /// The price threshold specified for the MarketIfTouched Order. The MarketIfTouched Order will only be
1420    /// filled by a market price that crosses this price from the direction of the market price at the time when
1421    /// the Order was created (the initialMarketPrice). Depending on the value of the Order’s price and
1422    /// initialMarketPrice, the MarketIfTouchedOrder will behave like a Limit or a Stop Order.
1423    #[serde(rename = "price")]
1424    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1425    pub price: Decimal,
1426    /// The worst market price that may be used to fill this MarketIfTouched Order.
1427    #[serde(
1428        rename = "priceBound",
1429        default,
1430        skip_serializing_if = "Option::is_none"
1431    )]
1432    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1433    pub price_bound: Option<Decimal>,
1434    /// The time-in-force requested for the MarketIfTouched Order. Restricted to “GTC”, “GFD” and “GTD” for
1435    /// MarketIfTouched Orders.
1436    #[serde(rename = "timeInForce")]
1437    pub time_in_force: TimeInForce,
1438    /// The date/time when the MarketIfTouched Order will be cancelled if its timeInForce is “GTD”.
1439    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
1440    pub gtd_time: Option<Timestamp>,
1441    /// Specification of how Positions in the Account are modified when the Order is filled.
1442    #[serde(rename = "positionFill")]
1443    pub position_fill: OrderPositionFill,
1444    /// Specification of which price component should be used when determining if an Order should be triggered
1445    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
1446    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
1447    /// filled using their default price component. This feature is only provided through the REST API. Clients
1448    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
1449    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
1450    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
1451    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
1452    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
1453    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
1454    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
1455    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
1456    #[serde(rename = "triggerCondition")]
1457    pub trigger_condition: OrderTriggerCondition,
1458    /// The reason that the Market-if-touched Order was initiated
1459    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
1460    pub reason: Option<MarketIfTouchedOrderReason>,
1461    /// Client Extensions to add to the Order (only provided if the Order is being created with client
1462    /// extensions).
1463    #[serde(
1464        rename = "clientExtensions",
1465        default,
1466        skip_serializing_if = "Option::is_none"
1467    )]
1468    pub client_extensions: Option<ClientExtensions>,
1469    /// The specification of the Take Profit Order that should be created for a Trade opened when the Order is
1470    /// filled (if such a Trade is created).
1471    #[serde(
1472        rename = "takeProfitOnFill",
1473        default,
1474        skip_serializing_if = "Option::is_none"
1475    )]
1476    pub take_profit_on_fill: Option<TakeProfitDetails>,
1477    /// The specification of the Stop Loss Order that should be created for a Trade opened when the Order is
1478    /// filled (if such a Trade is created).
1479    #[serde(
1480        rename = "stopLossOnFill",
1481        default,
1482        skip_serializing_if = "Option::is_none"
1483    )]
1484    pub stop_loss_on_fill: Option<StopLossDetails>,
1485    /// The specification of the Trailing Stop Loss Order that should be created for a Trade that is opened when
1486    /// the Order is filled (if such a Trade is created).
1487    #[serde(
1488        rename = "trailingStopLossOnFill",
1489        default,
1490        skip_serializing_if = "Option::is_none"
1491    )]
1492    pub trailing_stop_loss_on_fill: Option<TrailingStopLossDetails>,
1493    /// The specification of the Guaranteed Stop Loss Order that should be created for a Trade that is opened
1494    /// when the Order is filled (if such a Trade is created).
1495    #[serde(
1496        rename = "guaranteedStopLossOnFill",
1497        default,
1498        skip_serializing_if = "Option::is_none"
1499    )]
1500    pub guaranteed_stop_loss_on_fill: Option<GuaranteedStopLossDetails>,
1501    /// Client Extensions to add to the Trade created when the Order is filled (if such a Trade is created). Do
1502    /// not set, modify, delete tradeClientExtensions if your account is associated with MT4.
1503    #[serde(
1504        rename = "tradeClientExtensions",
1505        default,
1506        skip_serializing_if = "Option::is_none"
1507    )]
1508    pub trade_client_extensions: Option<ClientExtensions>,
1509    /// The ID of the Order that this Order was intended to replace (only provided if this Order was intended to
1510    /// replace an existing Order).
1511    #[serde(
1512        rename = "intendedReplacesOrderID",
1513        default,
1514        skip_serializing_if = "Option::is_none"
1515    )]
1516    pub intended_replaces_order_id: Option<OrderID>,
1517    /// The reason that the Reject Transaction was created
1518    #[serde(
1519        rename = "rejectReason",
1520        default,
1521        skip_serializing_if = "Option::is_none"
1522    )]
1523    pub reject_reason: Option<TransactionRejectReason>,
1524}
1525
1526/// A TakeProfitOrderTransaction represents the creation of a TakeProfit Order in the user’s Account.
1527#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1528#[serde(rename_all = "camelCase")]
1529pub struct TakeProfitOrderTransaction {
1530    /// The Transaction’s Identifier.
1531    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
1532    pub id: Option<TransactionID>,
1533    /// The date/time when the Transaction was created.
1534    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
1535    pub time: Option<Timestamp>,
1536    /// The ID of the user that initiated the creation of the Transaction.
1537    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
1538    pub user_id: Option<i64>,
1539    /// The ID of the Account the Transaction was created for.
1540    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
1541    pub account_id: Option<AccountID>,
1542    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
1543    /// Account simultaneously.
1544    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
1545    pub batch_id: Option<TransactionID>,
1546    /// The Request ID of the request which generated the transaction.
1547    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
1548    pub request_id: Option<RequestID>,
1549    /// The Type of the Transaction. Always set to “TAKE_PROFIT_ORDER” in a TakeProfitOrderTransaction.
1550    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
1551    pub r#type: Option<TransactionType>,
1552    /// The ID of the Trade to close when the price threshold is breached.
1553    #[serde(rename = "tradeID")]
1554    pub trade_id: TradeID,
1555    /// The client ID of the Trade to be closed when the price threshold is breached.
1556    #[serde(
1557        rename = "clientTradeID",
1558        default,
1559        skip_serializing_if = "Option::is_none"
1560    )]
1561    pub client_trade_id: Option<ClientID>,
1562    /// The price threshold specified for the TakeProfit Order. The associated Trade will be closed by a market
1563    /// price that is equal to or better than this threshold.
1564    #[serde(rename = "price")]
1565    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1566    pub price: Decimal,
1567    /// The time-in-force requested for the TakeProfit Order. Restricted to “GTC”, “GFD” and “GTD” for
1568    /// TakeProfit Orders.
1569    #[serde(rename = "timeInForce")]
1570    pub time_in_force: TimeInForce,
1571    /// The date/time when the TakeProfit Order will be cancelled if its timeInForce is “GTD”.
1572    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
1573    pub gtd_time: Option<Timestamp>,
1574    /// Specification of which price component should be used when determining if an Order should be triggered
1575    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
1576    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
1577    /// filled using their default price component. This feature is only provided through the REST API. Clients
1578    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
1579    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
1580    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
1581    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
1582    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
1583    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
1584    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
1585    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
1586    #[serde(rename = "triggerCondition")]
1587    pub trigger_condition: OrderTriggerCondition,
1588    /// The reason that the Take Profit Order was initiated
1589    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
1590    pub reason: Option<TakeProfitOrderReason>,
1591    /// Client Extensions to add to the Order (only provided if the Order is being created with client
1592    /// extensions).
1593    #[serde(
1594        rename = "clientExtensions",
1595        default,
1596        skip_serializing_if = "Option::is_none"
1597    )]
1598    pub client_extensions: Option<ClientExtensions>,
1599    /// The ID of the OrderFill Transaction that caused this Order to be created (only provided if this Order
1600    /// was created automatically when another Order was filled).
1601    #[serde(
1602        rename = "orderFillTransactionID",
1603        default,
1604        skip_serializing_if = "Option::is_none"
1605    )]
1606    pub order_fill_transaction_id: Option<TransactionID>,
1607    /// The ID of the Order that this Order replaces (only provided if this Order replaces an existing Order).
1608    #[serde(
1609        rename = "replacesOrderID",
1610        default,
1611        skip_serializing_if = "Option::is_none"
1612    )]
1613    pub replaces_order_id: Option<OrderID>,
1614    /// The ID of the Transaction that cancels the replaced Order (only provided if this Order replaces an
1615    /// existing Order).
1616    #[serde(
1617        rename = "cancellingTransactionID",
1618        default,
1619        skip_serializing_if = "Option::is_none"
1620    )]
1621    pub cancelling_transaction_id: Option<TransactionID>,
1622}
1623
1624/// A TakeProfitOrderRejectTransaction represents the rejection of the creation of a TakeProfit Order.
1625#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1626#[serde(rename_all = "camelCase")]
1627pub struct TakeProfitOrderRejectTransaction {
1628    /// The Transaction’s Identifier.
1629    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
1630    pub id: Option<TransactionID>,
1631    /// The date/time when the Transaction was created.
1632    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
1633    pub time: Option<Timestamp>,
1634    /// The ID of the user that initiated the creation of the Transaction.
1635    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
1636    pub user_id: Option<i64>,
1637    /// The ID of the Account the Transaction was created for.
1638    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
1639    pub account_id: Option<AccountID>,
1640    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
1641    /// Account simultaneously.
1642    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
1643    pub batch_id: Option<TransactionID>,
1644    /// The Request ID of the request which generated the transaction.
1645    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
1646    pub request_id: Option<RequestID>,
1647    /// The Type of the Transaction. Always set to “TAKE_PROFIT_ORDER_REJECT” in a
1648    /// TakeProfitOrderRejectTransaction.
1649    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
1650    pub r#type: Option<TransactionType>,
1651    /// The ID of the Trade to close when the price threshold is breached.
1652    #[serde(rename = "tradeID")]
1653    pub trade_id: TradeID,
1654    /// The client ID of the Trade to be closed when the price threshold is breached.
1655    #[serde(
1656        rename = "clientTradeID",
1657        default,
1658        skip_serializing_if = "Option::is_none"
1659    )]
1660    pub client_trade_id: Option<ClientID>,
1661    /// The price threshold specified for the TakeProfit Order. The associated Trade will be closed by a market
1662    /// price that is equal to or better than this threshold.
1663    #[serde(rename = "price")]
1664    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1665    pub price: Decimal,
1666    /// The time-in-force requested for the TakeProfit Order. Restricted to “GTC”, “GFD” and “GTD” for
1667    /// TakeProfit Orders.
1668    #[serde(rename = "timeInForce")]
1669    pub time_in_force: TimeInForce,
1670    /// The date/time when the TakeProfit Order will be cancelled if its timeInForce is “GTD”.
1671    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
1672    pub gtd_time: Option<Timestamp>,
1673    /// Specification of which price component should be used when determining if an Order should be triggered
1674    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
1675    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
1676    /// filled using their default price component. This feature is only provided through the REST API. Clients
1677    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
1678    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
1679    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
1680    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
1681    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
1682    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
1683    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
1684    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
1685    #[serde(rename = "triggerCondition")]
1686    pub trigger_condition: OrderTriggerCondition,
1687    /// The reason that the Take Profit Order was initiated
1688    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
1689    pub reason: Option<TakeProfitOrderReason>,
1690    /// Client Extensions to add to the Order (only provided if the Order is being created with client
1691    /// extensions).
1692    #[serde(
1693        rename = "clientExtensions",
1694        default,
1695        skip_serializing_if = "Option::is_none"
1696    )]
1697    pub client_extensions: Option<ClientExtensions>,
1698    /// The ID of the OrderFill Transaction that caused this Order to be created (only provided if this Order
1699    /// was created automatically when another Order was filled).
1700    #[serde(
1701        rename = "orderFillTransactionID",
1702        default,
1703        skip_serializing_if = "Option::is_none"
1704    )]
1705    pub order_fill_transaction_id: Option<TransactionID>,
1706    /// The ID of the Order that this Order was intended to replace (only provided if this Order was intended to
1707    /// replace an existing Order).
1708    #[serde(
1709        rename = "intendedReplacesOrderID",
1710        default,
1711        skip_serializing_if = "Option::is_none"
1712    )]
1713    pub intended_replaces_order_id: Option<OrderID>,
1714    /// The reason that the Reject Transaction was created
1715    #[serde(
1716        rename = "rejectReason",
1717        default,
1718        skip_serializing_if = "Option::is_none"
1719    )]
1720    pub reject_reason: Option<TransactionRejectReason>,
1721}
1722
1723/// A StopLossOrderTransaction represents the creation of a StopLoss Order in the user’s Account.
1724#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1725#[serde(rename_all = "camelCase")]
1726pub struct StopLossOrderTransaction {
1727    /// The Transaction’s Identifier.
1728    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
1729    pub id: Option<TransactionID>,
1730    /// The date/time when the Transaction was created.
1731    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
1732    pub time: Option<Timestamp>,
1733    /// The ID of the user that initiated the creation of the Transaction.
1734    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
1735    pub user_id: Option<i64>,
1736    /// The ID of the Account the Transaction was created for.
1737    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
1738    pub account_id: Option<AccountID>,
1739    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
1740    /// Account simultaneously.
1741    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
1742    pub batch_id: Option<TransactionID>,
1743    /// The Request ID of the request which generated the transaction.
1744    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
1745    pub request_id: Option<RequestID>,
1746    /// The Type of the Transaction. Always set to “STOP_LOSS_ORDER” in a StopLossOrderTransaction.
1747    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
1748    pub r#type: Option<TransactionType>,
1749    /// The ID of the Trade to close when the price threshold is breached.
1750    #[serde(rename = "tradeID")]
1751    pub trade_id: TradeID,
1752    /// The client ID of the Trade to be closed when the price threshold is breached.
1753    #[serde(
1754        rename = "clientTradeID",
1755        default,
1756        skip_serializing_if = "Option::is_none"
1757    )]
1758    pub client_trade_id: Option<ClientID>,
1759    /// The price threshold specified for the Stop Loss Order. The associated Trade will be closed by a market
1760    /// price that is equal to or worse than this threshold.
1761    #[serde(rename = "price")]
1762    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1763    pub price: Decimal,
1764    /// Specifies the distance (in price units) from the Account’s current price to use as the Stop Loss Order
1765    /// price. If the Trade is short the Instrument’s bid price is used, and for long Trades the ask is used.
1766    #[serde(rename = "distance", default, skip_serializing_if = "Option::is_none")]
1767    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1768    pub distance: Option<Decimal>,
1769    /// The time-in-force requested for the StopLoss Order. Restricted to “GTC”, “GFD” and “GTD” for StopLoss
1770    /// Orders.
1771    #[serde(rename = "timeInForce")]
1772    pub time_in_force: TimeInForce,
1773    /// The date/time when the StopLoss Order will be cancelled if its timeInForce is “GTD”.
1774    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
1775    pub gtd_time: Option<Timestamp>,
1776    /// Specification of which price component should be used when determining if an Order should be triggered
1777    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
1778    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
1779    /// filled using their default price component. This feature is only provided through the REST API. Clients
1780    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
1781    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
1782    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
1783    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
1784    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
1785    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
1786    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
1787    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
1788    #[serde(rename = "triggerCondition")]
1789    pub trigger_condition: OrderTriggerCondition,
1790    /// Flag indicating that the Stop Loss Order is guaranteed. The default value depends on the
1791    /// GuaranteedStopLossOrderMode of the account, if it is REQUIRED, the default will be true, for DISABLED or
1792    /// ENABLED the default is false. Deprecated: Will be removed in a future API update.
1793    #[serde(
1794        rename = "guaranteed",
1795        default,
1796        skip_serializing_if = "Option::is_none"
1797    )]
1798    pub guaranteed: Option<bool>,
1799    /// The fee that will be charged if the Stop Loss Order is guaranteed and the Order is filled at the
1800    /// guaranteed price. The value is determined at Order creation time. It is in price units and is charged
1801    /// for each unit of the Trade. Deprecated: Will be removed in a future API update.
1802    #[serde(
1803        rename = "guaranteedExecutionPremium",
1804        default,
1805        skip_serializing_if = "Option::is_none"
1806    )]
1807    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1808    pub guaranteed_execution_premium: Option<Decimal>,
1809    /// The reason that the Stop Loss Order was initiated
1810    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
1811    pub reason: Option<StopLossOrderReason>,
1812    /// Client Extensions to add to the Order (only provided if the Order is being created with client
1813    /// extensions).
1814    #[serde(
1815        rename = "clientExtensions",
1816        default,
1817        skip_serializing_if = "Option::is_none"
1818    )]
1819    pub client_extensions: Option<ClientExtensions>,
1820    /// The ID of the OrderFill Transaction that caused this Order to be created (only provided if this Order
1821    /// was created automatically when another Order was filled).
1822    #[serde(
1823        rename = "orderFillTransactionID",
1824        default,
1825        skip_serializing_if = "Option::is_none"
1826    )]
1827    pub order_fill_transaction_id: Option<TransactionID>,
1828    /// The ID of the Order that this Order replaces (only provided if this Order replaces an existing Order).
1829    #[serde(
1830        rename = "replacesOrderID",
1831        default,
1832        skip_serializing_if = "Option::is_none"
1833    )]
1834    pub replaces_order_id: Option<OrderID>,
1835    /// The ID of the Transaction that cancels the replaced Order (only provided if this Order replaces an
1836    /// existing Order).
1837    #[serde(
1838        rename = "cancellingTransactionID",
1839        default,
1840        skip_serializing_if = "Option::is_none"
1841    )]
1842    pub cancelling_transaction_id: Option<TransactionID>,
1843}
1844
1845/// A StopLossOrderRejectTransaction represents the rejection of the creation of a StopLoss Order.
1846#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1847#[serde(rename_all = "camelCase")]
1848pub struct StopLossOrderRejectTransaction {
1849    /// The Transaction’s Identifier.
1850    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
1851    pub id: Option<TransactionID>,
1852    /// The date/time when the Transaction was created.
1853    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
1854    pub time: Option<Timestamp>,
1855    /// The ID of the user that initiated the creation of the Transaction.
1856    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
1857    pub user_id: Option<i64>,
1858    /// The ID of the Account the Transaction was created for.
1859    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
1860    pub account_id: Option<AccountID>,
1861    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
1862    /// Account simultaneously.
1863    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
1864    pub batch_id: Option<TransactionID>,
1865    /// The Request ID of the request which generated the transaction.
1866    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
1867    pub request_id: Option<RequestID>,
1868    /// The Type of the Transaction. Always set to “STOP_LOSS_ORDER_REJECT” in a StopLossOrderRejectTransaction.
1869    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
1870    pub r#type: Option<TransactionType>,
1871    /// The ID of the Trade to close when the price threshold is breached.
1872    #[serde(rename = "tradeID")]
1873    pub trade_id: TradeID,
1874    /// The client ID of the Trade to be closed when the price threshold is breached.
1875    #[serde(
1876        rename = "clientTradeID",
1877        default,
1878        skip_serializing_if = "Option::is_none"
1879    )]
1880    pub client_trade_id: Option<ClientID>,
1881    /// The price threshold specified for the Stop Loss Order. The associated Trade will be closed by a market
1882    /// price that is equal to or worse than this threshold.
1883    #[serde(rename = "price")]
1884    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1885    pub price: Decimal,
1886    /// Specifies the distance (in price units) from the Account’s current price to use as the Stop Loss Order
1887    /// price. If the Trade is short the Instrument’s bid price is used, and for long Trades the ask is used.
1888    #[serde(rename = "distance", default, skip_serializing_if = "Option::is_none")]
1889    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1890    pub distance: Option<Decimal>,
1891    /// The time-in-force requested for the StopLoss Order. Restricted to “GTC”, “GFD” and “GTD” for StopLoss
1892    /// Orders.
1893    #[serde(rename = "timeInForce")]
1894    pub time_in_force: TimeInForce,
1895    /// The date/time when the StopLoss Order will be cancelled if its timeInForce is “GTD”.
1896    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
1897    pub gtd_time: Option<Timestamp>,
1898    /// Specification of which price component should be used when determining if an Order should be triggered
1899    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
1900    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
1901    /// filled using their default price component. This feature is only provided through the REST API. Clients
1902    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
1903    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
1904    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
1905    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
1906    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
1907    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
1908    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
1909    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
1910    #[serde(rename = "triggerCondition")]
1911    pub trigger_condition: OrderTriggerCondition,
1912    /// Flag indicating that the Stop Loss Order is guaranteed. The default value depends on the
1913    /// GuaranteedStopLossOrderMode of the account, if it is REQUIRED, the default will be true, for DISABLED or
1914    /// ENABLED the default is false. Deprecated: Will be removed in a future API update.
1915    #[serde(
1916        rename = "guaranteed",
1917        default,
1918        skip_serializing_if = "Option::is_none"
1919    )]
1920    pub guaranteed: Option<bool>,
1921    /// The reason that the Stop Loss Order was initiated
1922    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
1923    pub reason: Option<StopLossOrderReason>,
1924    /// Client Extensions to add to the Order (only provided if the Order is being created with client
1925    /// extensions).
1926    #[serde(
1927        rename = "clientExtensions",
1928        default,
1929        skip_serializing_if = "Option::is_none"
1930    )]
1931    pub client_extensions: Option<ClientExtensions>,
1932    /// The ID of the OrderFill Transaction that caused this Order to be created (only provided if this Order
1933    /// was created automatically when another Order was filled).
1934    #[serde(
1935        rename = "orderFillTransactionID",
1936        default,
1937        skip_serializing_if = "Option::is_none"
1938    )]
1939    pub order_fill_transaction_id: Option<TransactionID>,
1940    /// The ID of the Order that this Order was intended to replace (only provided if this Order was intended to
1941    /// replace an existing Order).
1942    #[serde(
1943        rename = "intendedReplacesOrderID",
1944        default,
1945        skip_serializing_if = "Option::is_none"
1946    )]
1947    pub intended_replaces_order_id: Option<OrderID>,
1948    /// The reason that the Reject Transaction was created
1949    #[serde(
1950        rename = "rejectReason",
1951        default,
1952        skip_serializing_if = "Option::is_none"
1953    )]
1954    pub reject_reason: Option<TransactionRejectReason>,
1955}
1956
1957/// A GuaranteedStopLossOrderTransaction represents the creation of a GuaranteedStopLoss Order in the user’s
1958/// Account.
1959#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1960#[serde(rename_all = "camelCase")]
1961pub struct GuaranteedStopLossOrderTransaction {
1962    /// The Transaction’s Identifier.
1963    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
1964    pub id: Option<TransactionID>,
1965    /// The date/time when the Transaction was created.
1966    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
1967    pub time: Option<Timestamp>,
1968    /// The ID of the user that initiated the creation of the Transaction.
1969    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
1970    pub user_id: Option<i64>,
1971    /// The ID of the Account the Transaction was created for.
1972    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
1973    pub account_id: Option<AccountID>,
1974    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
1975    /// Account simultaneously.
1976    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
1977    pub batch_id: Option<TransactionID>,
1978    /// The Request ID of the request which generated the transaction.
1979    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
1980    pub request_id: Option<RequestID>,
1981    /// The Type of the Transaction. Always set to “GUARANTEED_STOP_LOSS_ORDER” in a
1982    /// GuaranteedStopLossOrderTransaction.
1983    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
1984    pub r#type: Option<TransactionType>,
1985    /// The ID of the Trade to close when the price threshold is breached.
1986    #[serde(rename = "tradeID")]
1987    pub trade_id: TradeID,
1988    /// The client ID of the Trade to be closed when the price threshold is breached.
1989    #[serde(
1990        rename = "clientTradeID",
1991        default,
1992        skip_serializing_if = "Option::is_none"
1993    )]
1994    pub client_trade_id: Option<ClientID>,
1995    /// The price threshold specified for the Guaranteed Stop Loss Order. The associated Trade will be closed at
1996    /// this price.
1997    #[serde(rename = "price")]
1998    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
1999    pub price: Decimal,
2000    /// Specifies the distance (in price units) from the Account’s current price to use as the Guaranteed Stop
2001    /// Loss Order price. If the Trade is short the Instrument’s bid price is used, and for long Trades the ask
2002    /// is used.
2003    #[serde(rename = "distance", default, skip_serializing_if = "Option::is_none")]
2004    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2005    pub distance: Option<Decimal>,
2006    /// The time-in-force requested for the GuaranteedStopLoss Order. Restricted to “GTC”, “GFD” and “GTD” for
2007    /// GuaranteedStopLoss Orders.
2008    #[serde(rename = "timeInForce")]
2009    pub time_in_force: TimeInForce,
2010    /// The date/time when the GuaranteedStopLoss Order will be cancelled if its timeInForce is “GTD”.
2011    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
2012    pub gtd_time: Option<Timestamp>,
2013    /// Specification of which price component should be used when determining if an Order should be triggered
2014    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
2015    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
2016    /// filled using their default price component. This feature is only provided through the REST API. Clients
2017    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
2018    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
2019    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
2020    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
2021    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
2022    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
2023    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
2024    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
2025    #[serde(rename = "triggerCondition")]
2026    pub trigger_condition: OrderTriggerCondition,
2027    /// The fee that will be charged if the Guaranteed Stop Loss Order is filled at the guaranteed price. The
2028    /// value is determined at Order creation time. It is in price units and is charged for each unit of the
2029    /// Trade.
2030    #[serde(
2031        rename = "guaranteedExecutionPremium",
2032        default,
2033        skip_serializing_if = "Option::is_none"
2034    )]
2035    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2036    pub guaranteed_execution_premium: Option<Decimal>,
2037    /// The reason that the Guaranteed Stop Loss Order was initiated
2038    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
2039    pub reason: Option<GuaranteedStopLossOrderReason>,
2040    /// Client Extensions to add to the Order (only provided if the Order is being created with client
2041    /// extensions).
2042    #[serde(
2043        rename = "clientExtensions",
2044        default,
2045        skip_serializing_if = "Option::is_none"
2046    )]
2047    pub client_extensions: Option<ClientExtensions>,
2048    /// The ID of the OrderFill Transaction that caused this Order to be created (only provided if this Order
2049    /// was created automatically when another Order was filled).
2050    #[serde(
2051        rename = "orderFillTransactionID",
2052        default,
2053        skip_serializing_if = "Option::is_none"
2054    )]
2055    pub order_fill_transaction_id: Option<TransactionID>,
2056    /// The ID of the Order that this Order replaces (only provided if this Order replaces an existing Order).
2057    #[serde(
2058        rename = "replacesOrderID",
2059        default,
2060        skip_serializing_if = "Option::is_none"
2061    )]
2062    pub replaces_order_id: Option<OrderID>,
2063    /// The ID of the Transaction that cancels the replaced Order (only provided if this Order replaces an
2064    /// existing Order).
2065    #[serde(
2066        rename = "cancellingTransactionID",
2067        default,
2068        skip_serializing_if = "Option::is_none"
2069    )]
2070    pub cancelling_transaction_id: Option<TransactionID>,
2071}
2072
2073/// A GuaranteedStopLossOrderRejectTransaction represents the rejection of the creation of a
2074/// GuaranteedStopLoss Order.
2075#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2076#[serde(rename_all = "camelCase")]
2077pub struct GuaranteedStopLossOrderRejectTransaction {
2078    /// The Transaction’s Identifier.
2079    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2080    pub id: Option<TransactionID>,
2081    /// The date/time when the Transaction was created.
2082    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2083    pub time: Option<Timestamp>,
2084    /// The ID of the user that initiated the creation of the Transaction.
2085    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2086    pub user_id: Option<i64>,
2087    /// The ID of the Account the Transaction was created for.
2088    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2089    pub account_id: Option<AccountID>,
2090    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2091    /// Account simultaneously.
2092    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2093    pub batch_id: Option<TransactionID>,
2094    /// The Request ID of the request which generated the transaction.
2095    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2096    pub request_id: Option<RequestID>,
2097    /// The Type of the Transaction. Always set to “GUARANTEED_STOP_LOSS_ORDER_REJECT” in a
2098    /// GuaranteedStopLossOrderRejectTransaction.
2099    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2100    pub r#type: Option<TransactionType>,
2101    /// The ID of the Trade to close when the price threshold is breached.
2102    #[serde(rename = "tradeID")]
2103    pub trade_id: TradeID,
2104    /// The client ID of the Trade to be closed when the price threshold is breached.
2105    #[serde(
2106        rename = "clientTradeID",
2107        default,
2108        skip_serializing_if = "Option::is_none"
2109    )]
2110    pub client_trade_id: Option<ClientID>,
2111    /// The price threshold specified for the Guaranteed Stop Loss Order. The associated Trade will be closed at
2112    /// this price.
2113    #[serde(rename = "price")]
2114    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
2115    pub price: Decimal,
2116    /// Specifies the distance (in price units) from the Account’s current price to use as the Guaranteed Stop
2117    /// Loss Order price. If the Trade is short the Instrument’s bid price is used, and for long Trades the ask
2118    /// is used.
2119    #[serde(rename = "distance", default, skip_serializing_if = "Option::is_none")]
2120    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2121    pub distance: Option<Decimal>,
2122    /// The time-in-force requested for the GuaranteedStopLoss Order. Restricted to “GTC”, “GFD” and “GTD” for
2123    /// GuaranteedStopLoss Orders.
2124    #[serde(rename = "timeInForce")]
2125    pub time_in_force: TimeInForce,
2126    /// The date/time when the GuaranteedStopLoss Order will be cancelled if its timeInForce is “GTD”.
2127    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
2128    pub gtd_time: Option<Timestamp>,
2129    /// Specification of which price component should be used when determining if an Order should be triggered
2130    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
2131    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
2132    /// filled using their default price component. This feature is only provided through the REST API. Clients
2133    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
2134    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
2135    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
2136    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
2137    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
2138    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
2139    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
2140    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
2141    #[serde(rename = "triggerCondition")]
2142    pub trigger_condition: OrderTriggerCondition,
2143    /// The reason that the Guaranteed Stop Loss Order was initiated
2144    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
2145    pub reason: Option<GuaranteedStopLossOrderReason>,
2146    /// Client Extensions to add to the Order (only provided if the Order is being created with client
2147    /// extensions).
2148    #[serde(
2149        rename = "clientExtensions",
2150        default,
2151        skip_serializing_if = "Option::is_none"
2152    )]
2153    pub client_extensions: Option<ClientExtensions>,
2154    /// The ID of the OrderFill Transaction that caused this Order to be created (only provided if this Order
2155    /// was created automatically when another Order was filled).
2156    #[serde(
2157        rename = "orderFillTransactionID",
2158        default,
2159        skip_serializing_if = "Option::is_none"
2160    )]
2161    pub order_fill_transaction_id: Option<TransactionID>,
2162    /// The ID of the Order that this Order was intended to replace (only provided if this Order was intended to
2163    /// replace an existing Order).
2164    #[serde(
2165        rename = "intendedReplacesOrderID",
2166        default,
2167        skip_serializing_if = "Option::is_none"
2168    )]
2169    pub intended_replaces_order_id: Option<OrderID>,
2170    /// The reason that the Reject Transaction was created
2171    #[serde(
2172        rename = "rejectReason",
2173        default,
2174        skip_serializing_if = "Option::is_none"
2175    )]
2176    pub reject_reason: Option<TransactionRejectReason>,
2177}
2178
2179/// A TrailingStopLossOrderTransaction represents the creation of a TrailingStopLoss Order in the user’s
2180/// Account.
2181#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2182#[serde(rename_all = "camelCase")]
2183pub struct TrailingStopLossOrderTransaction {
2184    /// The Transaction’s Identifier.
2185    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2186    pub id: Option<TransactionID>,
2187    /// The date/time when the Transaction was created.
2188    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2189    pub time: Option<Timestamp>,
2190    /// The ID of the user that initiated the creation of the Transaction.
2191    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2192    pub user_id: Option<i64>,
2193    /// The ID of the Account the Transaction was created for.
2194    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2195    pub account_id: Option<AccountID>,
2196    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2197    /// Account simultaneously.
2198    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2199    pub batch_id: Option<TransactionID>,
2200    /// The Request ID of the request which generated the transaction.
2201    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2202    pub request_id: Option<RequestID>,
2203    /// The Type of the Transaction. Always set to “TRAILING_STOP_LOSS_ORDER” in a
2204    /// TrailingStopLossOrderTransaction.
2205    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2206    pub r#type: Option<TransactionType>,
2207    /// The ID of the Trade to close when the price threshold is breached.
2208    #[serde(rename = "tradeID")]
2209    pub trade_id: TradeID,
2210    /// The client ID of the Trade to be closed when the price threshold is breached.
2211    #[serde(
2212        rename = "clientTradeID",
2213        default,
2214        skip_serializing_if = "Option::is_none"
2215    )]
2216    pub client_trade_id: Option<ClientID>,
2217    /// The price distance (in price units) specified for the TrailingStopLoss Order.
2218    #[serde(rename = "distance")]
2219    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
2220    pub distance: Decimal,
2221    /// The time-in-force requested for the TrailingStopLoss Order. Restricted to “GTC”, “GFD” and “GTD” for
2222    /// TrailingStopLoss Orders.
2223    #[serde(rename = "timeInForce")]
2224    pub time_in_force: TimeInForce,
2225    /// The date/time when the StopLoss Order will be cancelled if its timeInForce is “GTD”.
2226    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
2227    pub gtd_time: Option<Timestamp>,
2228    /// Specification of which price component should be used when determining if an Order should be triggered
2229    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
2230    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
2231    /// filled using their default price component. This feature is only provided through the REST API. Clients
2232    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
2233    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
2234    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
2235    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
2236    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
2237    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
2238    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
2239    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
2240    #[serde(rename = "triggerCondition")]
2241    pub trigger_condition: OrderTriggerCondition,
2242    /// The reason that the Trailing Stop Loss Order was initiated
2243    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
2244    pub reason: Option<TrailingStopLossOrderReason>,
2245    /// Client Extensions to add to the Order (only provided if the Order is being created with client
2246    /// extensions).
2247    #[serde(
2248        rename = "clientExtensions",
2249        default,
2250        skip_serializing_if = "Option::is_none"
2251    )]
2252    pub client_extensions: Option<ClientExtensions>,
2253    /// The ID of the OrderFill Transaction that caused this Order to be created (only provided if this Order
2254    /// was created automatically when another Order was filled).
2255    #[serde(
2256        rename = "orderFillTransactionID",
2257        default,
2258        skip_serializing_if = "Option::is_none"
2259    )]
2260    pub order_fill_transaction_id: Option<TransactionID>,
2261    /// The ID of the Order that this Order replaces (only provided if this Order replaces an existing Order).
2262    #[serde(
2263        rename = "replacesOrderID",
2264        default,
2265        skip_serializing_if = "Option::is_none"
2266    )]
2267    pub replaces_order_id: Option<OrderID>,
2268    /// The ID of the Transaction that cancels the replaced Order (only provided if this Order replaces an
2269    /// existing Order).
2270    #[serde(
2271        rename = "cancellingTransactionID",
2272        default,
2273        skip_serializing_if = "Option::is_none"
2274    )]
2275    pub cancelling_transaction_id: Option<TransactionID>,
2276}
2277
2278/// A TrailingStopLossOrderRejectTransaction represents the rejection of the creation of a TrailingStopLoss
2279/// Order.
2280#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2281#[serde(rename_all = "camelCase")]
2282pub struct TrailingStopLossOrderRejectTransaction {
2283    /// The Transaction’s Identifier.
2284    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2285    pub id: Option<TransactionID>,
2286    /// The date/time when the Transaction was created.
2287    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2288    pub time: Option<Timestamp>,
2289    /// The ID of the user that initiated the creation of the Transaction.
2290    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2291    pub user_id: Option<i64>,
2292    /// The ID of the Account the Transaction was created for.
2293    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2294    pub account_id: Option<AccountID>,
2295    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2296    /// Account simultaneously.
2297    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2298    pub batch_id: Option<TransactionID>,
2299    /// The Request ID of the request which generated the transaction.
2300    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2301    pub request_id: Option<RequestID>,
2302    /// The Type of the Transaction. Always set to “TRAILING_STOP_LOSS_ORDER_REJECT” in a
2303    /// TrailingStopLossOrderRejectTransaction.
2304    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2305    pub r#type: Option<TransactionType>,
2306    /// The ID of the Trade to close when the price threshold is breached.
2307    #[serde(rename = "tradeID")]
2308    pub trade_id: TradeID,
2309    /// The client ID of the Trade to be closed when the price threshold is breached.
2310    #[serde(
2311        rename = "clientTradeID",
2312        default,
2313        skip_serializing_if = "Option::is_none"
2314    )]
2315    pub client_trade_id: Option<ClientID>,
2316    /// The price distance (in price units) specified for the TrailingStopLoss Order.
2317    #[serde(rename = "distance")]
2318    #[serde(deserialize_with = "crate::decimal_wire::number_or_string")]
2319    pub distance: Decimal,
2320    /// The time-in-force requested for the TrailingStopLoss Order. Restricted to “GTC”, “GFD” and “GTD” for
2321    /// TrailingStopLoss Orders.
2322    #[serde(rename = "timeInForce")]
2323    pub time_in_force: TimeInForce,
2324    /// The date/time when the StopLoss Order will be cancelled if its timeInForce is “GTD”.
2325    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
2326    pub gtd_time: Option<Timestamp>,
2327    /// Specification of which price component should be used when determining if an Order should be triggered
2328    /// and filled. This allows Orders to be triggered based on the bid, ask, mid, default (ask for buy, bid for
2329    /// sell) or inverse (ask for sell, bid for buy) price depending on the desired behaviour. Orders are always
2330    /// filled using their default price component. This feature is only provided through the REST API. Clients
2331    /// who choose to specify a non-default trigger condition will not see it reflected in any of OANDA’s
2332    /// proprietary or partner trading platforms, their transaction history or their account statements. OANDA
2333    /// platforms always assume that an Order’s trigger condition is set to the default value when indicating
2334    /// the distance from an Order’s trigger price, and will always provide the default trigger condition when
2335    /// creating or modifying an Order. A special restriction applies when creating a Guaranteed Stop Loss
2336    /// Order. In this case the TriggerCondition value must either be “DEFAULT”, or the “natural” trigger side
2337    /// “DEFAULT” results in. So for a Guaranteed Stop Loss Order for a long trade valid values are “DEFAULT”
2338    /// and “BID”, and for short trades “DEFAULT” and “ASK” are valid.
2339    #[serde(rename = "triggerCondition")]
2340    pub trigger_condition: OrderTriggerCondition,
2341    /// The reason that the Trailing Stop Loss Order was initiated
2342    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
2343    pub reason: Option<TrailingStopLossOrderReason>,
2344    /// Client Extensions to add to the Order (only provided if the Order is being created with client
2345    /// extensions).
2346    #[serde(
2347        rename = "clientExtensions",
2348        default,
2349        skip_serializing_if = "Option::is_none"
2350    )]
2351    pub client_extensions: Option<ClientExtensions>,
2352    /// The ID of the OrderFill Transaction that caused this Order to be created (only provided if this Order
2353    /// was created automatically when another Order was filled).
2354    #[serde(
2355        rename = "orderFillTransactionID",
2356        default,
2357        skip_serializing_if = "Option::is_none"
2358    )]
2359    pub order_fill_transaction_id: Option<TransactionID>,
2360    /// The ID of the Order that this Order was intended to replace (only provided if this Order was intended to
2361    /// replace an existing Order).
2362    #[serde(
2363        rename = "intendedReplacesOrderID",
2364        default,
2365        skip_serializing_if = "Option::is_none"
2366    )]
2367    pub intended_replaces_order_id: Option<OrderID>,
2368    /// The reason that the Reject Transaction was created
2369    #[serde(
2370        rename = "rejectReason",
2371        default,
2372        skip_serializing_if = "Option::is_none"
2373    )]
2374    pub reject_reason: Option<TransactionRejectReason>,
2375}
2376
2377/// An OrderFillTransaction represents the filling of an Order in the client’s Account.
2378#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2379#[serde(rename_all = "camelCase")]
2380pub struct OrderFillTransaction {
2381    /// The Transaction’s Identifier.
2382    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2383    pub id: Option<TransactionID>,
2384    /// The date/time when the Transaction was created.
2385    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2386    pub time: Option<Timestamp>,
2387    /// The ID of the user that initiated the creation of the Transaction.
2388    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2389    pub user_id: Option<i64>,
2390    /// The ID of the Account the Transaction was created for.
2391    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2392    pub account_id: Option<AccountID>,
2393    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2394    /// Account simultaneously.
2395    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2396    pub batch_id: Option<TransactionID>,
2397    /// The Request ID of the request which generated the transaction.
2398    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2399    pub request_id: Option<RequestID>,
2400    /// The Type of the Transaction. Always set to “ORDER_FILL” for an OrderFillTransaction.
2401    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2402    pub r#type: Option<TransactionType>,
2403    /// The ID of the Order filled.
2404    #[serde(rename = "orderID", default, skip_serializing_if = "Option::is_none")]
2405    pub order_id: Option<OrderID>,
2406    /// The client Order ID of the Order filled (only provided if the client has assigned one).
2407    #[serde(
2408        rename = "clientOrderID",
2409        default,
2410        skip_serializing_if = "Option::is_none"
2411    )]
2412    pub client_order_id: Option<ClientID>,
2413    /// The name of the filled Order’s instrument.
2414    #[serde(
2415        rename = "instrument",
2416        default,
2417        skip_serializing_if = "Option::is_none"
2418    )]
2419    pub instrument: Option<InstrumentName>,
2420    /// The number of units filled by the OrderFill.
2421    #[serde(rename = "units", default, skip_serializing_if = "Option::is_none")]
2422    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2423    pub units: Option<Decimal>,
2424    /// This is the conversion factor in effect for the Account at the time of the OrderFill for converting any
2425    /// gains realized in Instrument quote units into units of the Account’s home currency. Deprecated: Will be
2426    /// removed in a future API update.
2427    #[serde(
2428        rename = "gainQuoteHomeConversionFactor",
2429        default,
2430        skip_serializing_if = "Option::is_none"
2431    )]
2432    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2433    pub gain_quote_home_conversion_factor: Option<Decimal>,
2434    /// This is the conversion factor in effect for the Account at the time of the OrderFill for converting any
2435    /// losses realized in Instrument quote units into units of the Account’s home currency. Deprecated: Will be
2436    /// removed in a future API update.
2437    #[serde(
2438        rename = "lossQuoteHomeConversionFactor",
2439        default,
2440        skip_serializing_if = "Option::is_none"
2441    )]
2442    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2443    pub loss_quote_home_conversion_factor: Option<Decimal>,
2444    /// The HomeConversionFactors in effect at the time of the OrderFill.
2445    #[serde(
2446        rename = "homeConversionFactors",
2447        default,
2448        skip_serializing_if = "Option::is_none"
2449    )]
2450    pub home_conversion_factors: Option<HomeConversionFactors>,
2451    /// This field is now deprecated and should no longer be used. The individual tradesClosed, tradeReduced and
2452    /// tradeOpened fields contain the exact/official price each unit was filled at. Deprecated: Will be removed
2453    /// in a future API update.
2454    #[serde(rename = "price", default, skip_serializing_if = "Option::is_none")]
2455    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2456    pub price: Option<Decimal>,
2457    /// The price that all of the units of the OrderFill should have been filled at, in the absence of
2458    /// guaranteed price execution. This factors in the Account’s current ClientPrice, used liquidity and the
2459    /// units of the OrderFill only. If no Trades were closed with their price clamped for guaranteed stop loss
2460    /// enforcement, then this value will match the price fields of each Trade opened, closed, and reduced, and
2461    /// they will all be the exact same.
2462    #[serde(rename = "fullVWAP", default, skip_serializing_if = "Option::is_none")]
2463    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2464    pub full_vwap: Option<Decimal>,
2465    /// The price in effect for the account at the time of the Order fill.
2466    #[serde(rename = "fullPrice", default, skip_serializing_if = "Option::is_none")]
2467    pub full_price: Option<ClientPrice>,
2468    /// The reason that an Order was filled
2469    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
2470    pub reason: Option<OrderFillReason>,
2471    /// The profit or loss incurred when the Order was filled.
2472    #[serde(rename = "pl", default, skip_serializing_if = "Option::is_none")]
2473    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2474    pub pl: Option<Decimal>,
2475    /// The profit or loss incurred when the Order was filled, in the Instrument’s quote currency.
2476    #[serde(rename = "quotePL", default, skip_serializing_if = "Option::is_none")]
2477    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2478    pub quote_pl: Option<Decimal>,
2479    /// The financing paid or collected when the Order was filled.
2480    #[serde(rename = "financing", default, skip_serializing_if = "Option::is_none")]
2481    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2482    pub financing: Option<Decimal>,
2483    /// The financing paid or collected when the Order was filled, in the Instrument’s base currency.
2484    #[serde(
2485        rename = "baseFinancing",
2486        default,
2487        skip_serializing_if = "Option::is_none"
2488    )]
2489    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2490    pub base_financing: Option<Decimal>,
2491    /// The financing paid or collected when the Order was filled, in the Instrument’s quote currency.
2492    #[serde(
2493        rename = "quoteFinancing",
2494        default,
2495        skip_serializing_if = "Option::is_none"
2496    )]
2497    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2498    pub quote_financing: Option<Decimal>,
2499    /// The commission charged in the Account’s home currency as a result of filling the Order. The commission
2500    /// is always represented as a positive quantity of the Account’s home currency, however it reduces the
2501    /// balance in the Account.
2502    #[serde(
2503        rename = "commission",
2504        default,
2505        skip_serializing_if = "Option::is_none"
2506    )]
2507    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2508    pub commission: Option<Decimal>,
2509    /// The total guaranteed execution fees charged for all Trades opened, closed or reduced with guaranteed
2510    /// Stop Loss Orders.
2511    #[serde(
2512        rename = "guaranteedExecutionFee",
2513        default,
2514        skip_serializing_if = "Option::is_none"
2515    )]
2516    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2517    pub guaranteed_execution_fee: Option<Decimal>,
2518    /// The total guaranteed execution fees charged for all Trades opened, closed or reduced with guaranteed
2519    /// Stop Loss Orders, expressed in the Instrument’s quote currency.
2520    #[serde(
2521        rename = "quoteGuaranteedExecutionFee",
2522        default,
2523        skip_serializing_if = "Option::is_none"
2524    )]
2525    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2526    pub quote_guaranteed_execution_fee: Option<Decimal>,
2527    /// The Account’s balance after the Order was filled.
2528    #[serde(
2529        rename = "accountBalance",
2530        default,
2531        skip_serializing_if = "Option::is_none"
2532    )]
2533    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2534    pub account_balance: Option<Decimal>,
2535    /// The Trade that was opened when the Order was filled (only provided if filling the Order resulted in a
2536    /// new Trade).
2537    #[serde(
2538        rename = "tradeOpened",
2539        default,
2540        skip_serializing_if = "Option::is_none"
2541    )]
2542    pub trade_opened: Option<TradeOpen>,
2543    /// The Trades that were closed when the Order was filled (only provided if filling the Order resulted in a
2544    /// closing open Trades).
2545    #[serde(
2546        rename = "tradesClosed",
2547        default,
2548        skip_serializing_if = "Option::is_none"
2549    )]
2550    pub trades_closed: Option<Vec<TradeReduce>>,
2551    /// The Trade that was reduced when the Order was filled (only provided if filling the Order resulted in
2552    /// reducing an open Trade).
2553    #[serde(
2554        rename = "tradeReduced",
2555        default,
2556        skip_serializing_if = "Option::is_none"
2557    )]
2558    pub trade_reduced: Option<TradeReduce>,
2559    /// The half spread cost for the OrderFill, which is the sum of the halfSpreadCost values in the
2560    /// tradeOpened, tradesClosed and tradeReduced fields. This can be a positive or negative value and is
2561    /// represented in the home currency of the Account.
2562    #[serde(
2563        rename = "halfSpreadCost",
2564        default,
2565        skip_serializing_if = "Option::is_none"
2566    )]
2567    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
2568    pub half_spread_cost: Option<Decimal>,
2569}
2570
2571/// An OrderCancelTransaction represents the cancellation of an Order in the client’s Account.
2572#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2573#[serde(rename_all = "camelCase")]
2574pub struct OrderCancelTransaction {
2575    /// The Transaction’s Identifier.
2576    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2577    pub id: Option<TransactionID>,
2578    /// The date/time when the Transaction was created.
2579    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2580    pub time: Option<Timestamp>,
2581    /// The ID of the user that initiated the creation of the Transaction.
2582    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2583    pub user_id: Option<i64>,
2584    /// The ID of the Account the Transaction was created for.
2585    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2586    pub account_id: Option<AccountID>,
2587    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2588    /// Account simultaneously.
2589    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2590    pub batch_id: Option<TransactionID>,
2591    /// The Request ID of the request which generated the transaction.
2592    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2593    pub request_id: Option<RequestID>,
2594    /// The Type of the Transaction. Always set to “ORDER_CANCEL” for an OrderCancelTransaction.
2595    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2596    pub r#type: Option<TransactionType>,
2597    /// The ID of the Order cancelled
2598    #[serde(rename = "orderID", default, skip_serializing_if = "Option::is_none")]
2599    pub order_id: Option<OrderID>,
2600    /// The client ID of the Order cancelled (only provided if the Order has a client Order ID).
2601    #[serde(
2602        rename = "clientOrderID",
2603        default,
2604        skip_serializing_if = "Option::is_none"
2605    )]
2606    pub client_order_id: Option<OrderID>,
2607    /// The reason that the Order was cancelled.
2608    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
2609    pub reason: Option<OrderCancelReason>,
2610    /// The ID of the Order that replaced this Order (only provided if this Order was cancelled for replacement).
2611    #[serde(
2612        rename = "replacedByOrderID",
2613        default,
2614        skip_serializing_if = "Option::is_none"
2615    )]
2616    pub replaced_by_order_id: Option<OrderID>,
2617}
2618
2619/// An OrderCancelRejectTransaction represents the rejection of the cancellation of an Order in the client’s
2620/// Account.
2621#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2622#[serde(rename_all = "camelCase")]
2623pub struct OrderCancelRejectTransaction {
2624    /// The Transaction’s Identifier.
2625    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2626    pub id: Option<TransactionID>,
2627    /// The date/time when the Transaction was created.
2628    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2629    pub time: Option<Timestamp>,
2630    /// The ID of the user that initiated the creation of the Transaction.
2631    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2632    pub user_id: Option<i64>,
2633    /// The ID of the Account the Transaction was created for.
2634    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2635    pub account_id: Option<AccountID>,
2636    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2637    /// Account simultaneously.
2638    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2639    pub batch_id: Option<TransactionID>,
2640    /// The Request ID of the request which generated the transaction.
2641    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2642    pub request_id: Option<RequestID>,
2643    /// The Type of the Transaction. Always set to “ORDER_CANCEL_REJECT” for an OrderCancelRejectTransaction.
2644    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2645    pub r#type: Option<TransactionType>,
2646    /// The ID of the Order intended to be cancelled
2647    #[serde(rename = "orderID", default, skip_serializing_if = "Option::is_none")]
2648    pub order_id: Option<OrderID>,
2649    /// The client ID of the Order intended to be cancelled (only provided if the Order has a client Order ID).
2650    #[serde(
2651        rename = "clientOrderID",
2652        default,
2653        skip_serializing_if = "Option::is_none"
2654    )]
2655    pub client_order_id: Option<OrderID>,
2656    /// The reason that the Reject Transaction was created
2657    #[serde(
2658        rename = "rejectReason",
2659        default,
2660        skip_serializing_if = "Option::is_none"
2661    )]
2662    pub reject_reason: Option<TransactionRejectReason>,
2663}
2664
2665/// A OrderClientExtensionsModifyTransaction represents the modification of an Order’s Client Extensions.
2666#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2667#[serde(rename_all = "camelCase")]
2668pub struct OrderClientExtensionsModifyTransaction {
2669    /// The Transaction’s Identifier.
2670    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2671    pub id: Option<TransactionID>,
2672    /// The date/time when the Transaction was created.
2673    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2674    pub time: Option<Timestamp>,
2675    /// The ID of the user that initiated the creation of the Transaction.
2676    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2677    pub user_id: Option<i64>,
2678    /// The ID of the Account the Transaction was created for.
2679    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2680    pub account_id: Option<AccountID>,
2681    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2682    /// Account simultaneously.
2683    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2684    pub batch_id: Option<TransactionID>,
2685    /// The Request ID of the request which generated the transaction.
2686    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2687    pub request_id: Option<RequestID>,
2688    /// The Type of the Transaction. Always set to “ORDER_CLIENT_EXTENSIONS_MODIFY” for a
2689    /// OrderClientExtensionsModifyTransaction.
2690    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2691    pub r#type: Option<TransactionType>,
2692    /// The ID of the Order who’s client extensions are to be modified.
2693    #[serde(rename = "orderID", default, skip_serializing_if = "Option::is_none")]
2694    pub order_id: Option<OrderID>,
2695    /// The original Client ID of the Order who’s client extensions are to be modified.
2696    #[serde(
2697        rename = "clientOrderID",
2698        default,
2699        skip_serializing_if = "Option::is_none"
2700    )]
2701    pub client_order_id: Option<ClientID>,
2702    /// The new Client Extensions for the Order.
2703    #[serde(
2704        rename = "clientExtensionsModify",
2705        default,
2706        skip_serializing_if = "Option::is_none"
2707    )]
2708    pub client_extensions_modify: Option<ClientExtensions>,
2709    /// The new Client Extensions for the Order’s Trade on fill.
2710    #[serde(
2711        rename = "tradeClientExtensionsModify",
2712        default,
2713        skip_serializing_if = "Option::is_none"
2714    )]
2715    pub trade_client_extensions_modify: Option<ClientExtensions>,
2716}
2717
2718/// A OrderClientExtensionsModifyRejectTransaction represents the rejection of the modification of an
2719/// Order’s Client Extensions.
2720#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2721#[serde(rename_all = "camelCase")]
2722pub struct OrderClientExtensionsModifyRejectTransaction {
2723    /// The Transaction’s Identifier.
2724    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2725    pub id: Option<TransactionID>,
2726    /// The date/time when the Transaction was created.
2727    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2728    pub time: Option<Timestamp>,
2729    /// The ID of the user that initiated the creation of the Transaction.
2730    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2731    pub user_id: Option<i64>,
2732    /// The ID of the Account the Transaction was created for.
2733    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2734    pub account_id: Option<AccountID>,
2735    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2736    /// Account simultaneously.
2737    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2738    pub batch_id: Option<TransactionID>,
2739    /// The Request ID of the request which generated the transaction.
2740    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2741    pub request_id: Option<RequestID>,
2742    /// The Type of the Transaction. Always set to “ORDER_CLIENT_EXTENSIONS_MODIFY_REJECT” for a
2743    /// OrderClientExtensionsModifyRejectTransaction.
2744    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2745    pub r#type: Option<TransactionType>,
2746    /// The ID of the Order who’s client extensions are to be modified.
2747    #[serde(rename = "orderID", default, skip_serializing_if = "Option::is_none")]
2748    pub order_id: Option<OrderID>,
2749    /// The original Client ID of the Order who’s client extensions are to be modified.
2750    #[serde(
2751        rename = "clientOrderID",
2752        default,
2753        skip_serializing_if = "Option::is_none"
2754    )]
2755    pub client_order_id: Option<ClientID>,
2756    /// The new Client Extensions for the Order.
2757    #[serde(
2758        rename = "clientExtensionsModify",
2759        default,
2760        skip_serializing_if = "Option::is_none"
2761    )]
2762    pub client_extensions_modify: Option<ClientExtensions>,
2763    /// The new Client Extensions for the Order’s Trade on fill.
2764    #[serde(
2765        rename = "tradeClientExtensionsModify",
2766        default,
2767        skip_serializing_if = "Option::is_none"
2768    )]
2769    pub trade_client_extensions_modify: Option<ClientExtensions>,
2770    /// The reason that the Reject Transaction was created
2771    #[serde(
2772        rename = "rejectReason",
2773        default,
2774        skip_serializing_if = "Option::is_none"
2775    )]
2776    pub reject_reason: Option<TransactionRejectReason>,
2777}
2778
2779/// A TradeClientExtensionsModifyTransaction represents the modification of a Trade’s Client Extensions.
2780#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2781#[serde(rename_all = "camelCase")]
2782pub struct TradeClientExtensionsModifyTransaction {
2783    /// The Transaction’s Identifier.
2784    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2785    pub id: Option<TransactionID>,
2786    /// The date/time when the Transaction was created.
2787    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2788    pub time: Option<Timestamp>,
2789    /// The ID of the user that initiated the creation of the Transaction.
2790    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2791    pub user_id: Option<i64>,
2792    /// The ID of the Account the Transaction was created for.
2793    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2794    pub account_id: Option<AccountID>,
2795    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2796    /// Account simultaneously.
2797    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2798    pub batch_id: Option<TransactionID>,
2799    /// The Request ID of the request which generated the transaction.
2800    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2801    pub request_id: Option<RequestID>,
2802    /// The Type of the Transaction. Always set to “TRADE_CLIENT_EXTENSIONS_MODIFY” for a
2803    /// TradeClientExtensionsModifyTransaction.
2804    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2805    pub r#type: Option<TransactionType>,
2806    /// The ID of the Trade who’s client extensions are to be modified.
2807    #[serde(rename = "tradeID", default, skip_serializing_if = "Option::is_none")]
2808    pub trade_id: Option<TradeID>,
2809    /// The original Client ID of the Trade who’s client extensions are to be modified.
2810    #[serde(
2811        rename = "clientTradeID",
2812        default,
2813        skip_serializing_if = "Option::is_none"
2814    )]
2815    pub client_trade_id: Option<ClientID>,
2816    /// The new Client Extensions for the Trade.
2817    #[serde(
2818        rename = "tradeClientExtensionsModify",
2819        default,
2820        skip_serializing_if = "Option::is_none"
2821    )]
2822    pub trade_client_extensions_modify: Option<ClientExtensions>,
2823}
2824
2825/// A TradeClientExtensionsModifyRejectTransaction represents the rejection of the modification of a Trade’s
2826/// Client Extensions.
2827#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2828#[serde(rename_all = "camelCase")]
2829pub struct TradeClientExtensionsModifyRejectTransaction {
2830    /// The Transaction’s Identifier.
2831    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2832    pub id: Option<TransactionID>,
2833    /// The date/time when the Transaction was created.
2834    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2835    pub time: Option<Timestamp>,
2836    /// The ID of the user that initiated the creation of the Transaction.
2837    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2838    pub user_id: Option<i64>,
2839    /// The ID of the Account the Transaction was created for.
2840    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2841    pub account_id: Option<AccountID>,
2842    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2843    /// Account simultaneously.
2844    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2845    pub batch_id: Option<TransactionID>,
2846    /// The Request ID of the request which generated the transaction.
2847    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2848    pub request_id: Option<RequestID>,
2849    /// The Type of the Transaction. Always set to “TRADE_CLIENT_EXTENSIONS_MODIFY_REJECT” for a
2850    /// TradeClientExtensionsModifyRejectTransaction.
2851    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2852    pub r#type: Option<TransactionType>,
2853    /// The ID of the Trade who’s client extensions are to be modified.
2854    #[serde(rename = "tradeID", default, skip_serializing_if = "Option::is_none")]
2855    pub trade_id: Option<TradeID>,
2856    /// The original Client ID of the Trade who’s client extensions are to be modified.
2857    #[serde(
2858        rename = "clientTradeID",
2859        default,
2860        skip_serializing_if = "Option::is_none"
2861    )]
2862    pub client_trade_id: Option<ClientID>,
2863    /// The new Client Extensions for the Trade.
2864    #[serde(
2865        rename = "tradeClientExtensionsModify",
2866        default,
2867        skip_serializing_if = "Option::is_none"
2868    )]
2869    pub trade_client_extensions_modify: Option<ClientExtensions>,
2870    /// The reason that the Reject Transaction was created
2871    #[serde(
2872        rename = "rejectReason",
2873        default,
2874        skip_serializing_if = "Option::is_none"
2875    )]
2876    pub reject_reason: Option<TransactionRejectReason>,
2877}
2878
2879/// A MarginCallEnterTransaction is created when an Account enters the margin call state.
2880#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2881#[serde(rename_all = "camelCase")]
2882pub struct MarginCallEnterTransaction {
2883    /// The Transaction’s Identifier.
2884    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2885    pub id: Option<TransactionID>,
2886    /// The date/time when the Transaction was created.
2887    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2888    pub time: Option<Timestamp>,
2889    /// The ID of the user that initiated the creation of the Transaction.
2890    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2891    pub user_id: Option<i64>,
2892    /// The ID of the Account the Transaction was created for.
2893    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2894    pub account_id: Option<AccountID>,
2895    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2896    /// Account simultaneously.
2897    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2898    pub batch_id: Option<TransactionID>,
2899    /// The Request ID of the request which generated the transaction.
2900    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2901    pub request_id: Option<RequestID>,
2902    /// The Type of the Transaction. Always set to “MARGIN_CALL_ENTER” for an MarginCallEnterTransaction.
2903    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2904    pub r#type: Option<TransactionType>,
2905}
2906
2907/// A MarginCallExtendTransaction is created when the margin call state for an Account has been extended.
2908#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2909#[serde(rename_all = "camelCase")]
2910pub struct MarginCallExtendTransaction {
2911    /// The Transaction’s Identifier.
2912    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2913    pub id: Option<TransactionID>,
2914    /// The date/time when the Transaction was created.
2915    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2916    pub time: Option<Timestamp>,
2917    /// The ID of the user that initiated the creation of the Transaction.
2918    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2919    pub user_id: Option<i64>,
2920    /// The ID of the Account the Transaction was created for.
2921    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2922    pub account_id: Option<AccountID>,
2923    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2924    /// Account simultaneously.
2925    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2926    pub batch_id: Option<TransactionID>,
2927    /// The Request ID of the request which generated the transaction.
2928    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2929    pub request_id: Option<RequestID>,
2930    /// The Type of the Transaction. Always set to “MARGIN_CALL_EXTEND” for an MarginCallExtendTransaction.
2931    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2932    pub r#type: Option<TransactionType>,
2933    /// The number of the extensions to the Account’s current margin call that have been applied. This value
2934    /// will be set to 1 for the first MarginCallExtend Transaction
2935    #[serde(
2936        rename = "extensionNumber",
2937        default,
2938        skip_serializing_if = "Option::is_none"
2939    )]
2940    pub extension_number: Option<i64>,
2941}
2942
2943/// A MarginCallExitTransaction is created when an Account leaves the margin call state.
2944#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2945#[serde(rename_all = "camelCase")]
2946pub struct MarginCallExitTransaction {
2947    /// The Transaction’s Identifier.
2948    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2949    pub id: Option<TransactionID>,
2950    /// The date/time when the Transaction was created.
2951    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2952    pub time: Option<Timestamp>,
2953    /// The ID of the user that initiated the creation of the Transaction.
2954    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2955    pub user_id: Option<i64>,
2956    /// The ID of the Account the Transaction was created for.
2957    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2958    pub account_id: Option<AccountID>,
2959    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2960    /// Account simultaneously.
2961    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2962    pub batch_id: Option<TransactionID>,
2963    /// The Request ID of the request which generated the transaction.
2964    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2965    pub request_id: Option<RequestID>,
2966    /// The Type of the Transaction. Always set to “MARGIN_CALL_EXIT” for an MarginCallExitTransaction.
2967    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2968    pub r#type: Option<TransactionType>,
2969}
2970
2971/// A DelayedTradeClosure Transaction is created administratively to indicate open trades that should have
2972/// been closed but weren’t because the open trades’ instruments were untradeable at the time. Open trades
2973/// listed in this transaction will be closed once their respective instruments become tradeable.
2974#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2975#[serde(rename_all = "camelCase")]
2976pub struct DelayedTradeClosureTransaction {
2977    /// The Transaction’s Identifier.
2978    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
2979    pub id: Option<TransactionID>,
2980    /// The date/time when the Transaction was created.
2981    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
2982    pub time: Option<Timestamp>,
2983    /// The ID of the user that initiated the creation of the Transaction.
2984    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
2985    pub user_id: Option<i64>,
2986    /// The ID of the Account the Transaction was created for.
2987    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
2988    pub account_id: Option<AccountID>,
2989    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
2990    /// Account simultaneously.
2991    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
2992    pub batch_id: Option<TransactionID>,
2993    /// The Request ID of the request which generated the transaction.
2994    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
2995    pub request_id: Option<RequestID>,
2996    /// The Type of the Transaction. Always set to “DELAYED_TRADE_CLOSURE” for an DelayedTradeClosureTransaction.
2997    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2998    pub r#type: Option<TransactionType>,
2999    /// The reason for the delayed trade closure
3000    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
3001    pub reason: Option<MarketOrderReason>,
3002    /// List of Trade ID’s identifying the open trades that will be closed when their respective instruments
3003    /// become tradeable
3004    #[serde(rename = "tradeIDs", default, skip_serializing_if = "Option::is_none")]
3005    pub trade_ids: Option<TradeID>,
3006}
3007
3008/// A DailyFinancingTransaction represents the daily payment/collection of financing for an Account.
3009#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3010#[serde(rename_all = "camelCase")]
3011pub struct DailyFinancingTransaction {
3012    /// The Transaction’s Identifier.
3013    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
3014    pub id: Option<TransactionID>,
3015    /// The date/time when the Transaction was created.
3016    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
3017    pub time: Option<Timestamp>,
3018    /// The ID of the user that initiated the creation of the Transaction.
3019    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
3020    pub user_id: Option<i64>,
3021    /// The ID of the Account the Transaction was created for.
3022    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
3023    pub account_id: Option<AccountID>,
3024    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
3025    /// Account simultaneously.
3026    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
3027    pub batch_id: Option<TransactionID>,
3028    /// The Request ID of the request which generated the transaction.
3029    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
3030    pub request_id: Option<RequestID>,
3031    /// The Type of the Transaction. Always set to “DAILY_FINANCING” for a DailyFinancingTransaction.
3032    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
3033    pub r#type: Option<TransactionType>,
3034    /// The amount of financing paid/collected for the Account.
3035    #[serde(rename = "financing", default, skip_serializing_if = "Option::is_none")]
3036    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
3037    pub financing: Option<Decimal>,
3038    /// The Account’s balance after daily financing.
3039    #[serde(
3040        rename = "accountBalance",
3041        default,
3042        skip_serializing_if = "Option::is_none"
3043    )]
3044    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
3045    pub account_balance: Option<Decimal>,
3046    /// The account financing mode at the time of the daily financing. This field is no longer in use moving
3047    /// forward and was replaced by accountFinancingMode in individual positionFinancings since the financing
3048    /// mode could differ between instruments. Deprecated: Will be removed in a future API update.
3049    #[serde(
3050        rename = "accountFinancingMode",
3051        default,
3052        skip_serializing_if = "Option::is_none"
3053    )]
3054    pub account_financing_mode: Option<AccountFinancingMode>,
3055    /// The financing paid/collected for each Position in the Account.
3056    #[serde(
3057        rename = "positionFinancings",
3058        default,
3059        skip_serializing_if = "Option::is_none"
3060    )]
3061    pub position_financings: Option<Vec<PositionFinancing>>,
3062}
3063
3064/// A DividendAdjustment Transaction is created administratively to pay or collect dividend adjustment
3065/// mounts to or from an Account.
3066#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3067#[serde(rename_all = "camelCase")]
3068pub struct DividendAdjustmentTransaction {
3069    /// The Transaction’s Identifier.
3070    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
3071    pub id: Option<TransactionID>,
3072    /// The date/time when the Transaction was created.
3073    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
3074    pub time: Option<Timestamp>,
3075    /// The ID of the user that initiated the creation of the Transaction.
3076    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
3077    pub user_id: Option<i64>,
3078    /// The ID of the Account the Transaction was created for.
3079    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
3080    pub account_id: Option<AccountID>,
3081    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
3082    /// Account simultaneously.
3083    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
3084    pub batch_id: Option<TransactionID>,
3085    /// The Request ID of the request which generated the transaction.
3086    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
3087    pub request_id: Option<RequestID>,
3088    /// The Type of the Transaction. Always set to “DIVIDEND_ADJUSTMENT” for a DividendAdjustmentTransaction.
3089    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
3090    pub r#type: Option<TransactionType>,
3091    /// The name of the instrument for the dividendAdjustment transaction
3092    #[serde(
3093        rename = "instrument",
3094        default,
3095        skip_serializing_if = "Option::is_none"
3096    )]
3097    pub instrument: Option<InstrumentName>,
3098    /// The total dividend adjustment amount paid or collected in the Account’s home currency for the Account as
3099    /// a result of applying the DividendAdjustment Transaction. This is the sum of the dividend adjustments
3100    /// paid/collected for each OpenTradeDividendAdjustment found within the Transaction.
3101    #[serde(
3102        rename = "dividendAdjustment",
3103        default,
3104        skip_serializing_if = "Option::is_none"
3105    )]
3106    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
3107    pub dividend_adjustment: Option<Decimal>,
3108    /// The total dividend adjustment amount paid or collected in the Instrument’s quote currency for the
3109    /// Account as a result of applying the DividendAdjustment Transaction. This is the sum of the quote
3110    /// dividend adjustments paid/collected for each OpenTradeDividendAdjustment found within the Transaction.
3111    #[serde(
3112        rename = "quoteDividendAdjustment",
3113        default,
3114        skip_serializing_if = "Option::is_none"
3115    )]
3116    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
3117    pub quote_dividend_adjustment: Option<Decimal>,
3118    /// The HomeConversionFactors in effect at the time of the DividendAdjustment.
3119    #[serde(
3120        rename = "homeConversionFactors",
3121        default,
3122        skip_serializing_if = "Option::is_none"
3123    )]
3124    pub home_conversion_factors: Option<HomeConversionFactors>,
3125    /// The Account balance after applying the DividendAdjustment Transaction
3126    #[serde(
3127        rename = "accountBalance",
3128        default,
3129        skip_serializing_if = "Option::is_none"
3130    )]
3131    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
3132    pub account_balance: Option<Decimal>,
3133    /// The dividend adjustment payment/collection details for each open Trade, within the Account, for which a
3134    /// dividend adjustment is to be paid or collected.
3135    #[serde(
3136        rename = "openTradeDividendAdjustments",
3137        default,
3138        skip_serializing_if = "Option::is_none"
3139    )]
3140    pub open_trade_dividend_adjustments: Option<Vec<OpenTradeDividendAdjustment>>,
3141}
3142
3143/// A ResetResettablePLTransaction represents the resetting of the Account’s resettable PL counters.
3144#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3145#[serde(rename_all = "camelCase")]
3146pub struct ResetResettablePLTransaction {
3147    /// The Transaction’s Identifier.
3148    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
3149    pub id: Option<TransactionID>,
3150    /// The date/time when the Transaction was created.
3151    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
3152    pub time: Option<Timestamp>,
3153    /// The ID of the user that initiated the creation of the Transaction.
3154    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
3155    pub user_id: Option<i64>,
3156    /// The ID of the Account the Transaction was created for.
3157    #[serde(rename = "accountID", default, skip_serializing_if = "Option::is_none")]
3158    pub account_id: Option<AccountID>,
3159    /// The ID of the “batch” that the Transaction belongs to. Transactions in the same batch are applied to the
3160    /// Account simultaneously.
3161    #[serde(rename = "batchID", default, skip_serializing_if = "Option::is_none")]
3162    pub batch_id: Option<TransactionID>,
3163    /// The Request ID of the request which generated the transaction.
3164    #[serde(rename = "requestID", default, skip_serializing_if = "Option::is_none")]
3165    pub request_id: Option<RequestID>,
3166    /// The Type of the Transaction. Always set to “RESET_RESETTABLE_PL” for a ResetResettablePLTransaction.
3167    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
3168    pub r#type: Option<TransactionType>,
3169}
3170
3171/// The possible types of a Transaction
3172#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3173#[non_exhaustive]
3174pub enum TransactionType {
3175    /// Account Create Transaction
3176    Create,
3177    /// Account Close Transaction
3178    Close,
3179    /// Account Reopen Transaction
3180    Reopen,
3181    /// Client Configuration Transaction
3182    ClientConfigure,
3183    /// Client Configuration Reject Transaction
3184    ClientConfigureReject,
3185    /// Transfer Funds Transaction
3186    TransferFunds,
3187    /// Transfer Funds Reject Transaction
3188    TransferFundsReject,
3189    /// Market Order Transaction
3190    MarketOrder,
3191    /// Market Order Reject Transaction
3192    MarketOrderReject,
3193    /// Fixed Price Order Transaction
3194    FixedPriceOrder,
3195    /// Limit Order Transaction
3196    LimitOrder,
3197    /// Limit Order Reject Transaction
3198    LimitOrderReject,
3199    /// Stop Order Transaction
3200    StopOrder,
3201    /// Stop Order Reject Transaction
3202    StopOrderReject,
3203    /// Market if Touched Order Transaction
3204    MarketIfTouchedOrder,
3205    /// Market if Touched Order Reject Transaction
3206    MarketIfTouchedOrderReject,
3207    /// Take Profit Order Transaction
3208    TakeProfitOrder,
3209    /// Take Profit Order Reject Transaction
3210    TakeProfitOrderReject,
3211    /// Stop Loss Order Transaction
3212    StopLossOrder,
3213    /// Stop Loss Order Reject Transaction
3214    StopLossOrderReject,
3215    /// Guaranteed Stop Loss Order Transaction
3216    GuaranteedStopLossOrder,
3217    /// Guaranteed Stop Loss Order Reject Transaction
3218    GuaranteedStopLossOrderReject,
3219    /// Trailing Stop Loss Order Transaction
3220    TrailingStopLossOrder,
3221    /// Trailing Stop Loss Order Reject Transaction
3222    TrailingStopLossOrderReject,
3223    /// Order Fill Transaction
3224    OrderFill,
3225    /// Order Cancel Transaction
3226    OrderCancel,
3227    /// Order Cancel Reject Transaction
3228    OrderCancelReject,
3229    /// Order Client Extensions Modify Transaction
3230    OrderClientExtensionsModify,
3231    /// Order Client Extensions Modify Reject Transaction
3232    OrderClientExtensionsModifyReject,
3233    /// Trade Client Extensions Modify Transaction
3234    TradeClientExtensionsModify,
3235    /// Trade Client Extensions Modify Reject Transaction
3236    TradeClientExtensionsModifyReject,
3237    /// Margin Call Enter Transaction
3238    MarginCallEnter,
3239    /// Margin Call Extend Transaction
3240    MarginCallExtend,
3241    /// Margin Call Exit Transaction
3242    MarginCallExit,
3243    /// Delayed Trade Closure Transaction
3244    DelayedTradeClosure,
3245    /// Daily Financing Transaction
3246    DailyFinancing,
3247    /// Dividend Adjustment Transaction
3248    DividendAdjustment,
3249    /// Reset Resettable PL Transaction
3250    ResetResettablePl,
3251    /// An unrecognized provider value, preserved for forward compatibility.
3252    Unknown(String),
3253}
3254
3255impl TransactionType {
3256    /// Return the exact provider spelling.
3257    pub fn as_str(&self) -> &str {
3258        match self {
3259            Self::Create => "CREATE",
3260            Self::Close => "CLOSE",
3261            Self::Reopen => "REOPEN",
3262            Self::ClientConfigure => "CLIENT_CONFIGURE",
3263            Self::ClientConfigureReject => "CLIENT_CONFIGURE_REJECT",
3264            Self::TransferFunds => "TRANSFER_FUNDS",
3265            Self::TransferFundsReject => "TRANSFER_FUNDS_REJECT",
3266            Self::MarketOrder => "MARKET_ORDER",
3267            Self::MarketOrderReject => "MARKET_ORDER_REJECT",
3268            Self::FixedPriceOrder => "FIXED_PRICE_ORDER",
3269            Self::LimitOrder => "LIMIT_ORDER",
3270            Self::LimitOrderReject => "LIMIT_ORDER_REJECT",
3271            Self::StopOrder => "STOP_ORDER",
3272            Self::StopOrderReject => "STOP_ORDER_REJECT",
3273            Self::MarketIfTouchedOrder => "MARKET_IF_TOUCHED_ORDER",
3274            Self::MarketIfTouchedOrderReject => "MARKET_IF_TOUCHED_ORDER_REJECT",
3275            Self::TakeProfitOrder => "TAKE_PROFIT_ORDER",
3276            Self::TakeProfitOrderReject => "TAKE_PROFIT_ORDER_REJECT",
3277            Self::StopLossOrder => "STOP_LOSS_ORDER",
3278            Self::StopLossOrderReject => "STOP_LOSS_ORDER_REJECT",
3279            Self::GuaranteedStopLossOrder => "GUARANTEED_STOP_LOSS_ORDER",
3280            Self::GuaranteedStopLossOrderReject => "GUARANTEED_STOP_LOSS_ORDER_REJECT",
3281            Self::TrailingStopLossOrder => "TRAILING_STOP_LOSS_ORDER",
3282            Self::TrailingStopLossOrderReject => "TRAILING_STOP_LOSS_ORDER_REJECT",
3283            Self::OrderFill => "ORDER_FILL",
3284            Self::OrderCancel => "ORDER_CANCEL",
3285            Self::OrderCancelReject => "ORDER_CANCEL_REJECT",
3286            Self::OrderClientExtensionsModify => "ORDER_CLIENT_EXTENSIONS_MODIFY",
3287            Self::OrderClientExtensionsModifyReject => "ORDER_CLIENT_EXTENSIONS_MODIFY_REJECT",
3288            Self::TradeClientExtensionsModify => "TRADE_CLIENT_EXTENSIONS_MODIFY",
3289            Self::TradeClientExtensionsModifyReject => "TRADE_CLIENT_EXTENSIONS_MODIFY_REJECT",
3290            Self::MarginCallEnter => "MARGIN_CALL_ENTER",
3291            Self::MarginCallExtend => "MARGIN_CALL_EXTEND",
3292            Self::MarginCallExit => "MARGIN_CALL_EXIT",
3293            Self::DelayedTradeClosure => "DELAYED_TRADE_CLOSURE",
3294            Self::DailyFinancing => "DAILY_FINANCING",
3295            Self::DividendAdjustment => "DIVIDEND_ADJUSTMENT",
3296            Self::ResetResettablePl => "RESET_RESETTABLE_PL",
3297            Self::Unknown(value) => value,
3298        }
3299    }
3300}
3301
3302impl Serialize for TransactionType {
3303    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3304        serializer.serialize_str(self.as_str())
3305    }
3306}
3307
3308impl<'de> Deserialize<'de> for TransactionType {
3309    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3310        let value = String::deserialize(deserializer)?;
3311        Ok(match value.as_str() {
3312            "CREATE" => Self::Create,
3313            "CLOSE" => Self::Close,
3314            "REOPEN" => Self::Reopen,
3315            "CLIENT_CONFIGURE" => Self::ClientConfigure,
3316            "CLIENT_CONFIGURE_REJECT" => Self::ClientConfigureReject,
3317            "TRANSFER_FUNDS" => Self::TransferFunds,
3318            "TRANSFER_FUNDS_REJECT" => Self::TransferFundsReject,
3319            "MARKET_ORDER" => Self::MarketOrder,
3320            "MARKET_ORDER_REJECT" => Self::MarketOrderReject,
3321            "FIXED_PRICE_ORDER" => Self::FixedPriceOrder,
3322            "LIMIT_ORDER" => Self::LimitOrder,
3323            "LIMIT_ORDER_REJECT" => Self::LimitOrderReject,
3324            "STOP_ORDER" => Self::StopOrder,
3325            "STOP_ORDER_REJECT" => Self::StopOrderReject,
3326            "MARKET_IF_TOUCHED_ORDER" => Self::MarketIfTouchedOrder,
3327            "MARKET_IF_TOUCHED_ORDER_REJECT" => Self::MarketIfTouchedOrderReject,
3328            "TAKE_PROFIT_ORDER" => Self::TakeProfitOrder,
3329            "TAKE_PROFIT_ORDER_REJECT" => Self::TakeProfitOrderReject,
3330            "STOP_LOSS_ORDER" => Self::StopLossOrder,
3331            "STOP_LOSS_ORDER_REJECT" => Self::StopLossOrderReject,
3332            "GUARANTEED_STOP_LOSS_ORDER" => Self::GuaranteedStopLossOrder,
3333            "GUARANTEED_STOP_LOSS_ORDER_REJECT" => Self::GuaranteedStopLossOrderReject,
3334            "TRAILING_STOP_LOSS_ORDER" => Self::TrailingStopLossOrder,
3335            "TRAILING_STOP_LOSS_ORDER_REJECT" => Self::TrailingStopLossOrderReject,
3336            "ORDER_FILL" => Self::OrderFill,
3337            "ORDER_CANCEL" => Self::OrderCancel,
3338            "ORDER_CANCEL_REJECT" => Self::OrderCancelReject,
3339            "ORDER_CLIENT_EXTENSIONS_MODIFY" => Self::OrderClientExtensionsModify,
3340            "ORDER_CLIENT_EXTENSIONS_MODIFY_REJECT" => Self::OrderClientExtensionsModifyReject,
3341            "TRADE_CLIENT_EXTENSIONS_MODIFY" => Self::TradeClientExtensionsModify,
3342            "TRADE_CLIENT_EXTENSIONS_MODIFY_REJECT" => Self::TradeClientExtensionsModifyReject,
3343            "MARGIN_CALL_ENTER" => Self::MarginCallEnter,
3344            "MARGIN_CALL_EXTEND" => Self::MarginCallExtend,
3345            "MARGIN_CALL_EXIT" => Self::MarginCallExit,
3346            "DELAYED_TRADE_CLOSURE" => Self::DelayedTradeClosure,
3347            "DAILY_FINANCING" => Self::DailyFinancing,
3348            "DIVIDEND_ADJUSTMENT" => Self::DividendAdjustment,
3349            "RESET_RESETTABLE_PL" => Self::ResetResettablePl,
3350            _ => Self::Unknown(value),
3351        })
3352    }
3353}
3354
3355/// The reason that an Account is being funded.
3356#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3357#[non_exhaustive]
3358pub enum FundingReason {
3359    /// The client has initiated a funds transfer
3360    ClientFunding,
3361    /// Funds are being transferred between two Accounts.
3362    AccountTransfer,
3363    /// Funds are being transferred as part of a Division migration
3364    DivisionMigration,
3365    /// Funds are being transferred as part of a Site migration
3366    SiteMigration,
3367    /// Funds are being transferred as part of an Account adjustment
3368    Adjustment,
3369    /// An unrecognized provider value, preserved for forward compatibility.
3370    Unknown(String),
3371}
3372
3373impl FundingReason {
3374    /// Return the exact provider spelling.
3375    pub fn as_str(&self) -> &str {
3376        match self {
3377            Self::ClientFunding => "CLIENT_FUNDING",
3378            Self::AccountTransfer => "ACCOUNT_TRANSFER",
3379            Self::DivisionMigration => "DIVISION_MIGRATION",
3380            Self::SiteMigration => "SITE_MIGRATION",
3381            Self::Adjustment => "ADJUSTMENT",
3382            Self::Unknown(value) => value,
3383        }
3384    }
3385}
3386
3387impl Serialize for FundingReason {
3388    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3389        serializer.serialize_str(self.as_str())
3390    }
3391}
3392
3393impl<'de> Deserialize<'de> for FundingReason {
3394    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3395        let value = String::deserialize(deserializer)?;
3396        Ok(match value.as_str() {
3397            "CLIENT_FUNDING" => Self::ClientFunding,
3398            "ACCOUNT_TRANSFER" => Self::AccountTransfer,
3399            "DIVISION_MIGRATION" => Self::DivisionMigration,
3400            "SITE_MIGRATION" => Self::SiteMigration,
3401            "ADJUSTMENT" => Self::Adjustment,
3402            _ => Self::Unknown(value),
3403        })
3404    }
3405}
3406
3407/// The reason that the Market Order was created
3408#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3409#[non_exhaustive]
3410pub enum MarketOrderReason {
3411    /// The Market Order was created at the request of a client
3412    ClientOrder,
3413    /// The Market Order was created to close a Trade at the request of a client
3414    TradeClose,
3415    /// The Market Order was created to close a Position at the request of a client
3416    PositionCloseout,
3417    /// The Market Order was created as part of a Margin Closeout
3418    MarginCloseout,
3419    /// The Market Order was created to close a trade marked for delayed closure
3420    DelayedTradeClose,
3421    /// An unrecognized provider value, preserved for forward compatibility.
3422    Unknown(String),
3423}
3424
3425impl MarketOrderReason {
3426    /// Return the exact provider spelling.
3427    pub fn as_str(&self) -> &str {
3428        match self {
3429            Self::ClientOrder => "CLIENT_ORDER",
3430            Self::TradeClose => "TRADE_CLOSE",
3431            Self::PositionCloseout => "POSITION_CLOSEOUT",
3432            Self::MarginCloseout => "MARGIN_CLOSEOUT",
3433            Self::DelayedTradeClose => "DELAYED_TRADE_CLOSE",
3434            Self::Unknown(value) => value,
3435        }
3436    }
3437}
3438
3439impl Serialize for MarketOrderReason {
3440    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3441        serializer.serialize_str(self.as_str())
3442    }
3443}
3444
3445impl<'de> Deserialize<'de> for MarketOrderReason {
3446    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3447        let value = String::deserialize(deserializer)?;
3448        Ok(match value.as_str() {
3449            "CLIENT_ORDER" => Self::ClientOrder,
3450            "TRADE_CLOSE" => Self::TradeClose,
3451            "POSITION_CLOSEOUT" => Self::PositionCloseout,
3452            "MARGIN_CLOSEOUT" => Self::MarginCloseout,
3453            "DELAYED_TRADE_CLOSE" => Self::DelayedTradeClose,
3454            _ => Self::Unknown(value),
3455        })
3456    }
3457}
3458
3459/// The reason that the Fixed Price Order was created
3460#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3461#[non_exhaustive]
3462pub enum FixedPriceOrderReason {
3463    /// The Fixed Price Order was created as part of a platform account migration
3464    PlatformAccountMigration,
3465    /// The Fixed Price Order was created to close a Trade as part of division account migration
3466    TradeCloseDivisionAccountMigration,
3467    /// The Fixed Price Order was created to close a Trade administratively
3468    TradeCloseAdministrativeAction,
3469    /// An unrecognized provider value, preserved for forward compatibility.
3470    Unknown(String),
3471}
3472
3473impl FixedPriceOrderReason {
3474    /// Return the exact provider spelling.
3475    pub fn as_str(&self) -> &str {
3476        match self {
3477            Self::PlatformAccountMigration => "PLATFORM_ACCOUNT_MIGRATION",
3478            Self::TradeCloseDivisionAccountMigration => "TRADE_CLOSE_DIVISION_ACCOUNT_MIGRATION",
3479            Self::TradeCloseAdministrativeAction => "TRADE_CLOSE_ADMINISTRATIVE_ACTION",
3480            Self::Unknown(value) => value,
3481        }
3482    }
3483}
3484
3485impl Serialize for FixedPriceOrderReason {
3486    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3487        serializer.serialize_str(self.as_str())
3488    }
3489}
3490
3491impl<'de> Deserialize<'de> for FixedPriceOrderReason {
3492    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3493        let value = String::deserialize(deserializer)?;
3494        Ok(match value.as_str() {
3495            "PLATFORM_ACCOUNT_MIGRATION" => Self::PlatformAccountMigration,
3496            "TRADE_CLOSE_DIVISION_ACCOUNT_MIGRATION" => Self::TradeCloseDivisionAccountMigration,
3497            "TRADE_CLOSE_ADMINISTRATIVE_ACTION" => Self::TradeCloseAdministrativeAction,
3498            _ => Self::Unknown(value),
3499        })
3500    }
3501}
3502
3503/// The reason that the Limit Order was initiated
3504#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3505#[non_exhaustive]
3506pub enum LimitOrderReason {
3507    /// The Limit Order was initiated at the request of a client
3508    ClientOrder,
3509    /// The Limit Order was initiated as a replacement for an existing Order
3510    Replacement,
3511    /// An unrecognized provider value, preserved for forward compatibility.
3512    Unknown(String),
3513}
3514
3515impl LimitOrderReason {
3516    /// Return the exact provider spelling.
3517    pub fn as_str(&self) -> &str {
3518        match self {
3519            Self::ClientOrder => "CLIENT_ORDER",
3520            Self::Replacement => "REPLACEMENT",
3521            Self::Unknown(value) => value,
3522        }
3523    }
3524}
3525
3526impl Serialize for LimitOrderReason {
3527    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3528        serializer.serialize_str(self.as_str())
3529    }
3530}
3531
3532impl<'de> Deserialize<'de> for LimitOrderReason {
3533    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3534        let value = String::deserialize(deserializer)?;
3535        Ok(match value.as_str() {
3536            "CLIENT_ORDER" => Self::ClientOrder,
3537            "REPLACEMENT" => Self::Replacement,
3538            _ => Self::Unknown(value),
3539        })
3540    }
3541}
3542
3543/// The reason that the Stop Order was initiated
3544#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3545#[non_exhaustive]
3546pub enum StopOrderReason {
3547    /// The Stop Order was initiated at the request of a client
3548    ClientOrder,
3549    /// The Stop Order was initiated as a replacement for an existing Order
3550    Replacement,
3551    /// An unrecognized provider value, preserved for forward compatibility.
3552    Unknown(String),
3553}
3554
3555impl StopOrderReason {
3556    /// Return the exact provider spelling.
3557    pub fn as_str(&self) -> &str {
3558        match self {
3559            Self::ClientOrder => "CLIENT_ORDER",
3560            Self::Replacement => "REPLACEMENT",
3561            Self::Unknown(value) => value,
3562        }
3563    }
3564}
3565
3566impl Serialize for StopOrderReason {
3567    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3568        serializer.serialize_str(self.as_str())
3569    }
3570}
3571
3572impl<'de> Deserialize<'de> for StopOrderReason {
3573    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3574        let value = String::deserialize(deserializer)?;
3575        Ok(match value.as_str() {
3576            "CLIENT_ORDER" => Self::ClientOrder,
3577            "REPLACEMENT" => Self::Replacement,
3578            _ => Self::Unknown(value),
3579        })
3580    }
3581}
3582
3583/// The reason that the Market-if-touched Order was initiated
3584#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3585#[non_exhaustive]
3586pub enum MarketIfTouchedOrderReason {
3587    /// The Market-if-touched Order was initiated at the request of a client
3588    ClientOrder,
3589    /// The Market-if-touched Order was initiated as a replacement for an existing Order
3590    Replacement,
3591    /// An unrecognized provider value, preserved for forward compatibility.
3592    Unknown(String),
3593}
3594
3595impl MarketIfTouchedOrderReason {
3596    /// Return the exact provider spelling.
3597    pub fn as_str(&self) -> &str {
3598        match self {
3599            Self::ClientOrder => "CLIENT_ORDER",
3600            Self::Replacement => "REPLACEMENT",
3601            Self::Unknown(value) => value,
3602        }
3603    }
3604}
3605
3606impl Serialize for MarketIfTouchedOrderReason {
3607    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3608        serializer.serialize_str(self.as_str())
3609    }
3610}
3611
3612impl<'de> Deserialize<'de> for MarketIfTouchedOrderReason {
3613    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3614        let value = String::deserialize(deserializer)?;
3615        Ok(match value.as_str() {
3616            "CLIENT_ORDER" => Self::ClientOrder,
3617            "REPLACEMENT" => Self::Replacement,
3618            _ => Self::Unknown(value),
3619        })
3620    }
3621}
3622
3623/// The reason that the Take Profit Order was initiated
3624#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3625#[non_exhaustive]
3626pub enum TakeProfitOrderReason {
3627    /// The Take Profit Order was initiated at the request of a client
3628    ClientOrder,
3629    /// The Take Profit Order was initiated as a replacement for an existing Order
3630    Replacement,
3631    /// The Take Profit Order was initiated automatically when an Order was filled that opened a new Trade
3632    /// requiring a Take Profit Order.
3633    OnFill,
3634    /// An unrecognized provider value, preserved for forward compatibility.
3635    Unknown(String),
3636}
3637
3638impl TakeProfitOrderReason {
3639    /// Return the exact provider spelling.
3640    pub fn as_str(&self) -> &str {
3641        match self {
3642            Self::ClientOrder => "CLIENT_ORDER",
3643            Self::Replacement => "REPLACEMENT",
3644            Self::OnFill => "ON_FILL",
3645            Self::Unknown(value) => value,
3646        }
3647    }
3648}
3649
3650impl Serialize for TakeProfitOrderReason {
3651    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3652        serializer.serialize_str(self.as_str())
3653    }
3654}
3655
3656impl<'de> Deserialize<'de> for TakeProfitOrderReason {
3657    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3658        let value = String::deserialize(deserializer)?;
3659        Ok(match value.as_str() {
3660            "CLIENT_ORDER" => Self::ClientOrder,
3661            "REPLACEMENT" => Self::Replacement,
3662            "ON_FILL" => Self::OnFill,
3663            _ => Self::Unknown(value),
3664        })
3665    }
3666}
3667
3668/// The reason that the Stop Loss Order was initiated
3669#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3670#[non_exhaustive]
3671pub enum StopLossOrderReason {
3672    /// The Stop Loss Order was initiated at the request of a client
3673    ClientOrder,
3674    /// The Stop Loss Order was initiated as a replacement for an existing Order
3675    Replacement,
3676    /// The Stop Loss Order was initiated automatically when an Order was filled that opened a new Trade
3677    /// requiring a Stop Loss Order.
3678    OnFill,
3679    /// An unrecognized provider value, preserved for forward compatibility.
3680    Unknown(String),
3681}
3682
3683impl StopLossOrderReason {
3684    /// Return the exact provider spelling.
3685    pub fn as_str(&self) -> &str {
3686        match self {
3687            Self::ClientOrder => "CLIENT_ORDER",
3688            Self::Replacement => "REPLACEMENT",
3689            Self::OnFill => "ON_FILL",
3690            Self::Unknown(value) => value,
3691        }
3692    }
3693}
3694
3695impl Serialize for StopLossOrderReason {
3696    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3697        serializer.serialize_str(self.as_str())
3698    }
3699}
3700
3701impl<'de> Deserialize<'de> for StopLossOrderReason {
3702    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3703        let value = String::deserialize(deserializer)?;
3704        Ok(match value.as_str() {
3705            "CLIENT_ORDER" => Self::ClientOrder,
3706            "REPLACEMENT" => Self::Replacement,
3707            "ON_FILL" => Self::OnFill,
3708            _ => Self::Unknown(value),
3709        })
3710    }
3711}
3712
3713/// The reason that the Guaranteed Stop Loss Order was initiated
3714#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3715#[non_exhaustive]
3716pub enum GuaranteedStopLossOrderReason {
3717    /// The Guaranteed Stop Loss Order was initiated at the request of a client
3718    ClientOrder,
3719    /// The Guaranteed Stop Loss Order was initiated as a replacement for an existing Order
3720    Replacement,
3721    /// The Guaranteed Stop Loss Order was initiated automatically when an Order was filled that opened a new
3722    /// Trade requiring a Guaranteed Stop Loss Order.
3723    OnFill,
3724    /// An unrecognized provider value, preserved for forward compatibility.
3725    Unknown(String),
3726}
3727
3728impl GuaranteedStopLossOrderReason {
3729    /// Return the exact provider spelling.
3730    pub fn as_str(&self) -> &str {
3731        match self {
3732            Self::ClientOrder => "CLIENT_ORDER",
3733            Self::Replacement => "REPLACEMENT",
3734            Self::OnFill => "ON_FILL",
3735            Self::Unknown(value) => value,
3736        }
3737    }
3738}
3739
3740impl Serialize for GuaranteedStopLossOrderReason {
3741    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3742        serializer.serialize_str(self.as_str())
3743    }
3744}
3745
3746impl<'de> Deserialize<'de> for GuaranteedStopLossOrderReason {
3747    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3748        let value = String::deserialize(deserializer)?;
3749        Ok(match value.as_str() {
3750            "CLIENT_ORDER" => Self::ClientOrder,
3751            "REPLACEMENT" => Self::Replacement,
3752            "ON_FILL" => Self::OnFill,
3753            _ => Self::Unknown(value),
3754        })
3755    }
3756}
3757
3758/// The reason that the Trailing Stop Loss Order was initiated
3759#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3760#[non_exhaustive]
3761pub enum TrailingStopLossOrderReason {
3762    /// The Trailing Stop Loss Order was initiated at the request of a client
3763    ClientOrder,
3764    /// The Trailing Stop Loss Order was initiated as a replacement for an existing Order
3765    Replacement,
3766    /// The Trailing Stop Loss Order was initiated automatically when an Order was filled that opened a new
3767    /// Trade requiring a Trailing Stop Loss Order.
3768    OnFill,
3769    /// An unrecognized provider value, preserved for forward compatibility.
3770    Unknown(String),
3771}
3772
3773impl TrailingStopLossOrderReason {
3774    /// Return the exact provider spelling.
3775    pub fn as_str(&self) -> &str {
3776        match self {
3777            Self::ClientOrder => "CLIENT_ORDER",
3778            Self::Replacement => "REPLACEMENT",
3779            Self::OnFill => "ON_FILL",
3780            Self::Unknown(value) => value,
3781        }
3782    }
3783}
3784
3785impl Serialize for TrailingStopLossOrderReason {
3786    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3787        serializer.serialize_str(self.as_str())
3788    }
3789}
3790
3791impl<'de> Deserialize<'de> for TrailingStopLossOrderReason {
3792    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3793        let value = String::deserialize(deserializer)?;
3794        Ok(match value.as_str() {
3795            "CLIENT_ORDER" => Self::ClientOrder,
3796            "REPLACEMENT" => Self::Replacement,
3797            "ON_FILL" => Self::OnFill,
3798            _ => Self::Unknown(value),
3799        })
3800    }
3801}
3802
3803/// The reason that an Order was filled
3804#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3805#[non_exhaustive]
3806pub enum OrderFillReason {
3807    /// The Order filled was a Limit Order
3808    LimitOrder,
3809    /// The Order filled was a Stop Order
3810    StopOrder,
3811    /// The Order filled was a Market-if-touched Order
3812    MarketIfTouchedOrder,
3813    /// The Order filled was a Take Profit Order
3814    TakeProfitOrder,
3815    /// The Order filled was a Stop Loss Order
3816    StopLossOrder,
3817    /// The Order filled was a Guaranteed Stop Loss Order
3818    GuaranteedStopLossOrder,
3819    /// The Order filled was a Trailing Stop Loss Order
3820    TrailingStopLossOrder,
3821    /// The Order filled was a Market Order
3822    MarketOrder,
3823    /// The Order filled was a Market Order used to explicitly close a Trade
3824    MarketOrderTradeClose,
3825    /// The Order filled was a Market Order used to explicitly close a Position
3826    MarketOrderPositionCloseout,
3827    /// The Order filled was a Market Order used for a Margin Closeout
3828    MarketOrderMarginCloseout,
3829    /// The Order filled was a Market Order used for a delayed Trade close
3830    MarketOrderDelayedTradeClose,
3831    /// The Order filled was a Fixed Price Order
3832    FixedPriceOrder,
3833    /// The Order filled was a Fixed Price Order created as part of a platform account migration
3834    FixedPriceOrderPlatformAccountMigration,
3835    /// The Order filled was a Fixed Price Order created to close a Trade as part of division account migration
3836    FixedPriceOrderDivisionAccountMigration,
3837    /// The Order filled was a Fixed Price Order created to close a Trade administratively
3838    FixedPriceOrderAdministrativeAction,
3839    /// An unrecognized provider value, preserved for forward compatibility.
3840    Unknown(String),
3841}
3842
3843impl OrderFillReason {
3844    /// Return the exact provider spelling.
3845    pub fn as_str(&self) -> &str {
3846        match self {
3847            Self::LimitOrder => "LIMIT_ORDER",
3848            Self::StopOrder => "STOP_ORDER",
3849            Self::MarketIfTouchedOrder => "MARKET_IF_TOUCHED_ORDER",
3850            Self::TakeProfitOrder => "TAKE_PROFIT_ORDER",
3851            Self::StopLossOrder => "STOP_LOSS_ORDER",
3852            Self::GuaranteedStopLossOrder => "GUARANTEED_STOP_LOSS_ORDER",
3853            Self::TrailingStopLossOrder => "TRAILING_STOP_LOSS_ORDER",
3854            Self::MarketOrder => "MARKET_ORDER",
3855            Self::MarketOrderTradeClose => "MARKET_ORDER_TRADE_CLOSE",
3856            Self::MarketOrderPositionCloseout => "MARKET_ORDER_POSITION_CLOSEOUT",
3857            Self::MarketOrderMarginCloseout => "MARKET_ORDER_MARGIN_CLOSEOUT",
3858            Self::MarketOrderDelayedTradeClose => "MARKET_ORDER_DELAYED_TRADE_CLOSE",
3859            Self::FixedPriceOrder => "FIXED_PRICE_ORDER",
3860            Self::FixedPriceOrderPlatformAccountMigration => {
3861                "FIXED_PRICE_ORDER_PLATFORM_ACCOUNT_MIGRATION"
3862            }
3863            Self::FixedPriceOrderDivisionAccountMigration => {
3864                "FIXED_PRICE_ORDER_DIVISION_ACCOUNT_MIGRATION"
3865            }
3866            Self::FixedPriceOrderAdministrativeAction => "FIXED_PRICE_ORDER_ADMINISTRATIVE_ACTION",
3867            Self::Unknown(value) => value,
3868        }
3869    }
3870}
3871
3872impl Serialize for OrderFillReason {
3873    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3874        serializer.serialize_str(self.as_str())
3875    }
3876}
3877
3878impl<'de> Deserialize<'de> for OrderFillReason {
3879    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3880        let value = String::deserialize(deserializer)?;
3881        Ok(match value.as_str() {
3882            "LIMIT_ORDER" => Self::LimitOrder,
3883            "STOP_ORDER" => Self::StopOrder,
3884            "MARKET_IF_TOUCHED_ORDER" => Self::MarketIfTouchedOrder,
3885            "TAKE_PROFIT_ORDER" => Self::TakeProfitOrder,
3886            "STOP_LOSS_ORDER" => Self::StopLossOrder,
3887            "GUARANTEED_STOP_LOSS_ORDER" => Self::GuaranteedStopLossOrder,
3888            "TRAILING_STOP_LOSS_ORDER" => Self::TrailingStopLossOrder,
3889            "MARKET_ORDER" => Self::MarketOrder,
3890            "MARKET_ORDER_TRADE_CLOSE" => Self::MarketOrderTradeClose,
3891            "MARKET_ORDER_POSITION_CLOSEOUT" => Self::MarketOrderPositionCloseout,
3892            "MARKET_ORDER_MARGIN_CLOSEOUT" => Self::MarketOrderMarginCloseout,
3893            "MARKET_ORDER_DELAYED_TRADE_CLOSE" => Self::MarketOrderDelayedTradeClose,
3894            "FIXED_PRICE_ORDER" => Self::FixedPriceOrder,
3895            "FIXED_PRICE_ORDER_PLATFORM_ACCOUNT_MIGRATION" => {
3896                Self::FixedPriceOrderPlatformAccountMigration
3897            }
3898            "FIXED_PRICE_ORDER_DIVISION_ACCOUNT_MIGRATION" => {
3899                Self::FixedPriceOrderDivisionAccountMigration
3900            }
3901            "FIXED_PRICE_ORDER_ADMINISTRATIVE_ACTION" => Self::FixedPriceOrderAdministrativeAction,
3902            _ => Self::Unknown(value),
3903        })
3904    }
3905}
3906
3907/// The reason that an Order was cancelled.
3908#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3909#[non_exhaustive]
3910pub enum OrderCancelReason {
3911    /// The Order was cancelled because at the time of filling, an unexpected internal server error occurred.
3912    InternalServerError,
3913    /// The Order was cancelled because at the time of filling the account was locked.
3914    AccountLocked,
3915    /// The order was to be filled, however the account is configured to not allow new positions to be created.
3916    AccountNewPositionsLocked,
3917    /// Filling the Order wasn’t possible because it required the creation of a dependent Order and the Account
3918    /// is locked for Order creation.
3919    AccountOrderCreationLocked,
3920    /// Filling the Order was not possible because the Account is locked for filling Orders.
3921    AccountOrderFillLocked,
3922    /// The Order was cancelled explicitly at the request of the client.
3923    ClientRequest,
3924    /// The Order cancelled because it is being migrated to another account.
3925    Migration,
3926    /// Filling the Order wasn’t possible because the Order’s instrument was halted.
3927    MarketHalted,
3928    /// The Order is linked to an open Trade that was closed.
3929    LinkedTradeClosed,
3930    /// The time in force specified for this order has passed.
3931    TimeInForceExpired,
3932    /// Filling the Order wasn’t possible because the Account had insufficient margin.
3933    InsufficientMargin,
3934    /// Filling the Order would have resulted in a a FIFO violation.
3935    FifoViolation,
3936    /// Filling the Order would have violated the Order’s price bound.
3937    BoundsViolation,
3938    /// The Order was cancelled for replacement at the request of the client.
3939    ClientRequestReplaced,
3940    /// The Order was cancelled for replacement with an adjusted fillPrice to accommodate for the price movement
3941    /// caused by a dividendAdjustment.
3942    DividendAdjustmentReplaced,
3943    /// Filling the Order wasn’t possible because enough liquidity available.
3944    InsufficientLiquidity,
3945    /// Filling the Order would have resulted in the creation of a Take Profit Order with a GTD time in the past.
3946    TakeProfitOnFillGtdTimestampInPast,
3947    /// Filling the Order would result in the creation of a Take Profit Order that would have been filled
3948    /// immediately, closing the new Trade at a loss.
3949    TakeProfitOnFillLoss,
3950    /// Filling the Order would result in the creation of a Take Profit Loss Order that would close the new
3951    /// Trade at a loss when filled.
3952    LosingTakeProfit,
3953    /// Filling the Order would have resulted in the creation of a Stop Loss Order with a GTD time in the past.
3954    StopLossOnFillGtdTimestampInPast,
3955    /// Filling the Order would result in the creation of a Stop Loss Order that would have been filled
3956    /// immediately, closing the new Trade at a loss.
3957    StopLossOnFillLoss,
3958    /// Filling the Order would result in the creation of a Stop Loss Order whose price would be zero or
3959    /// negative due to the specified distance.
3960    StopLossOnFillPriceDistanceMaximumExceeded,
3961    /// Filling the Order would not result in the creation of Stop Loss Order, however the Account’s
3962    /// configuration requires that all Trades have a Stop Loss Order attached to them.
3963    StopLossOnFillRequired,
3964    /// Filling the Order would not result in the creation of a guaranteed Stop Loss Order, however the
3965    /// Account’s configuration requires that all Trades have a guaranteed Stop Loss Order attached to them.
3966    StopLossOnFillGuaranteedRequired,
3967    /// Filling the Order would result in the creation of a guaranteed Stop Loss Order, however the Account’s
3968    /// configuration does not allow guaranteed Stop Loss Orders.
3969    StopLossOnFillGuaranteedNotAllowed,
3970    /// Filling the Order would result in the creation of a guaranteed Stop Loss Order with a distance smaller
3971    /// than the configured minimum distance.
3972    StopLossOnFillGuaranteedMinimumDistanceNotMet,
3973    /// Filling the Order would result in the creation of a guaranteed Stop Loss Order with trigger price and
3974    /// number of units that that violates the account’s guaranteed Stop Loss Order level restriction.
3975    StopLossOnFillGuaranteedLevelRestrictionExceeded,
3976    /// Filling the Order would result in the creation of a guaranteed Stop Loss Order for a hedged Trade,
3977    /// however the Account’s configuration does not allow guaranteed Stop Loss Orders for hedged
3978    /// Trades/Positions.
3979    StopLossOnFillGuaranteedHedgingNotAllowed,
3980    /// Filling the Order would result in the creation of a Stop Loss Order whose TimeInForce value is invalid.
3981    /// A likely cause would be if the Account requires guaranteed stop loss orders and the TimeInForce value
3982    /// were not GTC.
3983    StopLossOnFillTimeInForceInvalid,
3984    /// Filling the Order would result in the creation of a Stop Loss Order whose TriggerCondition value is
3985    /// invalid. A likely cause would be if the stop loss order is guaranteed and the TimeInForce is not
3986    /// TRIGGER_DEFAULT or TRIGGER_BID for a long trade, or not TRIGGER_DEFAULT or TRIGGER_ASK for a short trade.
3987    StopLossOnFillTriggerConditionInvalid,
3988    /// Filling the Order would have resulted in the creation of a Guaranteed Stop Loss Order with a GTD time in
3989    /// the past.
3990    GuaranteedStopLossOnFillGtdTimestampInPast,
3991    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order that would have been
3992    /// filled immediately, closing the new Trade at a loss.
3993    GuaranteedStopLossOnFillLoss,
3994    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order whose price would be zero
3995    /// or negative due to the specified distance.
3996    GuaranteedStopLossOnFillPriceDistanceMaximumExceeded,
3997    /// Filling the Order would not result in the creation of a Guaranteed Stop Loss Order, however the
3998    /// Account’s configuration requires that all Trades have a Guaranteed Stop Loss Order attached to them.
3999    GuaranteedStopLossOnFillRequired,
4000    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order, however the Account’s
4001    /// configuration does not allow Guaranteed Stop Loss Orders.
4002    GuaranteedStopLossOnFillNotAllowed,
4003    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order with a distance smaller
4004    /// than the configured minimum distance.
4005    GuaranteedStopLossOnFillMinimumDistanceNotMet,
4006    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order with trigger number of
4007    /// units that violates the account’s Guaranteed Stop Loss Order level restriction volume.
4008    GuaranteedStopLossOnFillLevelRestrictionVolumeExceeded,
4009    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order with trigger price that
4010    /// violates the account’s Guaranteed Stop Loss Order level restriction price range.
4011    GuaranteedStopLossOnFillLevelRestrictionPriceRangeExceeded,
4012    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order for a hedged Trade,
4013    /// however the Account’s configuration does not allow Guaranteed Stop Loss Orders for hedged
4014    /// Trades/Positions.
4015    GuaranteedStopLossOnFillHedgingNotAllowed,
4016    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order whose TimeInForce value
4017    /// is invalid. A likely cause would be if the Account requires guaranteed stop loss orders and the
4018    /// TimeInForce value were not GTC.
4019    GuaranteedStopLossOnFillTimeInForceInvalid,
4020    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order whose TriggerCondition
4021    /// value is invalid. A likely cause would be the TimeInForce is not TRIGGER_DEFAULT or TRIGGER_BID for a
4022    /// long trade, or not TRIGGER_DEFAULT or TRIGGER_ASK for a short trade.
4023    GuaranteedStopLossOnFillTriggerConditionInvalid,
4024    /// Filling the Order would result in the creation of a Take Profit Order whose price would be zero or
4025    /// negative due to the specified distance.
4026    TakeProfitOnFillPriceDistanceMaximumExceeded,
4027    /// Filling the Order would have resulted in the creation of a Trailing Stop Loss Order with a GTD time in
4028    /// the past.
4029    TrailingStopLossOnFillGtdTimestampInPast,
4030    /// Filling the Order would result in the creation of a new Open Trade with a client Trade ID already in use.
4031    ClientTradeIdAlreadyExists,
4032    /// Closing out a position wasn’t fully possible.
4033    PositionCloseoutFailed,
4034    /// Filling the Order would cause the maximum open trades allowed for the Account to be exceeded.
4035    OpenTradesAllowedExceeded,
4036    /// Filling the Order would have resulted in exceeding the number of pending Orders allowed for the Account.
4037    PendingOrdersAllowedExceeded,
4038    /// Filling the Order would have resulted in the creation of a Take Profit Order with a client Order ID that
4039    /// is already in use.
4040    TakeProfitOnFillClientOrderIdAlreadyExists,
4041    /// Filling the Order would have resulted in the creation of a Stop Loss Order with a client Order ID that
4042    /// is already in use.
4043    StopLossOnFillClientOrderIdAlreadyExists,
4044    /// Filling the Order would have resulted in the creation of a Guaranteed Stop Loss Order with a client
4045    /// Order ID that is already in use.
4046    GuaranteedStopLossOnFillClientOrderIdAlreadyExists,
4047    /// Filling the Order would have resulted in the creation of a Trailing Stop Loss Order with a client Order
4048    /// ID that is already in use.
4049    TrailingStopLossOnFillClientOrderIdAlreadyExists,
4050    /// Filling the Order would have resulted in the Account’s maximum position size limit being exceeded for
4051    /// the Order’s instrument.
4052    PositionSizeExceeded,
4053    /// Filling the Order would result in the creation of a Trade, however there already exists an opposing
4054    /// (hedged) Trade that has a guaranteed Stop Loss Order attached to it. Guaranteed Stop Loss Orders cannot
4055    /// be combined with hedged positions.
4056    HedgingGsloViolation,
4057    /// Filling the order would cause the maximum position value allowed for the account to be exceeded. The
4058    /// Order has been cancelled as a result.
4059    AccountPositionValueLimitExceeded,
4060    /// Filling the order would require the creation of a short trade, however the instrument is configured such
4061    /// that orders being filled using bid prices can only reduce existing positions. New short positions cannot
4062    /// be created, but existing long positions may be reduced or closed.
4063    InstrumentBidReduceOnly,
4064    /// Filling the order would require the creation of a long trade, however the instrument is configured such
4065    /// that orders being filled using ask prices can only reduce existing positions. New long positions cannot
4066    /// be created, but existing short positions may be reduced or closed.
4067    InstrumentAskReduceOnly,
4068    /// Filling the order would require using the bid, however the instrument is configured such that the bids
4069    /// are halted, and so no short orders may be filled.
4070    InstrumentBidHalted,
4071    /// Filling the order would require using the ask, however the instrument is configured such that the asks
4072    /// are halted, and so no long orders may be filled.
4073    InstrumentAskHalted,
4074    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order (GSLO). Since the trade
4075    /// is long the GSLO would be short, however the bid side is currently halted. GSLOs cannot be created in
4076    /// this situation.
4077    StopLossOnFillGuaranteedBidHalted,
4078    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order (GSLO). Since the trade
4079    /// is short the GSLO would be long, however the ask side is currently halted. GSLOs cannot be created in
4080    /// this situation.
4081    StopLossOnFillGuaranteedAskHalted,
4082    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order (GSLO). Since the trade
4083    /// is long the GSLO would be short, however the bid side is currently halted. GSLOs cannot be created in
4084    /// this situation.
4085    GuaranteedStopLossOnFillBidHalted,
4086    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order (GSLO). Since the trade
4087    /// is short the GSLO would be long, however the ask side is currently halted. GSLOs cannot be created in
4088    /// this situation.
4089    GuaranteedStopLossOnFillAskHalted,
4090    /// Filling the Order would have resulted in a new Trade that violates the FIFO violation safeguard
4091    /// constraints.
4092    FifoViolationSafeguardViolation,
4093    /// Filling the Order would have reduced an existing Trade such that the reduced Trade violates the FIFO
4094    /// violation safeguard constraints.
4095    FifoViolationSafeguardPartialCloseViolation,
4096    /// The Orders on fill would be in violation of the risk management Order mutual exclusivity configuration
4097    /// specifying that only one risk management Order can be attached to a Trade.
4098    OrdersOnFillRmoMutualExclusivityMutuallyExclusiveViolation,
4099    /// An unrecognized provider value, preserved for forward compatibility.
4100    Unknown(String),
4101}
4102
4103impl OrderCancelReason {
4104    /// Return the exact provider spelling.
4105    pub fn as_str(&self) -> &str {
4106        match self {
4107            Self::InternalServerError => "INTERNAL_SERVER_ERROR",
4108            Self::AccountLocked => "ACCOUNT_LOCKED",
4109            Self::AccountNewPositionsLocked => "ACCOUNT_NEW_POSITIONS_LOCKED",
4110            Self::AccountOrderCreationLocked => "ACCOUNT_ORDER_CREATION_LOCKED",
4111            Self::AccountOrderFillLocked => "ACCOUNT_ORDER_FILL_LOCKED",
4112            Self::ClientRequest => "CLIENT_REQUEST",
4113            Self::Migration => "MIGRATION",
4114            Self::MarketHalted => "MARKET_HALTED",
4115            Self::LinkedTradeClosed => "LINKED_TRADE_CLOSED",
4116            Self::TimeInForceExpired => "TIME_IN_FORCE_EXPIRED",
4117            Self::InsufficientMargin => "INSUFFICIENT_MARGIN",
4118            Self::FifoViolation => "FIFO_VIOLATION",
4119            Self::BoundsViolation => "BOUNDS_VIOLATION",
4120            Self::ClientRequestReplaced => "CLIENT_REQUEST_REPLACED",
4121            Self::DividendAdjustmentReplaced => "DIVIDEND_ADJUSTMENT_REPLACED",
4122            Self::InsufficientLiquidity => "INSUFFICIENT_LIQUIDITY",
4123            Self::TakeProfitOnFillGtdTimestampInPast => "TAKE_PROFIT_ON_FILL_GTD_TIMESTAMP_IN_PAST",
4124            Self::TakeProfitOnFillLoss => "TAKE_PROFIT_ON_FILL_LOSS",
4125            Self::LosingTakeProfit => "LOSING_TAKE_PROFIT",
4126            Self::StopLossOnFillGtdTimestampInPast => "STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST",
4127            Self::StopLossOnFillLoss => "STOP_LOSS_ON_FILL_LOSS",
4128            Self::StopLossOnFillPriceDistanceMaximumExceeded => {
4129                "STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED"
4130            }
4131            Self::StopLossOnFillRequired => "STOP_LOSS_ON_FILL_REQUIRED",
4132            Self::StopLossOnFillGuaranteedRequired => "STOP_LOSS_ON_FILL_GUARANTEED_REQUIRED",
4133            Self::StopLossOnFillGuaranteedNotAllowed => "STOP_LOSS_ON_FILL_GUARANTEED_NOT_ALLOWED",
4134            Self::StopLossOnFillGuaranteedMinimumDistanceNotMet => {
4135                "STOP_LOSS_ON_FILL_GUARANTEED_MINIMUM_DISTANCE_NOT_MET"
4136            }
4137            Self::StopLossOnFillGuaranteedLevelRestrictionExceeded => {
4138                "STOP_LOSS_ON_FILL_GUARANTEED_LEVEL_RESTRICTION_EXCEEDED"
4139            }
4140            Self::StopLossOnFillGuaranteedHedgingNotAllowed => {
4141                "STOP_LOSS_ON_FILL_GUARANTEED_HEDGING_NOT_ALLOWED"
4142            }
4143            Self::StopLossOnFillTimeInForceInvalid => "STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID",
4144            Self::StopLossOnFillTriggerConditionInvalid => {
4145                "STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID"
4146            }
4147            Self::GuaranteedStopLossOnFillGtdTimestampInPast => {
4148                "GUARANTEED_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST"
4149            }
4150            Self::GuaranteedStopLossOnFillLoss => "GUARANTEED_STOP_LOSS_ON_FILL_LOSS",
4151            Self::GuaranteedStopLossOnFillPriceDistanceMaximumExceeded => {
4152                "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED"
4153            }
4154            Self::GuaranteedStopLossOnFillRequired => "GUARANTEED_STOP_LOSS_ON_FILL_REQUIRED",
4155            Self::GuaranteedStopLossOnFillNotAllowed => "GUARANTEED_STOP_LOSS_ON_FILL_NOT_ALLOWED",
4156            Self::GuaranteedStopLossOnFillMinimumDistanceNotMet => {
4157                "GUARANTEED_STOP_LOSS_ON_FILL_MINIMUM_DISTANCE_NOT_MET"
4158            }
4159            Self::GuaranteedStopLossOnFillLevelRestrictionVolumeExceeded => {
4160                "GUARANTEED_STOP_LOSS_ON_FILL_LEVEL_RESTRICTION_VOLUME_EXCEEDED"
4161            }
4162            Self::GuaranteedStopLossOnFillLevelRestrictionPriceRangeExceeded => {
4163                "GUARANTEED_STOP_LOSS_ON_FILL_LEVEL_RESTRICTION_PRICE_RANGE_EXCEEDED"
4164            }
4165            Self::GuaranteedStopLossOnFillHedgingNotAllowed => {
4166                "GUARANTEED_STOP_LOSS_ON_FILL_HEDGING_NOT_ALLOWED"
4167            }
4168            Self::GuaranteedStopLossOnFillTimeInForceInvalid => {
4169                "GUARANTEED_STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID"
4170            }
4171            Self::GuaranteedStopLossOnFillTriggerConditionInvalid => {
4172                "GUARANTEED_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID"
4173            }
4174            Self::TakeProfitOnFillPriceDistanceMaximumExceeded => {
4175                "TAKE_PROFIT_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED"
4176            }
4177            Self::TrailingStopLossOnFillGtdTimestampInPast => {
4178                "TRAILING_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST"
4179            }
4180            Self::ClientTradeIdAlreadyExists => "CLIENT_TRADE_ID_ALREADY_EXISTS",
4181            Self::PositionCloseoutFailed => "POSITION_CLOSEOUT_FAILED",
4182            Self::OpenTradesAllowedExceeded => "OPEN_TRADES_ALLOWED_EXCEEDED",
4183            Self::PendingOrdersAllowedExceeded => "PENDING_ORDERS_ALLOWED_EXCEEDED",
4184            Self::TakeProfitOnFillClientOrderIdAlreadyExists => {
4185                "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_ID_ALREADY_EXISTS"
4186            }
4187            Self::StopLossOnFillClientOrderIdAlreadyExists => {
4188                "STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_ALREADY_EXISTS"
4189            }
4190            Self::GuaranteedStopLossOnFillClientOrderIdAlreadyExists => {
4191                "GUARANTEED_STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_ALREADY_EXISTS"
4192            }
4193            Self::TrailingStopLossOnFillClientOrderIdAlreadyExists => {
4194                "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_ALREADY_EXISTS"
4195            }
4196            Self::PositionSizeExceeded => "POSITION_SIZE_EXCEEDED",
4197            Self::HedgingGsloViolation => "HEDGING_GSLO_VIOLATION",
4198            Self::AccountPositionValueLimitExceeded => "ACCOUNT_POSITION_VALUE_LIMIT_EXCEEDED",
4199            Self::InstrumentBidReduceOnly => "INSTRUMENT_BID_REDUCE_ONLY",
4200            Self::InstrumentAskReduceOnly => "INSTRUMENT_ASK_REDUCE_ONLY",
4201            Self::InstrumentBidHalted => "INSTRUMENT_BID_HALTED",
4202            Self::InstrumentAskHalted => "INSTRUMENT_ASK_HALTED",
4203            Self::StopLossOnFillGuaranteedBidHalted => "STOP_LOSS_ON_FILL_GUARANTEED_BID_HALTED",
4204            Self::StopLossOnFillGuaranteedAskHalted => "STOP_LOSS_ON_FILL_GUARANTEED_ASK_HALTED",
4205            Self::GuaranteedStopLossOnFillBidHalted => "GUARANTEED_STOP_LOSS_ON_FILL_BID_HALTED",
4206            Self::GuaranteedStopLossOnFillAskHalted => "GUARANTEED_STOP_LOSS_ON_FILL_ASK_HALTED",
4207            Self::FifoViolationSafeguardViolation => "FIFO_VIOLATION_SAFEGUARD_VIOLATION",
4208            Self::FifoViolationSafeguardPartialCloseViolation => {
4209                "FIFO_VIOLATION_SAFEGUARD_PARTIAL_CLOSE_VIOLATION"
4210            }
4211            Self::OrdersOnFillRmoMutualExclusivityMutuallyExclusiveViolation => {
4212                "ORDERS_ON_FILL_RMO_MUTUAL_EXCLUSIVITY_MUTUALLY_EXCLUSIVE_VIOLATION"
4213            }
4214            Self::Unknown(value) => value,
4215        }
4216    }
4217}
4218
4219impl Serialize for OrderCancelReason {
4220    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4221        serializer.serialize_str(self.as_str())
4222    }
4223}
4224
4225impl<'de> Deserialize<'de> for OrderCancelReason {
4226    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4227        let value = String::deserialize(deserializer)?;
4228        Ok(match value.as_str() {
4229            "INTERNAL_SERVER_ERROR" => Self::InternalServerError,
4230            "ACCOUNT_LOCKED" => Self::AccountLocked,
4231            "ACCOUNT_NEW_POSITIONS_LOCKED" => Self::AccountNewPositionsLocked,
4232            "ACCOUNT_ORDER_CREATION_LOCKED" => Self::AccountOrderCreationLocked,
4233            "ACCOUNT_ORDER_FILL_LOCKED" => Self::AccountOrderFillLocked,
4234            "CLIENT_REQUEST" => Self::ClientRequest,
4235            "MIGRATION" => Self::Migration,
4236            "MARKET_HALTED" => Self::MarketHalted,
4237            "LINKED_TRADE_CLOSED" => Self::LinkedTradeClosed,
4238            "TIME_IN_FORCE_EXPIRED" => Self::TimeInForceExpired,
4239            "INSUFFICIENT_MARGIN" => Self::InsufficientMargin,
4240            "FIFO_VIOLATION" => Self::FifoViolation,
4241            "BOUNDS_VIOLATION" => Self::BoundsViolation,
4242            "CLIENT_REQUEST_REPLACED" => Self::ClientRequestReplaced,
4243            "DIVIDEND_ADJUSTMENT_REPLACED" => Self::DividendAdjustmentReplaced,
4244            "INSUFFICIENT_LIQUIDITY" => Self::InsufficientLiquidity,
4245            "TAKE_PROFIT_ON_FILL_GTD_TIMESTAMP_IN_PAST" => Self::TakeProfitOnFillGtdTimestampInPast,
4246            "TAKE_PROFIT_ON_FILL_LOSS" => Self::TakeProfitOnFillLoss,
4247            "LOSING_TAKE_PROFIT" => Self::LosingTakeProfit,
4248            "STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST" => Self::StopLossOnFillGtdTimestampInPast,
4249            "STOP_LOSS_ON_FILL_LOSS" => Self::StopLossOnFillLoss,
4250            "STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED" => {
4251                Self::StopLossOnFillPriceDistanceMaximumExceeded
4252            }
4253            "STOP_LOSS_ON_FILL_REQUIRED" => Self::StopLossOnFillRequired,
4254            "STOP_LOSS_ON_FILL_GUARANTEED_REQUIRED" => Self::StopLossOnFillGuaranteedRequired,
4255            "STOP_LOSS_ON_FILL_GUARANTEED_NOT_ALLOWED" => Self::StopLossOnFillGuaranteedNotAllowed,
4256            "STOP_LOSS_ON_FILL_GUARANTEED_MINIMUM_DISTANCE_NOT_MET" => {
4257                Self::StopLossOnFillGuaranteedMinimumDistanceNotMet
4258            }
4259            "STOP_LOSS_ON_FILL_GUARANTEED_LEVEL_RESTRICTION_EXCEEDED" => {
4260                Self::StopLossOnFillGuaranteedLevelRestrictionExceeded
4261            }
4262            "STOP_LOSS_ON_FILL_GUARANTEED_HEDGING_NOT_ALLOWED" => {
4263                Self::StopLossOnFillGuaranteedHedgingNotAllowed
4264            }
4265            "STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID" => Self::StopLossOnFillTimeInForceInvalid,
4266            "STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID" => {
4267                Self::StopLossOnFillTriggerConditionInvalid
4268            }
4269            "GUARANTEED_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST" => {
4270                Self::GuaranteedStopLossOnFillGtdTimestampInPast
4271            }
4272            "GUARANTEED_STOP_LOSS_ON_FILL_LOSS" => Self::GuaranteedStopLossOnFillLoss,
4273            "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED" => {
4274                Self::GuaranteedStopLossOnFillPriceDistanceMaximumExceeded
4275            }
4276            "GUARANTEED_STOP_LOSS_ON_FILL_REQUIRED" => Self::GuaranteedStopLossOnFillRequired,
4277            "GUARANTEED_STOP_LOSS_ON_FILL_NOT_ALLOWED" => Self::GuaranteedStopLossOnFillNotAllowed,
4278            "GUARANTEED_STOP_LOSS_ON_FILL_MINIMUM_DISTANCE_NOT_MET" => {
4279                Self::GuaranteedStopLossOnFillMinimumDistanceNotMet
4280            }
4281            "GUARANTEED_STOP_LOSS_ON_FILL_LEVEL_RESTRICTION_VOLUME_EXCEEDED" => {
4282                Self::GuaranteedStopLossOnFillLevelRestrictionVolumeExceeded
4283            }
4284            "GUARANTEED_STOP_LOSS_ON_FILL_LEVEL_RESTRICTION_PRICE_RANGE_EXCEEDED" => {
4285                Self::GuaranteedStopLossOnFillLevelRestrictionPriceRangeExceeded
4286            }
4287            "GUARANTEED_STOP_LOSS_ON_FILL_HEDGING_NOT_ALLOWED" => {
4288                Self::GuaranteedStopLossOnFillHedgingNotAllowed
4289            }
4290            "GUARANTEED_STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID" => {
4291                Self::GuaranteedStopLossOnFillTimeInForceInvalid
4292            }
4293            "GUARANTEED_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID" => {
4294                Self::GuaranteedStopLossOnFillTriggerConditionInvalid
4295            }
4296            "TAKE_PROFIT_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED" => {
4297                Self::TakeProfitOnFillPriceDistanceMaximumExceeded
4298            }
4299            "TRAILING_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST" => {
4300                Self::TrailingStopLossOnFillGtdTimestampInPast
4301            }
4302            "CLIENT_TRADE_ID_ALREADY_EXISTS" => Self::ClientTradeIdAlreadyExists,
4303            "POSITION_CLOSEOUT_FAILED" => Self::PositionCloseoutFailed,
4304            "OPEN_TRADES_ALLOWED_EXCEEDED" => Self::OpenTradesAllowedExceeded,
4305            "PENDING_ORDERS_ALLOWED_EXCEEDED" => Self::PendingOrdersAllowedExceeded,
4306            "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_ID_ALREADY_EXISTS" => {
4307                Self::TakeProfitOnFillClientOrderIdAlreadyExists
4308            }
4309            "STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_ALREADY_EXISTS" => {
4310                Self::StopLossOnFillClientOrderIdAlreadyExists
4311            }
4312            "GUARANTEED_STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_ALREADY_EXISTS" => {
4313                Self::GuaranteedStopLossOnFillClientOrderIdAlreadyExists
4314            }
4315            "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_ALREADY_EXISTS" => {
4316                Self::TrailingStopLossOnFillClientOrderIdAlreadyExists
4317            }
4318            "POSITION_SIZE_EXCEEDED" => Self::PositionSizeExceeded,
4319            "HEDGING_GSLO_VIOLATION" => Self::HedgingGsloViolation,
4320            "ACCOUNT_POSITION_VALUE_LIMIT_EXCEEDED" => Self::AccountPositionValueLimitExceeded,
4321            "INSTRUMENT_BID_REDUCE_ONLY" => Self::InstrumentBidReduceOnly,
4322            "INSTRUMENT_ASK_REDUCE_ONLY" => Self::InstrumentAskReduceOnly,
4323            "INSTRUMENT_BID_HALTED" => Self::InstrumentBidHalted,
4324            "INSTRUMENT_ASK_HALTED" => Self::InstrumentAskHalted,
4325            "STOP_LOSS_ON_FILL_GUARANTEED_BID_HALTED" => Self::StopLossOnFillGuaranteedBidHalted,
4326            "STOP_LOSS_ON_FILL_GUARANTEED_ASK_HALTED" => Self::StopLossOnFillGuaranteedAskHalted,
4327            "GUARANTEED_STOP_LOSS_ON_FILL_BID_HALTED" => Self::GuaranteedStopLossOnFillBidHalted,
4328            "GUARANTEED_STOP_LOSS_ON_FILL_ASK_HALTED" => Self::GuaranteedStopLossOnFillAskHalted,
4329            "FIFO_VIOLATION_SAFEGUARD_VIOLATION" => Self::FifoViolationSafeguardViolation,
4330            "FIFO_VIOLATION_SAFEGUARD_PARTIAL_CLOSE_VIOLATION" => {
4331                Self::FifoViolationSafeguardPartialCloseViolation
4332            }
4333            "ORDERS_ON_FILL_RMO_MUTUAL_EXCLUSIVITY_MUTUALLY_EXCLUSIVE_VIOLATION" => {
4334                Self::OrdersOnFillRmoMutualExclusivityMutuallyExclusiveViolation
4335            }
4336            _ => Self::Unknown(value),
4337        })
4338    }
4339}
4340
4341/// Used to pay or collect a dividend adjustment amount for an open Trade within the Account.
4342#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4343#[serde(rename_all = "camelCase")]
4344pub struct OpenTradeDividendAdjustment {
4345    /// The ID of the Trade for which the dividend adjustment is to be paid or collected.
4346    #[serde(rename = "tradeID", default, skip_serializing_if = "Option::is_none")]
4347    pub trade_id: Option<TradeID>,
4348    /// The dividend adjustment amount to pay or collect for the Trade.
4349    #[serde(
4350        rename = "dividendAdjustment",
4351        default,
4352        skip_serializing_if = "Option::is_none"
4353    )]
4354    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4355    pub dividend_adjustment: Option<Decimal>,
4356    /// The dividend adjustment amount to pay or collect for the Trade, in the Instrument’s quote currency.
4357    #[serde(
4358        rename = "quoteDividendAdjustment",
4359        default,
4360        skip_serializing_if = "Option::is_none"
4361    )]
4362    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4363    pub quote_dividend_adjustment: Option<Decimal>,
4364}
4365
4366/// A ClientExtensions object allows a client to attach a clientID, tag and comment to Orders and Trades in
4367/// their Account. Do not set, modify, or delete this field if your account is associated with MT4.
4368#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4369#[serde(rename_all = "camelCase")]
4370pub struct ClientExtensions {
4371    /// The Client ID of the Order/Trade
4372    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
4373    pub id: Option<ClientID>,
4374    /// A tag associated with the Order/Trade
4375    #[serde(rename = "tag", default, skip_serializing_if = "Option::is_none")]
4376    pub tag: Option<ClientTag>,
4377    /// A comment associated with the Order/Trade
4378    #[serde(rename = "comment", default, skip_serializing_if = "Option::is_none")]
4379    pub comment: Option<ClientComment>,
4380}
4381
4382/// TakeProfitDetails specifies the details of a Take Profit Order to be created on behalf of a client. This
4383/// may happen when an Order is filled that opens a Trade requiring a Take Profit, or when a Trade’s
4384/// dependent Take Profit Order is modified directly through the Trade.
4385#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4386#[serde(rename_all = "camelCase")]
4387pub struct TakeProfitDetails {
4388    /// The price that the Take Profit Order will be triggered at. Only one of the price and distance fields may
4389    /// be specified.
4390    #[serde(rename = "price", default, skip_serializing_if = "Option::is_none")]
4391    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4392    pub price: Option<Decimal>,
4393    /// The time in force for the created Take Profit Order. This may only be GTC, GTD or GFD.
4394    #[serde(
4395        rename = "timeInForce",
4396        default,
4397        skip_serializing_if = "Option::is_none"
4398    )]
4399    pub time_in_force: Option<TimeInForce>,
4400    /// The date when the Take Profit Order will be cancelled on if timeInForce is GTD.
4401    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
4402    pub gtd_time: Option<Timestamp>,
4403    /// The Client Extensions to add to the Take Profit Order when created.
4404    #[serde(
4405        rename = "clientExtensions",
4406        default,
4407        skip_serializing_if = "Option::is_none"
4408    )]
4409    pub client_extensions: Option<ClientExtensions>,
4410}
4411
4412/// StopLossDetails specifies the details of a Stop Loss Order to be created on behalf of a client. This may
4413/// happen when an Order is filled that opens a Trade requiring a Stop Loss, or when a Trade’s dependent
4414/// Stop Loss Order is modified directly through the Trade.
4415#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4416#[serde(rename_all = "camelCase")]
4417pub struct StopLossDetails {
4418    /// The price that the Stop Loss Order will be triggered at. Only one of the price and distance fields may
4419    /// be specified.
4420    #[serde(rename = "price", default, skip_serializing_if = "Option::is_none")]
4421    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4422    pub price: Option<Decimal>,
4423    /// Specifies the distance (in price units) from the Trade’s open price to use as the Stop Loss Order price.
4424    /// Only one of the distance and price fields may be specified.
4425    #[serde(rename = "distance", default, skip_serializing_if = "Option::is_none")]
4426    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4427    pub distance: Option<Decimal>,
4428    /// The time in force for the created Stop Loss Order. This may only be GTC, GTD or GFD.
4429    #[serde(
4430        rename = "timeInForce",
4431        default,
4432        skip_serializing_if = "Option::is_none"
4433    )]
4434    pub time_in_force: Option<TimeInForce>,
4435    /// The date when the Stop Loss Order will be cancelled on if timeInForce is GTD.
4436    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
4437    pub gtd_time: Option<Timestamp>,
4438    /// The Client Extensions to add to the Stop Loss Order when created.
4439    #[serde(
4440        rename = "clientExtensions",
4441        default,
4442        skip_serializing_if = "Option::is_none"
4443    )]
4444    pub client_extensions: Option<ClientExtensions>,
4445    /// Flag indicating that the price for the Stop Loss Order is guaranteed. The default value depends on the
4446    /// GuaranteedStopLossOrderMode of the account, if it is REQUIRED, the default will be true, for DISABLED or
4447    /// ENABLED the default is false. Deprecated: Will be removed in a future API update.
4448    #[serde(
4449        rename = "guaranteed",
4450        default,
4451        skip_serializing_if = "Option::is_none"
4452    )]
4453    pub guaranteed: Option<bool>,
4454}
4455
4456/// GuaranteedStopLossDetails specifies the details of a Guaranteed Stop Loss Order to be created on behalf
4457/// of a client. This may happen when an Order is filled that opens a Trade requiring a Guaranteed Stop
4458/// Loss, or when a Trade’s dependent Guaranteed Stop Loss Order is modified directly through the Trade.
4459#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4460#[serde(rename_all = "camelCase")]
4461pub struct GuaranteedStopLossDetails {
4462    /// The price that the Guaranteed Stop Loss Order will be triggered at. Only one of the price and distance
4463    /// fields may be specified.
4464    #[serde(rename = "price", default, skip_serializing_if = "Option::is_none")]
4465    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4466    pub price: Option<Decimal>,
4467    /// Specifies the distance (in price units) from the Trade’s open price to use as the Guaranteed Stop Loss
4468    /// Order price. Only one of the distance and price fields may be specified.
4469    #[serde(rename = "distance", default, skip_serializing_if = "Option::is_none")]
4470    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4471    pub distance: Option<Decimal>,
4472    /// The time in force for the created Guaranteed Stop Loss Order. This may only be GTC, GTD or GFD.
4473    #[serde(
4474        rename = "timeInForce",
4475        default,
4476        skip_serializing_if = "Option::is_none"
4477    )]
4478    pub time_in_force: Option<TimeInForce>,
4479    /// The date when the Guaranteed Stop Loss Order will be cancelled on if timeInForce is GTD.
4480    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
4481    pub gtd_time: Option<Timestamp>,
4482    /// The Client Extensions to add to the Guaranteed Stop Loss Order when created.
4483    #[serde(
4484        rename = "clientExtensions",
4485        default,
4486        skip_serializing_if = "Option::is_none"
4487    )]
4488    pub client_extensions: Option<ClientExtensions>,
4489}
4490
4491/// TrailingStopLossDetails specifies the details of a Trailing Stop Loss Order to be created on behalf of a
4492/// client. This may happen when an Order is filled that opens a Trade requiring a Trailing Stop Loss, or
4493/// when a Trade’s dependent Trailing Stop Loss Order is modified directly through the Trade.
4494#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4495#[serde(rename_all = "camelCase")]
4496pub struct TrailingStopLossDetails {
4497    /// The distance (in price units) from the Trade’s fill price that the Trailing Stop Loss Order will be
4498    /// triggered at.
4499    #[serde(rename = "distance", default, skip_serializing_if = "Option::is_none")]
4500    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4501    pub distance: Option<Decimal>,
4502    /// The time in force for the created Trailing Stop Loss Order. This may only be GTC, GTD or GFD.
4503    #[serde(
4504        rename = "timeInForce",
4505        default,
4506        skip_serializing_if = "Option::is_none"
4507    )]
4508    pub time_in_force: Option<TimeInForce>,
4509    /// The date when the Trailing Stop Loss Order will be cancelled on if timeInForce is GTD.
4510    #[serde(rename = "gtdTime", default, skip_serializing_if = "Option::is_none")]
4511    pub gtd_time: Option<Timestamp>,
4512    /// The Client Extensions to add to the Trailing Stop Loss Order when created.
4513    #[serde(
4514        rename = "clientExtensions",
4515        default,
4516        skip_serializing_if = "Option::is_none"
4517    )]
4518    pub client_extensions: Option<ClientExtensions>,
4519}
4520
4521/// A TradeOpen object represents a Trade for an instrument that was opened in an Account. It is found
4522/// embedded in Transactions that affect the position of an instrument in the Account, specifically the
4523/// OrderFill Transaction.
4524#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4525#[serde(rename_all = "camelCase")]
4526pub struct TradeOpen {
4527    /// The ID of the Trade that was opened
4528    #[serde(rename = "tradeID", default, skip_serializing_if = "Option::is_none")]
4529    pub trade_id: Option<TradeID>,
4530    /// The number of units opened by the Trade
4531    #[serde(rename = "units", default, skip_serializing_if = "Option::is_none")]
4532    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4533    pub units: Option<Decimal>,
4534    /// The average price that the units were opened at.
4535    #[serde(rename = "price", default, skip_serializing_if = "Option::is_none")]
4536    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4537    pub price: Option<Decimal>,
4538    /// This is the fee charged for opening the trade if it has a guaranteed Stop Loss Order attached to it.
4539    #[serde(
4540        rename = "guaranteedExecutionFee",
4541        default,
4542        skip_serializing_if = "Option::is_none"
4543    )]
4544    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4545    pub guaranteed_execution_fee: Option<Decimal>,
4546    /// This is the fee charged for opening the trade if it has a guaranteed Stop Loss Order attached to it,
4547    /// expressed in the Instrument’s quote currency.
4548    #[serde(
4549        rename = "quoteGuaranteedExecutionFee",
4550        default,
4551        skip_serializing_if = "Option::is_none"
4552    )]
4553    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4554    pub quote_guaranteed_execution_fee: Option<Decimal>,
4555    /// The client extensions for the newly opened Trade
4556    #[serde(
4557        rename = "clientExtensions",
4558        default,
4559        skip_serializing_if = "Option::is_none"
4560    )]
4561    pub client_extensions: Option<ClientExtensions>,
4562    /// The half spread cost for the trade open. This can be a positive or negative value and is represented in
4563    /// the home currency of the Account.
4564    #[serde(
4565        rename = "halfSpreadCost",
4566        default,
4567        skip_serializing_if = "Option::is_none"
4568    )]
4569    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4570    pub half_spread_cost: Option<Decimal>,
4571    /// The margin required at the time the Trade was created. Note, this is the ‘pure’ margin required, it is
4572    /// not the ‘effective’ margin used that factors in the trade risk if a GSLO is attached to the trade.
4573    #[serde(
4574        rename = "initialMarginRequired",
4575        default,
4576        skip_serializing_if = "Option::is_none"
4577    )]
4578    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4579    pub initial_margin_required: Option<Decimal>,
4580}
4581
4582/// A TradeReduce object represents a Trade for an instrument that was reduced (either partially or fully)
4583/// in an Account. It is found embedded in Transactions that affect the position of an instrument in the
4584/// account, specifically the OrderFill Transaction.
4585#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4586#[serde(rename_all = "camelCase")]
4587pub struct TradeReduce {
4588    /// The ID of the Trade that was reduced or closed
4589    #[serde(rename = "tradeID", default, skip_serializing_if = "Option::is_none")]
4590    pub trade_id: Option<TradeID>,
4591    /// The number of units that the Trade was reduced by
4592    #[serde(rename = "units", default, skip_serializing_if = "Option::is_none")]
4593    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4594    pub units: Option<Decimal>,
4595    /// The average price that the units were closed at. This price may be clamped for guaranteed Stop Loss
4596    /// Orders.
4597    #[serde(rename = "price", default, skip_serializing_if = "Option::is_none")]
4598    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4599    pub price: Option<Decimal>,
4600    /// The PL realized when reducing the Trade
4601    #[serde(
4602        rename = "realizedPL",
4603        default,
4604        skip_serializing_if = "Option::is_none"
4605    )]
4606    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4607    pub realized_pl: Option<Decimal>,
4608    /// The financing paid/collected when reducing the Trade
4609    #[serde(rename = "financing", default, skip_serializing_if = "Option::is_none")]
4610    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4611    pub financing: Option<Decimal>,
4612    /// The base financing paid/collected when reducing the Trade
4613    #[serde(
4614        rename = "baseFinancing",
4615        default,
4616        skip_serializing_if = "Option::is_none"
4617    )]
4618    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4619    pub base_financing: Option<Decimal>,
4620    /// The quote financing paid/collected when reducing the Trade
4621    #[serde(
4622        rename = "quoteFinancing",
4623        default,
4624        skip_serializing_if = "Option::is_none"
4625    )]
4626    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4627    pub quote_financing: Option<Decimal>,
4628    /// The financing rate in effect for the instrument used to calculate the amount of financing paid/collected
4629    /// when reducing the Trade. This field will only be set if the AccountFinancingMode at the time of the
4630    /// order fill is SECOND_BY_SECOND_INSTRUMENT. The value is in decimal rather than percentage points, e.g.
4631    /// 5% is represented as 0.05.
4632    #[serde(
4633        rename = "financingRate",
4634        default,
4635        skip_serializing_if = "Option::is_none"
4636    )]
4637    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4638    pub financing_rate: Option<Decimal>,
4639    /// This is the fee that is charged for closing the Trade if it has a guaranteed Stop Loss Order attached to
4640    /// it.
4641    #[serde(
4642        rename = "guaranteedExecutionFee",
4643        default,
4644        skip_serializing_if = "Option::is_none"
4645    )]
4646    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4647    pub guaranteed_execution_fee: Option<Decimal>,
4648    /// This is the fee that is charged for closing the Trade if it has a guaranteed Stop Loss Order attached to
4649    /// it, expressed in the Instrument’s quote currency.
4650    #[serde(
4651        rename = "quoteGuaranteedExecutionFee",
4652        default,
4653        skip_serializing_if = "Option::is_none"
4654    )]
4655    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4656    pub quote_guaranteed_execution_fee: Option<Decimal>,
4657    /// The half spread cost for the trade reduce/close. This can be a positive or negative value and is
4658    /// represented in the home currency of the Account.
4659    #[serde(
4660        rename = "halfSpreadCost",
4661        default,
4662        skip_serializing_if = "Option::is_none"
4663    )]
4664    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4665    pub half_spread_cost: Option<Decimal>,
4666}
4667
4668/// A MarketOrderTradeClose specifies the extensions to a Market Order that has been created specifically to
4669/// close a Trade.
4670#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4671#[serde(rename_all = "camelCase")]
4672pub struct MarketOrderTradeClose {
4673    /// The ID of the Trade requested to be closed
4674    #[serde(rename = "tradeID", default, skip_serializing_if = "Option::is_none")]
4675    pub trade_id: Option<TradeID>,
4676    /// The client ID of the Trade requested to be closed
4677    #[serde(
4678        rename = "clientTradeID",
4679        default,
4680        skip_serializing_if = "Option::is_none"
4681    )]
4682    pub client_trade_id: Option<String>,
4683    /// Indication of how much of the Trade to close. Either “ALL”, or a DecimalNumber reflection a partial
4684    /// close of the Trade.
4685    #[serde(rename = "units", default, skip_serializing_if = "Option::is_none")]
4686    pub units: Option<String>,
4687}
4688
4689/// Details for the Market Order extensions specific to a Market Order placed that is part of a Market Order
4690/// Margin Closeout in a client’s account
4691#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4692#[serde(rename_all = "camelCase")]
4693pub struct MarketOrderMarginCloseout {
4694    /// The reason the Market Order was created to perform a margin closeout
4695    #[serde(rename = "reason", default, skip_serializing_if = "Option::is_none")]
4696    pub reason: Option<MarketOrderMarginCloseoutReason>,
4697}
4698
4699/// The reason that the Market Order was created to perform a margin closeout
4700#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4701#[non_exhaustive]
4702pub enum MarketOrderMarginCloseoutReason {
4703    /// Trade closures resulted from violating OANDA’s margin policy
4704    MarginCheckViolation,
4705    /// Trade closures came from a margin closeout event resulting from regulatory conditions placed on the
4706    /// Account’s margin call
4707    RegulatoryMarginCallViolation,
4708    /// Trade closures resulted from violating the margin policy imposed by regulatory requirements
4709    RegulatoryMarginCheckViolation,
4710    /// An unrecognized provider value, preserved for forward compatibility.
4711    Unknown(String),
4712}
4713
4714impl MarketOrderMarginCloseoutReason {
4715    /// Return the exact provider spelling.
4716    pub fn as_str(&self) -> &str {
4717        match self {
4718            Self::MarginCheckViolation => "MARGIN_CHECK_VIOLATION",
4719            Self::RegulatoryMarginCallViolation => "REGULATORY_MARGIN_CALL_VIOLATION",
4720            Self::RegulatoryMarginCheckViolation => "REGULATORY_MARGIN_CHECK_VIOLATION",
4721            Self::Unknown(value) => value,
4722        }
4723    }
4724}
4725
4726impl Serialize for MarketOrderMarginCloseoutReason {
4727    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4728        serializer.serialize_str(self.as_str())
4729    }
4730}
4731
4732impl<'de> Deserialize<'de> for MarketOrderMarginCloseoutReason {
4733    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4734        let value = String::deserialize(deserializer)?;
4735        Ok(match value.as_str() {
4736            "MARGIN_CHECK_VIOLATION" => Self::MarginCheckViolation,
4737            "REGULATORY_MARGIN_CALL_VIOLATION" => Self::RegulatoryMarginCallViolation,
4738            "REGULATORY_MARGIN_CHECK_VIOLATION" => Self::RegulatoryMarginCheckViolation,
4739            _ => Self::Unknown(value),
4740        })
4741    }
4742}
4743
4744/// Details for the Market Order extensions specific to a Market Order placed with the intent of fully
4745/// closing a specific open trade that should have already been closed but wasn’t due to halted market
4746/// conditions
4747#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4748#[serde(rename_all = "camelCase")]
4749pub struct MarketOrderDelayedTradeClose {
4750    /// The ID of the Trade being closed
4751    #[serde(rename = "tradeID", default, skip_serializing_if = "Option::is_none")]
4752    pub trade_id: Option<TradeID>,
4753    /// The Client ID of the Trade being closed
4754    #[serde(
4755        rename = "clientTradeID",
4756        default,
4757        skip_serializing_if = "Option::is_none"
4758    )]
4759    pub client_trade_id: Option<TradeID>,
4760    /// The Transaction ID of the DelayedTradeClosure transaction to which this Delayed Trade Close belongs to
4761    #[serde(
4762        rename = "sourceTransactionID",
4763        default,
4764        skip_serializing_if = "Option::is_none"
4765    )]
4766    pub source_transaction_id: Option<TransactionID>,
4767}
4768
4769/// A MarketOrderPositionCloseout specifies the extensions to a Market Order when it has been created to
4770/// closeout a specific Position.
4771#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4772#[serde(rename_all = "camelCase")]
4773pub struct MarketOrderPositionCloseout {
4774    /// The instrument of the Position being closed out.
4775    #[serde(
4776        rename = "instrument",
4777        default,
4778        skip_serializing_if = "Option::is_none"
4779    )]
4780    pub instrument: Option<InstrumentName>,
4781    /// Indication of how much of the Position to close. Either “ALL”, or a DecimalNumber reflection a partial
4782    /// close of the Trade. The DecimalNumber must always be positive, and represent a number that doesn’t
4783    /// exceed the absolute size of the Position.
4784    #[serde(rename = "units", default, skip_serializing_if = "Option::is_none")]
4785    pub units: Option<String>,
4786}
4787
4788/// A LiquidityRegenerationSchedule indicates how liquidity that is used when filling an Order for an
4789/// instrument is regenerated following the fill. A liquidity regeneration schedule will be in effect until
4790/// the timestamp of its final step, but may be replaced by a schedule created for an Order of the same
4791/// instrument that is filled while it is still in effect.
4792#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4793#[serde(rename_all = "camelCase")]
4794pub struct LiquidityRegenerationSchedule {
4795    /// The steps in the Liquidity Regeneration Schedule
4796    #[serde(rename = "steps", default, skip_serializing_if = "Option::is_none")]
4797    pub steps: Option<Vec<LiquidityRegenerationScheduleStep>>,
4798}
4799
4800/// A liquidity regeneration schedule Step indicates the amount of bid and ask liquidity that is used by the
4801/// Account at a certain time. These amounts will only change at the timestamp of the following step.
4802#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4803#[serde(rename_all = "camelCase")]
4804pub struct LiquidityRegenerationScheduleStep {
4805    /// The timestamp of the schedule step.
4806    #[serde(rename = "timestamp", default, skip_serializing_if = "Option::is_none")]
4807    pub timestamp: Option<Timestamp>,
4808    /// The amount of bid liquidity used at this step in the schedule.
4809    #[serde(
4810        rename = "bidLiquidityUsed",
4811        default,
4812        skip_serializing_if = "Option::is_none"
4813    )]
4814    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4815    pub bid_liquidity_used: Option<Decimal>,
4816    /// The amount of ask liquidity used at this step in the schedule.
4817    #[serde(
4818        rename = "askLiquidityUsed",
4819        default,
4820        skip_serializing_if = "Option::is_none"
4821    )]
4822    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4823    pub ask_liquidity_used: Option<Decimal>,
4824}
4825
4826/// OpenTradeFinancing is used to pay/collect daily financing charge for an open Trade within an Account
4827#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4828#[serde(rename_all = "camelCase")]
4829pub struct OpenTradeFinancing {
4830    /// The ID of the Trade that financing is being paid/collected for.
4831    #[serde(rename = "tradeID", default, skip_serializing_if = "Option::is_none")]
4832    pub trade_id: Option<TradeID>,
4833    /// The amount of financing paid/collected for the Trade.
4834    #[serde(rename = "financing", default, skip_serializing_if = "Option::is_none")]
4835    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4836    pub financing: Option<Decimal>,
4837    /// The amount of financing paid/collected in the Instrument’s base currency for the Trade.
4838    #[serde(
4839        rename = "baseFinancing",
4840        default,
4841        skip_serializing_if = "Option::is_none"
4842    )]
4843    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4844    pub base_financing: Option<Decimal>,
4845    /// The amount of financing paid/collected in the Instrument’s quote currency for the Trade.
4846    #[serde(
4847        rename = "quoteFinancing",
4848        default,
4849        skip_serializing_if = "Option::is_none"
4850    )]
4851    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4852    pub quote_financing: Option<Decimal>,
4853    /// The financing rate in effect for the instrument used to calculate the the amount of financing
4854    /// paid/collected for the Trade. This field will only be set if the AccountFinancingMode at the time of the
4855    /// daily financing is DAILY_INSTRUMENT or SECOND_BY_SECOND_INSTRUMENT. The value is in decimal rather than
4856    /// percentage points, e.g. 5% is represented as 0.05.
4857    #[serde(
4858        rename = "financingRate",
4859        default,
4860        skip_serializing_if = "Option::is_none"
4861    )]
4862    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4863    pub financing_rate: Option<Decimal>,
4864}
4865
4866/// OpenTradeFinancing is used to pay/collect daily financing charge for a Position within an Account
4867#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4868#[serde(rename_all = "camelCase")]
4869pub struct PositionFinancing {
4870    /// The instrument of the Position that financing is being paid/collected for.
4871    #[serde(
4872        rename = "instrument",
4873        default,
4874        skip_serializing_if = "Option::is_none"
4875    )]
4876    pub instrument: Option<InstrumentName>,
4877    /// The amount of financing paid/collected for the Position.
4878    #[serde(rename = "financing", default, skip_serializing_if = "Option::is_none")]
4879    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4880    pub financing: Option<Decimal>,
4881    /// The amount of base financing paid/collected for the Position.
4882    #[serde(
4883        rename = "baseFinancing",
4884        default,
4885        skip_serializing_if = "Option::is_none"
4886    )]
4887    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4888    pub base_financing: Option<Decimal>,
4889    /// The amount of quote financing paid/collected for the Position.
4890    #[serde(
4891        rename = "quoteFinancing",
4892        default,
4893        skip_serializing_if = "Option::is_none"
4894    )]
4895    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
4896    pub quote_financing: Option<Decimal>,
4897    /// The HomeConversionFactors in effect for the Position’s Instrument at the time of the DailyFinancing.
4898    #[serde(
4899        rename = "homeConversionFactors",
4900        default,
4901        skip_serializing_if = "Option::is_none"
4902    )]
4903    pub home_conversion_factors: Option<HomeConversionFactors>,
4904    /// The financing paid/collected for each open Trade within the Position.
4905    #[serde(
4906        rename = "openTradeFinancings",
4907        default,
4908        skip_serializing_if = "Option::is_none"
4909    )]
4910    pub open_trade_financings: Option<Vec<OpenTradeFinancing>>,
4911    /// The account financing mode at the time of the daily financing.
4912    #[serde(
4913        rename = "accountFinancingMode",
4914        default,
4915        skip_serializing_if = "Option::is_none"
4916    )]
4917    pub account_financing_mode: Option<AccountFinancingMode>,
4918}
4919
4920/// The reason that a Transaction was rejected.
4921#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4922#[non_exhaustive]
4923pub enum TransactionRejectReason {
4924    /// An unexpected internal server error has occurred
4925    InternalServerError,
4926    /// The system was unable to determine the current price for the Order’s instrument
4927    InstrumentPriceUnknown,
4928    /// The Account is not active
4929    AccountNotActive,
4930    /// The Account is locked
4931    AccountLocked,
4932    /// The Account is locked for Order creation
4933    AccountOrderCreationLocked,
4934    /// The Account is locked for configuration
4935    AccountConfigurationLocked,
4936    /// The Account is locked for deposits
4937    AccountDepositLocked,
4938    /// The Account is locked for withdrawals
4939    AccountWithdrawalLocked,
4940    /// The Account is locked for Order cancellation
4941    AccountOrderCancelLocked,
4942    /// The instrument specified is not tradeable by the Account
4943    InstrumentNotTradeable,
4944    /// Creating the Order would result in the maximum number of allowed pending Orders being exceeded
4945    PendingOrdersAllowedExceeded,
4946    /// Neither the Order ID nor client Order ID are specified
4947    OrderIdUnspecified,
4948    /// The Order specified does not exist
4949    OrderDoesntExist,
4950    /// The Order ID and client Order ID specified do not identify the same Order
4951    OrderIdentifierInconsistency,
4952    /// Neither the Trade ID nor client Trade ID are specified
4953    TradeIdUnspecified,
4954    /// The Trade specified does not exist
4955    TradeDoesntExist,
4956    /// The Trade ID and client Trade ID specified do not identify the same Trade
4957    TradeIdentifierInconsistency,
4958    /// The Account had insufficient margin to perform the action specified. One possible reason for this is due
4959    /// to the creation or modification of a guaranteed StopLoss Order.
4960    InsufficientMargin,
4961    /// Order instrument has not been specified
4962    InstrumentMissing,
4963    /// The instrument specified is unknown
4964    InstrumentUnknown,
4965    /// Order units have not been not specified
4966    UnitsMissing,
4967    /// Order units specified are invalid
4968    UnitsInvalid,
4969    /// The units specified contain more precision than is allowed for the Order’s instrument
4970    UnitsPrecisionExceeded,
4971    /// The units specified exceeds the maximum number of units allowed
4972    UnitsLimitExceeded,
4973    /// The units specified is less than the minimum number of units required
4974    UnitsMinimumNotMet,
4975    /// The price has not been specified
4976    PriceMissing,
4977    /// The price specified is invalid
4978    PriceInvalid,
4979    /// The price specified contains more precision than is allowed for the instrument
4980    PricePrecisionExceeded,
4981    /// The price distance has not been specified
4982    PriceDistanceMissing,
4983    /// The price distance specified is invalid
4984    PriceDistanceInvalid,
4985    /// The price distance specified contains more precision than is allowed for the instrument
4986    PriceDistancePrecisionExceeded,
4987    /// The price distance exceeds that maximum allowed amount
4988    PriceDistanceMaximumExceeded,
4989    /// The price distance does not meet the minimum allowed amount
4990    PriceDistanceMinimumNotMet,
4991    /// The TimeInForce field has not been specified
4992    TimeInForceMissing,
4993    /// The TimeInForce specified is invalid
4994    TimeInForceInvalid,
4995    /// The TimeInForce is GTD but no GTD timestamp is provided
4996    TimeInForceGtdTimestampMissing,
4997    /// The TimeInForce is GTD but the GTD timestamp is in the past
4998    TimeInForceGtdTimestampInPast,
4999    /// The price bound specified is invalid
5000    PriceBoundInvalid,
5001    /// The price bound specified contains more precision than is allowed for the Order’s instrument
5002    PriceBoundPrecisionExceeded,
5003    /// Multiple Orders on fill share the same client Order ID
5004    OrdersOnFillDuplicateClientOrderIds,
5005    /// The Order does not support Trade on fill client extensions because it cannot create a new Trade
5006    TradeOnFillClientExtensionsNotSupported,
5007    /// The client Order ID specified is invalid
5008    ClientOrderIdInvalid,
5009    /// The client Order ID specified is already assigned to another pending Order
5010    ClientOrderIdAlreadyExists,
5011    /// The client Order tag specified is invalid
5012    ClientOrderTagInvalid,
5013    /// The client Order comment specified is invalid
5014    ClientOrderCommentInvalid,
5015    /// The client Trade ID specified is invalid
5016    ClientTradeIdInvalid,
5017    /// The client Trade ID specified is already assigned to another open Trade
5018    ClientTradeIdAlreadyExists,
5019    /// The client Trade tag specified is invalid
5020    ClientTradeTagInvalid,
5021    /// The client Trade comment is invalid
5022    ClientTradeCommentInvalid,
5023    /// The OrderFillPositionAction field has not been specified
5024    OrderFillPositionActionMissing,
5025    /// The OrderFillPositionAction specified is invalid
5026    OrderFillPositionActionInvalid,
5027    /// The TriggerCondition field has not been specified
5028    TriggerConditionMissing,
5029    /// The TriggerCondition specified is invalid
5030    TriggerConditionInvalid,
5031    /// The OrderFillPositionAction field has not been specified
5032    OrderPartialFillOptionMissing,
5033    /// The OrderFillPositionAction specified is invalid.
5034    OrderPartialFillOptionInvalid,
5035    /// When attempting to reissue an order (currently only a MarketIfTouched) that was immediately partially
5036    /// filled, it is not possible to create a correct pending Order.
5037    InvalidReissueImmediatePartialFill,
5038    /// The Orders on fill would be in violation of the risk management Order mutual exclusivity configuration
5039    /// specifying that only one risk management Order can be attached to a Trade.
5040    OrdersOnFillRmoMutualExclusivityMutuallyExclusiveViolation,
5041    /// The Orders on fill would be in violation of the risk management Order mutual exclusivity configuration
5042    /// specifying that if a GSLO is already attached to a Trade, no other risk management Order can be attached
5043    /// to a Trade.
5044    OrdersOnFillRmoMutualExclusivityGsloExcludesOthersViolation,
5045    /// A Take Profit Order for the specified Trade already exists
5046    TakeProfitOrderAlreadyExists,
5047    /// The Take Profit Order would cause the associated Trade to be in violation of the FIFO violation
5048    /// safeguard constraints.
5049    TakeProfitOrderWouldViolateFifoViolationSafeguard,
5050    /// The Take Profit on fill specified does not provide a price
5051    TakeProfitOnFillPriceMissing,
5052    /// The Take Profit on fill specified contains an invalid price
5053    TakeProfitOnFillPriceInvalid,
5054    /// The Take Profit on fill specified contains a price with more precision than is allowed by the Order’s
5055    /// instrument
5056    TakeProfitOnFillPricePrecisionExceeded,
5057    /// The Take Profit on fill specified does not provide a TimeInForce
5058    TakeProfitOnFillTimeInForceMissing,
5059    /// The Take Profit on fill specifies an invalid TimeInForce
5060    TakeProfitOnFillTimeInForceInvalid,
5061    /// The Take Profit on fill specifies a GTD TimeInForce but does not provide a GTD timestamp
5062    TakeProfitOnFillGtdTimestampMissing,
5063    /// The Take Profit on fill specifies a GTD timestamp that is in the past
5064    TakeProfitOnFillGtdTimestampInPast,
5065    /// The Take Profit on fill client Order ID specified is invalid
5066    TakeProfitOnFillClientOrderIdInvalid,
5067    /// The Take Profit on fill client Order tag specified is invalid
5068    TakeProfitOnFillClientOrderTagInvalid,
5069    /// The Take Profit on fill client Order comment specified is invalid
5070    TakeProfitOnFillClientOrderCommentInvalid,
5071    /// The Take Profit on fill specified does not provide a TriggerCondition
5072    TakeProfitOnFillTriggerConditionMissing,
5073    /// The Take Profit on fill specifies an invalid TriggerCondition
5074    TakeProfitOnFillTriggerConditionInvalid,
5075    /// A Stop Loss Order for the specified Trade already exists
5076    StopLossOrderAlreadyExists,
5077    /// An attempt was made to to create a non-guaranteed stop loss order in an account that requires all stop
5078    /// loss orders to be guaranteed.
5079    StopLossOrderGuaranteedRequired,
5080    /// An attempt to create a guaranteed stop loss order with a price that is within the current tradeable
5081    /// spread.
5082    StopLossOrderGuaranteedPriceWithinSpread,
5083    /// An attempt was made to create a guaranteed Stop Loss Order, however the Account’s configuration does not
5084    /// allow guaranteed Stop Loss Orders.
5085    StopLossOrderGuaranteedNotAllowed,
5086    /// An attempt was made to create a guaranteed Stop Loss Order when the market was halted.
5087    StopLossOrderGuaranteedHaltedCreateViolation,
5088    /// An attempt was made to re-create a guaranteed Stop Loss Order with a tighter fill price when the market
5089    /// was halted.
5090    StopLossOrderGuaranteedHaltedTightenViolation,
5091    /// An attempt was made to create a guaranteed Stop Loss Order on a hedged Trade (ie there is an existing
5092    /// open Trade in the opposing direction), however the Account’s configuration does not allow guaranteed
5093    /// Stop Loss Orders for hedged Trades/Positions.
5094    StopLossOrderGuaranteedHedgingNotAllowed,
5095    /// An attempt was made to create a guaranteed Stop Loss Order, however the distance between the current
5096    /// price and the trigger price does not meet the Account’s configured minimum Guaranteed Stop Loss distance.
5097    StopLossOrderGuaranteedMinimumDistanceNotMet,
5098    /// An attempt was made to cancel a Stop Loss Order, however the Account’s configuration requires every
5099    /// Trade have an associated Stop Loss Order.
5100    StopLossOrderNotCancelable,
5101    /// An attempt was made to cancel and replace a Stop Loss Order, however the Account’s configuration
5102    /// prevents the modification of Stop Loss Orders.
5103    StopLossOrderNotReplaceable,
5104    /// An attempt was made to create a guaranteed Stop Loss Order, however doing so would exceed the Account’s
5105    /// configured guaranteed StopLoss Order level restriction volume.
5106    StopLossOrderGuaranteedLevelRestrictionExceeded,
5107    /// The Stop Loss Order request contains both the price and distance fields.
5108    StopLossOrderPriceAndDistanceBothSpecified,
5109    /// The Stop Loss Order request contains neither the price nor distance fields.
5110    StopLossOrderPriceAndDistanceBothMissing,
5111    /// The Stop Loss Order would cause the associated Trade to be in violation of the FIFO violation safeguard
5112    /// constraints
5113    StopLossOrderWouldViolateFifoViolationSafeguard,
5114    /// The Stop Loss Order would be in violation of the risk management Order mutual exclusivity configuration
5115    /// specifying that only one risk management order can be attached to a Trade.
5116    StopLossOrderRmoMutualExclusivityMutuallyExclusiveViolation,
5117    /// The Stop Loss Order would be in violation of the risk management Order mutual exclusivity configuration
5118    /// specifying that if a GSLO is already attached to a Trade, no other risk management Order can be attached
5119    /// to the same Trade.
5120    StopLossOrderRmoMutualExclusivityGsloExcludesOthersViolation,
5121    /// An attempt to create a pending Order was made with no Stop Loss Order on fill specified and the
5122    /// Account’s configuration requires that every Trade have an associated Stop Loss Order.
5123    StopLossOnFillRequiredForPendingOrder,
5124    /// An attempt to create a pending Order was made with a Stop Loss Order on fill that was explicitly
5125    /// configured to be guaranteed, however the Account’s configuration does not allow guaranteed Stop Loss
5126    /// Orders.
5127    StopLossOnFillGuaranteedNotAllowed,
5128    /// An attempt to create a pending Order was made with a Stop Loss Order on fill that was explicitly
5129    /// configured to be not guaranteed, however the Account’s configuration requires guaranteed Stop Loss
5130    /// Orders.
5131    StopLossOnFillGuaranteedRequired,
5132    /// The Stop Loss on fill specified does not provide a price
5133    StopLossOnFillPriceMissing,
5134    /// The Stop Loss on fill specifies an invalid price
5135    StopLossOnFillPriceInvalid,
5136    /// The Stop Loss on fill specifies a price with more precision than is allowed by the Order’s instrument
5137    StopLossOnFillPricePrecisionExceeded,
5138    /// An attempt to create a pending Order was made with the distance between the guaranteed Stop Loss Order
5139    /// on fill’s price and the pending Order’s price is less than the Account’s configured minimum guaranteed
5140    /// stop loss distance.
5141    StopLossOnFillGuaranteedMinimumDistanceNotMet,
5142    /// An attempt to create a pending Order was made with a guaranteed Stop Loss Order on fill configured, and
5143    /// the Order’s units exceed the Account’s configured guaranteed StopLoss Order level restriction volume.
5144    StopLossOnFillGuaranteedLevelRestrictionExceeded,
5145    /// The Stop Loss on fill distance is invalid
5146    StopLossOnFillDistanceInvalid,
5147    /// The Stop Loss on fill price distance exceeds the maximum allowed amount
5148    StopLossOnFillPriceDistanceMaximumExceeded,
5149    /// The Stop Loss on fill distance contains more precision than is allowed by the instrument
5150    StopLossOnFillDistancePrecisionExceeded,
5151    /// The Stop Loss on fill contains both the price and distance fields.
5152    StopLossOnFillPriceAndDistanceBothSpecified,
5153    /// The Stop Loss on fill contains neither the price nor distance fields.
5154    StopLossOnFillPriceAndDistanceBothMissing,
5155    /// The Stop Loss on fill specified does not provide a TimeInForce
5156    StopLossOnFillTimeInForceMissing,
5157    /// The Stop Loss on fill specifies an invalid TimeInForce
5158    StopLossOnFillTimeInForceInvalid,
5159    /// The Stop Loss on fill specifies a GTD TimeInForce but does not provide a GTD timestamp
5160    StopLossOnFillGtdTimestampMissing,
5161    /// The Stop Loss on fill specifies a GTD timestamp that is in the past
5162    StopLossOnFillGtdTimestampInPast,
5163    /// The Stop Loss on fill client Order ID specified is invalid
5164    StopLossOnFillClientOrderIdInvalid,
5165    /// The Stop Loss on fill client Order tag specified is invalid
5166    StopLossOnFillClientOrderTagInvalid,
5167    /// The Stop Loss on fill client Order comment specified is invalid
5168    StopLossOnFillClientOrderCommentInvalid,
5169    /// The Stop Loss on fill specified does not provide a TriggerCondition
5170    StopLossOnFillTriggerConditionMissing,
5171    /// The Stop Loss on fill specifies an invalid TriggerCondition
5172    StopLossOnFillTriggerConditionInvalid,
5173    /// A Guaranteed Stop Loss Order for the specified Trade already exists
5174    GuaranteedStopLossOrderAlreadyExists,
5175    /// An attempt was made to to create a non-guaranteed stop loss order in an account that requires all stop
5176    /// loss orders to be guaranteed.
5177    GuaranteedStopLossOrderRequired,
5178    /// An attempt to create a guaranteed stop loss order with a price that is within the current tradeable
5179    /// spread.
5180    GuaranteedStopLossOrderPriceWithinSpread,
5181    /// An attempt was made to create a Guaranteed Stop Loss Order, however the Account’s configuration does not
5182    /// allow Guaranteed Stop Loss Orders.
5183    GuaranteedStopLossOrderNotAllowed,
5184    /// An attempt was made to create a Guaranteed Stop Loss Order when the market was halted.
5185    GuaranteedStopLossOrderHaltedCreateViolation,
5186    /// An attempt was made to create a Guaranteed Stop Loss Order when the market was open.
5187    GuaranteedStopLossOrderCreateViolation,
5188    /// An attempt was made to re-create a Guaranteed Stop Loss Order with a tighter fill price when the market
5189    /// was halted.
5190    GuaranteedStopLossOrderHaltedTightenViolation,
5191    /// An attempt was made to re-create a Guaranteed Stop Loss Order with a tighter fill price when the market
5192    /// was open.
5193    GuaranteedStopLossOrderTightenViolation,
5194    /// An attempt was made to create a Guaranteed Stop Loss Order on a hedged Trade (ie there is an existing
5195    /// open Trade in the opposing direction), however the Account’s configuration does not allow Guaranteed
5196    /// Stop Loss Orders for hedged Trades/Positions.
5197    GuaranteedStopLossOrderHedgingNotAllowed,
5198    /// An attempt was made to create a Guaranteed Stop Loss Order, however the distance between the current
5199    /// price and the trigger price does not meet the Account’s configured minimum Guaranteed Stop Loss distance.
5200    GuaranteedStopLossOrderMinimumDistanceNotMet,
5201    /// An attempt was made to cancel a Guaranteed Stop Loss Order when the market is open, however the
5202    /// Account’s configuration requires every Trade have an associated Guaranteed Stop Loss Order.
5203    GuaranteedStopLossOrderNotCancelable,
5204    /// An attempt was made to cancel a Guaranteed Stop Loss Order when the market is halted, however the
5205    /// Account’s configuration requires every Trade have an associated Guaranteed Stop Loss Order.
5206    GuaranteedStopLossOrderHaltedNotCancelable,
5207    /// An attempt was made to cancel and replace a Guaranteed Stop Loss Order when the market is open, however
5208    /// the Account’s configuration prevents the modification of Guaranteed Stop Loss Orders.
5209    GuaranteedStopLossOrderNotReplaceable,
5210    /// An attempt was made to cancel and replace a Guaranteed Stop Loss Order when the market is halted,
5211    /// however the Account’s configuration prevents the modification of Guaranteed Stop Loss Orders.
5212    GuaranteedStopLossOrderHaltedNotReplaceable,
5213    /// An attempt was made to create a Guaranteed Stop Loss Order, however doing so would exceed the Account’s
5214    /// configured guaranteed StopLoss Order level restriction volume.
5215    GuaranteedStopLossOrderLevelRestrictionVolumeExceeded,
5216    /// An attempt was made to create a Guaranteed Stop Loss Order, however doing so would exceed the Account’s
5217    /// configured guaranteed StopLoss Order level restriction price range.
5218    GuaranteedStopLossOrderLevelRestrictionPriceRangeExceeded,
5219    /// The Guaranteed Stop Loss Order request contains both the price and distance fields.
5220    GuaranteedStopLossOrderPriceAndDistanceBothSpecified,
5221    /// The Guaranteed Stop Loss Order request contains neither the price nor distance fields.
5222    GuaranteedStopLossOrderPriceAndDistanceBothMissing,
5223    /// The Guaranteed Stop Loss Order would cause the associated Trade to be in violation of the FIFO violation
5224    /// safeguard constraints
5225    GuaranteedStopLossOrderWouldViolateFifoViolationSafeguard,
5226    /// The Guaranteed Stop Loss Order would be in violation of the risk management Order mutual exclusivity
5227    /// configuration specifying that only one risk management order can be attached to a Trade.
5228    GuaranteedStopLossOrderRmoMutualExclusivityMutuallyExclusiveViolation,
5229    /// The Guaranteed Stop Loss Order would be in violation of the risk management Order mutual exclusivity
5230    /// configuration specifying that if a GSLO is already attached to a Trade, no other risk management Order
5231    /// can be attached to the same Trade.
5232    GuaranteedStopLossOrderRmoMutualExclusivityGsloExcludesOthersViolation,
5233    /// An attempt to create a pending Order was made with no Guaranteed Stop Loss Order on fill specified and
5234    /// the Account’s configuration requires that every Trade have an associated Guaranteed Stop Loss Order.
5235    GuaranteedStopLossOnFillRequiredForPendingOrder,
5236    /// An attempt to create a pending Order was made with a Guaranteed Stop Loss Order on fill that was
5237    /// explicitly configured to be guaranteed, however the Account’s configuration does not allow guaranteed
5238    /// Stop Loss Orders.
5239    GuaranteedStopLossOnFillNotAllowed,
5240    /// An attempt to create a pending Order was made with a Guaranteed Stop Loss Order on fill that was
5241    /// explicitly configured to be not guaranteed, however the Account’s configuration requires Guaranteed Stop
5242    /// Loss Orders.
5243    GuaranteedStopLossOnFillRequired,
5244    /// The Guaranteed Stop Loss on fill specified does not provide a price
5245    GuaranteedStopLossOnFillPriceMissing,
5246    /// The Guaranteed Stop Loss on fill specifies an invalid price
5247    GuaranteedStopLossOnFillPriceInvalid,
5248    /// The Guaranteed Stop Loss on fill specifies a price with more precision than is allowed by the Order’s
5249    /// instrument
5250    GuaranteedStopLossOnFillPricePrecisionExceeded,
5251    /// An attempt to create a pending Order was made with the distance between the Guaranteed Stop Loss Order
5252    /// on fill’s price and the pending Order’s price is less than the Account’s configured minimum guaranteed
5253    /// stop loss distance.
5254    GuaranteedStopLossOnFillMinimumDistanceNotMet,
5255    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order with trigger number of
5256    /// units that violates the account’s Guaranteed Stop Loss Order level restriction volume.
5257    GuaranteedStopLossOnFillLevelRestrictionVolumeExceeded,
5258    /// Filling the Order would result in the creation of a Guaranteed Stop Loss Order with trigger price that
5259    /// violates the account’s Guaranteed Stop Loss Order level restriction price range.
5260    GuaranteedStopLossOnFillLevelRestrictionPriceRangeExceeded,
5261    /// The Guaranteed Stop Loss on fill distance is invalid
5262    GuaranteedStopLossOnFillDistanceInvalid,
5263    /// The Guaranteed Stop Loss on fill price distance exceeds the maximum allowed amount.
5264    GuaranteedStopLossOnFillPriceDistanceMaximumExceeded,
5265    /// The Guaranteed Stop Loss on fill distance contains more precision than is allowed by the instrument
5266    GuaranteedStopLossOnFillDistancePrecisionExceeded,
5267    /// The Guaranteed Stop Loss on fill contains both the price and distance fields.
5268    GuaranteedStopLossOnFillPriceAndDistanceBothSpecified,
5269    /// The Guaranteed Stop Loss on fill contains neither the price nor distance fields.
5270    GuaranteedStopLossOnFillPriceAndDistanceBothMissing,
5271    /// The Guaranteed Stop Loss on fill specified does not provide a TimeInForce
5272    GuaranteedStopLossOnFillTimeInForceMissing,
5273    /// The Guaranteed Stop Loss on fill specifies an invalid TimeInForce
5274    GuaranteedStopLossOnFillTimeInForceInvalid,
5275    /// The Guaranteed Stop Loss on fill specifies a GTD TimeInForce but does not provide a GTD timestamp
5276    GuaranteedStopLossOnFillGtdTimestampMissing,
5277    /// The Guaranteed Stop Loss on fill specifies a GTD timestamp that is in the past.
5278    GuaranteedStopLossOnFillGtdTimestampInPast,
5279    /// The Guaranteed Stop Loss on fill client Order ID specified is invalid
5280    GuaranteedStopLossOnFillClientOrderIdInvalid,
5281    /// The Guaranteed Stop Loss on fill client Order tag specified is invalid
5282    GuaranteedStopLossOnFillClientOrderTagInvalid,
5283    /// The Guaranteed Stop Loss on fill client Order comment specified is invalid.
5284    GuaranteedStopLossOnFillClientOrderCommentInvalid,
5285    /// The Guaranteed Stop Loss on fill specified does not provide a TriggerCondition.
5286    GuaranteedStopLossOnFillTriggerConditionMissing,
5287    /// The Guaranteed Stop Loss on fill specifies an invalid TriggerCondition.
5288    GuaranteedStopLossOnFillTriggerConditionInvalid,
5289    /// A Trailing Stop Loss Order for the specified Trade already exists
5290    TrailingStopLossOrderAlreadyExists,
5291    /// The Trailing Stop Loss Order would cause the associated Trade to be in violation of the FIFO violation
5292    /// safeguard constraints
5293    TrailingStopLossOrderWouldViolateFifoViolationSafeguard,
5294    /// The Trailing Stop Loss Order would be in violation of the risk management Order mutual exclusivity
5295    /// configuration specifying that only one risk management order can be attached to a Trade.
5296    TrailingStopLossOrderRmoMutualExclusivityMutuallyExclusiveViolation,
5297    /// The Trailing Stop Loss Order would be in violation of the risk management Order mutual exclusivity
5298    /// configuration specifying that if a GSLO is already attached to a Trade, no other risk management Order
5299    /// can be attached to the same Trade.
5300    TrailingStopLossOrderRmoMutualExclusivityGsloExcludesOthersViolation,
5301    /// The Trailing Stop Loss on fill specified does not provide a distance
5302    TrailingStopLossOnFillPriceDistanceMissing,
5303    /// The Trailing Stop Loss on fill distance is invalid
5304    TrailingStopLossOnFillPriceDistanceInvalid,
5305    /// The Trailing Stop Loss on fill distance contains more precision than is allowed by the instrument
5306    TrailingStopLossOnFillPriceDistancePrecisionExceeded,
5307    /// The Trailing Stop Loss on fill price distance exceeds the maximum allowed amount
5308    TrailingStopLossOnFillPriceDistanceMaximumExceeded,
5309    /// The Trailing Stop Loss on fill price distance does not meet the minimum allowed amount
5310    TrailingStopLossOnFillPriceDistanceMinimumNotMet,
5311    /// The Trailing Stop Loss on fill specified does not provide a TimeInForce
5312    TrailingStopLossOnFillTimeInForceMissing,
5313    /// The Trailing Stop Loss on fill specifies an invalid TimeInForce
5314    TrailingStopLossOnFillTimeInForceInvalid,
5315    /// The Trailing Stop Loss on fill TimeInForce is specified as GTD but no GTD timestamp is provided
5316    TrailingStopLossOnFillGtdTimestampMissing,
5317    /// The Trailing Stop Loss on fill GTD timestamp is in the past
5318    TrailingStopLossOnFillGtdTimestampInPast,
5319    /// The Trailing Stop Loss on fill client Order ID specified is invalid
5320    TrailingStopLossOnFillClientOrderIdInvalid,
5321    /// The Trailing Stop Loss on fill client Order tag specified is invalid
5322    TrailingStopLossOnFillClientOrderTagInvalid,
5323    /// The Trailing Stop Loss on fill client Order comment specified is invalid
5324    TrailingStopLossOnFillClientOrderCommentInvalid,
5325    /// A client attempted to create either a Trailing Stop Loss order or an order with a Trailing Stop Loss On
5326    /// Fill specified, which may not yet be supported.
5327    TrailingStopLossOrdersNotSupported,
5328    /// The Trailing Stop Loss on fill specified does not provide a TriggerCondition
5329    TrailingStopLossOnFillTriggerConditionMissing,
5330    /// The Tailing Stop Loss on fill specifies an invalid TriggerCondition
5331    TrailingStopLossOnFillTriggerConditionInvalid,
5332    /// The request to close a Trade does not specify a full or partial close
5333    CloseTradeTypeMissing,
5334    /// The request to close a Trade partially did not specify the number of units to close
5335    CloseTradePartialUnitsMissing,
5336    /// The request to partially close a Trade specifies a number of units that exceeds the current size of the
5337    /// given Trade
5338    CloseTradeUnitsExceedTradeSize,
5339    /// The Position requested to be closed out does not exist
5340    CloseoutPositionDoesntExist,
5341    /// The request to closeout a Position was specified incompletely
5342    CloseoutPositionIncompleteSpecification,
5343    /// A partial Position closeout request specifies a number of units that exceeds the current Position
5344    CloseoutPositionUnitsExceedPositionSize,
5345    /// The request to closeout a Position could not be fully satisfied
5346    CloseoutPositionReject,
5347    /// The request to partially closeout a Position did not specify the number of units to close.
5348    CloseoutPositionPartialUnitsMissing,
5349    /// The markup group ID provided is invalid
5350    MarkupGroupIdInvalid,
5351    /// The PositionAggregationMode provided is not supported/valid.
5352    PositionAggregationModeInvalid,
5353    /// No configuration parameters provided
5354    AdminConfigureDataMissing,
5355    /// The margin rate provided is invalid
5356    MarginRateInvalid,
5357    /// The margin rate provided would cause an immediate margin closeout
5358    MarginRateWouldTriggerCloseout,
5359    /// The account alias string provided is invalid
5360    AliasInvalid,
5361    /// No configuration parameters provided
5362    ClientConfigureDataMissing,
5363    /// The margin rate provided would cause the Account to enter a margin call state.
5364    MarginRateWouldTriggerMarginCall,
5365    /// Funding is not possible because the requested transfer amount is invalid
5366    AmountInvalid,
5367    /// The Account does not have sufficient balance to complete the funding request
5368    InsufficientFunds,
5369    /// Funding amount has not been specified
5370    AmountMissing,
5371    /// Funding reason has not been specified
5372    FundingReasonMissing,
5373    /// The list of Order Identifiers provided for a One Cancels All Order contains an Order Identifier that
5374    /// refers to a Stop Loss Order. OCA groups cannot contain Stop Loss Orders.
5375    OcaOrderIdsStopLossNotAllowed,
5376    /// Neither Order nor Trade on Fill client extensions were provided for modification
5377    ClientExtensionsDataMissing,
5378    /// The Order to be replaced has a different type than the replacing Order.
5379    ReplacingOrderInvalid,
5380    /// The replacing Order refers to a different Trade than the Order that is being replaced.
5381    ReplacingTradeIdInvalid,
5382    /// Canceling the order would cause an immediate margin closeout.
5383    OrderCancelWouldTriggerCloseout,
5384    /// An unrecognized provider value, preserved for forward compatibility.
5385    Unknown(String),
5386}
5387
5388impl TransactionRejectReason {
5389    /// Return the exact provider spelling.
5390    pub fn as_str(&self) -> &str {
5391        match self {
5392            Self::InternalServerError => "INTERNAL_SERVER_ERROR",
5393            Self::InstrumentPriceUnknown => "INSTRUMENT_PRICE_UNKNOWN",
5394            Self::AccountNotActive => "ACCOUNT_NOT_ACTIVE",
5395            Self::AccountLocked => "ACCOUNT_LOCKED",
5396            Self::AccountOrderCreationLocked => "ACCOUNT_ORDER_CREATION_LOCKED",
5397            Self::AccountConfigurationLocked => "ACCOUNT_CONFIGURATION_LOCKED",
5398            Self::AccountDepositLocked => "ACCOUNT_DEPOSIT_LOCKED",
5399            Self::AccountWithdrawalLocked => "ACCOUNT_WITHDRAWAL_LOCKED",
5400            Self::AccountOrderCancelLocked => "ACCOUNT_ORDER_CANCEL_LOCKED",
5401            Self::InstrumentNotTradeable => "INSTRUMENT_NOT_TRADEABLE",
5402            Self::PendingOrdersAllowedExceeded => "PENDING_ORDERS_ALLOWED_EXCEEDED",
5403            Self::OrderIdUnspecified => "ORDER_ID_UNSPECIFIED",
5404            Self::OrderDoesntExist => "ORDER_DOESNT_EXIST",
5405            Self::OrderIdentifierInconsistency => "ORDER_IDENTIFIER_INCONSISTENCY",
5406            Self::TradeIdUnspecified => "TRADE_ID_UNSPECIFIED",
5407            Self::TradeDoesntExist => "TRADE_DOESNT_EXIST",
5408            Self::TradeIdentifierInconsistency => "TRADE_IDENTIFIER_INCONSISTENCY",
5409            Self::InsufficientMargin => "INSUFFICIENT_MARGIN",
5410            Self::InstrumentMissing => "INSTRUMENT_MISSING",
5411            Self::InstrumentUnknown => "INSTRUMENT_UNKNOWN",
5412            Self::UnitsMissing => "UNITS_MISSING",
5413            Self::UnitsInvalid => "UNITS_INVALID",
5414            Self::UnitsPrecisionExceeded => "UNITS_PRECISION_EXCEEDED",
5415            Self::UnitsLimitExceeded => "UNITS_LIMIT_EXCEEDED",
5416            Self::UnitsMinimumNotMet => "UNITS_MINIMUM_NOT_MET",
5417            Self::PriceMissing => "PRICE_MISSING",
5418            Self::PriceInvalid => "PRICE_INVALID",
5419            Self::PricePrecisionExceeded => "PRICE_PRECISION_EXCEEDED",
5420            Self::PriceDistanceMissing => "PRICE_DISTANCE_MISSING",
5421            Self::PriceDistanceInvalid => "PRICE_DISTANCE_INVALID",
5422            Self::PriceDistancePrecisionExceeded => "PRICE_DISTANCE_PRECISION_EXCEEDED",
5423            Self::PriceDistanceMaximumExceeded => "PRICE_DISTANCE_MAXIMUM_EXCEEDED",
5424            Self::PriceDistanceMinimumNotMet => "PRICE_DISTANCE_MINIMUM_NOT_MET",
5425            Self::TimeInForceMissing => "TIME_IN_FORCE_MISSING",
5426            Self::TimeInForceInvalid => "TIME_IN_FORCE_INVALID",
5427            Self::TimeInForceGtdTimestampMissing => "TIME_IN_FORCE_GTD_TIMESTAMP_MISSING",
5428            Self::TimeInForceGtdTimestampInPast => "TIME_IN_FORCE_GTD_TIMESTAMP_IN_PAST",
5429            Self::PriceBoundInvalid => "PRICE_BOUND_INVALID",
5430            Self::PriceBoundPrecisionExceeded => "PRICE_BOUND_PRECISION_EXCEEDED",
5431            Self::OrdersOnFillDuplicateClientOrderIds => {
5432                "ORDERS_ON_FILL_DUPLICATE_CLIENT_ORDER_IDS"
5433            }
5434            Self::TradeOnFillClientExtensionsNotSupported => {
5435                "TRADE_ON_FILL_CLIENT_EXTENSIONS_NOT_SUPPORTED"
5436            }
5437            Self::ClientOrderIdInvalid => "CLIENT_ORDER_ID_INVALID",
5438            Self::ClientOrderIdAlreadyExists => "CLIENT_ORDER_ID_ALREADY_EXISTS",
5439            Self::ClientOrderTagInvalid => "CLIENT_ORDER_TAG_INVALID",
5440            Self::ClientOrderCommentInvalid => "CLIENT_ORDER_COMMENT_INVALID",
5441            Self::ClientTradeIdInvalid => "CLIENT_TRADE_ID_INVALID",
5442            Self::ClientTradeIdAlreadyExists => "CLIENT_TRADE_ID_ALREADY_EXISTS",
5443            Self::ClientTradeTagInvalid => "CLIENT_TRADE_TAG_INVALID",
5444            Self::ClientTradeCommentInvalid => "CLIENT_TRADE_COMMENT_INVALID",
5445            Self::OrderFillPositionActionMissing => "ORDER_FILL_POSITION_ACTION_MISSING",
5446            Self::OrderFillPositionActionInvalid => "ORDER_FILL_POSITION_ACTION_INVALID",
5447            Self::TriggerConditionMissing => "TRIGGER_CONDITION_MISSING",
5448            Self::TriggerConditionInvalid => "TRIGGER_CONDITION_INVALID",
5449            Self::OrderPartialFillOptionMissing => "ORDER_PARTIAL_FILL_OPTION_MISSING",
5450            Self::OrderPartialFillOptionInvalid => "ORDER_PARTIAL_FILL_OPTION_INVALID",
5451            Self::InvalidReissueImmediatePartialFill => "INVALID_REISSUE_IMMEDIATE_PARTIAL_FILL",
5452            Self::OrdersOnFillRmoMutualExclusivityMutuallyExclusiveViolation => {
5453                "ORDERS_ON_FILL_RMO_MUTUAL_EXCLUSIVITY_MUTUALLY_EXCLUSIVE_VIOLATION"
5454            }
5455            Self::OrdersOnFillRmoMutualExclusivityGsloExcludesOthersViolation => {
5456                "ORDERS_ON_FILL_RMO_MUTUAL_EXCLUSIVITY_GSLO_EXCLUDES_OTHERS_VIOLATION"
5457            }
5458            Self::TakeProfitOrderAlreadyExists => "TAKE_PROFIT_ORDER_ALREADY_EXISTS",
5459            Self::TakeProfitOrderWouldViolateFifoViolationSafeguard => {
5460                "TAKE_PROFIT_ORDER_WOULD_VIOLATE_FIFO_VIOLATION_SAFEGUARD"
5461            }
5462            Self::TakeProfitOnFillPriceMissing => "TAKE_PROFIT_ON_FILL_PRICE_MISSING",
5463            Self::TakeProfitOnFillPriceInvalid => "TAKE_PROFIT_ON_FILL_PRICE_INVALID",
5464            Self::TakeProfitOnFillPricePrecisionExceeded => {
5465                "TAKE_PROFIT_ON_FILL_PRICE_PRECISION_EXCEEDED"
5466            }
5467            Self::TakeProfitOnFillTimeInForceMissing => "TAKE_PROFIT_ON_FILL_TIME_IN_FORCE_MISSING",
5468            Self::TakeProfitOnFillTimeInForceInvalid => "TAKE_PROFIT_ON_FILL_TIME_IN_FORCE_INVALID",
5469            Self::TakeProfitOnFillGtdTimestampMissing => {
5470                "TAKE_PROFIT_ON_FILL_GTD_TIMESTAMP_MISSING"
5471            }
5472            Self::TakeProfitOnFillGtdTimestampInPast => "TAKE_PROFIT_ON_FILL_GTD_TIMESTAMP_IN_PAST",
5473            Self::TakeProfitOnFillClientOrderIdInvalid => {
5474                "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_ID_INVALID"
5475            }
5476            Self::TakeProfitOnFillClientOrderTagInvalid => {
5477                "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_TAG_INVALID"
5478            }
5479            Self::TakeProfitOnFillClientOrderCommentInvalid => {
5480                "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_COMMENT_INVALID"
5481            }
5482            Self::TakeProfitOnFillTriggerConditionMissing => {
5483                "TAKE_PROFIT_ON_FILL_TRIGGER_CONDITION_MISSING"
5484            }
5485            Self::TakeProfitOnFillTriggerConditionInvalid => {
5486                "TAKE_PROFIT_ON_FILL_TRIGGER_CONDITION_INVALID"
5487            }
5488            Self::StopLossOrderAlreadyExists => "STOP_LOSS_ORDER_ALREADY_EXISTS",
5489            Self::StopLossOrderGuaranteedRequired => "STOP_LOSS_ORDER_GUARANTEED_REQUIRED",
5490            Self::StopLossOrderGuaranteedPriceWithinSpread => {
5491                "STOP_LOSS_ORDER_GUARANTEED_PRICE_WITHIN_SPREAD"
5492            }
5493            Self::StopLossOrderGuaranteedNotAllowed => "STOP_LOSS_ORDER_GUARANTEED_NOT_ALLOWED",
5494            Self::StopLossOrderGuaranteedHaltedCreateViolation => {
5495                "STOP_LOSS_ORDER_GUARANTEED_HALTED_CREATE_VIOLATION"
5496            }
5497            Self::StopLossOrderGuaranteedHaltedTightenViolation => {
5498                "STOP_LOSS_ORDER_GUARANTEED_HALTED_TIGHTEN_VIOLATION"
5499            }
5500            Self::StopLossOrderGuaranteedHedgingNotAllowed => {
5501                "STOP_LOSS_ORDER_GUARANTEED_HEDGING_NOT_ALLOWED"
5502            }
5503            Self::StopLossOrderGuaranteedMinimumDistanceNotMet => {
5504                "STOP_LOSS_ORDER_GUARANTEED_MINIMUM_DISTANCE_NOT_MET"
5505            }
5506            Self::StopLossOrderNotCancelable => "STOP_LOSS_ORDER_NOT_CANCELABLE",
5507            Self::StopLossOrderNotReplaceable => "STOP_LOSS_ORDER_NOT_REPLACEABLE",
5508            Self::StopLossOrderGuaranteedLevelRestrictionExceeded => {
5509                "STOP_LOSS_ORDER_GUARANTEED_LEVEL_RESTRICTION_EXCEEDED"
5510            }
5511            Self::StopLossOrderPriceAndDistanceBothSpecified => {
5512                "STOP_LOSS_ORDER_PRICE_AND_DISTANCE_BOTH_SPECIFIED"
5513            }
5514            Self::StopLossOrderPriceAndDistanceBothMissing => {
5515                "STOP_LOSS_ORDER_PRICE_AND_DISTANCE_BOTH_MISSING"
5516            }
5517            Self::StopLossOrderWouldViolateFifoViolationSafeguard => {
5518                "STOP_LOSS_ORDER_WOULD_VIOLATE_FIFO_VIOLATION_SAFEGUARD"
5519            }
5520            Self::StopLossOrderRmoMutualExclusivityMutuallyExclusiveViolation => {
5521                "STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_MUTUALLY_EXCLUSIVE_VIOLATION"
5522            }
5523            Self::StopLossOrderRmoMutualExclusivityGsloExcludesOthersViolation => {
5524                "STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_GSLO_EXCLUDES_OTHERS_VIOLATION"
5525            }
5526            Self::StopLossOnFillRequiredForPendingOrder => {
5527                "STOP_LOSS_ON_FILL_REQUIRED_FOR_PENDING_ORDER"
5528            }
5529            Self::StopLossOnFillGuaranteedNotAllowed => "STOP_LOSS_ON_FILL_GUARANTEED_NOT_ALLOWED",
5530            Self::StopLossOnFillGuaranteedRequired => "STOP_LOSS_ON_FILL_GUARANTEED_REQUIRED",
5531            Self::StopLossOnFillPriceMissing => "STOP_LOSS_ON_FILL_PRICE_MISSING",
5532            Self::StopLossOnFillPriceInvalid => "STOP_LOSS_ON_FILL_PRICE_INVALID",
5533            Self::StopLossOnFillPricePrecisionExceeded => {
5534                "STOP_LOSS_ON_FILL_PRICE_PRECISION_EXCEEDED"
5535            }
5536            Self::StopLossOnFillGuaranteedMinimumDistanceNotMet => {
5537                "STOP_LOSS_ON_FILL_GUARANTEED_MINIMUM_DISTANCE_NOT_MET"
5538            }
5539            Self::StopLossOnFillGuaranteedLevelRestrictionExceeded => {
5540                "STOP_LOSS_ON_FILL_GUARANTEED_LEVEL_RESTRICTION_EXCEEDED"
5541            }
5542            Self::StopLossOnFillDistanceInvalid => "STOP_LOSS_ON_FILL_DISTANCE_INVALID",
5543            Self::StopLossOnFillPriceDistanceMaximumExceeded => {
5544                "STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED"
5545            }
5546            Self::StopLossOnFillDistancePrecisionExceeded => {
5547                "STOP_LOSS_ON_FILL_DISTANCE_PRECISION_EXCEEDED"
5548            }
5549            Self::StopLossOnFillPriceAndDistanceBothSpecified => {
5550                "STOP_LOSS_ON_FILL_PRICE_AND_DISTANCE_BOTH_SPECIFIED"
5551            }
5552            Self::StopLossOnFillPriceAndDistanceBothMissing => {
5553                "STOP_LOSS_ON_FILL_PRICE_AND_DISTANCE_BOTH_MISSING"
5554            }
5555            Self::StopLossOnFillTimeInForceMissing => "STOP_LOSS_ON_FILL_TIME_IN_FORCE_MISSING",
5556            Self::StopLossOnFillTimeInForceInvalid => "STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID",
5557            Self::StopLossOnFillGtdTimestampMissing => "STOP_LOSS_ON_FILL_GTD_TIMESTAMP_MISSING",
5558            Self::StopLossOnFillGtdTimestampInPast => "STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST",
5559            Self::StopLossOnFillClientOrderIdInvalid => "STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_INVALID",
5560            Self::StopLossOnFillClientOrderTagInvalid => {
5561                "STOP_LOSS_ON_FILL_CLIENT_ORDER_TAG_INVALID"
5562            }
5563            Self::StopLossOnFillClientOrderCommentInvalid => {
5564                "STOP_LOSS_ON_FILL_CLIENT_ORDER_COMMENT_INVALID"
5565            }
5566            Self::StopLossOnFillTriggerConditionMissing => {
5567                "STOP_LOSS_ON_FILL_TRIGGER_CONDITION_MISSING"
5568            }
5569            Self::StopLossOnFillTriggerConditionInvalid => {
5570                "STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID"
5571            }
5572            Self::GuaranteedStopLossOrderAlreadyExists => {
5573                "GUARANTEED_STOP_LOSS_ORDER_ALREADY_EXISTS"
5574            }
5575            Self::GuaranteedStopLossOrderRequired => "GUARANTEED_STOP_LOSS_ORDER_REQUIRED",
5576            Self::GuaranteedStopLossOrderPriceWithinSpread => {
5577                "GUARANTEED_STOP_LOSS_ORDER_PRICE_WITHIN_SPREAD"
5578            }
5579            Self::GuaranteedStopLossOrderNotAllowed => "GUARANTEED_STOP_LOSS_ORDER_NOT_ALLOWED",
5580            Self::GuaranteedStopLossOrderHaltedCreateViolation => {
5581                "GUARANTEED_STOP_LOSS_ORDER_HALTED_CREATE_VIOLATION"
5582            }
5583            Self::GuaranteedStopLossOrderCreateViolation => {
5584                "GUARANTEED_STOP_LOSS_ORDER_CREATE_VIOLATION"
5585            }
5586            Self::GuaranteedStopLossOrderHaltedTightenViolation => {
5587                "GUARANTEED_STOP_LOSS_ORDER_HALTED_TIGHTEN_VIOLATION"
5588            }
5589            Self::GuaranteedStopLossOrderTightenViolation => {
5590                "GUARANTEED_STOP_LOSS_ORDER_TIGHTEN_VIOLATION"
5591            }
5592            Self::GuaranteedStopLossOrderHedgingNotAllowed => {
5593                "GUARANTEED_STOP_LOSS_ORDER_HEDGING_NOT_ALLOWED"
5594            }
5595            Self::GuaranteedStopLossOrderMinimumDistanceNotMet => {
5596                "GUARANTEED_STOP_LOSS_ORDER_MINIMUM_DISTANCE_NOT_MET"
5597            }
5598            Self::GuaranteedStopLossOrderNotCancelable => {
5599                "GUARANTEED_STOP_LOSS_ORDER_NOT_CANCELABLE"
5600            }
5601            Self::GuaranteedStopLossOrderHaltedNotCancelable => {
5602                "GUARANTEED_STOP_LOSS_ORDER_HALTED_NOT_CANCELABLE"
5603            }
5604            Self::GuaranteedStopLossOrderNotReplaceable => {
5605                "GUARANTEED_STOP_LOSS_ORDER_NOT_REPLACEABLE"
5606            }
5607            Self::GuaranteedStopLossOrderHaltedNotReplaceable => {
5608                "GUARANTEED_STOP_LOSS_ORDER_HALTED_NOT_REPLACEABLE"
5609            }
5610            Self::GuaranteedStopLossOrderLevelRestrictionVolumeExceeded => {
5611                "GUARANTEED_STOP_LOSS_ORDER_LEVEL_RESTRICTION_VOLUME_EXCEEDED"
5612            }
5613            Self::GuaranteedStopLossOrderLevelRestrictionPriceRangeExceeded => {
5614                "GUARANTEED_STOP_LOSS_ORDER_LEVEL_RESTRICTION_PRICE_RANGE_EXCEEDED"
5615            }
5616            Self::GuaranteedStopLossOrderPriceAndDistanceBothSpecified => {
5617                "GUARANTEED_STOP_LOSS_ORDER_PRICE_AND_DISTANCE_BOTH_SPECIFIED"
5618            }
5619            Self::GuaranteedStopLossOrderPriceAndDistanceBothMissing => {
5620                "GUARANTEED_STOP_LOSS_ORDER_PRICE_AND_DISTANCE_BOTH_MISSING"
5621            }
5622            Self::GuaranteedStopLossOrderWouldViolateFifoViolationSafeguard => {
5623                "GUARANTEED_STOP_LOSS_ORDER_WOULD_VIOLATE_FIFO_VIOLATION_SAFEGUARD"
5624            }
5625            Self::GuaranteedStopLossOrderRmoMutualExclusivityMutuallyExclusiveViolation => {
5626                "GUARANTEED_STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_MUTUALLY_EXCLUSIVE_VIOLATION"
5627            }
5628            Self::GuaranteedStopLossOrderRmoMutualExclusivityGsloExcludesOthersViolation => {
5629                "GUARANTEED_STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_GSLO_EXCLUDES_OTHERS_VIOLATION"
5630            }
5631            Self::GuaranteedStopLossOnFillRequiredForPendingOrder => {
5632                "GUARANTEED_STOP_LOSS_ON_FILL_REQUIRED_FOR_PENDING_ORDER"
5633            }
5634            Self::GuaranteedStopLossOnFillNotAllowed => "GUARANTEED_STOP_LOSS_ON_FILL_NOT_ALLOWED",
5635            Self::GuaranteedStopLossOnFillRequired => "GUARANTEED_STOP_LOSS_ON_FILL_REQUIRED",
5636            Self::GuaranteedStopLossOnFillPriceMissing => {
5637                "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_MISSING"
5638            }
5639            Self::GuaranteedStopLossOnFillPriceInvalid => {
5640                "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_INVALID"
5641            }
5642            Self::GuaranteedStopLossOnFillPricePrecisionExceeded => {
5643                "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_PRECISION_EXCEEDED"
5644            }
5645            Self::GuaranteedStopLossOnFillMinimumDistanceNotMet => {
5646                "GUARANTEED_STOP_LOSS_ON_FILL_MINIMUM_DISTANCE_NOT_MET"
5647            }
5648            Self::GuaranteedStopLossOnFillLevelRestrictionVolumeExceeded => {
5649                "GUARANTEED_STOP_LOSS_ON_FILL_LEVEL_RESTRICTION_VOLUME_EXCEEDED"
5650            }
5651            Self::GuaranteedStopLossOnFillLevelRestrictionPriceRangeExceeded => {
5652                "GUARANTEED_STOP_LOSS_ON_FILL_LEVEL_RESTRICTION_PRICE_RANGE_EXCEEDED"
5653            }
5654            Self::GuaranteedStopLossOnFillDistanceInvalid => {
5655                "GUARANTEED_STOP_LOSS_ON_FILL_DISTANCE_INVALID"
5656            }
5657            Self::GuaranteedStopLossOnFillPriceDistanceMaximumExceeded => {
5658                "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED"
5659            }
5660            Self::GuaranteedStopLossOnFillDistancePrecisionExceeded => {
5661                "GUARANTEED_STOP_LOSS_ON_FILL_DISTANCE_PRECISION_EXCEEDED"
5662            }
5663            Self::GuaranteedStopLossOnFillPriceAndDistanceBothSpecified => {
5664                "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_AND_DISTANCE_BOTH_SPECIFIED"
5665            }
5666            Self::GuaranteedStopLossOnFillPriceAndDistanceBothMissing => {
5667                "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_AND_DISTANCE_BOTH_MISSING"
5668            }
5669            Self::GuaranteedStopLossOnFillTimeInForceMissing => {
5670                "GUARANTEED_STOP_LOSS_ON_FILL_TIME_IN_FORCE_MISSING"
5671            }
5672            Self::GuaranteedStopLossOnFillTimeInForceInvalid => {
5673                "GUARANTEED_STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID"
5674            }
5675            Self::GuaranteedStopLossOnFillGtdTimestampMissing => {
5676                "GUARANTEED_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_MISSING"
5677            }
5678            Self::GuaranteedStopLossOnFillGtdTimestampInPast => {
5679                "GUARANTEED_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST"
5680            }
5681            Self::GuaranteedStopLossOnFillClientOrderIdInvalid => {
5682                "GUARANTEED_STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_INVALID"
5683            }
5684            Self::GuaranteedStopLossOnFillClientOrderTagInvalid => {
5685                "GUARANTEED_STOP_LOSS_ON_FILL_CLIENT_ORDER_TAG_INVALID"
5686            }
5687            Self::GuaranteedStopLossOnFillClientOrderCommentInvalid => {
5688                "GUARANTEED_STOP_LOSS_ON_FILL_CLIENT_ORDER_COMMENT_INVALID"
5689            }
5690            Self::GuaranteedStopLossOnFillTriggerConditionMissing => {
5691                "GUARANTEED_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_MISSING"
5692            }
5693            Self::GuaranteedStopLossOnFillTriggerConditionInvalid => {
5694                "GUARANTEED_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID"
5695            }
5696            Self::TrailingStopLossOrderAlreadyExists => "TRAILING_STOP_LOSS_ORDER_ALREADY_EXISTS",
5697            Self::TrailingStopLossOrderWouldViolateFifoViolationSafeguard => {
5698                "TRAILING_STOP_LOSS_ORDER_WOULD_VIOLATE_FIFO_VIOLATION_SAFEGUARD"
5699            }
5700            Self::TrailingStopLossOrderRmoMutualExclusivityMutuallyExclusiveViolation => {
5701                "TRAILING_STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_MUTUALLY_EXCLUSIVE_VIOLATION"
5702            }
5703            Self::TrailingStopLossOrderRmoMutualExclusivityGsloExcludesOthersViolation => {
5704                "TRAILING_STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_GSLO_EXCLUDES_OTHERS_VIOLATION"
5705            }
5706            Self::TrailingStopLossOnFillPriceDistanceMissing => {
5707                "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MISSING"
5708            }
5709            Self::TrailingStopLossOnFillPriceDistanceInvalid => {
5710                "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_INVALID"
5711            }
5712            Self::TrailingStopLossOnFillPriceDistancePrecisionExceeded => {
5713                "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_PRECISION_EXCEEDED"
5714            }
5715            Self::TrailingStopLossOnFillPriceDistanceMaximumExceeded => {
5716                "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED"
5717            }
5718            Self::TrailingStopLossOnFillPriceDistanceMinimumNotMet => {
5719                "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MINIMUM_NOT_MET"
5720            }
5721            Self::TrailingStopLossOnFillTimeInForceMissing => {
5722                "TRAILING_STOP_LOSS_ON_FILL_TIME_IN_FORCE_MISSING"
5723            }
5724            Self::TrailingStopLossOnFillTimeInForceInvalid => {
5725                "TRAILING_STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID"
5726            }
5727            Self::TrailingStopLossOnFillGtdTimestampMissing => {
5728                "TRAILING_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_MISSING"
5729            }
5730            Self::TrailingStopLossOnFillGtdTimestampInPast => {
5731                "TRAILING_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST"
5732            }
5733            Self::TrailingStopLossOnFillClientOrderIdInvalid => {
5734                "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_INVALID"
5735            }
5736            Self::TrailingStopLossOnFillClientOrderTagInvalid => {
5737                "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_TAG_INVALID"
5738            }
5739            Self::TrailingStopLossOnFillClientOrderCommentInvalid => {
5740                "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_COMMENT_INVALID"
5741            }
5742            Self::TrailingStopLossOrdersNotSupported => "TRAILING_STOP_LOSS_ORDERS_NOT_SUPPORTED",
5743            Self::TrailingStopLossOnFillTriggerConditionMissing => {
5744                "TRAILING_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_MISSING"
5745            }
5746            Self::TrailingStopLossOnFillTriggerConditionInvalid => {
5747                "TRAILING_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID"
5748            }
5749            Self::CloseTradeTypeMissing => "CLOSE_TRADE_TYPE_MISSING",
5750            Self::CloseTradePartialUnitsMissing => "CLOSE_TRADE_PARTIAL_UNITS_MISSING",
5751            Self::CloseTradeUnitsExceedTradeSize => "CLOSE_TRADE_UNITS_EXCEED_TRADE_SIZE",
5752            Self::CloseoutPositionDoesntExist => "CLOSEOUT_POSITION_DOESNT_EXIST",
5753            Self::CloseoutPositionIncompleteSpecification => {
5754                "CLOSEOUT_POSITION_INCOMPLETE_SPECIFICATION"
5755            }
5756            Self::CloseoutPositionUnitsExceedPositionSize => {
5757                "CLOSEOUT_POSITION_UNITS_EXCEED_POSITION_SIZE"
5758            }
5759            Self::CloseoutPositionReject => "CLOSEOUT_POSITION_REJECT",
5760            Self::CloseoutPositionPartialUnitsMissing => "CLOSEOUT_POSITION_PARTIAL_UNITS_MISSING",
5761            Self::MarkupGroupIdInvalid => "MARKUP_GROUP_ID_INVALID",
5762            Self::PositionAggregationModeInvalid => "POSITION_AGGREGATION_MODE_INVALID",
5763            Self::AdminConfigureDataMissing => "ADMIN_CONFIGURE_DATA_MISSING",
5764            Self::MarginRateInvalid => "MARGIN_RATE_INVALID",
5765            Self::MarginRateWouldTriggerCloseout => "MARGIN_RATE_WOULD_TRIGGER_CLOSEOUT",
5766            Self::AliasInvalid => "ALIAS_INVALID",
5767            Self::ClientConfigureDataMissing => "CLIENT_CONFIGURE_DATA_MISSING",
5768            Self::MarginRateWouldTriggerMarginCall => "MARGIN_RATE_WOULD_TRIGGER_MARGIN_CALL",
5769            Self::AmountInvalid => "AMOUNT_INVALID",
5770            Self::InsufficientFunds => "INSUFFICIENT_FUNDS",
5771            Self::AmountMissing => "AMOUNT_MISSING",
5772            Self::FundingReasonMissing => "FUNDING_REASON_MISSING",
5773            Self::OcaOrderIdsStopLossNotAllowed => "OCA_ORDER_IDS_STOP_LOSS_NOT_ALLOWED",
5774            Self::ClientExtensionsDataMissing => "CLIENT_EXTENSIONS_DATA_MISSING",
5775            Self::ReplacingOrderInvalid => "REPLACING_ORDER_INVALID",
5776            Self::ReplacingTradeIdInvalid => "REPLACING_TRADE_ID_INVALID",
5777            Self::OrderCancelWouldTriggerCloseout => "ORDER_CANCEL_WOULD_TRIGGER_CLOSEOUT",
5778            Self::Unknown(value) => value,
5779        }
5780    }
5781}
5782
5783impl Serialize for TransactionRejectReason {
5784    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5785        serializer.serialize_str(self.as_str())
5786    }
5787}
5788
5789impl<'de> Deserialize<'de> for TransactionRejectReason {
5790    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5791        let value = String::deserialize(deserializer)?;
5792        Ok(match value.as_str() {
5793            "INTERNAL_SERVER_ERROR" => Self::InternalServerError,
5794            "INSTRUMENT_PRICE_UNKNOWN" => Self::InstrumentPriceUnknown,
5795            "ACCOUNT_NOT_ACTIVE" => Self::AccountNotActive,
5796            "ACCOUNT_LOCKED" => Self::AccountLocked,
5797            "ACCOUNT_ORDER_CREATION_LOCKED" => Self::AccountOrderCreationLocked,
5798            "ACCOUNT_CONFIGURATION_LOCKED" => Self::AccountConfigurationLocked,
5799            "ACCOUNT_DEPOSIT_LOCKED" => Self::AccountDepositLocked,
5800            "ACCOUNT_WITHDRAWAL_LOCKED" => Self::AccountWithdrawalLocked,
5801            "ACCOUNT_ORDER_CANCEL_LOCKED" => Self::AccountOrderCancelLocked,
5802            "INSTRUMENT_NOT_TRADEABLE" => Self::InstrumentNotTradeable,
5803            "PENDING_ORDERS_ALLOWED_EXCEEDED" => Self::PendingOrdersAllowedExceeded,
5804            "ORDER_ID_UNSPECIFIED" => Self::OrderIdUnspecified,
5805            "ORDER_DOESNT_EXIST" => Self::OrderDoesntExist,
5806            "ORDER_IDENTIFIER_INCONSISTENCY" => Self::OrderIdentifierInconsistency,
5807            "TRADE_ID_UNSPECIFIED" => Self::TradeIdUnspecified,
5808            "TRADE_DOESNT_EXIST" => Self::TradeDoesntExist,
5809            "TRADE_IDENTIFIER_INCONSISTENCY" => Self::TradeIdentifierInconsistency,
5810            "INSUFFICIENT_MARGIN" => Self::InsufficientMargin,
5811            "INSTRUMENT_MISSING" => Self::InstrumentMissing,
5812            "INSTRUMENT_UNKNOWN" => Self::InstrumentUnknown,
5813            "UNITS_MISSING" => Self::UnitsMissing,
5814            "UNITS_INVALID" => Self::UnitsInvalid,
5815            "UNITS_PRECISION_EXCEEDED" => Self::UnitsPrecisionExceeded,
5816            "UNITS_LIMIT_EXCEEDED" => Self::UnitsLimitExceeded,
5817            "UNITS_MINIMUM_NOT_MET" => Self::UnitsMinimumNotMet,
5818            "PRICE_MISSING" => Self::PriceMissing,
5819            "PRICE_INVALID" => Self::PriceInvalid,
5820            "PRICE_PRECISION_EXCEEDED" => Self::PricePrecisionExceeded,
5821            "PRICE_DISTANCE_MISSING" => Self::PriceDistanceMissing,
5822            "PRICE_DISTANCE_INVALID" => Self::PriceDistanceInvalid,
5823            "PRICE_DISTANCE_PRECISION_EXCEEDED" => Self::PriceDistancePrecisionExceeded,
5824            "PRICE_DISTANCE_MAXIMUM_EXCEEDED" => Self::PriceDistanceMaximumExceeded,
5825            "PRICE_DISTANCE_MINIMUM_NOT_MET" => Self::PriceDistanceMinimumNotMet,
5826            "TIME_IN_FORCE_MISSING" => Self::TimeInForceMissing,
5827            "TIME_IN_FORCE_INVALID" => Self::TimeInForceInvalid,
5828            "TIME_IN_FORCE_GTD_TIMESTAMP_MISSING" => Self::TimeInForceGtdTimestampMissing,
5829            "TIME_IN_FORCE_GTD_TIMESTAMP_IN_PAST" => Self::TimeInForceGtdTimestampInPast,
5830            "PRICE_BOUND_INVALID" => Self::PriceBoundInvalid,
5831            "PRICE_BOUND_PRECISION_EXCEEDED" => Self::PriceBoundPrecisionExceeded,
5832            "ORDERS_ON_FILL_DUPLICATE_CLIENT_ORDER_IDS" => {
5833                Self::OrdersOnFillDuplicateClientOrderIds
5834            }
5835            "TRADE_ON_FILL_CLIENT_EXTENSIONS_NOT_SUPPORTED" => {
5836                Self::TradeOnFillClientExtensionsNotSupported
5837            }
5838            "CLIENT_ORDER_ID_INVALID" => Self::ClientOrderIdInvalid,
5839            "CLIENT_ORDER_ID_ALREADY_EXISTS" => Self::ClientOrderIdAlreadyExists,
5840            "CLIENT_ORDER_TAG_INVALID" => Self::ClientOrderTagInvalid,
5841            "CLIENT_ORDER_COMMENT_INVALID" => Self::ClientOrderCommentInvalid,
5842            "CLIENT_TRADE_ID_INVALID" => Self::ClientTradeIdInvalid,
5843            "CLIENT_TRADE_ID_ALREADY_EXISTS" => Self::ClientTradeIdAlreadyExists,
5844            "CLIENT_TRADE_TAG_INVALID" => Self::ClientTradeTagInvalid,
5845            "CLIENT_TRADE_COMMENT_INVALID" => Self::ClientTradeCommentInvalid,
5846            "ORDER_FILL_POSITION_ACTION_MISSING" => Self::OrderFillPositionActionMissing,
5847            "ORDER_FILL_POSITION_ACTION_INVALID" => Self::OrderFillPositionActionInvalid,
5848            "TRIGGER_CONDITION_MISSING" => Self::TriggerConditionMissing,
5849            "TRIGGER_CONDITION_INVALID" => Self::TriggerConditionInvalid,
5850            "ORDER_PARTIAL_FILL_OPTION_MISSING" => Self::OrderPartialFillOptionMissing,
5851            "ORDER_PARTIAL_FILL_OPTION_INVALID" => Self::OrderPartialFillOptionInvalid,
5852            "INVALID_REISSUE_IMMEDIATE_PARTIAL_FILL" => Self::InvalidReissueImmediatePartialFill,
5853            "ORDERS_ON_FILL_RMO_MUTUAL_EXCLUSIVITY_MUTUALLY_EXCLUSIVE_VIOLATION" => {
5854                Self::OrdersOnFillRmoMutualExclusivityMutuallyExclusiveViolation
5855            }
5856            "ORDERS_ON_FILL_RMO_MUTUAL_EXCLUSIVITY_GSLO_EXCLUDES_OTHERS_VIOLATION" => {
5857                Self::OrdersOnFillRmoMutualExclusivityGsloExcludesOthersViolation
5858            }
5859            "TAKE_PROFIT_ORDER_ALREADY_EXISTS" => Self::TakeProfitOrderAlreadyExists,
5860            "TAKE_PROFIT_ORDER_WOULD_VIOLATE_FIFO_VIOLATION_SAFEGUARD" => {
5861                Self::TakeProfitOrderWouldViolateFifoViolationSafeguard
5862            }
5863            "TAKE_PROFIT_ON_FILL_PRICE_MISSING" => Self::TakeProfitOnFillPriceMissing,
5864            "TAKE_PROFIT_ON_FILL_PRICE_INVALID" => Self::TakeProfitOnFillPriceInvalid,
5865            "TAKE_PROFIT_ON_FILL_PRICE_PRECISION_EXCEEDED" => {
5866                Self::TakeProfitOnFillPricePrecisionExceeded
5867            }
5868            "TAKE_PROFIT_ON_FILL_TIME_IN_FORCE_MISSING" => Self::TakeProfitOnFillTimeInForceMissing,
5869            "TAKE_PROFIT_ON_FILL_TIME_IN_FORCE_INVALID" => Self::TakeProfitOnFillTimeInForceInvalid,
5870            "TAKE_PROFIT_ON_FILL_GTD_TIMESTAMP_MISSING" => {
5871                Self::TakeProfitOnFillGtdTimestampMissing
5872            }
5873            "TAKE_PROFIT_ON_FILL_GTD_TIMESTAMP_IN_PAST" => Self::TakeProfitOnFillGtdTimestampInPast,
5874            "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_ID_INVALID" => {
5875                Self::TakeProfitOnFillClientOrderIdInvalid
5876            }
5877            "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_TAG_INVALID" => {
5878                Self::TakeProfitOnFillClientOrderTagInvalid
5879            }
5880            "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_COMMENT_INVALID" => {
5881                Self::TakeProfitOnFillClientOrderCommentInvalid
5882            }
5883            "TAKE_PROFIT_ON_FILL_TRIGGER_CONDITION_MISSING" => {
5884                Self::TakeProfitOnFillTriggerConditionMissing
5885            }
5886            "TAKE_PROFIT_ON_FILL_TRIGGER_CONDITION_INVALID" => {
5887                Self::TakeProfitOnFillTriggerConditionInvalid
5888            }
5889            "STOP_LOSS_ORDER_ALREADY_EXISTS" => Self::StopLossOrderAlreadyExists,
5890            "STOP_LOSS_ORDER_GUARANTEED_REQUIRED" => Self::StopLossOrderGuaranteedRequired,
5891            "STOP_LOSS_ORDER_GUARANTEED_PRICE_WITHIN_SPREAD" => {
5892                Self::StopLossOrderGuaranteedPriceWithinSpread
5893            }
5894            "STOP_LOSS_ORDER_GUARANTEED_NOT_ALLOWED" => Self::StopLossOrderGuaranteedNotAllowed,
5895            "STOP_LOSS_ORDER_GUARANTEED_HALTED_CREATE_VIOLATION" => {
5896                Self::StopLossOrderGuaranteedHaltedCreateViolation
5897            }
5898            "STOP_LOSS_ORDER_GUARANTEED_HALTED_TIGHTEN_VIOLATION" => {
5899                Self::StopLossOrderGuaranteedHaltedTightenViolation
5900            }
5901            "STOP_LOSS_ORDER_GUARANTEED_HEDGING_NOT_ALLOWED" => {
5902                Self::StopLossOrderGuaranteedHedgingNotAllowed
5903            }
5904            "STOP_LOSS_ORDER_GUARANTEED_MINIMUM_DISTANCE_NOT_MET" => {
5905                Self::StopLossOrderGuaranteedMinimumDistanceNotMet
5906            }
5907            "STOP_LOSS_ORDER_NOT_CANCELABLE" => Self::StopLossOrderNotCancelable,
5908            "STOP_LOSS_ORDER_NOT_REPLACEABLE" => Self::StopLossOrderNotReplaceable,
5909            "STOP_LOSS_ORDER_GUARANTEED_LEVEL_RESTRICTION_EXCEEDED" => {
5910                Self::StopLossOrderGuaranteedLevelRestrictionExceeded
5911            }
5912            "STOP_LOSS_ORDER_PRICE_AND_DISTANCE_BOTH_SPECIFIED" => {
5913                Self::StopLossOrderPriceAndDistanceBothSpecified
5914            }
5915            "STOP_LOSS_ORDER_PRICE_AND_DISTANCE_BOTH_MISSING" => {
5916                Self::StopLossOrderPriceAndDistanceBothMissing
5917            }
5918            "STOP_LOSS_ORDER_WOULD_VIOLATE_FIFO_VIOLATION_SAFEGUARD" => {
5919                Self::StopLossOrderWouldViolateFifoViolationSafeguard
5920            }
5921            "STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_MUTUALLY_EXCLUSIVE_VIOLATION" => {
5922                Self::StopLossOrderRmoMutualExclusivityMutuallyExclusiveViolation
5923            }
5924            "STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_GSLO_EXCLUDES_OTHERS_VIOLATION" => {
5925                Self::StopLossOrderRmoMutualExclusivityGsloExcludesOthersViolation
5926            }
5927            "STOP_LOSS_ON_FILL_REQUIRED_FOR_PENDING_ORDER" => {
5928                Self::StopLossOnFillRequiredForPendingOrder
5929            }
5930            "STOP_LOSS_ON_FILL_GUARANTEED_NOT_ALLOWED" => Self::StopLossOnFillGuaranteedNotAllowed,
5931            "STOP_LOSS_ON_FILL_GUARANTEED_REQUIRED" => Self::StopLossOnFillGuaranteedRequired,
5932            "STOP_LOSS_ON_FILL_PRICE_MISSING" => Self::StopLossOnFillPriceMissing,
5933            "STOP_LOSS_ON_FILL_PRICE_INVALID" => Self::StopLossOnFillPriceInvalid,
5934            "STOP_LOSS_ON_FILL_PRICE_PRECISION_EXCEEDED" => {
5935                Self::StopLossOnFillPricePrecisionExceeded
5936            }
5937            "STOP_LOSS_ON_FILL_GUARANTEED_MINIMUM_DISTANCE_NOT_MET" => {
5938                Self::StopLossOnFillGuaranteedMinimumDistanceNotMet
5939            }
5940            "STOP_LOSS_ON_FILL_GUARANTEED_LEVEL_RESTRICTION_EXCEEDED" => {
5941                Self::StopLossOnFillGuaranteedLevelRestrictionExceeded
5942            }
5943            "STOP_LOSS_ON_FILL_DISTANCE_INVALID" => Self::StopLossOnFillDistanceInvalid,
5944            "STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED" => {
5945                Self::StopLossOnFillPriceDistanceMaximumExceeded
5946            }
5947            "STOP_LOSS_ON_FILL_DISTANCE_PRECISION_EXCEEDED" => {
5948                Self::StopLossOnFillDistancePrecisionExceeded
5949            }
5950            "STOP_LOSS_ON_FILL_PRICE_AND_DISTANCE_BOTH_SPECIFIED" => {
5951                Self::StopLossOnFillPriceAndDistanceBothSpecified
5952            }
5953            "STOP_LOSS_ON_FILL_PRICE_AND_DISTANCE_BOTH_MISSING" => {
5954                Self::StopLossOnFillPriceAndDistanceBothMissing
5955            }
5956            "STOP_LOSS_ON_FILL_TIME_IN_FORCE_MISSING" => Self::StopLossOnFillTimeInForceMissing,
5957            "STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID" => Self::StopLossOnFillTimeInForceInvalid,
5958            "STOP_LOSS_ON_FILL_GTD_TIMESTAMP_MISSING" => Self::StopLossOnFillGtdTimestampMissing,
5959            "STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST" => Self::StopLossOnFillGtdTimestampInPast,
5960            "STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_INVALID" => Self::StopLossOnFillClientOrderIdInvalid,
5961            "STOP_LOSS_ON_FILL_CLIENT_ORDER_TAG_INVALID" => {
5962                Self::StopLossOnFillClientOrderTagInvalid
5963            }
5964            "STOP_LOSS_ON_FILL_CLIENT_ORDER_COMMENT_INVALID" => {
5965                Self::StopLossOnFillClientOrderCommentInvalid
5966            }
5967            "STOP_LOSS_ON_FILL_TRIGGER_CONDITION_MISSING" => {
5968                Self::StopLossOnFillTriggerConditionMissing
5969            }
5970            "STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID" => {
5971                Self::StopLossOnFillTriggerConditionInvalid
5972            }
5973            "GUARANTEED_STOP_LOSS_ORDER_ALREADY_EXISTS" => {
5974                Self::GuaranteedStopLossOrderAlreadyExists
5975            }
5976            "GUARANTEED_STOP_LOSS_ORDER_REQUIRED" => Self::GuaranteedStopLossOrderRequired,
5977            "GUARANTEED_STOP_LOSS_ORDER_PRICE_WITHIN_SPREAD" => {
5978                Self::GuaranteedStopLossOrderPriceWithinSpread
5979            }
5980            "GUARANTEED_STOP_LOSS_ORDER_NOT_ALLOWED" => Self::GuaranteedStopLossOrderNotAllowed,
5981            "GUARANTEED_STOP_LOSS_ORDER_HALTED_CREATE_VIOLATION" => {
5982                Self::GuaranteedStopLossOrderHaltedCreateViolation
5983            }
5984            "GUARANTEED_STOP_LOSS_ORDER_CREATE_VIOLATION" => {
5985                Self::GuaranteedStopLossOrderCreateViolation
5986            }
5987            "GUARANTEED_STOP_LOSS_ORDER_HALTED_TIGHTEN_VIOLATION" => {
5988                Self::GuaranteedStopLossOrderHaltedTightenViolation
5989            }
5990            "GUARANTEED_STOP_LOSS_ORDER_TIGHTEN_VIOLATION" => {
5991                Self::GuaranteedStopLossOrderTightenViolation
5992            }
5993            "GUARANTEED_STOP_LOSS_ORDER_HEDGING_NOT_ALLOWED" => {
5994                Self::GuaranteedStopLossOrderHedgingNotAllowed
5995            }
5996            "GUARANTEED_STOP_LOSS_ORDER_MINIMUM_DISTANCE_NOT_MET" => {
5997                Self::GuaranteedStopLossOrderMinimumDistanceNotMet
5998            }
5999            "GUARANTEED_STOP_LOSS_ORDER_NOT_CANCELABLE" => {
6000                Self::GuaranteedStopLossOrderNotCancelable
6001            }
6002            "GUARANTEED_STOP_LOSS_ORDER_HALTED_NOT_CANCELABLE" => {
6003                Self::GuaranteedStopLossOrderHaltedNotCancelable
6004            }
6005            "GUARANTEED_STOP_LOSS_ORDER_NOT_REPLACEABLE" => {
6006                Self::GuaranteedStopLossOrderNotReplaceable
6007            }
6008            "GUARANTEED_STOP_LOSS_ORDER_HALTED_NOT_REPLACEABLE" => {
6009                Self::GuaranteedStopLossOrderHaltedNotReplaceable
6010            }
6011            "GUARANTEED_STOP_LOSS_ORDER_LEVEL_RESTRICTION_VOLUME_EXCEEDED" => {
6012                Self::GuaranteedStopLossOrderLevelRestrictionVolumeExceeded
6013            }
6014            "GUARANTEED_STOP_LOSS_ORDER_LEVEL_RESTRICTION_PRICE_RANGE_EXCEEDED" => {
6015                Self::GuaranteedStopLossOrderLevelRestrictionPriceRangeExceeded
6016            }
6017            "GUARANTEED_STOP_LOSS_ORDER_PRICE_AND_DISTANCE_BOTH_SPECIFIED" => {
6018                Self::GuaranteedStopLossOrderPriceAndDistanceBothSpecified
6019            }
6020            "GUARANTEED_STOP_LOSS_ORDER_PRICE_AND_DISTANCE_BOTH_MISSING" => {
6021                Self::GuaranteedStopLossOrderPriceAndDistanceBothMissing
6022            }
6023            "GUARANTEED_STOP_LOSS_ORDER_WOULD_VIOLATE_FIFO_VIOLATION_SAFEGUARD" => {
6024                Self::GuaranteedStopLossOrderWouldViolateFifoViolationSafeguard
6025            }
6026            "GUARANTEED_STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_MUTUALLY_EXCLUSIVE_VIOLATION" => {
6027                Self::GuaranteedStopLossOrderRmoMutualExclusivityMutuallyExclusiveViolation
6028            }
6029            "GUARANTEED_STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_GSLO_EXCLUDES_OTHERS_VIOLATION" => {
6030                Self::GuaranteedStopLossOrderRmoMutualExclusivityGsloExcludesOthersViolation
6031            }
6032            "GUARANTEED_STOP_LOSS_ON_FILL_REQUIRED_FOR_PENDING_ORDER" => {
6033                Self::GuaranteedStopLossOnFillRequiredForPendingOrder
6034            }
6035            "GUARANTEED_STOP_LOSS_ON_FILL_NOT_ALLOWED" => Self::GuaranteedStopLossOnFillNotAllowed,
6036            "GUARANTEED_STOP_LOSS_ON_FILL_REQUIRED" => Self::GuaranteedStopLossOnFillRequired,
6037            "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_MISSING" => {
6038                Self::GuaranteedStopLossOnFillPriceMissing
6039            }
6040            "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_INVALID" => {
6041                Self::GuaranteedStopLossOnFillPriceInvalid
6042            }
6043            "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_PRECISION_EXCEEDED" => {
6044                Self::GuaranteedStopLossOnFillPricePrecisionExceeded
6045            }
6046            "GUARANTEED_STOP_LOSS_ON_FILL_MINIMUM_DISTANCE_NOT_MET" => {
6047                Self::GuaranteedStopLossOnFillMinimumDistanceNotMet
6048            }
6049            "GUARANTEED_STOP_LOSS_ON_FILL_LEVEL_RESTRICTION_VOLUME_EXCEEDED" => {
6050                Self::GuaranteedStopLossOnFillLevelRestrictionVolumeExceeded
6051            }
6052            "GUARANTEED_STOP_LOSS_ON_FILL_LEVEL_RESTRICTION_PRICE_RANGE_EXCEEDED" => {
6053                Self::GuaranteedStopLossOnFillLevelRestrictionPriceRangeExceeded
6054            }
6055            "GUARANTEED_STOP_LOSS_ON_FILL_DISTANCE_INVALID" => {
6056                Self::GuaranteedStopLossOnFillDistanceInvalid
6057            }
6058            "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED" => {
6059                Self::GuaranteedStopLossOnFillPriceDistanceMaximumExceeded
6060            }
6061            "GUARANTEED_STOP_LOSS_ON_FILL_DISTANCE_PRECISION_EXCEEDED" => {
6062                Self::GuaranteedStopLossOnFillDistancePrecisionExceeded
6063            }
6064            "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_AND_DISTANCE_BOTH_SPECIFIED" => {
6065                Self::GuaranteedStopLossOnFillPriceAndDistanceBothSpecified
6066            }
6067            "GUARANTEED_STOP_LOSS_ON_FILL_PRICE_AND_DISTANCE_BOTH_MISSING" => {
6068                Self::GuaranteedStopLossOnFillPriceAndDistanceBothMissing
6069            }
6070            "GUARANTEED_STOP_LOSS_ON_FILL_TIME_IN_FORCE_MISSING" => {
6071                Self::GuaranteedStopLossOnFillTimeInForceMissing
6072            }
6073            "GUARANTEED_STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID" => {
6074                Self::GuaranteedStopLossOnFillTimeInForceInvalid
6075            }
6076            "GUARANTEED_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_MISSING" => {
6077                Self::GuaranteedStopLossOnFillGtdTimestampMissing
6078            }
6079            "GUARANTEED_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST" => {
6080                Self::GuaranteedStopLossOnFillGtdTimestampInPast
6081            }
6082            "GUARANTEED_STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_INVALID" => {
6083                Self::GuaranteedStopLossOnFillClientOrderIdInvalid
6084            }
6085            "GUARANTEED_STOP_LOSS_ON_FILL_CLIENT_ORDER_TAG_INVALID" => {
6086                Self::GuaranteedStopLossOnFillClientOrderTagInvalid
6087            }
6088            "GUARANTEED_STOP_LOSS_ON_FILL_CLIENT_ORDER_COMMENT_INVALID" => {
6089                Self::GuaranteedStopLossOnFillClientOrderCommentInvalid
6090            }
6091            "GUARANTEED_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_MISSING" => {
6092                Self::GuaranteedStopLossOnFillTriggerConditionMissing
6093            }
6094            "GUARANTEED_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID" => {
6095                Self::GuaranteedStopLossOnFillTriggerConditionInvalid
6096            }
6097            "TRAILING_STOP_LOSS_ORDER_ALREADY_EXISTS" => Self::TrailingStopLossOrderAlreadyExists,
6098            "TRAILING_STOP_LOSS_ORDER_WOULD_VIOLATE_FIFO_VIOLATION_SAFEGUARD" => {
6099                Self::TrailingStopLossOrderWouldViolateFifoViolationSafeguard
6100            }
6101            "TRAILING_STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_MUTUALLY_EXCLUSIVE_VIOLATION" => {
6102                Self::TrailingStopLossOrderRmoMutualExclusivityMutuallyExclusiveViolation
6103            }
6104            "TRAILING_STOP_LOSS_ORDER_RMO_MUTUAL_EXCLUSIVITY_GSLO_EXCLUDES_OTHERS_VIOLATION" => {
6105                Self::TrailingStopLossOrderRmoMutualExclusivityGsloExcludesOthersViolation
6106            }
6107            "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MISSING" => {
6108                Self::TrailingStopLossOnFillPriceDistanceMissing
6109            }
6110            "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_INVALID" => {
6111                Self::TrailingStopLossOnFillPriceDistanceInvalid
6112            }
6113            "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_PRECISION_EXCEEDED" => {
6114                Self::TrailingStopLossOnFillPriceDistancePrecisionExceeded
6115            }
6116            "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED" => {
6117                Self::TrailingStopLossOnFillPriceDistanceMaximumExceeded
6118            }
6119            "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MINIMUM_NOT_MET" => {
6120                Self::TrailingStopLossOnFillPriceDistanceMinimumNotMet
6121            }
6122            "TRAILING_STOP_LOSS_ON_FILL_TIME_IN_FORCE_MISSING" => {
6123                Self::TrailingStopLossOnFillTimeInForceMissing
6124            }
6125            "TRAILING_STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID" => {
6126                Self::TrailingStopLossOnFillTimeInForceInvalid
6127            }
6128            "TRAILING_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_MISSING" => {
6129                Self::TrailingStopLossOnFillGtdTimestampMissing
6130            }
6131            "TRAILING_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST" => {
6132                Self::TrailingStopLossOnFillGtdTimestampInPast
6133            }
6134            "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_INVALID" => {
6135                Self::TrailingStopLossOnFillClientOrderIdInvalid
6136            }
6137            "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_TAG_INVALID" => {
6138                Self::TrailingStopLossOnFillClientOrderTagInvalid
6139            }
6140            "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_COMMENT_INVALID" => {
6141                Self::TrailingStopLossOnFillClientOrderCommentInvalid
6142            }
6143            "TRAILING_STOP_LOSS_ORDERS_NOT_SUPPORTED" => Self::TrailingStopLossOrdersNotSupported,
6144            "TRAILING_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_MISSING" => {
6145                Self::TrailingStopLossOnFillTriggerConditionMissing
6146            }
6147            "TRAILING_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID" => {
6148                Self::TrailingStopLossOnFillTriggerConditionInvalid
6149            }
6150            "CLOSE_TRADE_TYPE_MISSING" => Self::CloseTradeTypeMissing,
6151            "CLOSE_TRADE_PARTIAL_UNITS_MISSING" => Self::CloseTradePartialUnitsMissing,
6152            "CLOSE_TRADE_UNITS_EXCEED_TRADE_SIZE" => Self::CloseTradeUnitsExceedTradeSize,
6153            "CLOSEOUT_POSITION_DOESNT_EXIST" => Self::CloseoutPositionDoesntExist,
6154            "CLOSEOUT_POSITION_INCOMPLETE_SPECIFICATION" => {
6155                Self::CloseoutPositionIncompleteSpecification
6156            }
6157            "CLOSEOUT_POSITION_UNITS_EXCEED_POSITION_SIZE" => {
6158                Self::CloseoutPositionUnitsExceedPositionSize
6159            }
6160            "CLOSEOUT_POSITION_REJECT" => Self::CloseoutPositionReject,
6161            "CLOSEOUT_POSITION_PARTIAL_UNITS_MISSING" => Self::CloseoutPositionPartialUnitsMissing,
6162            "MARKUP_GROUP_ID_INVALID" => Self::MarkupGroupIdInvalid,
6163            "POSITION_AGGREGATION_MODE_INVALID" => Self::PositionAggregationModeInvalid,
6164            "ADMIN_CONFIGURE_DATA_MISSING" => Self::AdminConfigureDataMissing,
6165            "MARGIN_RATE_INVALID" => Self::MarginRateInvalid,
6166            "MARGIN_RATE_WOULD_TRIGGER_CLOSEOUT" => Self::MarginRateWouldTriggerCloseout,
6167            "ALIAS_INVALID" => Self::AliasInvalid,
6168            "CLIENT_CONFIGURE_DATA_MISSING" => Self::ClientConfigureDataMissing,
6169            "MARGIN_RATE_WOULD_TRIGGER_MARGIN_CALL" => Self::MarginRateWouldTriggerMarginCall,
6170            "AMOUNT_INVALID" => Self::AmountInvalid,
6171            "INSUFFICIENT_FUNDS" => Self::InsufficientFunds,
6172            "AMOUNT_MISSING" => Self::AmountMissing,
6173            "FUNDING_REASON_MISSING" => Self::FundingReasonMissing,
6174            "OCA_ORDER_IDS_STOP_LOSS_NOT_ALLOWED" => Self::OcaOrderIdsStopLossNotAllowed,
6175            "CLIENT_EXTENSIONS_DATA_MISSING" => Self::ClientExtensionsDataMissing,
6176            "REPLACING_ORDER_INVALID" => Self::ReplacingOrderInvalid,
6177            "REPLACING_TRADE_ID_INVALID" => Self::ReplacingTradeIdInvalid,
6178            "ORDER_CANCEL_WOULD_TRIGGER_CLOSEOUT" => Self::OrderCancelWouldTriggerCloseout,
6179            _ => Self::Unknown(value),
6180        })
6181    }
6182}
6183
6184/// A filter that can be used when fetching Transactions
6185#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6186#[non_exhaustive]
6187pub enum TransactionFilter {
6188    /// Order-related Transactions. These are the Transactions that create, cancel, fill or trigger Orders
6189    Order,
6190    /// Funding-related Transactions
6191    Funding,
6192    /// Administrative Transactions
6193    Admin,
6194    /// Account Create Transaction
6195    Create,
6196    /// Account Close Transaction
6197    Close,
6198    /// Account Reopen Transaction
6199    Reopen,
6200    /// Client Configuration Transaction
6201    ClientConfigure,
6202    /// Client Configuration Reject Transaction
6203    ClientConfigureReject,
6204    /// Transfer Funds Transaction
6205    TransferFunds,
6206    /// Transfer Funds Reject Transaction
6207    TransferFundsReject,
6208    /// Market Order Transaction
6209    MarketOrder,
6210    /// Market Order Reject Transaction
6211    MarketOrderReject,
6212    /// Limit Order Transaction
6213    LimitOrder,
6214    /// Limit Order Reject Transaction
6215    LimitOrderReject,
6216    /// Stop Order Transaction
6217    StopOrder,
6218    /// Stop Order Reject Transaction
6219    StopOrderReject,
6220    /// Market if Touched Order Transaction
6221    MarketIfTouchedOrder,
6222    /// Market if Touched Order Reject Transaction
6223    MarketIfTouchedOrderReject,
6224    /// Take Profit Order Transaction
6225    TakeProfitOrder,
6226    /// Take Profit Order Reject Transaction
6227    TakeProfitOrderReject,
6228    /// Stop Loss Order Transaction
6229    StopLossOrder,
6230    /// Stop Loss Order Reject Transaction
6231    StopLossOrderReject,
6232    /// Guaranteed Stop Loss Order Transaction
6233    GuaranteedStopLossOrder,
6234    /// Guaranteed Stop Loss Order Reject Transaction
6235    GuaranteedStopLossOrderReject,
6236    /// Trailing Stop Loss Order Transaction
6237    TrailingStopLossOrder,
6238    /// Trailing Stop Loss Order Reject Transaction
6239    TrailingStopLossOrderReject,
6240    /// One Cancels All Order Transaction
6241    OneCancelsAllOrder,
6242    /// One Cancels All Order Reject Transaction
6243    OneCancelsAllOrderReject,
6244    /// One Cancels All Order Trigger Transaction
6245    OneCancelsAllOrderTriggered,
6246    /// Order Fill Transaction
6247    OrderFill,
6248    /// Order Cancel Transaction
6249    OrderCancel,
6250    /// Order Cancel Reject Transaction
6251    OrderCancelReject,
6252    /// Order Client Extensions Modify Transaction
6253    OrderClientExtensionsModify,
6254    /// Order Client Extensions Modify Reject Transaction
6255    OrderClientExtensionsModifyReject,
6256    /// Trade Client Extensions Modify Transaction
6257    TradeClientExtensionsModify,
6258    /// Trade Client Extensions Modify Reject Transaction
6259    TradeClientExtensionsModifyReject,
6260    /// Margin Call Enter Transaction
6261    MarginCallEnter,
6262    /// Margin Call Extend Transaction
6263    MarginCallExtend,
6264    /// Margin Call Exit Transaction
6265    MarginCallExit,
6266    /// Delayed Trade Closure Transaction
6267    DelayedTradeClosure,
6268    /// Daily Financing Transaction
6269    DailyFinancing,
6270    /// Reset Resettable PL Transaction
6271    ResetResettablePl,
6272    /// An unrecognized provider value, preserved for forward compatibility.
6273    Unknown(String),
6274}
6275
6276impl TransactionFilter {
6277    /// Return the exact provider spelling.
6278    pub fn as_str(&self) -> &str {
6279        match self {
6280            Self::Order => "ORDER",
6281            Self::Funding => "FUNDING",
6282            Self::Admin => "ADMIN",
6283            Self::Create => "CREATE",
6284            Self::Close => "CLOSE",
6285            Self::Reopen => "REOPEN",
6286            Self::ClientConfigure => "CLIENT_CONFIGURE",
6287            Self::ClientConfigureReject => "CLIENT_CONFIGURE_REJECT",
6288            Self::TransferFunds => "TRANSFER_FUNDS",
6289            Self::TransferFundsReject => "TRANSFER_FUNDS_REJECT",
6290            Self::MarketOrder => "MARKET_ORDER",
6291            Self::MarketOrderReject => "MARKET_ORDER_REJECT",
6292            Self::LimitOrder => "LIMIT_ORDER",
6293            Self::LimitOrderReject => "LIMIT_ORDER_REJECT",
6294            Self::StopOrder => "STOP_ORDER",
6295            Self::StopOrderReject => "STOP_ORDER_REJECT",
6296            Self::MarketIfTouchedOrder => "MARKET_IF_TOUCHED_ORDER",
6297            Self::MarketIfTouchedOrderReject => "MARKET_IF_TOUCHED_ORDER_REJECT",
6298            Self::TakeProfitOrder => "TAKE_PROFIT_ORDER",
6299            Self::TakeProfitOrderReject => "TAKE_PROFIT_ORDER_REJECT",
6300            Self::StopLossOrder => "STOP_LOSS_ORDER",
6301            Self::StopLossOrderReject => "STOP_LOSS_ORDER_REJECT",
6302            Self::GuaranteedStopLossOrder => "GUARANTEED_STOP_LOSS_ORDER",
6303            Self::GuaranteedStopLossOrderReject => "GUARANTEED_STOP_LOSS_ORDER_REJECT",
6304            Self::TrailingStopLossOrder => "TRAILING_STOP_LOSS_ORDER",
6305            Self::TrailingStopLossOrderReject => "TRAILING_STOP_LOSS_ORDER_REJECT",
6306            Self::OneCancelsAllOrder => "ONE_CANCELS_ALL_ORDER",
6307            Self::OneCancelsAllOrderReject => "ONE_CANCELS_ALL_ORDER_REJECT",
6308            Self::OneCancelsAllOrderTriggered => "ONE_CANCELS_ALL_ORDER_TRIGGERED",
6309            Self::OrderFill => "ORDER_FILL",
6310            Self::OrderCancel => "ORDER_CANCEL",
6311            Self::OrderCancelReject => "ORDER_CANCEL_REJECT",
6312            Self::OrderClientExtensionsModify => "ORDER_CLIENT_EXTENSIONS_MODIFY",
6313            Self::OrderClientExtensionsModifyReject => "ORDER_CLIENT_EXTENSIONS_MODIFY_REJECT",
6314            Self::TradeClientExtensionsModify => "TRADE_CLIENT_EXTENSIONS_MODIFY",
6315            Self::TradeClientExtensionsModifyReject => "TRADE_CLIENT_EXTENSIONS_MODIFY_REJECT",
6316            Self::MarginCallEnter => "MARGIN_CALL_ENTER",
6317            Self::MarginCallExtend => "MARGIN_CALL_EXTEND",
6318            Self::MarginCallExit => "MARGIN_CALL_EXIT",
6319            Self::DelayedTradeClosure => "DELAYED_TRADE_CLOSURE",
6320            Self::DailyFinancing => "DAILY_FINANCING",
6321            Self::ResetResettablePl => "RESET_RESETTABLE_PL",
6322            Self::Unknown(value) => value,
6323        }
6324    }
6325}
6326
6327impl Serialize for TransactionFilter {
6328    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6329        serializer.serialize_str(self.as_str())
6330    }
6331}
6332
6333impl<'de> Deserialize<'de> for TransactionFilter {
6334    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6335        let value = String::deserialize(deserializer)?;
6336        Ok(match value.as_str() {
6337            "ORDER" => Self::Order,
6338            "FUNDING" => Self::Funding,
6339            "ADMIN" => Self::Admin,
6340            "CREATE" => Self::Create,
6341            "CLOSE" => Self::Close,
6342            "REOPEN" => Self::Reopen,
6343            "CLIENT_CONFIGURE" => Self::ClientConfigure,
6344            "CLIENT_CONFIGURE_REJECT" => Self::ClientConfigureReject,
6345            "TRANSFER_FUNDS" => Self::TransferFunds,
6346            "TRANSFER_FUNDS_REJECT" => Self::TransferFundsReject,
6347            "MARKET_ORDER" => Self::MarketOrder,
6348            "MARKET_ORDER_REJECT" => Self::MarketOrderReject,
6349            "LIMIT_ORDER" => Self::LimitOrder,
6350            "LIMIT_ORDER_REJECT" => Self::LimitOrderReject,
6351            "STOP_ORDER" => Self::StopOrder,
6352            "STOP_ORDER_REJECT" => Self::StopOrderReject,
6353            "MARKET_IF_TOUCHED_ORDER" => Self::MarketIfTouchedOrder,
6354            "MARKET_IF_TOUCHED_ORDER_REJECT" => Self::MarketIfTouchedOrderReject,
6355            "TAKE_PROFIT_ORDER" => Self::TakeProfitOrder,
6356            "TAKE_PROFIT_ORDER_REJECT" => Self::TakeProfitOrderReject,
6357            "STOP_LOSS_ORDER" => Self::StopLossOrder,
6358            "STOP_LOSS_ORDER_REJECT" => Self::StopLossOrderReject,
6359            "GUARANTEED_STOP_LOSS_ORDER" => Self::GuaranteedStopLossOrder,
6360            "GUARANTEED_STOP_LOSS_ORDER_REJECT" => Self::GuaranteedStopLossOrderReject,
6361            "TRAILING_STOP_LOSS_ORDER" => Self::TrailingStopLossOrder,
6362            "TRAILING_STOP_LOSS_ORDER_REJECT" => Self::TrailingStopLossOrderReject,
6363            "ONE_CANCELS_ALL_ORDER" => Self::OneCancelsAllOrder,
6364            "ONE_CANCELS_ALL_ORDER_REJECT" => Self::OneCancelsAllOrderReject,
6365            "ONE_CANCELS_ALL_ORDER_TRIGGERED" => Self::OneCancelsAllOrderTriggered,
6366            "ORDER_FILL" => Self::OrderFill,
6367            "ORDER_CANCEL" => Self::OrderCancel,
6368            "ORDER_CANCEL_REJECT" => Self::OrderCancelReject,
6369            "ORDER_CLIENT_EXTENSIONS_MODIFY" => Self::OrderClientExtensionsModify,
6370            "ORDER_CLIENT_EXTENSIONS_MODIFY_REJECT" => Self::OrderClientExtensionsModifyReject,
6371            "TRADE_CLIENT_EXTENSIONS_MODIFY" => Self::TradeClientExtensionsModify,
6372            "TRADE_CLIENT_EXTENSIONS_MODIFY_REJECT" => Self::TradeClientExtensionsModifyReject,
6373            "MARGIN_CALL_ENTER" => Self::MarginCallEnter,
6374            "MARGIN_CALL_EXTEND" => Self::MarginCallExtend,
6375            "MARGIN_CALL_EXIT" => Self::MarginCallExit,
6376            "DELAYED_TRADE_CLOSURE" => Self::DelayedTradeClosure,
6377            "DAILY_FINANCING" => Self::DailyFinancing,
6378            "RESET_RESETTABLE_PL" => Self::ResetResettablePl,
6379            _ => Self::Unknown(value),
6380        })
6381    }
6382}
6383
6384/// A TransactionHeartbeat object is injected into the Transaction stream to ensure that the HTTP connection
6385/// remains active.
6386#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6387#[serde(rename_all = "camelCase")]
6388pub struct TransactionHeartbeat {
6389    /// The string “HEARTBEAT”
6390    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
6391    pub r#type: Option<String>,
6392    /// The ID of the most recent Transaction created for the Account
6393    #[serde(
6394        rename = "lastTransactionID",
6395        default,
6396        skip_serializing_if = "Option::is_none"
6397    )]
6398    pub last_transaction_id: Option<TransactionID>,
6399    /// The date/time when the TransactionHeartbeat was created.
6400    #[serde(rename = "time", default, skip_serializing_if = "Option::is_none")]
6401    pub time: Option<Timestamp>,
6402}