Skip to main content

oanda_client/
trade.rs

1//! OANDA trade endpoint contracts.
2// Shared imports vary by capability; unused ones are deliberately allowed.
3#[allow(unused_imports)]
4use crate::Timestamp;
5#[allow(unused_imports)]
6use crate::ids::*;
7#[allow(unused_imports)]
8use crate::models::*;
9#[allow(unused_imports)]
10use crate::{Client, Result};
11#[allow(unused_imports)]
12use reqwest::Method;
13#[allow(unused_imports)]
14use rust_decimal::Decimal;
15#[allow(unused_imports)]
16use serde::{Deserialize, Serialize};
17
18/// Query parameters for `list_trades`.
19#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
20#[serde(rename_all = "camelCase")]
21pub struct ListTradesQuery {
22    /// List of Trade IDs to retrieve.
23    #[serde(rename = "ids", default, skip_serializing_if = "Option::is_none")]
24    pub ids: Option<Vec<TradeID>>,
25    /// The state to filter the requested Trades by. \[default=OPEN\]
26    #[serde(rename = "state", default, skip_serializing_if = "Option::is_none")]
27    pub state: Option<TradeStateFilter>,
28    /// The instrument to filter the requested Trades by.
29    #[serde(
30        rename = "instrument",
31        default,
32        skip_serializing_if = "Option::is_none"
33    )]
34    pub instrument: Option<InstrumentName>,
35    /// The maximum number of Trades to return. \[default=50, maximum=500\]
36    #[serde(rename = "count", default, skip_serializing_if = "Option::is_none")]
37    pub count: Option<i64>,
38    /// The maximum Trade ID to return. If not provided the most recent Trades in the Account are returned.
39    #[serde(rename = "beforeID", default, skip_serializing_if = "Option::is_none")]
40    pub before_id: Option<TradeID>,
41}
42
43/// Successful response for `list_trades`.
44#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
45#[serde(rename_all = "camelCase")]
46pub struct ListTradesResponse {
47    /// The list of Trade detail objects
48    #[serde(rename = "trades", default, skip_serializing_if = "Option::is_none")]
49    pub trades: Option<Vec<Trade>>,
50    /// The ID of the most recent Transaction created for the Account
51    #[serde(
52        rename = "lastTransactionID",
53        default,
54        skip_serializing_if = "Option::is_none"
55    )]
56    pub last_transaction_id: Option<TransactionID>,
57}
58
59impl Client {
60    /// List trades.
61    pub async fn list_trades(
62        &self,
63        account_id: &AccountID,
64        query: Option<&ListTradesQuery>,
65    ) -> std::result::Result<
66        crate::ApiResponse<ListTradesResponse>,
67        crate::OperationError<crate::GenericRejection>,
68    > {
69        let account_id_encoded = crate::client::segment(account_id.as_str());
70        let path = format!("/v3/accounts/{account_id_encoded}/trades");
71        self.execute(Method::GET, &path, query, None::<&()>, None, None)
72            .await
73    }
74}
75
76/// Successful response for `list_open_trades`.
77#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
78#[serde(rename_all = "camelCase")]
79pub struct ListOpenTradesResponse {
80    /// The Account’s list of open Trades
81    #[serde(rename = "trades", default, skip_serializing_if = "Option::is_none")]
82    pub trades: Option<Vec<Trade>>,
83    /// The ID of the most recent Transaction created for the Account
84    #[serde(
85        rename = "lastTransactionID",
86        default,
87        skip_serializing_if = "Option::is_none"
88    )]
89    pub last_transaction_id: Option<TransactionID>,
90}
91
92impl Client {
93    /// List open trades.
94    pub async fn list_open_trades(
95        &self,
96        account_id: &AccountID,
97    ) -> std::result::Result<
98        crate::ApiResponse<ListOpenTradesResponse>,
99        crate::OperationError<crate::GenericRejection>,
100    > {
101        let account_id_encoded = crate::client::segment(account_id.as_str());
102        let path = format!("/v3/accounts/{account_id_encoded}/openTrades");
103        self.execute(Method::GET, &path, None::<&()>, None::<&()>, None, None)
104            .await
105    }
106}
107
108/// Successful response for `trade_details`.
109#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
110#[serde(rename_all = "camelCase")]
111pub struct TradeDetailsResponse {
112    /// The details of the requested trade
113    #[serde(rename = "trade", default, skip_serializing_if = "Option::is_none")]
114    pub trade: Option<Trade>,
115    /// The ID of the most recent Transaction created for the Account
116    #[serde(
117        rename = "lastTransactionID",
118        default,
119        skip_serializing_if = "Option::is_none"
120    )]
121    pub last_transaction_id: Option<TransactionID>,
122}
123
124impl Client {
125    /// Trade details.
126    pub async fn trade_details(
127        &self,
128        account_id: &AccountID,
129        trade_specifier: &TradeSpecifier,
130    ) -> std::result::Result<
131        crate::ApiResponse<TradeDetailsResponse>,
132        crate::OperationError<crate::GenericRejection>,
133    > {
134        let account_id_encoded = crate::client::segment(account_id.as_str());
135        let trade_specifier_encoded = crate::client::segment(trade_specifier.as_str());
136        let path = format!("/v3/accounts/{account_id_encoded}/trades/{trade_specifier_encoded}");
137        self.execute(Method::GET, &path, None::<&()>, None::<&()>, None, None)
138            .await
139    }
140}
141
142/// Request body for `close_trade`.
143#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
144#[serde(rename_all = "camelCase")]
145pub struct CloseTradeBody {
146    /// Indication of how much of the Trade to close. Either the string “ALL” (indicating that all of the Trade
147    /// should be closed), or a DecimalNumber representing the number of units of the open Trade to Close using
148    /// a TradeClose MarketOrder. The units specified must always be positive, and the magnitude of the value
149    /// cannot exceed the magnitude of the Trade’s open units.
150    #[serde(rename = "units", default, skip_serializing_if = "Option::is_none")]
151    pub units: Option<String>,
152}
153
154/// Successful response for `close_trade`.
155#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
156#[serde(rename_all = "camelCase")]
157pub struct CloseTradeResponse {
158    /// The MarketOrder Transaction created to close the Trade.
159    #[serde(
160        rename = "orderCreateTransaction",
161        default,
162        skip_serializing_if = "Option::is_none"
163    )]
164    pub order_create_transaction: Option<MarketOrderTransaction>,
165    /// The OrderFill Transaction that fills the Trade-closing MarketOrder and closes the Trade.
166    #[serde(
167        rename = "orderFillTransaction",
168        default,
169        skip_serializing_if = "Option::is_none"
170    )]
171    pub order_fill_transaction: Option<OrderFillTransaction>,
172    /// The OrderCancel Transaction that immediately cancelled the Trade-closing MarketOrder.
173    #[serde(
174        rename = "orderCancelTransaction",
175        default,
176        skip_serializing_if = "Option::is_none"
177    )]
178    pub order_cancel_transaction: Option<OrderCancelTransaction>,
179    /// The IDs of all Transactions that were created while satisfying the request.
180    #[serde(
181        rename = "relatedTransactionIDs",
182        default,
183        skip_serializing_if = "Option::is_none"
184    )]
185    pub related_transaction_ids: Option<Vec<TransactionID>>,
186    /// The ID of the most recent Transaction created for the Account
187    #[serde(
188        rename = "lastTransactionID",
189        default,
190        skip_serializing_if = "Option::is_none"
191    )]
192    pub last_transaction_id: Option<TransactionID>,
193}
194
195/// Documented rejection fields for `close_trade`.
196#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
197#[serde(rename_all = "camelCase")]
198pub struct CloseTradeRejection {
199    /// The MarketOrderReject Transaction that rejects the creation of the Trade- closing MarketOrder.
200    #[serde(
201        rename = "orderRejectTransaction",
202        default,
203        skip_serializing_if = "Option::is_none"
204    )]
205    pub order_reject_transaction: Option<MarketOrderRejectTransaction>,
206    /// The code of the error that has occurred. This field may not be returned for some errors.
207    #[serde(rename = "errorCode", default, skip_serializing_if = "Option::is_none")]
208    pub error_code: Option<String>,
209    /// The human-readable description of the error that has occurred.
210    #[serde(
211        rename = "errorMessage",
212        default,
213        skip_serializing_if = "Option::is_none"
214    )]
215    pub error_message: Option<String>,
216    /// The ID of the most recent Transaction created for the Account. Only present if the Account exists.
217    #[serde(
218        rename = "lastTransactionID",
219        default,
220        skip_serializing_if = "Option::is_none"
221    )]
222    pub last_transaction_id: Option<TransactionID>,
223    /// The IDs of all Transactions that were created while satisfying the request. Only present if the Account
224    /// exists.
225    #[serde(
226        rename = "relatedTransactionIDs",
227        default,
228        skip_serializing_if = "Option::is_none"
229    )]
230    pub related_transaction_ids: Option<Vec<TransactionID>>,
231}
232
233impl Client {
234    /// Close trade.
235    pub async fn close_trade(
236        &self,
237        account_id: &AccountID,
238        trade_specifier: &TradeSpecifier,
239        body: &CloseTradeBody,
240    ) -> std::result::Result<
241        crate::ApiResponse<CloseTradeResponse>,
242        crate::OperationError<CloseTradeRejection>,
243    > {
244        let account_id_encoded = crate::client::segment(account_id.as_str());
245        let trade_specifier_encoded = crate::client::segment(trade_specifier.as_str());
246        let path =
247            format!("/v3/accounts/{account_id_encoded}/trades/{trade_specifier_encoded}/close");
248        self.execute(
249            Method::PUT,
250            &path,
251            None::<&()>,
252            Some(body),
253            Some(crate::client::MutationAdmission::Exit(account_id)),
254            None,
255        )
256        .await
257    }
258}
259
260/// Request body for `update_trade_client_extensions`.
261#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
262#[serde(rename_all = "camelCase")]
263pub struct UpdateTradeClientExtensionsBody {
264    /// The Client Extensions to update the Trade with. Do not add, update, or delete the Client Extensions if
265    /// your account is associated with MT4.
266    #[serde(
267        rename = "clientExtensions",
268        default,
269        skip_serializing_if = "Option::is_none"
270    )]
271    pub client_extensions: Option<ClientExtensions>,
272}
273
274/// Successful response for `update_trade_client_extensions`.
275#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
276#[serde(rename_all = "camelCase")]
277pub struct UpdateTradeClientExtensionsResponse {
278    /// The Transaction that updates the Trade’s Client Extensions.
279    #[serde(
280        rename = "tradeClientExtensionsModifyTransaction",
281        default,
282        skip_serializing_if = "Option::is_none"
283    )]
284    pub trade_client_extensions_modify_transaction: Option<TradeClientExtensionsModifyTransaction>,
285    /// The IDs of all Transactions that were created while satisfying the request.
286    #[serde(
287        rename = "relatedTransactionIDs",
288        default,
289        skip_serializing_if = "Option::is_none"
290    )]
291    pub related_transaction_ids: Option<Vec<TransactionID>>,
292    /// The ID of the most recent Transaction created for the Account
293    #[serde(
294        rename = "lastTransactionID",
295        default,
296        skip_serializing_if = "Option::is_none"
297    )]
298    pub last_transaction_id: Option<TransactionID>,
299}
300
301/// Documented rejection fields for `update_trade_client_extensions`.
302#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
303#[serde(rename_all = "camelCase")]
304pub struct UpdateTradeClientExtensionsRejection {
305    /// The Transaction that rejects the modification of the Trade’s Client Extensions.
306    #[serde(
307        rename = "tradeClientExtensionsModifyRejectTransaction",
308        default,
309        skip_serializing_if = "Option::is_none"
310    )]
311    pub trade_client_extensions_modify_reject_transaction:
312        Option<TradeClientExtensionsModifyRejectTransaction>,
313    /// The ID of the most recent Transaction created for the Account.
314    #[serde(
315        rename = "lastTransactionID",
316        default,
317        skip_serializing_if = "Option::is_none"
318    )]
319    pub last_transaction_id: Option<TransactionID>,
320    /// The IDs of all Transactions that were created while satisfying the request.
321    #[serde(
322        rename = "relatedTransactionIDs",
323        default,
324        skip_serializing_if = "Option::is_none"
325    )]
326    pub related_transaction_ids: Option<Vec<TransactionID>>,
327    /// The code of the error that has occurred. This field may not be returned for some errors.
328    #[serde(rename = "errorCode", default, skip_serializing_if = "Option::is_none")]
329    pub error_code: Option<String>,
330    /// The human-readable description of the error that has occurred.
331    #[serde(
332        rename = "errorMessage",
333        default,
334        skip_serializing_if = "Option::is_none"
335    )]
336    pub error_message: Option<String>,
337}
338
339impl Client {
340    /// Update trade client extensions.
341    pub async fn update_trade_client_extensions(
342        &self,
343        account_id: &AccountID,
344        trade_specifier: &TradeSpecifier,
345        body: &UpdateTradeClientExtensionsBody,
346    ) -> std::result::Result<
347        crate::ApiResponse<UpdateTradeClientExtensionsResponse>,
348        crate::OperationError<UpdateTradeClientExtensionsRejection>,
349    > {
350        let account_id_encoded = crate::client::segment(account_id.as_str());
351        let trade_specifier_encoded = crate::client::segment(trade_specifier.as_str());
352        let path = format!(
353            "/v3/accounts/{account_id_encoded}/trades/{trade_specifier_encoded}/clientExtensions"
354        );
355        self.execute(
356            Method::PUT,
357            &path,
358            None::<&()>,
359            Some(body),
360            Some(crate::client::MutationAdmission::Ordinary(account_id)),
361            None,
362        )
363        .await
364    }
365}
366
367/// Request body for `set_trade_dependent_orders`.
368#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
369#[serde(rename_all = "camelCase")]
370pub struct SetTradeDependentOrdersBody {
371    /// The specification of the Take Profit to create/modify/cancel. If takeProfit is set to null, the Take
372    /// Profit Order will be cancelled if it exists. If takeProfit is not provided, the existing Take Profit
373    /// Order will not be modified. If a sub-field of takeProfit is not specified, that field will be set to a
374    /// default value on create, and be inherited by the replacing order on modify.
375    #[serde(
376        rename = "takeProfit",
377        default,
378        skip_serializing_if = "crate::Patch::is_unchanged"
379    )]
380    pub take_profit: crate::Patch<TakeProfitDetails>,
381    /// The specification of the Stop Loss to create/modify/cancel. If stopLoss is set to null, the Stop Loss
382    /// Order will be cancelled if it exists. If stopLoss is not provided, the existing Stop Loss Order will not
383    /// be modified. If a sub-field of stopLoss is not specified, that field will be set to a default value on
384    /// create, and be inherited by the replacing order on modify.
385    #[serde(
386        rename = "stopLoss",
387        default,
388        skip_serializing_if = "crate::Patch::is_unchanged"
389    )]
390    pub stop_loss: crate::Patch<StopLossDetails>,
391    /// The specification of the Trailing Stop Loss to create/modify/cancel. If trailingStopLoss is set to null,
392    /// the Trailing Stop Loss Order will be cancelled if it exists. If trailingStopLoss is not provided, the
393    /// existing Trailing Stop Loss Order will not be modified. If a sub-field of trailingStopLoss is not
394    /// specified, that field will be set to a default value on create, and be inherited by the replacing order
395    /// on modify.
396    #[serde(
397        rename = "trailingStopLoss",
398        default,
399        skip_serializing_if = "crate::Patch::is_unchanged"
400    )]
401    pub trailing_stop_loss: crate::Patch<TrailingStopLossDetails>,
402    /// The specification of the Guaranteed Stop Loss to create/modify/cancel. If guaranteedStopLoss is set to
403    /// null, the Guaranteed Stop Loss Order will be cancelled if it exists. If guaranteedStopLoss is not
404    /// provided, the existing Guaranteed Stop Loss Order will not be modified. If a sub-field of
405    /// guaranteedStopLoss is not specified, that field will be set to a default value on create, and be
406    /// inherited by the replacing order on modify.
407    #[serde(
408        rename = "guaranteedStopLoss",
409        default,
410        skip_serializing_if = "crate::Patch::is_unchanged"
411    )]
412    pub guaranteed_stop_loss: crate::Patch<GuaranteedStopLossDetails>,
413}
414
415/// Successful response for `set_trade_dependent_orders`.
416#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
417#[serde(rename_all = "camelCase")]
418pub struct SetTradeDependentOrdersResponse {
419    /// The Transaction created that cancels the Trade’s existing Take Profit Order.
420    #[serde(
421        rename = "takeProfitOrderCancelTransaction",
422        default,
423        skip_serializing_if = "Option::is_none"
424    )]
425    pub take_profit_order_cancel_transaction: Option<OrderCancelTransaction>,
426    /// The Transaction created that creates a new Take Profit Order for the Trade.
427    #[serde(
428        rename = "takeProfitOrderTransaction",
429        default,
430        skip_serializing_if = "Option::is_none"
431    )]
432    pub take_profit_order_transaction: Option<TakeProfitOrderTransaction>,
433    /// The Transaction created that immediately fills the Trade’s new Take Profit Order. Only provided if the
434    /// new Take Profit Order was immediately filled.
435    #[serde(
436        rename = "takeProfitOrderFillTransaction",
437        default,
438        skip_serializing_if = "Option::is_none"
439    )]
440    pub take_profit_order_fill_transaction: Option<OrderFillTransaction>,
441    /// The Transaction created that immediately cancels the Trade’s new Take Profit Order. Only provided if the
442    /// new Take Profit Order was immediately cancelled.
443    #[serde(
444        rename = "takeProfitOrderCreatedCancelTransaction",
445        default,
446        skip_serializing_if = "Option::is_none"
447    )]
448    pub take_profit_order_created_cancel_transaction: Option<OrderCancelTransaction>,
449    /// The Transaction created that cancels the Trade’s existing Stop Loss Order.
450    #[serde(
451        rename = "stopLossOrderCancelTransaction",
452        default,
453        skip_serializing_if = "Option::is_none"
454    )]
455    pub stop_loss_order_cancel_transaction: Option<OrderCancelTransaction>,
456    /// The Transaction created that creates a new Stop Loss Order for the Trade.
457    #[serde(
458        rename = "stopLossOrderTransaction",
459        default,
460        skip_serializing_if = "Option::is_none"
461    )]
462    pub stop_loss_order_transaction: Option<StopLossOrderTransaction>,
463    /// The Transaction created that immediately fills the Trade’s new Stop Order. Only provided if the new Stop
464    /// Loss Order was immediately filled.
465    #[serde(
466        rename = "stopLossOrderFillTransaction",
467        default,
468        skip_serializing_if = "Option::is_none"
469    )]
470    pub stop_loss_order_fill_transaction: Option<OrderFillTransaction>,
471    /// The Transaction created that immediately cancels the Trade’s new Stop Loss Order. Only provided if the
472    /// new Stop Loss Order was immediately cancelled.
473    #[serde(
474        rename = "stopLossOrderCreatedCancelTransaction",
475        default,
476        skip_serializing_if = "Option::is_none"
477    )]
478    pub stop_loss_order_created_cancel_transaction: Option<OrderCancelTransaction>,
479    /// The Transaction created that cancels the Trade’s existing Trailing Stop Loss Order.
480    #[serde(
481        rename = "trailingStopLossOrderCancelTransaction",
482        default,
483        skip_serializing_if = "Option::is_none"
484    )]
485    pub trailing_stop_loss_order_cancel_transaction: Option<OrderCancelTransaction>,
486    /// The Transaction created that creates a new Trailing Stop Loss Order for the Trade.
487    #[serde(
488        rename = "trailingStopLossOrderTransaction",
489        default,
490        skip_serializing_if = "Option::is_none"
491    )]
492    pub trailing_stop_loss_order_transaction: Option<TrailingStopLossOrderTransaction>,
493    /// The Transaction created that cancels the Trade’s existing Guaranteed Stop Loss Order.
494    #[serde(
495        rename = "guaranteedStopLossOrderCancelTransaction",
496        default,
497        skip_serializing_if = "Option::is_none"
498    )]
499    pub guaranteed_stop_loss_order_cancel_transaction: Option<OrderCancelTransaction>,
500    /// The Transaction created that creates a new Guaranteed Stop Loss Order for the Trade.
501    #[serde(
502        rename = "guaranteedStopLossOrderTransaction",
503        default,
504        skip_serializing_if = "Option::is_none"
505    )]
506    pub guaranteed_stop_loss_order_transaction: Option<GuaranteedStopLossOrderTransaction>,
507    /// The IDs of all Transactions that were created while satisfying the request.
508    #[serde(
509        rename = "relatedTransactionIDs",
510        default,
511        skip_serializing_if = "Option::is_none"
512    )]
513    pub related_transaction_ids: Option<Vec<TransactionID>>,
514    /// The ID of the most recent Transaction created for the Account
515    #[serde(
516        rename = "lastTransactionID",
517        default,
518        skip_serializing_if = "Option::is_none"
519    )]
520    pub last_transaction_id: Option<TransactionID>,
521}
522
523/// Documented rejection fields for `set_trade_dependent_orders`.
524#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
525#[serde(rename_all = "camelCase")]
526pub struct SetTradeDependentOrdersRejection {
527    /// An OrderCancelRejectTransaction represents the rejection of the cancellation of an Order in the client’s
528    /// Account.
529    #[serde(
530        rename = "takeProfitOrderCancelRejectTransaction",
531        default,
532        skip_serializing_if = "Option::is_none"
533    )]
534    pub take_profit_order_cancel_reject_transaction: Option<OrderCancelRejectTransaction>,
535    /// A TakeProfitOrderRejectTransaction represents the rejection of the creation of a TakeProfit Order.
536    #[serde(
537        rename = "takeProfitOrderRejectTransaction",
538        default,
539        skip_serializing_if = "Option::is_none"
540    )]
541    pub take_profit_order_reject_transaction: Option<TakeProfitOrderRejectTransaction>,
542    /// An OrderCancelRejectTransaction represents the rejection of the cancellation of an Order in the client’s
543    /// Account.
544    #[serde(
545        rename = "stopLossOrderCancelRejectTransaction",
546        default,
547        skip_serializing_if = "Option::is_none"
548    )]
549    pub stop_loss_order_cancel_reject_transaction: Option<OrderCancelRejectTransaction>,
550    /// A StopLossOrderRejectTransaction represents the rejection of the creation of a StopLoss Order.
551    #[serde(
552        rename = "stopLossOrderRejectTransaction",
553        default,
554        skip_serializing_if = "Option::is_none"
555    )]
556    pub stop_loss_order_reject_transaction: Option<StopLossOrderRejectTransaction>,
557    /// An OrderCancelRejectTransaction represents the rejection of the cancellation of an Order in the client’s
558    /// Account.
559    #[serde(
560        rename = "trailingStopLossOrderCancelRejectTransaction",
561        default,
562        skip_serializing_if = "Option::is_none"
563    )]
564    pub trailing_stop_loss_order_cancel_reject_transaction: Option<OrderCancelRejectTransaction>,
565    /// A TrailingStopLossOrderRejectTransaction represents the rejection of the creation of a TrailingStopLoss
566    /// Order.
567    #[serde(
568        rename = "trailingStopLossOrderRejectTransaction",
569        default,
570        skip_serializing_if = "Option::is_none"
571    )]
572    pub trailing_stop_loss_order_reject_transaction: Option<TrailingStopLossOrderRejectTransaction>,
573    /// An OrderCancelRejectTransaction represents the rejection of the cancellation of an Order in the client’s
574    /// Account.
575    #[serde(
576        rename = "guaranteedStopLossOrderCancelRejectTransaction",
577        default,
578        skip_serializing_if = "Option::is_none"
579    )]
580    pub guaranteed_stop_loss_order_cancel_reject_transaction: Option<OrderCancelRejectTransaction>,
581    /// A GuaranteedStopLossOrderRejectTransaction represents the rejection of the creation of a
582    /// GuaranteedStopLoss Order.
583    #[serde(
584        rename = "guaranteedStopLossOrderRejectTransaction",
585        default,
586        skip_serializing_if = "Option::is_none"
587    )]
588    pub guaranteed_stop_loss_order_reject_transaction:
589        Option<GuaranteedStopLossOrderRejectTransaction>,
590    /// The ID of the most recent Transaction created for the Account.
591    #[serde(
592        rename = "lastTransactionID",
593        default,
594        skip_serializing_if = "Option::is_none"
595    )]
596    pub last_transaction_id: Option<TransactionID>,
597    /// The IDs of all Transactions that were created while satisfying the request.
598    #[serde(
599        rename = "relatedTransactionIDs",
600        default,
601        skip_serializing_if = "Option::is_none"
602    )]
603    pub related_transaction_ids: Option<Vec<TransactionID>>,
604    /// The code of the error that has occurred. This field may not be returned for some errors.
605    #[serde(rename = "errorCode", default, skip_serializing_if = "Option::is_none")]
606    pub error_code: Option<String>,
607    /// The human-readable description of the error that has occurred.
608    #[serde(
609        rename = "errorMessage",
610        default,
611        skip_serializing_if = "Option::is_none"
612    )]
613    pub error_message: Option<String>,
614}
615
616impl Client {
617    /// Set trade dependent orders.
618    pub async fn set_trade_dependent_orders(
619        &self,
620        account_id: &AccountID,
621        trade_specifier: &TradeSpecifier,
622        body: &SetTradeDependentOrdersBody,
623    ) -> std::result::Result<
624        crate::ApiResponse<SetTradeDependentOrdersResponse>,
625        crate::OperationError<SetTradeDependentOrdersRejection>,
626    > {
627        let account_id_encoded = crate::client::segment(account_id.as_str());
628        let trade_specifier_encoded = crate::client::segment(trade_specifier.as_str());
629        let path =
630            format!("/v3/accounts/{account_id_encoded}/trades/{trade_specifier_encoded}/orders");
631        self.execute(
632            Method::PUT,
633            &path,
634            None::<&()>,
635            Some(body),
636            Some(crate::client::MutationAdmission::Ordinary(account_id)),
637            None,
638        )
639        .await
640    }
641}