oanda-client 1.1.0

An async, provider-native Rust client for OANDA's v20 REST API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
//! OANDA trade endpoint contracts.
// Shared imports vary by capability; unused ones are deliberately allowed.
#[allow(unused_imports)]
use crate::Timestamp;
#[allow(unused_imports)]
use crate::ids::*;
#[allow(unused_imports)]
use crate::models::*;
#[allow(unused_imports)]
use crate::{Client, Result};
#[allow(unused_imports)]
use reqwest::Method;
#[allow(unused_imports)]
use rust_decimal::Decimal;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};

/// Query parameters for `list_trades`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ListTradesQuery {
    /// List of Trade IDs to retrieve.
    #[serde(rename = "ids", default, skip_serializing_if = "Option::is_none")]
    pub ids: Option<Vec<TradeID>>,
    /// The state to filter the requested Trades by. \[default=OPEN\]
    #[serde(rename = "state", default, skip_serializing_if = "Option::is_none")]
    pub state: Option<TradeStateFilter>,
    /// The instrument to filter the requested Trades by.
    #[serde(
        rename = "instrument",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub instrument: Option<InstrumentName>,
    /// The maximum number of Trades to return. \[default=50, maximum=500\]
    #[serde(rename = "count", default, skip_serializing_if = "Option::is_none")]
    pub count: Option<i64>,
    /// The maximum Trade ID to return. If not provided the most recent Trades in the Account are returned.
    #[serde(rename = "beforeID", default, skip_serializing_if = "Option::is_none")]
    pub before_id: Option<TradeID>,
}

/// Successful response for `list_trades`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListTradesResponse {
    /// The list of Trade detail objects
    #[serde(rename = "trades", default, skip_serializing_if = "Option::is_none")]
    pub trades: Option<Vec<Trade>>,
    /// The ID of the most recent Transaction created for the Account
    #[serde(
        rename = "lastTransactionID",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub last_transaction_id: Option<TransactionID>,
}

impl Client {
    /// List trades.
    pub async fn list_trades(
        &self,
        account_id: &AccountID,
        query: Option<&ListTradesQuery>,
    ) -> std::result::Result<
        crate::ApiResponse<ListTradesResponse>,
        crate::OperationError<crate::GenericRejection>,
    > {
        let account_id_encoded = crate::client::segment(account_id.as_str());
        let path = format!("/v3/accounts/{account_id_encoded}/trades");
        self.execute(Method::GET, &path, query, None::<&()>, None, None)
            .await
    }
}

/// Successful response for `list_open_trades`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ListOpenTradesResponse {
    /// The Account’s list of open Trades
    #[serde(rename = "trades", default, skip_serializing_if = "Option::is_none")]
    pub trades: Option<Vec<Trade>>,
    /// The ID of the most recent Transaction created for the Account
    #[serde(
        rename = "lastTransactionID",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub last_transaction_id: Option<TransactionID>,
}

impl Client {
    /// List open trades.
    pub async fn list_open_trades(
        &self,
        account_id: &AccountID,
    ) -> std::result::Result<
        crate::ApiResponse<ListOpenTradesResponse>,
        crate::OperationError<crate::GenericRejection>,
    > {
        let account_id_encoded = crate::client::segment(account_id.as_str());
        let path = format!("/v3/accounts/{account_id_encoded}/openTrades");
        self.execute(Method::GET, &path, None::<&()>, None::<&()>, None, None)
            .await
    }
}

/// Successful response for `trade_details`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TradeDetailsResponse {
    /// The details of the requested trade
    #[serde(rename = "trade", default, skip_serializing_if = "Option::is_none")]
    pub trade: Option<Trade>,
    /// The ID of the most recent Transaction created for the Account
    #[serde(
        rename = "lastTransactionID",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub last_transaction_id: Option<TransactionID>,
}

impl Client {
    /// Trade details.
    pub async fn trade_details(
        &self,
        account_id: &AccountID,
        trade_specifier: &TradeSpecifier,
    ) -> std::result::Result<
        crate::ApiResponse<TradeDetailsResponse>,
        crate::OperationError<crate::GenericRejection>,
    > {
        let account_id_encoded = crate::client::segment(account_id.as_str());
        let trade_specifier_encoded = crate::client::segment(trade_specifier.as_str());
        let path = format!("/v3/accounts/{account_id_encoded}/trades/{trade_specifier_encoded}");
        self.execute(Method::GET, &path, None::<&()>, None::<&()>, None, None)
            .await
    }
}

