Skip to main content

oanda_rs/models/transaction/
fill_cancel_tx.rs

1//! Order fill/cancel and client-extension-modify transaction subtypes.
2
3use serde::{Deserialize, Serialize};
4
5use crate::models::macros::string_enum;
6use crate::models::transaction::TransactionRejectReason;
7use crate::models::{
8    AccountId, AccountUnits, ClientExtensions, ClientPrice, DateTime, DecimalNumber,
9    HomeConversionFactors, InstrumentName, OrderId, PriceValue, RequestId, TradeId, TradeOpen,
10    TradeReduce, TransactionId,
11};
12
13/// An OrderFillTransaction represents the filling of an Order in the client's
14/// Account.
15#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
16#[non_exhaustive]
17pub struct OrderFillTransaction {
18    /// The Transaction's Identifier.
19    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
20    pub id: Option<TransactionId>,
21
22    /// The date/time when the Transaction was created.
23    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
24    pub time: Option<DateTime>,
25
26    /// The ID of the user that initiated the creation of the Transaction.
27    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
28    pub user_id: Option<i64>,
29
30    /// The ID of the Account the Transaction was created for.
31    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
32    pub account_id: Option<AccountId>,
33
34    /// The ID of the "batch" that the Transaction belongs to. Transactions in
35    /// the same batch are applied to the Account simultaneously.
36    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
37    pub batch_id: Option<TransactionId>,
38
39    /// The Request ID of the request which generated the transaction.
40    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
41    pub request_id: Option<RequestId>,
42
43    // type is pinned to "ORDER_FILL" by the enum wrapper
44    /// The ID of the Order filled.
45    #[serde(rename = "orderID", skip_serializing_if = "Option::is_none")]
46    pub order_id: Option<OrderId>,
47
48    /// The client Order ID of the Order filled (only provided if the client has
49    /// assigned one).
50    #[serde(rename = "clientOrderID", skip_serializing_if = "Option::is_none")]
51    pub client_order_id: Option<String>,
52
53    /// The name of the filled Order's instrument.
54    #[serde(rename = "instrument", skip_serializing_if = "Option::is_none")]
55    pub instrument: Option<InstrumentName>,
56
57    /// The number of units filled by the OrderFill.
58    #[serde(rename = "units", skip_serializing_if = "Option::is_none")]
59    pub units: Option<DecimalNumber>,
60
61    /// This is the conversion factor in effect for the Account at the time of
62    /// the OrderFill for converting any gains realized in Instrument quote
63    /// units into units of the Account's home currency.
64    #[serde(
65        rename = "gainQuoteHomeConversionFactor",
66        skip_serializing_if = "Option::is_none"
67    )]
68    pub gain_quote_home_conversion_factor: Option<DecimalNumber>,
69
70    /// This is the conversion factor in effect for the Account at the time of
71    /// the OrderFill for converting any losses realized in Instrument quote
72    /// units into units of the Account's home currency.
73    #[serde(
74        rename = "lossQuoteHomeConversionFactor",
75        skip_serializing_if = "Option::is_none"
76    )]
77    pub loss_quote_home_conversion_factor: Option<DecimalNumber>,
78
79    /// This field is now deprecated and should no longer be used. The
80    /// individual tradesClosed, tradeReduced and tradeOpened fields contain the
81    /// exact/official price each unit was filled at.
82    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
83    pub price: Option<PriceValue>,
84
85    /// The price that all of the units of the OrderFill should have been filled
86    /// at, in the absence of guaranteed price execution. This factors in the
87    /// Account's current ClientPrice, used liquidity and the units of the
88    /// OrderFill only. If no Trades were closed with their price clamped for
89    /// guaranteed stop loss enforcement, then this value will match the price
90    /// fields of each Trade opened, closed, and reduced, and they will all be
91    /// the exact same.
92    #[serde(rename = "fullVWAP", skip_serializing_if = "Option::is_none")]
93    pub full_vwap: Option<PriceValue>,
94
95    /// The `fullPrice` field.
96    #[serde(rename = "fullPrice", skip_serializing_if = "Option::is_none")]
97    pub full_price: Option<ClientPrice>,
98
99    /// The `reason` field.
100    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
101    pub reason: Option<OrderFillReason>,
102
103    /// The profit or loss incurred when the Order was filled.
104    #[serde(rename = "pl", skip_serializing_if = "Option::is_none")]
105    pub pl: Option<AccountUnits>,
106
107    /// The financing paid or collected when the Order was filled.
108    #[serde(rename = "financing", skip_serializing_if = "Option::is_none")]
109    pub financing: Option<AccountUnits>,
110
111    /// The commission charged in the Account's home currency as a result of
112    /// filling the Order. The commission is always represented as a positive
113    /// quantity of the Account's home currency, however it reduces the balance
114    /// in the Account.
115    #[serde(rename = "commission", skip_serializing_if = "Option::is_none")]
116    pub commission: Option<AccountUnits>,
117
118    /// The total guaranteed execution fees charged for all Trades opened,
119    /// closed or reduced with guaranteed Stop Loss Orders.
120    #[serde(
121        rename = "guaranteedExecutionFee",
122        skip_serializing_if = "Option::is_none"
123    )]
124    pub guaranteed_execution_fee: Option<AccountUnits>,
125
126    /// The Account's balance after the Order was filled.
127    #[serde(rename = "accountBalance", skip_serializing_if = "Option::is_none")]
128    pub account_balance: Option<AccountUnits>,
129
130    /// The `tradeOpened` field.
131    #[serde(rename = "tradeOpened", skip_serializing_if = "Option::is_none")]
132    pub trade_opened: Option<TradeOpen>,
133
134    /// The Trades that were closed when the Order was filled (only provided if
135    /// filling the Order resulted in a closing open Trades).
136    #[serde(
137        rename = "tradesClosed",
138        default,
139        skip_serializing_if = "Vec::is_empty"
140    )]
141    pub trades_closed: Vec<TradeReduce>,
142
143    /// The `tradeReduced` field.
144    #[serde(rename = "tradeReduced", skip_serializing_if = "Option::is_none")]
145    pub trade_reduced: Option<TradeReduce>,
146
147    /// The half spread cost for the OrderFill, which is the sum of the
148    /// halfSpreadCost values in the tradeOpened, tradesClosed and tradeReduced
149    /// fields. This can be a positive or negative value and is represented in
150    /// the home currency of the Account.
151    #[serde(rename = "halfSpreadCost", skip_serializing_if = "Option::is_none")]
152    pub half_spread_cost: Option<AccountUnits>,
153
154    /// The number of units the Order requested to be filled. This field is
155    /// returned by the live v20 API but is not present in OANDA's official
156    /// documentation.
157    #[serde(rename = "requestedUnits", skip_serializing_if = "Option::is_none")]
158    pub requested_units: Option<DecimalNumber>,
159
160    /// The profit or loss of the fill expressed in the Instrument's quote
161    /// currency. This field is returned by the live v20 API but is not present
162    /// in OANDA's official documentation.
163    #[serde(rename = "quotePL", skip_serializing_if = "Option::is_none")]
164    pub quote_pl: Option<DecimalNumber>,
165
166    /// The financing paid or collected in the Instrument's base currency. This
167    /// field is returned by the live v20 API but is not present in OANDA's
168    /// official documentation.
169    #[serde(rename = "baseFinancing", skip_serializing_if = "Option::is_none")]
170    pub base_financing: Option<DecimalNumber>,
171
172    /// The guaranteed execution fee expressed in the Instrument's quote
173    /// currency. This field is returned by the live v20 API but is not present
174    /// in OANDA's official documentation.
175    #[serde(
176        rename = "quoteGuaranteedExecutionFee",
177        skip_serializing_if = "Option::is_none"
178    )]
179    pub quote_guaranteed_execution_fee: Option<DecimalNumber>,
180
181    /// The `homeConversionFactors` field.
182    #[serde(
183        rename = "homeConversionFactors",
184        skip_serializing_if = "Option::is_none"
185    )]
186    pub home_conversion_factors: Option<HomeConversionFactors>,
187
188    /// The total cost of currency conversions for the fill, in the Account's
189    /// home currency. This field is returned by the live v20 API but is not
190    /// present in OANDA's official documentation.
191    #[serde(rename = "homeConversionCost", skip_serializing_if = "Option::is_none")]
192    pub home_conversion_cost: Option<DecimalNumber>,
193
194    /// The cost of converting the fill's profit/loss to the Account's home
195    /// currency. This field is returned by the live v20 API but is not present
196    /// in OANDA's official documentation.
197    #[serde(
198        rename = "plHomeConversionCost",
199        skip_serializing_if = "Option::is_none"
200    )]
201    pub pl_home_conversion_cost: Option<DecimalNumber>,
202
203    /// The cost of converting the fill's base financing to the Account's home
204    /// currency. This field is returned by the live v20 API but is not present
205    /// in OANDA's official documentation.
206    #[serde(
207        rename = "baseFinancingHomeConversionCost",
208        skip_serializing_if = "Option::is_none"
209    )]
210    pub base_financing_home_conversion_cost: Option<DecimalNumber>,
211
212    /// The cost of converting the guaranteed execution fee to the Account's
213    /// home currency. This field is returned by the live v20 API but is not
214    /// present in OANDA's official documentation.
215    #[serde(
216        rename = "guaranteedExecutionFeeHomeConversionCost",
217        skip_serializing_if = "Option::is_none"
218    )]
219    pub guaranteed_execution_fee_home_conversion_cost: Option<DecimalNumber>,
220}
221
222/// An OrderCancelTransaction represents the cancellation of an Order in the
223/// client's Account.
224#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
225#[non_exhaustive]
226pub struct OrderCancelTransaction {
227    /// The Transaction's Identifier.
228    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
229    pub id: Option<TransactionId>,
230
231    /// The date/time when the Transaction was created.
232    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
233    pub time: Option<DateTime>,
234
235    /// The ID of the user that initiated the creation of the Transaction.
236    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
237    pub user_id: Option<i64>,
238
239    /// The ID of the Account the Transaction was created for.
240    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
241    pub account_id: Option<AccountId>,
242
243    /// The ID of the "batch" that the Transaction belongs to. Transactions in
244    /// the same batch are applied to the Account simultaneously.
245    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
246    pub batch_id: Option<TransactionId>,
247
248    /// The Request ID of the request which generated the transaction.
249    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
250    pub request_id: Option<RequestId>,
251
252    // type is pinned to "ORDER_CANCEL" by the enum wrapper
253    /// The ID of the Order cancelled
254    #[serde(rename = "orderID", skip_serializing_if = "Option::is_none")]
255    pub order_id: Option<OrderId>,
256
257    /// The client ID of the Order cancelled (only provided if the Order has a
258    /// client Order ID).
259    #[serde(rename = "clientOrderID", skip_serializing_if = "Option::is_none")]
260    pub client_order_id: Option<OrderId>,
261
262    /// The `reason` field.
263    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
264    pub reason: Option<OrderCancelReason>,
265
266    /// The ID of the Order that replaced this Order (only provided if this
267    /// Order was cancelled for replacement).
268    #[serde(rename = "replacedByOrderID", skip_serializing_if = "Option::is_none")]
269    pub replaced_by_order_id: Option<OrderId>,
270
271    /// The ID of the Trade whose closure triggered cancellation of this linked
272    /// Order. This field is returned by the live v20 API but is not present in
273    /// OANDA's official documentation.
274    #[serde(rename = "closedTradeID", skip_serializing_if = "Option::is_none")]
275    pub closed_trade_id: Option<String>,
276
277    /// The ID of the Transaction that closed the linked Trade. This field is
278    /// returned by the live v20 API but is not present in OANDA's official
279    /// documentation.
280    #[serde(
281        rename = "tradeCloseTransactionID",
282        skip_serializing_if = "Option::is_none"
283    )]
284    pub trade_close_transaction_id: Option<String>,
285}
286
287/// An OrderCancelRejectTransaction represents the rejection of the cancellation
288/// of an Order in the client's Account.
289#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
290#[non_exhaustive]
291pub struct OrderCancelRejectTransaction {
292    /// The Transaction's Identifier.
293    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
294    pub id: Option<TransactionId>,
295
296    /// The date/time when the Transaction was created.
297    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
298    pub time: Option<DateTime>,
299
300    /// The ID of the user that initiated the creation of the Transaction.
301    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
302    pub user_id: Option<i64>,
303
304    /// The ID of the Account the Transaction was created for.
305    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
306    pub account_id: Option<AccountId>,
307
308    /// The ID of the "batch" that the Transaction belongs to. Transactions in
309    /// the same batch are applied to the Account simultaneously.
310    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
311    pub batch_id: Option<TransactionId>,
312
313    /// The Request ID of the request which generated the transaction.
314    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
315    pub request_id: Option<RequestId>,
316
317    // type is pinned to "ORDER_CANCEL_REJECT" by the enum wrapper
318    /// The ID of the Order intended to be cancelled
319    #[serde(rename = "orderID", skip_serializing_if = "Option::is_none")]
320    pub order_id: Option<OrderId>,
321
322    /// The client ID of the Order intended to be cancelled (only provided if
323    /// the Order has a client Order ID).
324    #[serde(rename = "clientOrderID", skip_serializing_if = "Option::is_none")]
325    pub client_order_id: Option<OrderId>,
326
327    /// The `rejectReason` field.
328    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
329    pub reject_reason: Option<TransactionRejectReason>,
330}
331
332/// A OrderClientExtensionsModifyTransaction represents the modification of an
333/// Order's Client Extensions.
334#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
335#[non_exhaustive]
336pub struct OrderClientExtensionsModifyTransaction {
337    /// The Transaction's Identifier.
338    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
339    pub id: Option<TransactionId>,
340
341    /// The date/time when the Transaction was created.
342    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
343    pub time: Option<DateTime>,
344
345    /// The ID of the user that initiated the creation of the Transaction.
346    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
347    pub user_id: Option<i64>,
348
349    /// The ID of the Account the Transaction was created for.
350    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
351    pub account_id: Option<AccountId>,
352
353    /// The ID of the "batch" that the Transaction belongs to. Transactions in
354    /// the same batch are applied to the Account simultaneously.
355    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
356    pub batch_id: Option<TransactionId>,
357
358    /// The Request ID of the request which generated the transaction.
359    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
360    pub request_id: Option<RequestId>,
361
362    // type is pinned to "ORDER_CLIENT_EXTENSIONS_MODIFY" by the enum wrapper
363    /// The ID of the Order who's client extensions are to be modified.
364    #[serde(rename = "orderID", skip_serializing_if = "Option::is_none")]
365    pub order_id: Option<OrderId>,
366
367    /// The original Client ID of the Order who's client extensions are to be
368    /// modified.
369    #[serde(rename = "clientOrderID", skip_serializing_if = "Option::is_none")]
370    pub client_order_id: Option<String>,
371
372    /// The `clientExtensionsModify` field.
373    #[serde(
374        rename = "clientExtensionsModify",
375        skip_serializing_if = "Option::is_none"
376    )]
377    pub client_extensions_modify: Option<ClientExtensions>,
378
379    /// The `tradeClientExtensionsModify` field.
380    #[serde(
381        rename = "tradeClientExtensionsModify",
382        skip_serializing_if = "Option::is_none"
383    )]
384    pub trade_client_extensions_modify: Option<ClientExtensions>,
385}
386
387/// A OrderClientExtensionsModifyRejectTransaction represents the rejection of
388/// the modification of an Order's Client Extensions.
389#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
390#[non_exhaustive]
391pub struct OrderClientExtensionsModifyRejectTransaction {
392    /// The Transaction's Identifier.
393    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
394    pub id: Option<TransactionId>,
395
396    /// The date/time when the Transaction was created.
397    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
398    pub time: Option<DateTime>,
399
400    /// The ID of the user that initiated the creation of the Transaction.
401    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
402    pub user_id: Option<i64>,
403
404    /// The ID of the Account the Transaction was created for.
405    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
406    pub account_id: Option<AccountId>,
407
408    /// The ID of the "batch" that the Transaction belongs to. Transactions in
409    /// the same batch are applied to the Account simultaneously.
410    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
411    pub batch_id: Option<TransactionId>,
412
413    /// The Request ID of the request which generated the transaction.
414    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
415    pub request_id: Option<RequestId>,
416
417    // type is pinned to "ORDER_CLIENT_EXTENSIONS_MODIFY_REJECT" by the enum wrapper
418    /// The ID of the Order who's client extensions are to be modified.
419    #[serde(rename = "orderID", skip_serializing_if = "Option::is_none")]
420    pub order_id: Option<OrderId>,
421
422    /// The original Client ID of the Order who's client extensions are to be
423    /// modified.
424    #[serde(rename = "clientOrderID", skip_serializing_if = "Option::is_none")]
425    pub client_order_id: Option<String>,
426
427    /// The `clientExtensionsModify` field.
428    #[serde(
429        rename = "clientExtensionsModify",
430        skip_serializing_if = "Option::is_none"
431    )]
432    pub client_extensions_modify: Option<ClientExtensions>,
433
434    /// The `tradeClientExtensionsModify` field.
435    #[serde(
436        rename = "tradeClientExtensionsModify",
437        skip_serializing_if = "Option::is_none"
438    )]
439    pub trade_client_extensions_modify: Option<ClientExtensions>,
440
441    /// The `rejectReason` field.
442    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
443    pub reject_reason: Option<TransactionRejectReason>,
444}
445
446/// A TradeClientExtensionsModifyTransaction represents the modification of a
447/// Trade's Client Extensions.
448#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
449#[non_exhaustive]
450pub struct TradeClientExtensionsModifyTransaction {
451    /// The Transaction's Identifier.
452    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
453    pub id: Option<TransactionId>,
454
455    /// The date/time when the Transaction was created.
456    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
457    pub time: Option<DateTime>,
458
459    /// The ID of the user that initiated the creation of the Transaction.
460    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
461    pub user_id: Option<i64>,
462
463    /// The ID of the Account the Transaction was created for.
464    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
465    pub account_id: Option<AccountId>,
466
467    /// The ID of the "batch" that the Transaction belongs to. Transactions in
468    /// the same batch are applied to the Account simultaneously.
469    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
470    pub batch_id: Option<TransactionId>,
471
472    /// The Request ID of the request which generated the transaction.
473    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
474    pub request_id: Option<RequestId>,
475
476    // type is pinned to "TRADE_CLIENT_EXTENSIONS_MODIFY" by the enum wrapper
477    /// The ID of the Trade who's client extensions are to be modified.
478    #[serde(rename = "tradeID", skip_serializing_if = "Option::is_none")]
479    pub trade_id: Option<TradeId>,
480
481    /// The original Client ID of the Trade who's client extensions are to be
482    /// modified.
483    #[serde(rename = "clientTradeID", skip_serializing_if = "Option::is_none")]
484    pub client_trade_id: Option<String>,
485
486    /// The `tradeClientExtensionsModify` field.
487    #[serde(
488        rename = "tradeClientExtensionsModify",
489        skip_serializing_if = "Option::is_none"
490    )]
491    pub trade_client_extensions_modify: Option<ClientExtensions>,
492}
493
494/// A TradeClientExtensionsModifyRejectTransaction represents the rejection of
495/// the modification of a Trade's Client Extensions.
496#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
497#[non_exhaustive]
498pub struct TradeClientExtensionsModifyRejectTransaction {
499    /// The Transaction's Identifier.
500    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
501    pub id: Option<TransactionId>,
502
503    /// The date/time when the Transaction was created.
504    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
505    pub time: Option<DateTime>,
506
507    /// The ID of the user that initiated the creation of the Transaction.
508    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
509    pub user_id: Option<i64>,
510
511    /// The ID of the Account the Transaction was created for.
512    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
513    pub account_id: Option<AccountId>,
514
515    /// The ID of the "batch" that the Transaction belongs to. Transactions in
516    /// the same batch are applied to the Account simultaneously.
517    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
518    pub batch_id: Option<TransactionId>,
519
520    /// The Request ID of the request which generated the transaction.
521    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
522    pub request_id: Option<RequestId>,
523
524    // type is pinned to "TRADE_CLIENT_EXTENSIONS_MODIFY_REJECT" by the enum wrapper
525    /// The ID of the Trade who's client extensions are to be modified.
526    #[serde(rename = "tradeID", skip_serializing_if = "Option::is_none")]
527    pub trade_id: Option<TradeId>,
528
529    /// The original Client ID of the Trade who's client extensions are to be
530    /// modified.
531    #[serde(rename = "clientTradeID", skip_serializing_if = "Option::is_none")]
532    pub client_trade_id: Option<String>,
533
534    /// The `tradeClientExtensionsModify` field.
535    #[serde(
536        rename = "tradeClientExtensionsModify",
537        skip_serializing_if = "Option::is_none"
538    )]
539    pub trade_client_extensions_modify: Option<ClientExtensions>,
540
541    /// The `rejectReason` field.
542    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
543    pub reject_reason: Option<TransactionRejectReason>,
544}
545
546string_enum! {
547    /// The reason that an Order was filled
548    pub enum OrderFillReason {
549        LimitOrder => "LIMIT_ORDER",
550        StopOrder => "STOP_ORDER",
551        MarketIfTouchedOrder => "MARKET_IF_TOUCHED_ORDER",
552        TakeProfitOrder => "TAKE_PROFIT_ORDER",
553        StopLossOrder => "STOP_LOSS_ORDER",
554        TrailingStopLossOrder => "TRAILING_STOP_LOSS_ORDER",
555        MarketOrder => "MARKET_ORDER",
556        MarketOrderTradeClose => "MARKET_ORDER_TRADE_CLOSE",
557        MarketOrderPositionCloseout => "MARKET_ORDER_POSITION_CLOSEOUT",
558        MarketOrderMarginCloseout => "MARKET_ORDER_MARGIN_CLOSEOUT",
559        MarketOrderDelayedTradeClose => "MARKET_ORDER_DELAYED_TRADE_CLOSE",
560    }
561}
562
563string_enum! {
564    /// The reason that an Order was cancelled.
565    pub enum OrderCancelReason {
566        InternalServerError => "INTERNAL_SERVER_ERROR",
567        AccountLocked => "ACCOUNT_LOCKED",
568        AccountNewPositionsLocked => "ACCOUNT_NEW_POSITIONS_LOCKED",
569        AccountOrderCreationLocked => "ACCOUNT_ORDER_CREATION_LOCKED",
570        AccountOrderFillLocked => "ACCOUNT_ORDER_FILL_LOCKED",
571        ClientRequest => "CLIENT_REQUEST",
572        Migration => "MIGRATION",
573        MarketHalted => "MARKET_HALTED",
574        LinkedTradeClosed => "LINKED_TRADE_CLOSED",
575        TimeInForceExpired => "TIME_IN_FORCE_EXPIRED",
576        InsufficientMargin => "INSUFFICIENT_MARGIN",
577        FifoViolation => "FIFO_VIOLATION",
578        BoundsViolation => "BOUNDS_VIOLATION",
579        ClientRequestReplaced => "CLIENT_REQUEST_REPLACED",
580        InsufficientLiquidity => "INSUFFICIENT_LIQUIDITY",
581        TakeProfitOnFillGtdTimestampInPast => "TAKE_PROFIT_ON_FILL_GTD_TIMESTAMP_IN_PAST",
582        TakeProfitOnFillLoss => "TAKE_PROFIT_ON_FILL_LOSS",
583        LosingTakeProfit => "LOSING_TAKE_PROFIT",
584        StopLossOnFillGtdTimestampInPast => "STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST",
585        StopLossOnFillLoss => "STOP_LOSS_ON_FILL_LOSS",
586        StopLossOnFillPriceDistanceMaximumExceeded => "STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED",
587        StopLossOnFillRequired => "STOP_LOSS_ON_FILL_REQUIRED",
588        StopLossOnFillGuaranteedRequired => "STOP_LOSS_ON_FILL_GUARANTEED_REQUIRED",
589        StopLossOnFillGuaranteedNotAllowed => "STOP_LOSS_ON_FILL_GUARANTEED_NOT_ALLOWED",
590        StopLossOnFillGuaranteedMinimumDistanceNotMet => "STOP_LOSS_ON_FILL_GUARANTEED_MINIMUM_DISTANCE_NOT_MET",
591        StopLossOnFillGuaranteedLevelRestrictionExceeded => "STOP_LOSS_ON_FILL_GUARANTEED_LEVEL_RESTRICTION_EXCEEDED",
592        StopLossOnFillGuaranteedHedgingNotAllowed => "STOP_LOSS_ON_FILL_GUARANTEED_HEDGING_NOT_ALLOWED",
593        StopLossOnFillTimeInForceInvalid => "STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID",
594        StopLossOnFillTriggerConditionInvalid => "STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID",
595        TakeProfitOnFillPriceDistanceMaximumExceeded => "TAKE_PROFIT_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED",
596        TrailingStopLossOnFillGtdTimestampInPast => "TRAILING_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST",
597        ClientTradeIdAlreadyExists => "CLIENT_TRADE_ID_ALREADY_EXISTS",
598        PositionCloseoutFailed => "POSITION_CLOSEOUT_FAILED",
599        OpenTradesAllowedExceeded => "OPEN_TRADES_ALLOWED_EXCEEDED",
600        PendingOrdersAllowedExceeded => "PENDING_ORDERS_ALLOWED_EXCEEDED",
601        TakeProfitOnFillClientOrderIdAlreadyExists => "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_ID_ALREADY_EXISTS",
602        StopLossOnFillClientOrderIdAlreadyExists => "STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_ALREADY_EXISTS",
603        TrailingStopLossOnFillClientOrderIdAlreadyExists => "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_ALREADY_EXISTS",
604        PositionSizeExceeded => "POSITION_SIZE_EXCEEDED",
605        HedgingGsloViolation => "HEDGING_GSLO_VIOLATION",
606        AccountPositionValueLimitExceeded => "ACCOUNT_POSITION_VALUE_LIMIT_EXCEEDED",
607        InstrumentBidReduceOnly => "INSTRUMENT_BID_REDUCE_ONLY",
608        InstrumentAskReduceOnly => "INSTRUMENT_ASK_REDUCE_ONLY",
609        InstrumentBidHalted => "INSTRUMENT_BID_HALTED",
610        InstrumentAskHalted => "INSTRUMENT_ASK_HALTED",
611        StopLossOnFillGuaranteedBidHalted => "STOP_LOSS_ON_FILL_GUARANTEED_BID_HALTED",
612        StopLossOnFillGuaranteedAskHalted => "STOP_LOSS_ON_FILL_GUARANTEED_ASK_HALTED",
613    }
614}