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