/// Request body for `close_trade`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CloseTradeBody {
    /// Indication of how much of the Trade to close. Either the string “ALL” (indicating that all of the Trade
    /// should be closed), or a DecimalNumber representing the number of units of the open Trade to Close using
    /// a TradeClose MarketOrder. The units specified must always be positive, and the magnitude of the value
    /// cannot exceed the magnitude of the Trade’s open units.
    #[serde(rename = "units", default, skip_serializing_if = "Option::is_none")]
    pub units: Option<String>,
}

/// Successful response for `close_trade`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CloseTradeResponse {
    /// The MarketOrder Transaction created to close the Trade.
    #[serde(
        rename = "orderCreateTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub order_create_transaction: Option<MarketOrderTransaction>,
    /// The OrderFill Transaction that fills the Trade-closing MarketOrder and closes the Trade.
    #[serde(
        rename = "orderFillTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub order_fill_transaction: Option<OrderFillTransaction>,
    /// The OrderCancel Transaction that immediately cancelled the Trade-closing MarketOrder.
    #[serde(
        rename = "orderCancelTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub order_cancel_transaction: Option<OrderCancelTransaction>,
    /// The IDs of all Transactions that were created while satisfying the request.
    #[serde(
        rename = "relatedTransactionIDs",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub related_transaction_ids: Option<Vec<TransactionID>>,
    /// The ID of the most recent Transaction created for the Account
    #[serde(
        rename = "lastTransactionID",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub last_transaction_id: Option<TransactionID>,
}

/// Documented rejection fields for `close_trade`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CloseTradeRejection {
    /// The MarketOrderReject Transaction that rejects the creation of the Trade- closing MarketOrder.
    #[serde(
        rename = "orderRejectTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub order_reject_transaction: Option<MarketOrderRejectTransaction>,
    /// The code of the error that has occurred. This field may not be returned for some errors.
    #[serde(rename = "errorCode", default, skip_serializing_if = "Option::is_none")]
    pub error_code: Option<String>,
    /// The human-readable description of the error that has occurred.
    #[serde(
        rename = "errorMessage",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub error_message: Option<String>,
    /// The ID of the most recent Transaction created for the Account. Only present if the Account exists.
    #[serde(
        rename = "lastTransactionID",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub last_transaction_id: Option<TransactionID>,
    /// The IDs of all Transactions that were created while satisfying the request. Only present if the Account
    /// exists.
    #[serde(
        rename = "relatedTransactionIDs",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub related_transaction_ids: Option<Vec<TransactionID>>,
}

impl Client {
    /// Close trade.
    pub async fn close_trade(
        &self,
        account_id: &AccountID,
        trade_specifier: &TradeSpecifier,
        body: &CloseTradeBody,
    ) -> std::result::Result<
        crate::ApiResponse<CloseTradeResponse>,
        crate::OperationError<CloseTradeRejection>,
    > {
        let account_id_encoded = crate::client::segment(account_id.as_str());
        let trade_specifier_encoded = crate::client::segment(trade_specifier.as_str());
        let path =
            format!("/v3/accounts/{account_id_encoded}/trades/{trade_specifier_encoded}/close");
        self.execute(
            Method::PUT,
            &path,
            None::<&()>,
            Some(body),
            Some(crate::client::MutationAdmission::Exit(account_id)),
            None,
        )
        .await
    }
}

/// Request body for `update_trade_client_extensions`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateTradeClientExtensionsBody {
    /// The Client Extensions to update the Trade with. Do not add, update, or delete the Client Extensions if
    /// your account is associated with MT4.
    #[serde(
        rename = "clientExtensions",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub client_extensions: Option<ClientExtensions>,
}

