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