Skip to main content

oanda_client/models/
account.rs

1//! OANDA v20 account definitions.
2use super::{
3    CalculatedPositionState, CalculatedTradeState, DynamicOrderState, Order, Position,
4    TradeSummary, Transaction,
5};
6use crate::ids::{AccountID, Currency, TransactionID};
7use crate::timestamp::Timestamp;
8use rust_decimal::Decimal;
9use serde::{Deserialize, Serialize};
10
11/// The full details of a client’s Account. This includes full open Trade, open Position and pending Order
12/// representation.
13#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
14#[serde(rename_all = "camelCase")]
15pub struct Account {
16    /// The Account’s identifier
17    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
18    pub id: Option<AccountID>,
19    /// Client-assigned alias for the Account. Only provided if the Account has an alias set
20    #[serde(rename = "alias", default, skip_serializing_if = "Option::is_none")]
21    pub alias: Option<String>,
22    /// The home currency of the Account
23    #[serde(rename = "currency", default, skip_serializing_if = "Option::is_none")]
24    pub currency: Option<Currency>,
25    /// ID of the user that created the Account.
26    #[serde(
27        rename = "createdByUserID",
28        default,
29        skip_serializing_if = "Option::is_none"
30    )]
31    pub created_by_user_id: Option<i64>,
32    /// The date/time when the Account was created.
33    #[serde(
34        rename = "createdTime",
35        default,
36        skip_serializing_if = "Option::is_none"
37    )]
38    pub created_time: Option<Timestamp>,
39    /// The current guaranteed Stop Loss Order settings of the Account. This field will only be present if the
40    /// guaranteedStopLossOrderMode is not ‘DISABLED’.
41    #[serde(
42        rename = "guaranteedStopLossOrderParameters",
43        default,
44        skip_serializing_if = "Option::is_none"
45    )]
46    pub guaranteed_stop_loss_order_parameters: Option<GuaranteedStopLossOrderParameters>,
47    /// The current guaranteed Stop Loss Order mode of the Account.
48    #[serde(
49        rename = "guaranteedStopLossOrderMode",
50        default,
51        skip_serializing_if = "Option::is_none"
52    )]
53    pub guaranteed_stop_loss_order_mode: Option<GuaranteedStopLossOrderMode>,
54    /// The current guaranteed Stop Loss Order mutability setting of the Account. This field will only be
55    /// present if the guaranteedStopLossOrderMode is not ‘DISABLED’. Deprecated: Will be removed in a future
56    /// API update.
57    #[serde(
58        rename = "guaranteedStopLossOrderMutability",
59        default,
60        skip_serializing_if = "Option::is_none"
61    )]
62    pub guaranteed_stop_loss_order_mutability: Option<GuaranteedStopLossOrderMutability>,
63    /// The date/time that the Account’s resettablePL was last reset.
64    #[serde(
65        rename = "resettablePLTime",
66        default,
67        skip_serializing_if = "Option::is_none"
68    )]
69    pub resettable_pl_time: Option<Timestamp>,
70    /// Client-provided margin rate override for the Account. The effective margin rate of the Account is the
71    /// lesser of this value and the OANDA margin rate for the Account’s division. This value is only provided
72    /// if a margin rate override exists for the Account.
73    #[serde(
74        rename = "marginRate",
75        default,
76        skip_serializing_if = "Option::is_none"
77    )]
78    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
79    pub margin_rate: Option<Decimal>,
80    /// The number of Trades currently open in the Account.
81    #[serde(
82        rename = "openTradeCount",
83        default,
84        skip_serializing_if = "Option::is_none"
85    )]
86    pub open_trade_count: Option<i64>,
87    /// The number of Positions currently open in the Account.
88    #[serde(
89        rename = "openPositionCount",
90        default,
91        skip_serializing_if = "Option::is_none"
92    )]
93    pub open_position_count: Option<i64>,
94    /// The number of Orders currently pending in the Account.
95    #[serde(
96        rename = "pendingOrderCount",
97        default,
98        skip_serializing_if = "Option::is_none"
99    )]
100    pub pending_order_count: Option<i64>,
101    /// Flag indicating that the Account has hedging enabled.
102    #[serde(
103        rename = "hedgingEnabled",
104        default,
105        skip_serializing_if = "Option::is_none"
106    )]
107    pub hedging_enabled: Option<bool>,
108    /// The total unrealized profit/loss for all Trades currently open in the Account.
109    #[serde(
110        rename = "unrealizedPL",
111        default,
112        skip_serializing_if = "Option::is_none"
113    )]
114    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
115    pub unrealized_pl: Option<Decimal>,
116    /// The net asset value of the Account. Equal to Account balance + unrealizedPL.
117    #[serde(rename = "NAV", default, skip_serializing_if = "Option::is_none")]
118    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
119    pub nav: Option<Decimal>,
120    /// Margin currently used for the Account.
121    #[serde(
122        rename = "marginUsed",
123        default,
124        skip_serializing_if = "Option::is_none"
125    )]
126    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
127    pub margin_used: Option<Decimal>,
128    /// Margin available for Account currency.
129    #[serde(
130        rename = "marginAvailable",
131        default,
132        skip_serializing_if = "Option::is_none"
133    )]
134    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
135    pub margin_available: Option<Decimal>,
136    /// The value of the Account’s open positions represented in the Account’s home currency.
137    #[serde(
138        rename = "positionValue",
139        default,
140        skip_serializing_if = "Option::is_none"
141    )]
142    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
143    pub position_value: Option<Decimal>,
144    /// The Account’s margin closeout unrealized PL.
145    #[serde(
146        rename = "marginCloseoutUnrealizedPL",
147        default,
148        skip_serializing_if = "Option::is_none"
149    )]
150    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
151    pub margin_closeout_unrealized_pl: Option<Decimal>,
152    /// The Account’s margin closeout NAV.
153    #[serde(
154        rename = "marginCloseoutNAV",
155        default,
156        skip_serializing_if = "Option::is_none"
157    )]
158    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
159    pub margin_closeout_nav: Option<Decimal>,
160    /// The Account’s margin closeout margin used.
161    #[serde(
162        rename = "marginCloseoutMarginUsed",
163        default,
164        skip_serializing_if = "Option::is_none"
165    )]
166    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
167    pub margin_closeout_margin_used: Option<Decimal>,
168    /// The Account’s margin closeout percentage. When this value is 1.0 or above the Account is in a margin
169    /// closeout situation.
170    #[serde(
171        rename = "marginCloseoutPercent",
172        default,
173        skip_serializing_if = "Option::is_none"
174    )]
175    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
176    pub margin_closeout_percent: Option<Decimal>,
177    /// The value of the Account’s open positions as used for margin closeout calculations represented in the
178    /// Account’s home currency.
179    #[serde(
180        rename = "marginCloseoutPositionValue",
181        default,
182        skip_serializing_if = "Option::is_none"
183    )]
184    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
185    pub margin_closeout_position_value: Option<Decimal>,
186    /// The current `WithdrawalLimit` for the account which will be zero or a positive value indicating how much
187    /// can be withdrawn from the account.
188    #[serde(
189        rename = "withdrawalLimit",
190        default,
191        skip_serializing_if = "Option::is_none"
192    )]
193    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
194    pub withdrawal_limit: Option<Decimal>,
195    /// The Account’s margin call margin used.
196    #[serde(
197        rename = "marginCallMarginUsed",
198        default,
199        skip_serializing_if = "Option::is_none"
200    )]
201    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
202    pub margin_call_margin_used: Option<Decimal>,
203    /// The Account’s margin call percentage. When this value is 1.0 or above the Account is in a margin call
204    /// situation.
205    #[serde(
206        rename = "marginCallPercent",
207        default,
208        skip_serializing_if = "Option::is_none"
209    )]
210    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
211    pub margin_call_percent: Option<Decimal>,
212    /// The current balance of the account.
213    #[serde(rename = "balance", default, skip_serializing_if = "Option::is_none")]
214    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
215    pub balance: Option<Decimal>,
216    /// The total profit/loss realized over the lifetime of the Account.
217    #[serde(rename = "pl", default, skip_serializing_if = "Option::is_none")]
218    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
219    pub pl: Option<Decimal>,
220    /// The total realized profit/loss for the account since it was last reset by the client.
221    #[serde(
222        rename = "resettablePL",
223        default,
224        skip_serializing_if = "Option::is_none"
225    )]
226    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
227    pub resettable_pl: Option<Decimal>,
228    /// The total amount of financing paid/collected over the lifetime of the account.
229    #[serde(rename = "financing", default, skip_serializing_if = "Option::is_none")]
230    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
231    pub financing: Option<Decimal>,
232    /// The total amount of commission paid over the lifetime of the Account.
233    #[serde(
234        rename = "commission",
235        default,
236        skip_serializing_if = "Option::is_none"
237    )]
238    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
239    pub commission: Option<Decimal>,
240    /// The total amount of dividend adjustment paid over the lifetime of the Account in the Account’s home
241    /// currency.
242    #[serde(
243        rename = "dividendAdjustment",
244        default,
245        skip_serializing_if = "Option::is_none"
246    )]
247    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
248    pub dividend_adjustment: Option<Decimal>,
249    /// The total amount of fees charged over the lifetime of the Account for the execution of guaranteed Stop
250    /// Loss Orders.
251    #[serde(
252        rename = "guaranteedExecutionFees",
253        default,
254        skip_serializing_if = "Option::is_none"
255    )]
256    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
257    pub guaranteed_execution_fees: Option<Decimal>,
258    /// The date/time when the Account entered a margin call state. Only provided if the Account is in a margin
259    /// call.
260    #[serde(
261        rename = "marginCallEnterTime",
262        default,
263        skip_serializing_if = "Option::is_none"
264    )]
265    pub margin_call_enter_time: Option<Timestamp>,
266    /// The number of times that the Account’s current margin call was extended.
267    #[serde(
268        rename = "marginCallExtensionCount",
269        default,
270        skip_serializing_if = "Option::is_none"
271    )]
272    pub margin_call_extension_count: Option<i64>,
273    /// The date/time of the Account’s last margin call extension.
274    #[serde(
275        rename = "lastMarginCallExtensionTime",
276        default,
277        skip_serializing_if = "Option::is_none"
278    )]
279    pub last_margin_call_extension_time: Option<Timestamp>,
280    /// The date/time of the last order that was filled for this account.
281    ///
282    /// Not on the website's definition page; documented by the pinned `OpenAPI` spec and read by
283    /// OANDA's own v20 clients. `None` when OANDA does not send it.
284    #[serde(
285        rename = "lastOrderFillTimestamp",
286        default,
287        skip_serializing_if = "Option::is_none"
288    )]
289    pub last_order_fill_timestamp: Option<Timestamp>,
290    /// The ID of the last Transaction created for the Account.
291    #[serde(
292        rename = "lastTransactionID",
293        default,
294        skip_serializing_if = "Option::is_none"
295    )]
296    pub last_transaction_id: Option<TransactionID>,
297    /// The details of the Trades currently open in the Account.
298    #[serde(rename = "trades", default, skip_serializing_if = "Option::is_none")]
299    pub trades: Option<Vec<TradeSummary>>,
300    /// The details all Account Positions.
301    #[serde(rename = "positions", default, skip_serializing_if = "Option::is_none")]
302    pub positions: Option<Vec<Position>>,
303    /// The details of the Orders currently pending in the Account.
304    #[serde(rename = "orders", default, skip_serializing_if = "Option::is_none")]
305    pub orders: Option<Vec<Order>>,
306}
307
308/// An `AccountState` Object is used to represent an Account’s current price-dependent state. Price-dependent
309/// Account state is dependent on OANDA’s current Prices, and includes things like unrealized PL, NAV and
310/// Trailing Stop Loss Order state. Fields will be omitted if their value has not changed since the
311/// specified transaction ID.
312#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
313#[serde(rename_all = "camelCase")]
314pub struct AccountChangesState {
315    /// The total unrealized profit/loss for all Trades currently open in the Account.
316    #[serde(
317        rename = "unrealizedPL",
318        default,
319        skip_serializing_if = "Option::is_none"
320    )]
321    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
322    pub unrealized_pl: Option<Decimal>,
323    /// The net asset value of the Account. Equal to Account balance + unrealizedPL.
324    #[serde(rename = "NAV", default, skip_serializing_if = "Option::is_none")]
325    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
326    pub nav: Option<Decimal>,
327    /// Margin currently used for the Account.
328    #[serde(
329        rename = "marginUsed",
330        default,
331        skip_serializing_if = "Option::is_none"
332    )]
333    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
334    pub margin_used: Option<Decimal>,
335    /// Margin available for Account currency.
336    #[serde(
337        rename = "marginAvailable",
338        default,
339        skip_serializing_if = "Option::is_none"
340    )]
341    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
342    pub margin_available: Option<Decimal>,
343    /// The value of the Account’s open positions represented in the Account’s home currency.
344    #[serde(
345        rename = "positionValue",
346        default,
347        skip_serializing_if = "Option::is_none"
348    )]
349    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
350    pub position_value: Option<Decimal>,
351    /// The Account’s margin closeout unrealized PL.
352    #[serde(
353        rename = "marginCloseoutUnrealizedPL",
354        default,
355        skip_serializing_if = "Option::is_none"
356    )]
357    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
358    pub margin_closeout_unrealized_pl: Option<Decimal>,
359    /// The Account’s margin closeout NAV.
360    #[serde(
361        rename = "marginCloseoutNAV",
362        default,
363        skip_serializing_if = "Option::is_none"
364    )]
365    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
366    pub margin_closeout_nav: Option<Decimal>,
367    /// The Account’s margin closeout margin used.
368    #[serde(
369        rename = "marginCloseoutMarginUsed",
370        default,
371        skip_serializing_if = "Option::is_none"
372    )]
373    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
374    pub margin_closeout_margin_used: Option<Decimal>,
375    /// The Account’s margin closeout percentage. When this value is 1.0 or above the Account is in a margin
376    /// closeout situation.
377    #[serde(
378        rename = "marginCloseoutPercent",
379        default,
380        skip_serializing_if = "Option::is_none"
381    )]
382    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
383    pub margin_closeout_percent: Option<Decimal>,
384    /// The value of the Account’s open positions as used for margin closeout calculations represented in the
385    /// Account’s home currency.
386    #[serde(
387        rename = "marginCloseoutPositionValue",
388        default,
389        skip_serializing_if = "Option::is_none"
390    )]
391    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
392    pub margin_closeout_position_value: Option<Decimal>,
393    /// The current `WithdrawalLimit` for the account which will be zero or a positive value indicating how much
394    /// can be withdrawn from the account.
395    #[serde(
396        rename = "withdrawalLimit",
397        default,
398        skip_serializing_if = "Option::is_none"
399    )]
400    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
401    pub withdrawal_limit: Option<Decimal>,
402    /// The Account’s margin call margin used.
403    #[serde(
404        rename = "marginCallMarginUsed",
405        default,
406        skip_serializing_if = "Option::is_none"
407    )]
408    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
409    pub margin_call_margin_used: Option<Decimal>,
410    /// The Account’s margin call percentage. When this value is 1.0 or above the Account is in a margin call
411    /// situation.
412    #[serde(
413        rename = "marginCallPercent",
414        default,
415        skip_serializing_if = "Option::is_none"
416    )]
417    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
418    pub margin_call_percent: Option<Decimal>,
419    /// The current balance of the account.
420    #[serde(rename = "balance", default, skip_serializing_if = "Option::is_none")]
421    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
422    pub balance: Option<Decimal>,
423    /// The total profit/loss realized over the lifetime of the Account.
424    #[serde(rename = "pl", default, skip_serializing_if = "Option::is_none")]
425    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
426    pub pl: Option<Decimal>,
427    /// The total realized profit/loss for the account since it was last reset by the client.
428    #[serde(
429        rename = "resettablePL",
430        default,
431        skip_serializing_if = "Option::is_none"
432    )]
433    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
434    pub resettable_pl: Option<Decimal>,
435    /// The total amount of financing paid/collected over the lifetime of the account.
436    #[serde(rename = "financing", default, skip_serializing_if = "Option::is_none")]
437    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
438    pub financing: Option<Decimal>,
439    /// The total amount of commission paid over the lifetime of the Account.
440    #[serde(
441        rename = "commission",
442        default,
443        skip_serializing_if = "Option::is_none"
444    )]
445    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
446    pub commission: Option<Decimal>,
447    /// The total amount of dividend adjustment paid over the lifetime of the Account in the Account’s home
448    /// currency.
449    #[serde(
450        rename = "dividendAdjustment",
451        default,
452        skip_serializing_if = "Option::is_none"
453    )]
454    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
455    pub dividend_adjustment: Option<Decimal>,
456    /// The total amount of fees charged over the lifetime of the Account for the execution of guaranteed Stop
457    /// Loss Orders.
458    #[serde(
459        rename = "guaranteedExecutionFees",
460        default,
461        skip_serializing_if = "Option::is_none"
462    )]
463    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
464    pub guaranteed_execution_fees: Option<Decimal>,
465    /// The date/time when the Account entered a margin call state. Only provided if the Account is in a margin
466    /// call.
467    #[serde(
468        rename = "marginCallEnterTime",
469        default,
470        skip_serializing_if = "Option::is_none"
471    )]
472    pub margin_call_enter_time: Option<Timestamp>,
473    /// The number of times that the Account’s current margin call was extended.
474    #[serde(
475        rename = "marginCallExtensionCount",
476        default,
477        skip_serializing_if = "Option::is_none"
478    )]
479    pub margin_call_extension_count: Option<i64>,
480    /// The date/time of the Account’s last margin call extension.
481    #[serde(
482        rename = "lastMarginCallExtensionTime",
483        default,
484        skip_serializing_if = "Option::is_none"
485    )]
486    pub last_margin_call_extension_time: Option<Timestamp>,
487    /// The price-dependent state of each pending Order in the Account.
488    #[serde(rename = "orders", default, skip_serializing_if = "Option::is_none")]
489    pub orders: Option<Vec<DynamicOrderState>>,
490    /// The price-dependent state for each open Trade in the Account.
491    #[serde(rename = "trades", default, skip_serializing_if = "Option::is_none")]
492    pub trades: Option<Vec<CalculatedTradeState>>,
493    /// The price-dependent state for each open Position in the Account.
494    #[serde(rename = "positions", default, skip_serializing_if = "Option::is_none")]
495    pub positions: Option<Vec<CalculatedPositionState>>,
496}
497
498/// Properties related to an Account.
499#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
500#[serde(rename_all = "camelCase")]
501pub struct AccountProperties {
502    /// The Account’s identifier
503    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
504    pub id: Option<AccountID>,
505    /// The Account’s associated MT4 Account ID. This field will not be present if the Account is not an MT4
506    /// account.
507    #[serde(
508        rename = "mt4AccountID",
509        default,
510        skip_serializing_if = "Option::is_none"
511    )]
512    pub mt4_account_id: Option<i64>,
513    /// The Account’s tags
514    #[serde(rename = "tags", default, skip_serializing_if = "Option::is_none")]
515    pub tags: Option<Vec<String>>,
516}
517
518/// The current mutability and hedging settings related to guaranteed Stop Loss orders.
519#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
520#[serde(rename_all = "camelCase")]
521pub struct GuaranteedStopLossOrderParameters {
522    /// The current guaranteed Stop Loss Order mutability setting of the Account when market is open.
523    #[serde(
524        rename = "mutabilityMarketOpen",
525        default,
526        skip_serializing_if = "Option::is_none"
527    )]
528    pub mutability_market_open: Option<GuaranteedStopLossOrderMutability>,
529    /// The current guaranteed Stop Loss Order mutability setting of the Account when market is halted.
530    #[serde(
531        rename = "mutabilityMarketHalted",
532        default,
533        skip_serializing_if = "Option::is_none"
534    )]
535    pub mutability_market_halted: Option<GuaranteedStopLossOrderMutability>,
536}
537
538provider_enum! {
539    /// The overall behaviour of the Account regarding guaranteed Stop Loss Orders.
540    #[derive(Debug, Clone, PartialEq, Eq, Hash)]
541    #[non_exhaustive]
542    pub enum GuaranteedStopLossOrderMode {
543        /// The Account is not permitted to create guaranteed Stop Loss Orders.
544        Disabled => "DISABLED",
545        /// The Account is able, but not required to have guaranteed Stop Loss Orders for open Trades.
546        Allowed => "ALLOWED",
547        /// The Account is required to have guaranteed Stop Loss Orders for all open Trades.
548        Required => "REQUIRED",
549        ;
550        /// An unrecognized provider value, preserved for forward compatibility.
551        Unknown(String),
552    }
553}
554
555provider_enum! {
556    /// For Accounts that support guaranteed Stop Loss Orders, describes the actions that can be performed on
557    /// guaranteed Stop Loss Orders.
558    #[derive(Debug, Clone, PartialEq, Eq, Hash)]
559    #[non_exhaustive]
560    pub enum GuaranteedStopLossOrderMutability {
561        /// Once a guaranteed Stop Loss Order has been created it cannot be replaced or cancelled.
562        Fixed => "FIXED",
563        /// An existing guaranteed Stop Loss Order can only be replaced, not cancelled.
564        Replaceable => "REPLACEABLE",
565        /// Once a guaranteed Stop Loss Order has been created it can be either replaced or cancelled.
566        Cancelable => "CANCELABLE",
567        /// An existing guaranteed Stop Loss Order can only be replaced to widen the gap from the current price, not
568        /// cancelled.
569        PriceWidenOnly => "PRICE_WIDEN_ONLY",
570        ;
571        /// An unrecognized provider value, preserved for forward compatibility.
572        Unknown(String),
573    }
574}
575
576/// A summary representation of a client’s Account. The `AccountSummary` does not provide a full specification
577/// of pending Orders, open Trades and Positions.
578#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
579#[serde(rename_all = "camelCase")]
580pub struct AccountSummary {
581    /// The Account’s identifier
582    #[serde(rename = "id", default, skip_serializing_if = "Option::is_none")]
583    pub id: Option<AccountID>,
584    /// Client-assigned alias for the Account. Only provided if the Account has an alias set
585    #[serde(rename = "alias", default, skip_serializing_if = "Option::is_none")]
586    pub alias: Option<String>,
587    /// The home currency of the Account
588    #[serde(rename = "currency", default, skip_serializing_if = "Option::is_none")]
589    pub currency: Option<Currency>,
590    /// ID of the user that created the Account.
591    #[serde(
592        rename = "createdByUserID",
593        default,
594        skip_serializing_if = "Option::is_none"
595    )]
596    pub created_by_user_id: Option<i64>,
597    /// The date/time when the Account was created.
598    #[serde(
599        rename = "createdTime",
600        default,
601        skip_serializing_if = "Option::is_none"
602    )]
603    pub created_time: Option<Timestamp>,
604    /// The current guaranteed Stop Loss Order settings of the Account. This field will only be present if the
605    /// guaranteedStopLossOrderMode is not ‘DISABLED’.
606    #[serde(
607        rename = "guaranteedStopLossOrderParameters",
608        default,
609        skip_serializing_if = "Option::is_none"
610    )]
611    pub guaranteed_stop_loss_order_parameters: Option<GuaranteedStopLossOrderParameters>,
612    /// The current guaranteed Stop Loss Order mode of the Account.
613    #[serde(
614        rename = "guaranteedStopLossOrderMode",
615        default,
616        skip_serializing_if = "Option::is_none"
617    )]
618    pub guaranteed_stop_loss_order_mode: Option<GuaranteedStopLossOrderMode>,
619    /// The current guaranteed Stop Loss Order mutability setting of the Account. This field will only be
620    /// present if the guaranteedStopLossOrderMode is not ‘DISABLED’. Deprecated: Will be removed in a future
621    /// API update.
622    #[serde(
623        rename = "guaranteedStopLossOrderMutability",
624        default,
625        skip_serializing_if = "Option::is_none"
626    )]
627    pub guaranteed_stop_loss_order_mutability: Option<GuaranteedStopLossOrderMutability>,
628    /// The date/time that the Account’s resettablePL was last reset.
629    #[serde(
630        rename = "resettablePLTime",
631        default,
632        skip_serializing_if = "Option::is_none"
633    )]
634    pub resettable_pl_time: Option<Timestamp>,
635    /// Client-provided margin rate override for the Account. The effective margin rate of the Account is the
636    /// lesser of this value and the OANDA margin rate for the Account’s division. This value is only provided
637    /// if a margin rate override exists for the Account.
638    #[serde(
639        rename = "marginRate",
640        default,
641        skip_serializing_if = "Option::is_none"
642    )]
643    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
644    pub margin_rate: Option<Decimal>,
645    /// The number of Trades currently open in the Account.
646    #[serde(
647        rename = "openTradeCount",
648        default,
649        skip_serializing_if = "Option::is_none"
650    )]
651    pub open_trade_count: Option<i64>,
652    /// The number of Positions currently open in the Account.
653    #[serde(
654        rename = "openPositionCount",
655        default,
656        skip_serializing_if = "Option::is_none"
657    )]
658    pub open_position_count: Option<i64>,
659    /// The number of Orders currently pending in the Account.
660    #[serde(
661        rename = "pendingOrderCount",
662        default,
663        skip_serializing_if = "Option::is_none"
664    )]
665    pub pending_order_count: Option<i64>,
666    /// Flag indicating that the Account has hedging enabled.
667    #[serde(
668        rename = "hedgingEnabled",
669        default,
670        skip_serializing_if = "Option::is_none"
671    )]
672    pub hedging_enabled: Option<bool>,
673    /// The total unrealized profit/loss for all Trades currently open in the Account.
674    #[serde(
675        rename = "unrealizedPL",
676        default,
677        skip_serializing_if = "Option::is_none"
678    )]
679    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
680    pub unrealized_pl: Option<Decimal>,
681    /// The net asset value of the Account. Equal to Account balance + unrealizedPL.
682    #[serde(rename = "NAV", default, skip_serializing_if = "Option::is_none")]
683    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
684    pub nav: Option<Decimal>,
685    /// Margin currently used for the Account.
686    #[serde(
687        rename = "marginUsed",
688        default,
689        skip_serializing_if = "Option::is_none"
690    )]
691    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
692    pub margin_used: Option<Decimal>,
693    /// Margin available for Account currency.
694    #[serde(
695        rename = "marginAvailable",
696        default,
697        skip_serializing_if = "Option::is_none"
698    )]
699    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
700    pub margin_available: Option<Decimal>,
701    /// The value of the Account’s open positions represented in the Account’s home currency.
702    #[serde(
703        rename = "positionValue",
704        default,
705        skip_serializing_if = "Option::is_none"
706    )]
707    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
708    pub position_value: Option<Decimal>,
709    /// The Account’s margin closeout unrealized PL.
710    #[serde(
711        rename = "marginCloseoutUnrealizedPL",
712        default,
713        skip_serializing_if = "Option::is_none"
714    )]
715    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
716    pub margin_closeout_unrealized_pl: Option<Decimal>,
717    /// The Account’s margin closeout NAV.
718    #[serde(
719        rename = "marginCloseoutNAV",
720        default,
721        skip_serializing_if = "Option::is_none"
722    )]
723    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
724    pub margin_closeout_nav: Option<Decimal>,
725    /// The Account’s margin closeout margin used.
726    #[serde(
727        rename = "marginCloseoutMarginUsed",
728        default,
729        skip_serializing_if = "Option::is_none"
730    )]
731    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
732    pub margin_closeout_margin_used: Option<Decimal>,
733    /// The Account’s margin closeout percentage. When this value is 1.0 or above the Account is in a margin
734    /// closeout situation.
735    #[serde(
736        rename = "marginCloseoutPercent",
737        default,
738        skip_serializing_if = "Option::is_none"
739    )]
740    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
741    pub margin_closeout_percent: Option<Decimal>,
742    /// The value of the Account’s open positions as used for margin closeout calculations represented in the
743    /// Account’s home currency.
744    #[serde(
745        rename = "marginCloseoutPositionValue",
746        default,
747        skip_serializing_if = "Option::is_none"
748    )]
749    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
750    pub margin_closeout_position_value: Option<Decimal>,
751    /// The current `WithdrawalLimit` for the account which will be zero or a positive value indicating how much
752    /// can be withdrawn from the account.
753    #[serde(
754        rename = "withdrawalLimit",
755        default,
756        skip_serializing_if = "Option::is_none"
757    )]
758    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
759    pub withdrawal_limit: Option<Decimal>,
760    /// The Account’s margin call margin used.
761    #[serde(
762        rename = "marginCallMarginUsed",
763        default,
764        skip_serializing_if = "Option::is_none"
765    )]
766    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
767    pub margin_call_margin_used: Option<Decimal>,
768    /// The Account’s margin call percentage. When this value is 1.0 or above the Account is in a margin call
769    /// situation.
770    #[serde(
771        rename = "marginCallPercent",
772        default,
773        skip_serializing_if = "Option::is_none"
774    )]
775    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
776    pub margin_call_percent: Option<Decimal>,
777    /// The current balance of the account.
778    #[serde(rename = "balance", default, skip_serializing_if = "Option::is_none")]
779    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
780    pub balance: Option<Decimal>,
781    /// The total profit/loss realized over the lifetime of the Account.
782    #[serde(rename = "pl", default, skip_serializing_if = "Option::is_none")]
783    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
784    pub pl: Option<Decimal>,
785    /// The total realized profit/loss for the account since it was last reset by the client.
786    #[serde(
787        rename = "resettablePL",
788        default,
789        skip_serializing_if = "Option::is_none"
790    )]
791    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
792    pub resettable_pl: Option<Decimal>,
793    /// The total amount of financing paid/collected over the lifetime of the account.
794    #[serde(rename = "financing", default, skip_serializing_if = "Option::is_none")]
795    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
796    pub financing: Option<Decimal>,
797    /// The total amount of commission paid over the lifetime of the Account.
798    #[serde(
799        rename = "commission",
800        default,
801        skip_serializing_if = "Option::is_none"
802    )]
803    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
804    pub commission: Option<Decimal>,
805    /// The total amount of dividend adjustment paid over the lifetime of the Account in the Account’s home
806    /// currency.
807    #[serde(
808        rename = "dividendAdjustment",
809        default,
810        skip_serializing_if = "Option::is_none"
811    )]
812    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
813    pub dividend_adjustment: Option<Decimal>,
814    /// The total amount of fees charged over the lifetime of the Account for the execution of guaranteed Stop
815    /// Loss Orders.
816    #[serde(
817        rename = "guaranteedExecutionFees",
818        default,
819        skip_serializing_if = "Option::is_none"
820    )]
821    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
822    pub guaranteed_execution_fees: Option<Decimal>,
823    /// The date/time when the Account entered a margin call state. Only provided if the Account is in a margin
824    /// call.
825    #[serde(
826        rename = "marginCallEnterTime",
827        default,
828        skip_serializing_if = "Option::is_none"
829    )]
830    pub margin_call_enter_time: Option<Timestamp>,
831    /// The number of times that the Account’s current margin call was extended.
832    #[serde(
833        rename = "marginCallExtensionCount",
834        default,
835        skip_serializing_if = "Option::is_none"
836    )]
837    pub margin_call_extension_count: Option<i64>,
838    /// The date/time of the Account’s last margin call extension.
839    #[serde(
840        rename = "lastMarginCallExtensionTime",
841        default,
842        skip_serializing_if = "Option::is_none"
843    )]
844    pub last_margin_call_extension_time: Option<Timestamp>,
845    /// The date/time of the last order that was filled for this account.
846    ///
847    /// Not on the website's definition page; documented by the pinned `OpenAPI` spec and read by
848    /// OANDA's own v20 clients. `None` when OANDA does not send it.
849    #[serde(
850        rename = "lastOrderFillTimestamp",
851        default,
852        skip_serializing_if = "Option::is_none"
853    )]
854    pub last_order_fill_timestamp: Option<Timestamp>,
855    /// The ID of the last Transaction created for the Account.
856    #[serde(
857        rename = "lastTransactionID",
858        default,
859        skip_serializing_if = "Option::is_none"
860    )]
861    pub last_transaction_id: Option<TransactionID>,
862}
863
864/// The mutable state of a client’s Account.
865#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
866#[serde(rename_all = "camelCase")]
867pub struct AccumulatedAccountState {
868    /// The current balance of the account.
869    #[serde(rename = "balance", default, skip_serializing_if = "Option::is_none")]
870    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
871    pub balance: Option<Decimal>,
872    /// The total profit/loss realized over the lifetime of the Account.
873    #[serde(rename = "pl", default, skip_serializing_if = "Option::is_none")]
874    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
875    pub pl: Option<Decimal>,
876    /// The total realized profit/loss for the account since it was last reset by the client.
877    #[serde(
878        rename = "resettablePL",
879        default,
880        skip_serializing_if = "Option::is_none"
881    )]
882    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
883    pub resettable_pl: Option<Decimal>,
884    /// The total amount of financing paid/collected over the lifetime of the account.
885    #[serde(rename = "financing", default, skip_serializing_if = "Option::is_none")]
886    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
887    pub financing: Option<Decimal>,
888    /// The total amount of commission paid over the lifetime of the Account.
889    #[serde(
890        rename = "commission",
891        default,
892        skip_serializing_if = "Option::is_none"
893    )]
894    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
895    pub commission: Option<Decimal>,
896    /// The total amount of dividend adjustment paid over the lifetime of the Account in the Account’s home
897    /// currency.
898    #[serde(
899        rename = "dividendAdjustment",
900        default,
901        skip_serializing_if = "Option::is_none"
902    )]
903    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
904    pub dividend_adjustment: Option<Decimal>,
905    /// The total amount of fees charged over the lifetime of the Account for the execution of guaranteed Stop
906    /// Loss Orders.
907    #[serde(
908        rename = "guaranteedExecutionFees",
909        default,
910        skip_serializing_if = "Option::is_none"
911    )]
912    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
913    pub guaranteed_execution_fees: Option<Decimal>,
914    /// The date/time when the Account entered a margin call state. Only provided if the Account is in a margin
915    /// call.
916    #[serde(
917        rename = "marginCallEnterTime",
918        default,
919        skip_serializing_if = "Option::is_none"
920    )]
921    pub margin_call_enter_time: Option<Timestamp>,
922    /// The number of times that the Account’s current margin call was extended.
923    #[serde(
924        rename = "marginCallExtensionCount",
925        default,
926        skip_serializing_if = "Option::is_none"
927    )]
928    pub margin_call_extension_count: Option<i64>,
929    /// The date/time of the Account’s last margin call extension.
930    #[serde(
931        rename = "lastMarginCallExtensionTime",
932        default,
933        skip_serializing_if = "Option::is_none"
934    )]
935    pub last_margin_call_extension_time: Option<Timestamp>,
936}
937
938/// The dynamically calculated state of a client’s Account.
939#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
940#[serde(rename_all = "camelCase")]
941pub struct CalculatedAccountState {
942    /// The total unrealized profit/loss for all Trades currently open in the Account.
943    #[serde(
944        rename = "unrealizedPL",
945        default,
946        skip_serializing_if = "Option::is_none"
947    )]
948    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
949    pub unrealized_pl: Option<Decimal>,
950    /// The net asset value of the Account. Equal to Account balance + unrealizedPL.
951    #[serde(rename = "NAV", default, skip_serializing_if = "Option::is_none")]
952    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
953    pub nav: Option<Decimal>,
954    /// Margin currently used for the Account.
955    #[serde(
956        rename = "marginUsed",
957        default,
958        skip_serializing_if = "Option::is_none"
959    )]
960    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
961    pub margin_used: Option<Decimal>,
962    /// Margin available for Account currency.
963    #[serde(
964        rename = "marginAvailable",
965        default,
966        skip_serializing_if = "Option::is_none"
967    )]
968    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
969    pub margin_available: Option<Decimal>,
970    /// The value of the Account’s open positions represented in the Account’s home currency.
971    #[serde(
972        rename = "positionValue",
973        default,
974        skip_serializing_if = "Option::is_none"
975    )]
976    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
977    pub position_value: Option<Decimal>,
978    /// The Account’s margin closeout unrealized PL.
979    #[serde(
980        rename = "marginCloseoutUnrealizedPL",
981        default,
982        skip_serializing_if = "Option::is_none"
983    )]
984    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
985    pub margin_closeout_unrealized_pl: Option<Decimal>,
986    /// The Account’s margin closeout NAV.
987    #[serde(
988        rename = "marginCloseoutNAV",
989        default,
990        skip_serializing_if = "Option::is_none"
991    )]
992    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
993    pub margin_closeout_nav: Option<Decimal>,
994    /// The Account’s margin closeout margin used.
995    #[serde(
996        rename = "marginCloseoutMarginUsed",
997        default,
998        skip_serializing_if = "Option::is_none"
999    )]
1000    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1001    pub margin_closeout_margin_used: Option<Decimal>,
1002    /// The Account’s margin closeout percentage. When this value is 1.0 or above the Account is in a margin
1003    /// closeout situation.
1004    #[serde(
1005        rename = "marginCloseoutPercent",
1006        default,
1007        skip_serializing_if = "Option::is_none"
1008    )]
1009    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1010    pub margin_closeout_percent: Option<Decimal>,
1011    /// The value of the Account’s open positions as used for margin closeout calculations represented in the
1012    /// Account’s home currency.
1013    #[serde(
1014        rename = "marginCloseoutPositionValue",
1015        default,
1016        skip_serializing_if = "Option::is_none"
1017    )]
1018    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1019    pub margin_closeout_position_value: Option<Decimal>,
1020    /// The current `WithdrawalLimit` for the account which will be zero or a positive value indicating how much
1021    /// can be withdrawn from the account.
1022    #[serde(
1023        rename = "withdrawalLimit",
1024        default,
1025        skip_serializing_if = "Option::is_none"
1026    )]
1027    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1028    pub withdrawal_limit: Option<Decimal>,
1029    /// The Account’s margin call margin used.
1030    #[serde(
1031        rename = "marginCallMarginUsed",
1032        default,
1033        skip_serializing_if = "Option::is_none"
1034    )]
1035    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1036    pub margin_call_margin_used: Option<Decimal>,
1037    /// The Account’s margin call percentage. When this value is 1.0 or above the Account is in a margin call
1038    /// situation.
1039    #[serde(
1040        rename = "marginCallPercent",
1041        default,
1042        skip_serializing_if = "Option::is_none"
1043    )]
1044    #[serde(deserialize_with = "crate::decimal_wire::optional_number_or_string")]
1045    pub margin_call_percent: Option<Decimal>,
1046}
1047
1048/// An `AccountChanges` Object is used to represent the changes to an Account’s Orders, Trades and Positions
1049/// since a specified Account `TransactionID` in the past.
1050#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1051#[serde(rename_all = "camelCase")]
1052pub struct AccountChanges {
1053    /// The Orders created. These Orders may have been filled, cancelled or triggered in the same period.
1054    #[serde(
1055        rename = "ordersCreated",
1056        default,
1057        skip_serializing_if = "Option::is_none"
1058    )]
1059    pub orders_created: Option<Vec<Order>>,
1060    /// The Orders cancelled.
1061    #[serde(
1062        rename = "ordersCancelled",
1063        default,
1064        skip_serializing_if = "Option::is_none"
1065    )]
1066    pub orders_cancelled: Option<Vec<Order>>,
1067    /// The Orders filled.
1068    #[serde(
1069        rename = "ordersFilled",
1070        default,
1071        skip_serializing_if = "Option::is_none"
1072    )]
1073    pub orders_filled: Option<Vec<Order>>,
1074    /// The Orders triggered.
1075    #[serde(
1076        rename = "ordersTriggered",
1077        default,
1078        skip_serializing_if = "Option::is_none"
1079    )]
1080    pub orders_triggered: Option<Vec<Order>>,
1081    /// The Trades opened.
1082    #[serde(
1083        rename = "tradesOpened",
1084        default,
1085        skip_serializing_if = "Option::is_none"
1086    )]
1087    pub trades_opened: Option<Vec<TradeSummary>>,
1088    /// The Trades reduced.
1089    #[serde(
1090        rename = "tradesReduced",
1091        default,
1092        skip_serializing_if = "Option::is_none"
1093    )]
1094    pub trades_reduced: Option<Vec<TradeSummary>>,
1095    /// The Trades closed.
1096    #[serde(
1097        rename = "tradesClosed",
1098        default,
1099        skip_serializing_if = "Option::is_none"
1100    )]
1101    pub trades_closed: Option<Vec<TradeSummary>>,
1102    /// The Positions changed.
1103    #[serde(rename = "positions", default, skip_serializing_if = "Option::is_none")]
1104    pub positions: Option<Vec<Position>>,
1105    /// The Transactions that have been generated.
1106    #[serde(
1107        rename = "transactions",
1108        default,
1109        skip_serializing_if = "Option::is_none"
1110    )]
1111    pub transactions: Option<Vec<Transaction>>,
1112}
1113
1114provider_enum! {
1115    /// The financing mode of an Account
1116    #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1117    #[non_exhaustive]
1118    pub enum AccountFinancingMode {
1119        /// No financing is paid/charged for open Trades in the Account
1120        NoFinancing => "NO_FINANCING",
1121        /// Second-by-second financing is paid/charged for open Trades in the Account, both daily and when the the
1122        /// Trade is closed
1123        SecondBySecond => "SECOND_BY_SECOND",
1124        /// A full day’s worth of financing is paid/charged for open Trades in the Account daily at 5pm New York time
1125        Daily => "DAILY",
1126        ;
1127        /// An unrecognized provider value, preserved for forward compatibility.
1128        Unknown(String),
1129    }
1130}
1131
1132/// Contains the attributes of a user.
1133#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1134#[serde(rename_all = "camelCase")]
1135pub struct UserAttributes {
1136    /// The user’s OANDA-assigned user ID.
1137    #[serde(rename = "userID", default, skip_serializing_if = "Option::is_none")]
1138    pub user_id: Option<i64>,
1139    /// The user-provided username.
1140    #[serde(rename = "username", default, skip_serializing_if = "Option::is_none")]
1141    pub username: Option<String>,
1142    /// The user’s title.
1143    #[serde(rename = "title", default, skip_serializing_if = "Option::is_none")]
1144    pub title: Option<String>,
1145    /// The user’s name.
1146    #[serde(rename = "name", default, skip_serializing_if = "Option::is_none")]
1147    pub name: Option<String>,
1148    /// The user’s email address.
1149    #[serde(rename = "email", default, skip_serializing_if = "Option::is_none")]
1150    pub email: Option<String>,
1151    /// The OANDA division the user belongs to.
1152    #[serde(
1153        rename = "divisionAbbreviation",
1154        default,
1155        skip_serializing_if = "Option::is_none"
1156    )]
1157    pub division_abbreviation: Option<String>,
1158    /// The user’s preferred language.
1159    #[serde(
1160        rename = "languageAbbreviation",
1161        default,
1162        skip_serializing_if = "Option::is_none"
1163    )]
1164    pub language_abbreviation: Option<String>,
1165    /// The home currency of the Account.
1166    #[serde(
1167        rename = "homeCurrency",
1168        default,
1169        skip_serializing_if = "Option::is_none"
1170    )]
1171    pub home_currency: Option<Currency>,
1172}
1173
1174provider_enum! {
1175    /// The way that position values for an Account are calculated and aggregated.
1176    #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1177    #[non_exhaustive]
1178    pub enum PositionAggregationMode {
1179        /// The Position value or margin for each side (long and short) of the Position are computed independently
1180        /// and added together.
1181        AbsoluteSum => "ABSOLUTE_SUM",
1182        /// The Position value or margin for each side (long and short) of the Position are computed independently.
1183        /// The Position value or margin chosen is the maximal absolute value of the two.
1184        MaximalSide => "MAXIMAL_SIDE",
1185        /// The units for each side (long and short) of the Position are netted together and the resulting value
1186        /// (long or short) is used to compute the Position value or margin.
1187        NetSum => "NET_SUM",
1188        ;
1189        /// An unrecognized provider value, preserved for forward compatibility.
1190        Unknown(String),
1191    }
1192}