/// Successful response for `update_trade_client_extensions`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateTradeClientExtensionsResponse {
    /// The Transaction that updates the Trade’s Client Extensions.
    #[serde(
        rename = "tradeClientExtensionsModifyTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub trade_client_extensions_modify_transaction: Option<TradeClientExtensionsModifyTransaction>,
    /// The IDs of all Transactions that were created while satisfying the request.
    #[serde(
        rename = "relatedTransactionIDs",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub related_transaction_ids: Option<Vec<TransactionID>>,
    /// The ID of the most recent Transaction created for the Account
    #[serde(
        rename = "lastTransactionID",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub last_transaction_id: Option<TransactionID>,
}

/// Documented rejection fields for `update_trade_client_extensions`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct UpdateTradeClientExtensionsRejection {
    /// The Transaction that rejects the modification of the Trade’s Client Extensions.
    #[serde(
        rename = "tradeClientExtensionsModifyRejectTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub trade_client_extensions_modify_reject_transaction:
        Option<TradeClientExtensionsModifyRejectTransaction>,
    /// The ID of the most recent Transaction created for the Account.
    #[serde(
        rename = "lastTransactionID",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub last_transaction_id: Option<TransactionID>,
    /// The IDs of all Transactions that were created while satisfying the request.
    #[serde(
        rename = "relatedTransactionIDs",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub related_transaction_ids: Option<Vec<TransactionID>>,
    /// The code of the error that has occurred. This field may not be returned for some errors.
    #[serde(rename = "errorCode", default, skip_serializing_if = "Option::is_none")]
    pub error_code: Option<String>,
    /// The human-readable description of the error that has occurred.
    #[serde(
        rename = "errorMessage",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub error_message: Option<String>,
}

impl Client {
    /// Update trade client extensions.
    pub async fn update_trade_client_extensions(
        &self,
        account_id: &AccountID,
        trade_specifier: &TradeSpecifier,
        body: &UpdateTradeClientExtensionsBody,
    ) -> std::result::Result<
        crate::ApiResponse<UpdateTradeClientExtensionsResponse>,
        crate::OperationError<UpdateTradeClientExtensionsRejection>,
    > {
        let account_id_encoded = crate::client::segment(account_id.as_str());
        let trade_specifier_encoded = crate::client::segment(trade_specifier.as_str());
        let path = format!(
            "/v3/accounts/{account_id_encoded}/trades/{trade_specifier_encoded}/clientExtensions"
        );
        self.execute(
            Method::PUT,
            &path,
            None::<&()>,
            Some(body),
            Some(crate::client::MutationAdmission::Ordinary(account_id)),
            None,
        )
        .await
    }
}

/// Request body for `set_trade_dependent_orders`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetTradeDependentOrdersBody {
    /// The specification of the Take Profit to create/modify/cancel. If takeProfit is set to null, the Take
    /// Profit Order will be cancelled if it exists. If takeProfit is not provided, the existing Take Profit
    /// Order will not be modified. If a sub-field of takeProfit is not specified, that field will be set to a
    /// default value on create, and be inherited by the replacing order on modify.
    #[serde(
        rename = "takeProfit",
        default,
        skip_serializing_if = "crate::Patch::is_unchanged"
    )]
    pub take_profit: crate::Patch<TakeProfitDetails>,
    /// The specification of the Stop Loss to create/modify/cancel. If stopLoss is set to null, the Stop Loss
    /// Order will be cancelled if it exists. If stopLoss is not provided, the existing Stop Loss Order will not
    /// be modified. If a sub-field of stopLoss is not specified, that field will be set to a default value on
    /// create, and be inherited by the replacing order on modify.
    #[serde(
        rename = "stopLoss",
        default,
        skip_serializing_if = "crate::Patch::is_unchanged"
    )]
    pub stop_loss: crate::Patch<StopLossDetails>,
    /// The specification of the Trailing Stop Loss to create/modify/cancel. If trailingStopLoss is set to null,
    /// the Trailing Stop Loss Order will be cancelled if it exists. If trailingStopLoss is not provided, the
    /// existing Trailing Stop Loss Order will not be modified. If a sub-field of trailingStopLoss is not
    /// specified, that field will be set to a default value on create, and be inherited by the replacing order
    /// on modify.
    #[serde(
        rename = "trailingStopLoss",
        default,
        skip_serializing_if = "crate::Patch::is_unchanged"
    )]
    pub trailing_stop_loss: crate::Patch<TrailingStopLossDetails>,
    /// The specification of the Guaranteed Stop Loss to create/modify/cancel. If guaranteedStopLoss is set to
    /// null, the Guaranteed Stop Loss Order will be cancelled if it exists. If guaranteedStopLoss is not
    /// provided, the existing Guaranteed Stop Loss Order will not be modified. If a sub-field of
    /// guaranteedStopLoss is not specified, that field will be set to a default value on create, and be
    /// inherited by the replacing order on modify.
    #[serde(
        rename = "guaranteedStopLoss",
        default,
        skip_serializing_if = "crate::Patch::is_unchanged"
    )]
    pub guaranteed_stop_loss: crate::Patch<GuaranteedStopLossDetails>,
}

/// Successful response for `set_trade_dependent_orders`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetTradeDependentOrdersResponse {
    /// The Transaction created that cancels the Trade’s existing Take Profit Order.
    #[serde(
        rename = "takeProfitOrderCancelTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub take_profit_order_cancel_transaction: Option<OrderCancelTransaction>,
    /// The Transaction created that creates a new Take Profit Order for the Trade.
    #[serde(
        rename = "takeProfitOrderTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub take_profit_order_transaction: Option<TakeProfitOrderTransaction>,
    /// The Transaction created that immediately fills the Trade’s new Take Profit Order. Only provided if the
    /// new Take Profit Order was immediately filled.
    #[serde(
        rename = "takeProfitOrderFillTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub take_profit_order_fill_transaction: Option<OrderFillTransaction>,
    /// The Transaction created that immediately cancels the Trade’s new Take Profit Order. Only provided if the
    /// new Take Profit Order was immediately cancelled.
    #[serde(
        rename = "takeProfitOrderCreatedCancelTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub take_profit_order_created_cancel_transaction: Option<OrderCancelTransaction>,
    /// The Transaction created that cancels the Trade’s existing Stop Loss Order.
    #[serde(
        rename = "stopLossOrderCancelTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub stop_loss_order_cancel_transaction: Option<OrderCancelTransaction>,
    /// The Transaction created that creates a new Stop Loss Order for the Trade.
    #[serde(
        rename = "stopLossOrderTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub stop_loss_order_transaction: Option<StopLossOrderTransaction>,
    /// The Transaction created that immediately fills the Trade’s new Stop Order. Only provided if the new Stop
    /// Loss Order was immediately filled.
    #[serde(
        rename = "stopLossOrderFillTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub stop_loss_order_fill_transaction: Option<OrderFillTransaction>,
    /// The Transaction created that immediately cancels the Trade’s new Stop Loss Order. Only provided if the
    /// new Stop Loss Order was immediately cancelled.
    #[serde(
        rename = "stopLossOrderCreatedCancelTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub stop_loss_order_created_cancel_transaction: Option<OrderCancelTransaction>,
    /// The Transaction created that cancels the Trade’s existing Trailing Stop Loss Order.
    #[serde(
        rename = "trailingStopLossOrderCancelTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub trailing_stop_loss_order_cancel_transaction: Option<OrderCancelTransaction>,
    /// The Transaction created that creates a new Trailing Stop Loss Order for the Trade.
    #[serde(
        rename = "trailingStopLossOrderTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub trailing_stop_loss_order_transaction: Option<TrailingStopLossOrderTransaction>,
    /// The Transaction created that cancels the Trade’s existing Guaranteed Stop Loss Order.
    #[serde(
        rename = "guaranteedStopLossOrderCancelTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub guaranteed_stop_loss_order_cancel_transaction: Option<OrderCancelTransaction>,
    /// The Transaction created that creates a new Guaranteed Stop Loss Order for the Trade.
    #[serde(
        rename = "guaranteedStopLossOrderTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub guaranteed_stop_loss_order_transaction: Option<GuaranteedStopLossOrderTransaction>,
    /// The IDs of all Transactions that were created while satisfying the request.
    #[serde(
        rename = "relatedTransactionIDs",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub related_transaction_ids: Option<Vec<TransactionID>>,
    /// The ID of the most recent Transaction created for the Account
    #[serde(
        rename = "lastTransactionID",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub last_transaction_id: Option<TransactionID>,
}

/// Documented rejection fields for `set_trade_dependent_orders`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetTradeDependentOrdersRejection {
    /// An OrderCancelRejectTransaction represents the rejection of the cancellation of an Order in the client’s
    /// Account.
    #[serde(
        rename = "takeProfitOrderCancelRejectTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub take_profit_order_cancel_reject_transaction: Option<OrderCancelRejectTransaction>,
    /// A TakeProfitOrderRejectTransaction represents the rejection of the creation of a TakeProfit Order.
    #[serde(
        rename = "takeProfitOrderRejectTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub take_profit_order_reject_transaction: Option<TakeProfitOrderRejectTransaction>,
    /// An OrderCancelRejectTransaction represents the rejection of the cancellation of an Order in the client’s
    /// Account.
    #[serde(
        rename = "stopLossOrderCancelRejectTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub stop_loss_order_cancel_reject_transaction: Option<OrderCancelRejectTransaction>,
    /// A StopLossOrderRejectTransaction represents the rejection of the creation of a StopLoss Order.
    #[serde(
        rename = "stopLossOrderRejectTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub stop_loss_order_reject_transaction: Option<StopLossOrderRejectTransaction>,
    /// An OrderCancelRejectTransaction represents the rejection of the cancellation of an Order in the client’s
    /// Account.
    #[serde(
        rename = "trailingStopLossOrderCancelRejectTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub trailing_stop_loss_order_cancel_reject_transaction: Option<OrderCancelRejectTransaction>,
    /// A TrailingStopLossOrderRejectTransaction represents the rejection of the creation of a TrailingStopLoss
    /// Order.
    #[serde(
        rename = "trailingStopLossOrderRejectTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub trailing_stop_loss_order_reject_transaction: Option<TrailingStopLossOrderRejectTransaction>,
    /// An OrderCancelRejectTransaction represents the rejection of the cancellation of an Order in the client’s
    /// Account.
    #[serde(
        rename = "guaranteedStopLossOrderCancelRejectTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub guaranteed_stop_loss_order_cancel_reject_transaction: Option<OrderCancelRejectTransaction>,
    /// A GuaranteedStopLossOrderRejectTransaction represents the rejection of the creation of a
    /// GuaranteedStopLoss Order.
    #[serde(
        rename = "guaranteedStopLossOrderRejectTransaction",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub guaranteed_stop_loss_order_reject_transaction:
        Option<GuaranteedStopLossOrderRejectTransaction>,
    /// The ID of the most recent Transaction created for the Account.
    #[serde(
        rename = "lastTransactionID",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub last_transaction_id: Option<TransactionID>,
    /// The IDs of all Transactions that were created while satisfying the request.
    #[serde(
        rename = "relatedTransactionIDs",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub related_transaction_ids: Option<Vec<TransactionID>>,
    /// The code of the error that has occurred. This field may not be returned for some errors.
    #[serde(rename = "errorCode", default, skip_serializing_if = "Option::is_none")]
    pub error_code: Option<String>,
    /// The human-readable description of the error that has occurred.
    #[serde(
        rename = "errorMessage",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub error_message: Option<String>,
}

impl Client {
    /// Set trade dependent orders.
    pub async fn set_trade_dependent_orders(
        &self,
        account_id: &AccountID,
        trade_specifier: &TradeSpecifier,
        body: &SetTradeDependentOrdersBody,
    ) -> std::result::Result<
        crate::ApiResponse<SetTradeDependentOrdersResponse>,
        crate::OperationError<SetTradeDependentOrdersRejection>,
    > {
        let account_id_encoded = crate::client::segment(account_id.as_str());
        let trade_specifier_encoded = crate::client::segment(trade_specifier.as_str());
        let path =
            format!("/v3/accounts/{account_id_encoded}/trades/{trade_specifier_encoded}/orders");
        self.execute(
            Method::PUT,
            &path,
            None::<&()>,
            Some(body),
            Some(crate::client::MutationAdmission::Ordinary(account_id)),
            None,
        )
        .await
    }
}