Skip to main content

binance_sdk/margin_trading/rest_api/apis/
trade_api.rs

1/*
2 * Margin REST API
3 *
4 * Access account information, borrow and repay assets, and trade with Binance Margin.
5 *
6 * The version of the OpenAPI document: 1.0.0
7 *
8 *
9 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10 * https://openapi-generator.tech
11 * Do not edit the class manually.
12 */
13
14#![allow(unused_imports)]
15use async_trait::async_trait;
16use derive_builder::Builder;
17use reqwest;
18use rust_decimal::prelude::*;
19use serde::{Deserialize, Serialize};
20use serde_json::{Value, json};
21use std::collections::BTreeMap;
22
23use crate::common::{
24    config::ConfigurationRestApi,
25    models::{ParamBuildError, RestApiResponse},
26    utils::send_request,
27};
28use crate::margin_trading::rest_api::models;
29
30const HAS_TIME_UNIT: bool = false;
31
32#[async_trait]
33pub trait TradeApi: Send + Sync {
34    async fn create_special_key(
35        &self,
36        params: CreateSpecialKeyParams,
37    ) -> anyhow::Result<RestApiResponse<models::CreateSpecialKeyResponse>>;
38    async fn delete_special_key(
39        &self,
40        params: DeleteSpecialKeyParams,
41    ) -> anyhow::Result<RestApiResponse<Value>>;
42    async fn edit_ip_for_special_key(
43        &self,
44        params: EditIpForSpecialKeyParams,
45    ) -> anyhow::Result<RestApiResponse<Value>>;
46    async fn exit_special_key_mode(
47        &self,
48        params: ExitSpecialKeyModeParams,
49    ) -> anyhow::Result<RestApiResponse<serde_json::Value>>;
50    async fn get_force_liquidation_record(
51        &self,
52        params: GetForceLiquidationRecordParams,
53    ) -> anyhow::Result<RestApiResponse<models::GetForceLiquidationRecordResponse>>;
54    async fn get_small_liability_exchange_coin_list(
55        &self,
56        params: GetSmallLiabilityExchangeCoinListParams,
57    ) -> anyhow::Result<RestApiResponse<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>>;
58    async fn get_small_liability_exchange_history(
59        &self,
60        params: GetSmallLiabilityExchangeHistoryParams,
61    ) -> anyhow::Result<RestApiResponse<models::GetSmallLiabilityExchangeHistoryResponse>>;
62    async fn liquidation_loan_repay(
63        &self,
64        params: LiquidationLoanRepayParams,
65    ) -> anyhow::Result<RestApiResponse<models::LiquidationLoanRepayResponse>>;
66    async fn margin_account_cancel_all_open_orders_on_a_symbol(
67        &self,
68        params: MarginAccountCancelAllOpenOrdersOnASymbolParams,
69    ) -> anyhow::Result<
70        RestApiResponse<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>,
71    >;
72    async fn margin_account_cancel_oco(
73        &self,
74        params: MarginAccountCancelOcoParams,
75    ) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOcoResponse>>;
76    async fn margin_account_cancel_order(
77        &self,
78        params: MarginAccountCancelOrderParams,
79    ) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOrderResponse>>;
80    async fn margin_account_new_oco(
81        &self,
82        params: MarginAccountNewOcoParams,
83    ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOcoResponse>>;
84    async fn margin_account_new_order(
85        &self,
86        params: MarginAccountNewOrderParams,
87    ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOrderResponse>>;
88    async fn margin_account_new_oto(
89        &self,
90        params: MarginAccountNewOtoParams,
91    ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtoResponse>>;
92    async fn margin_account_new_otoco(
93        &self,
94        params: MarginAccountNewOtocoParams,
95    ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtocoResponse>>;
96    async fn margin_manual_liquidation(
97        &self,
98        params: MarginManualLiquidationParams,
99    ) -> anyhow::Result<RestApiResponse<models::MarginManualLiquidationResponse>>;
100    async fn query_current_margin_order_count_usage(
101        &self,
102        params: QueryCurrentMarginOrderCountUsageParams,
103    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>>;
104    async fn query_liquidation_loan(
105        &self,
106        params: QueryLiquidationLoanParams,
107    ) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanResponse>>;
108    async fn query_liquidation_loan_repay_history(
109        &self,
110        params: QueryLiquidationLoanRepayHistoryParams,
111    ) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanRepayHistoryResponse>>;
112    async fn query_margin_accounts_all_oco(
113        &self,
114        params: QueryMarginAccountsAllOcoParams,
115    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>>;
116    async fn query_margin_accounts_all_orders(
117        &self,
118        params: QueryMarginAccountsAllOrdersParams,
119    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>>;
120    async fn query_margin_accounts_oco(
121        &self,
122        params: QueryMarginAccountsOcoParams,
123    ) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOcoResponse>>;
124    async fn query_margin_accounts_open_oco(
125        &self,
126        params: QueryMarginAccountsOpenOcoParams,
127    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>>;
128    async fn query_margin_accounts_open_orders(
129        &self,
130        params: QueryMarginAccountsOpenOrdersParams,
131    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>>;
132    async fn query_margin_accounts_order(
133        &self,
134        params: QueryMarginAccountsOrderParams,
135    ) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOrderResponse>>;
136    async fn query_margin_accounts_trade_list(
137        &self,
138        params: QueryMarginAccountsTradeListParams,
139    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsTradeListResponseInner>>>;
140    async fn query_prevented_matches(
141        &self,
142        params: QueryPreventedMatchesParams,
143    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryPreventedMatchesResponseInner>>>;
144    async fn query_special_key(
145        &self,
146        params: QuerySpecialKeyParams,
147    ) -> anyhow::Result<RestApiResponse<models::QuerySpecialKeyResponse>>;
148    async fn query_special_key_list(
149        &self,
150        params: QuerySpecialKeyListParams,
151    ) -> anyhow::Result<RestApiResponse<Vec<models::QuerySpecialKeyListResponseInner>>>;
152    async fn small_liability_exchange(
153        &self,
154        params: SmallLiabilityExchangeParams,
155    ) -> anyhow::Result<RestApiResponse<Value>>;
156}
157
158#[derive(Debug, Clone)]
159pub struct TradeApiClient {
160    configuration: ConfigurationRestApi,
161}
162
163impl TradeApiClient {
164    pub fn new(configuration: ConfigurationRestApi) -> Self {
165        Self { configuration }
166    }
167}
168
169#[allow(non_camel_case_types)]
170#[derive(Debug, Clone, Serialize, Deserialize)]
171pub enum CreateSpecialKeyPermissionModeEnum {
172    #[serde(rename = "TRADE")]
173    Trade,
174    #[serde(rename = "READ")]
175    Read,
176}
177
178impl CreateSpecialKeyPermissionModeEnum {
179    #[must_use]
180    pub fn as_str(&self) -> &'static str {
181        match self {
182            Self::Trade => "TRADE",
183            Self::Read => "READ",
184        }
185    }
186}
187
188impl std::str::FromStr for CreateSpecialKeyPermissionModeEnum {
189    type Err = Box<dyn std::error::Error + Send + Sync>;
190
191    fn from_str(s: &str) -> Result<Self, Self::Err> {
192        match s {
193            "TRADE" => Ok(Self::Trade),
194            "READ" => Ok(Self::Read),
195            other => Err(format!("invalid CreateSpecialKeyPermissionModeEnum: {}", other).into()),
196        }
197    }
198}
199
200#[allow(non_camel_case_types)]
201#[derive(Debug, Clone, Serialize, Deserialize)]
202pub enum MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum {
203    #[serde(rename = "TRUE")]
204    True,
205    #[serde(rename = "FALSE")]
206    False,
207}
208
209impl MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum {
210    #[must_use]
211    pub fn as_str(&self) -> &'static str {
212        match self {
213            Self::True => "TRUE",
214            Self::False => "FALSE",
215        }
216    }
217}
218
219impl std::str::FromStr for MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum {
220    type Err = Box<dyn std::error::Error + Send + Sync>;
221
222    fn from_str(s: &str) -> Result<Self, Self::Err> {
223        match s {
224            "TRUE" => Ok(Self::True),
225            "FALSE" => Ok(Self::False),
226            other => Err(format!(
227                "invalid MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum: {}",
228                other
229            )
230            .into()),
231        }
232    }
233}
234
235#[allow(non_camel_case_types)]
236#[derive(Debug, Clone, Serialize, Deserialize)]
237pub enum MarginAccountCancelOcoIsIsolatedEnum {
238    #[serde(rename = "TRUE")]
239    True,
240    #[serde(rename = "FALSE")]
241    False,
242}
243
244impl MarginAccountCancelOcoIsIsolatedEnum {
245    #[must_use]
246    pub fn as_str(&self) -> &'static str {
247        match self {
248            Self::True => "TRUE",
249            Self::False => "FALSE",
250        }
251    }
252}
253
254impl std::str::FromStr for MarginAccountCancelOcoIsIsolatedEnum {
255    type Err = Box<dyn std::error::Error + Send + Sync>;
256
257    fn from_str(s: &str) -> Result<Self, Self::Err> {
258        match s {
259            "TRUE" => Ok(Self::True),
260            "FALSE" => Ok(Self::False),
261            other => Err(format!("invalid MarginAccountCancelOcoIsIsolatedEnum: {}", other).into()),
262        }
263    }
264}
265
266#[allow(non_camel_case_types)]
267#[derive(Debug, Clone, Serialize, Deserialize)]
268pub enum MarginAccountCancelOrderIsIsolatedEnum {
269    #[serde(rename = "TRUE")]
270    True,
271    #[serde(rename = "FALSE")]
272    False,
273}
274
275impl MarginAccountCancelOrderIsIsolatedEnum {
276    #[must_use]
277    pub fn as_str(&self) -> &'static str {
278        match self {
279            Self::True => "TRUE",
280            Self::False => "FALSE",
281        }
282    }
283}
284
285impl std::str::FromStr for MarginAccountCancelOrderIsIsolatedEnum {
286    type Err = Box<dyn std::error::Error + Send + Sync>;
287
288    fn from_str(s: &str) -> Result<Self, Self::Err> {
289        match s {
290            "TRUE" => Ok(Self::True),
291            "FALSE" => Ok(Self::False),
292            other => {
293                Err(format!("invalid MarginAccountCancelOrderIsIsolatedEnum: {}", other).into())
294            }
295        }
296    }
297}
298
299#[allow(non_camel_case_types)]
300#[derive(Debug, Clone, Serialize, Deserialize)]
301pub enum MarginAccountNewOcoSideEnum {
302    #[serde(rename = "BUY")]
303    Buy,
304    #[serde(rename = "SELL")]
305    Sell,
306}
307
308impl MarginAccountNewOcoSideEnum {
309    #[must_use]
310    pub fn as_str(&self) -> &'static str {
311        match self {
312            Self::Buy => "BUY",
313            Self::Sell => "SELL",
314        }
315    }
316}
317
318impl std::str::FromStr for MarginAccountNewOcoSideEnum {
319    type Err = Box<dyn std::error::Error + Send + Sync>;
320
321    fn from_str(s: &str) -> Result<Self, Self::Err> {
322        match s {
323            "BUY" => Ok(Self::Buy),
324            "SELL" => Ok(Self::Sell),
325            other => Err(format!("invalid MarginAccountNewOcoSideEnum: {}", other).into()),
326        }
327    }
328}
329
330#[allow(non_camel_case_types)]
331#[derive(Debug, Clone, Serialize, Deserialize)]
332pub enum MarginAccountNewOcoIsIsolatedEnum {
333    #[serde(rename = "TRUE")]
334    True,
335    #[serde(rename = "FALSE")]
336    False,
337}
338
339impl MarginAccountNewOcoIsIsolatedEnum {
340    #[must_use]
341    pub fn as_str(&self) -> &'static str {
342        match self {
343            Self::True => "TRUE",
344            Self::False => "FALSE",
345        }
346    }
347}
348
349impl std::str::FromStr for MarginAccountNewOcoIsIsolatedEnum {
350    type Err = Box<dyn std::error::Error + Send + Sync>;
351
352    fn from_str(s: &str) -> Result<Self, Self::Err> {
353        match s {
354            "TRUE" => Ok(Self::True),
355            "FALSE" => Ok(Self::False),
356            other => Err(format!("invalid MarginAccountNewOcoIsIsolatedEnum: {}", other).into()),
357        }
358    }
359}
360
361#[allow(non_camel_case_types)]
362#[derive(Debug, Clone, Serialize, Deserialize)]
363pub enum MarginAccountNewOcoStopLimitTimeInForceEnum {
364    #[serde(rename = "GTC")]
365    Gtc,
366    #[serde(rename = "FOK")]
367    Fok,
368    #[serde(rename = "IOC")]
369    Ioc,
370}
371
372impl MarginAccountNewOcoStopLimitTimeInForceEnum {
373    #[must_use]
374    pub fn as_str(&self) -> &'static str {
375        match self {
376            Self::Gtc => "GTC",
377            Self::Fok => "FOK",
378            Self::Ioc => "IOC",
379        }
380    }
381}
382
383impl std::str::FromStr for MarginAccountNewOcoStopLimitTimeInForceEnum {
384    type Err = Box<dyn std::error::Error + Send + Sync>;
385
386    fn from_str(s: &str) -> Result<Self, Self::Err> {
387        match s {
388            "GTC" => Ok(Self::Gtc),
389            "FOK" => Ok(Self::Fok),
390            "IOC" => Ok(Self::Ioc),
391            other => Err(format!(
392                "invalid MarginAccountNewOcoStopLimitTimeInForceEnum: {}",
393                other
394            )
395            .into()),
396        }
397    }
398}
399
400#[allow(non_camel_case_types)]
401#[derive(Debug, Clone, Serialize, Deserialize)]
402pub enum MarginAccountNewOcoNewOrderRespTypeEnum {
403    #[serde(rename = "ACK")]
404    Ack,
405    #[serde(rename = "RESULT")]
406    Result,
407    #[serde(rename = "FULL")]
408    Full,
409}
410
411impl MarginAccountNewOcoNewOrderRespTypeEnum {
412    #[must_use]
413    pub fn as_str(&self) -> &'static str {
414        match self {
415            Self::Ack => "ACK",
416            Self::Result => "RESULT",
417            Self::Full => "FULL",
418        }
419    }
420}
421
422impl std::str::FromStr for MarginAccountNewOcoNewOrderRespTypeEnum {
423    type Err = Box<dyn std::error::Error + Send + Sync>;
424
425    fn from_str(s: &str) -> Result<Self, Self::Err> {
426        match s {
427            "ACK" => Ok(Self::Ack),
428            "RESULT" => Ok(Self::Result),
429            "FULL" => Ok(Self::Full),
430            other => {
431                Err(format!("invalid MarginAccountNewOcoNewOrderRespTypeEnum: {}", other).into())
432            }
433        }
434    }
435}
436
437#[allow(non_camel_case_types)]
438#[derive(Debug, Clone, Serialize, Deserialize)]
439pub enum MarginAccountNewOcoSideEffectTypeEnum {
440    #[serde(rename = "NO_SIDE_EFFECT")]
441    NoSideEffect,
442    #[serde(rename = "MARGIN_BUY")]
443    MarginBuy,
444    #[serde(rename = "AUTO_REPAY")]
445    AutoRepay,
446    #[serde(rename = "AUTO_BORROW_REPAY")]
447    AutoBorrowRepay,
448}
449
450impl MarginAccountNewOcoSideEffectTypeEnum {
451    #[must_use]
452    pub fn as_str(&self) -> &'static str {
453        match self {
454            Self::NoSideEffect => "NO_SIDE_EFFECT",
455            Self::MarginBuy => "MARGIN_BUY",
456            Self::AutoRepay => "AUTO_REPAY",
457            Self::AutoBorrowRepay => "AUTO_BORROW_REPAY",
458        }
459    }
460}
461
462impl std::str::FromStr for MarginAccountNewOcoSideEffectTypeEnum {
463    type Err = Box<dyn std::error::Error + Send + Sync>;
464
465    fn from_str(s: &str) -> Result<Self, Self::Err> {
466        match s {
467            "NO_SIDE_EFFECT" => Ok(Self::NoSideEffect),
468            "MARGIN_BUY" => Ok(Self::MarginBuy),
469            "AUTO_REPAY" => Ok(Self::AutoRepay),
470            "AUTO_BORROW_REPAY" => Ok(Self::AutoBorrowRepay),
471            other => {
472                Err(format!("invalid MarginAccountNewOcoSideEffectTypeEnum: {}", other).into())
473            }
474        }
475    }
476}
477
478#[allow(non_camel_case_types)]
479#[derive(Debug, Clone, Serialize, Deserialize)]
480pub enum MarginAccountNewOcoSelfTradePreventionModeEnum {
481    #[serde(rename = "EXPIRE_TAKER")]
482    ExpireTaker,
483    #[serde(rename = "EXPIRE_MAKER")]
484    ExpireMaker,
485    #[serde(rename = "EXPIRE_BOTH")]
486    ExpireBoth,
487    #[serde(rename = "NONE")]
488    None,
489}
490
491impl MarginAccountNewOcoSelfTradePreventionModeEnum {
492    #[must_use]
493    pub fn as_str(&self) -> &'static str {
494        match self {
495            Self::ExpireTaker => "EXPIRE_TAKER",
496            Self::ExpireMaker => "EXPIRE_MAKER",
497            Self::ExpireBoth => "EXPIRE_BOTH",
498            Self::None => "NONE",
499        }
500    }
501}
502
503impl std::str::FromStr for MarginAccountNewOcoSelfTradePreventionModeEnum {
504    type Err = Box<dyn std::error::Error + Send + Sync>;
505
506    fn from_str(s: &str) -> Result<Self, Self::Err> {
507        match s {
508            "EXPIRE_TAKER" => Ok(Self::ExpireTaker),
509            "EXPIRE_MAKER" => Ok(Self::ExpireMaker),
510            "EXPIRE_BOTH" => Ok(Self::ExpireBoth),
511            "NONE" => Ok(Self::None),
512            other => Err(format!(
513                "invalid MarginAccountNewOcoSelfTradePreventionModeEnum: {}",
514                other
515            )
516            .into()),
517        }
518    }
519}
520
521#[allow(non_camel_case_types)]
522#[derive(Debug, Clone, Serialize, Deserialize)]
523pub enum MarginAccountNewOrderSideEnum {
524    #[serde(rename = "BUY")]
525    Buy,
526    #[serde(rename = "SELL")]
527    Sell,
528}
529
530impl MarginAccountNewOrderSideEnum {
531    #[must_use]
532    pub fn as_str(&self) -> &'static str {
533        match self {
534            Self::Buy => "BUY",
535            Self::Sell => "SELL",
536        }
537    }
538}
539
540impl std::str::FromStr for MarginAccountNewOrderSideEnum {
541    type Err = Box<dyn std::error::Error + Send + Sync>;
542
543    fn from_str(s: &str) -> Result<Self, Self::Err> {
544        match s {
545            "BUY" => Ok(Self::Buy),
546            "SELL" => Ok(Self::Sell),
547            other => Err(format!("invalid MarginAccountNewOrderSideEnum: {}", other).into()),
548        }
549    }
550}
551
552#[allow(non_camel_case_types)]
553#[derive(Debug, Clone, Serialize, Deserialize)]
554pub enum MarginAccountNewOrderTypeEnum {
555    #[serde(rename = "LIMIT")]
556    Limit,
557    #[serde(rename = "MARKET")]
558    Market,
559    #[serde(rename = "STOP_LOSS")]
560    StopLoss,
561    #[serde(rename = "STOP_LOSS_LIMIT")]
562    StopLossLimit,
563    #[serde(rename = "TAKE_PROFIT")]
564    TakeProfit,
565    #[serde(rename = "TAKE_PROFIT_LIMIT")]
566    TakeProfitLimit,
567    #[serde(rename = "LIMIT_MAKER")]
568    LimitMaker,
569}
570
571impl MarginAccountNewOrderTypeEnum {
572    #[must_use]
573    pub fn as_str(&self) -> &'static str {
574        match self {
575            Self::Limit => "LIMIT",
576            Self::Market => "MARKET",
577            Self::StopLoss => "STOP_LOSS",
578            Self::StopLossLimit => "STOP_LOSS_LIMIT",
579            Self::TakeProfit => "TAKE_PROFIT",
580            Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
581            Self::LimitMaker => "LIMIT_MAKER",
582        }
583    }
584}
585
586impl std::str::FromStr for MarginAccountNewOrderTypeEnum {
587    type Err = Box<dyn std::error::Error + Send + Sync>;
588
589    fn from_str(s: &str) -> Result<Self, Self::Err> {
590        match s {
591            "LIMIT" => Ok(Self::Limit),
592            "MARKET" => Ok(Self::Market),
593            "STOP_LOSS" => Ok(Self::StopLoss),
594            "STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
595            "TAKE_PROFIT" => Ok(Self::TakeProfit),
596            "TAKE_PROFIT_LIMIT" => Ok(Self::TakeProfitLimit),
597            "LIMIT_MAKER" => Ok(Self::LimitMaker),
598            other => Err(format!("invalid MarginAccountNewOrderTypeEnum: {}", other).into()),
599        }
600    }
601}
602
603#[allow(non_camel_case_types)]
604#[derive(Debug, Clone, Serialize, Deserialize)]
605pub enum MarginAccountNewOrderIsIsolatedEnum {
606    #[serde(rename = "TRUE")]
607    True,
608    #[serde(rename = "FALSE")]
609    False,
610}
611
612impl MarginAccountNewOrderIsIsolatedEnum {
613    #[must_use]
614    pub fn as_str(&self) -> &'static str {
615        match self {
616            Self::True => "TRUE",
617            Self::False => "FALSE",
618        }
619    }
620}
621
622impl std::str::FromStr for MarginAccountNewOrderIsIsolatedEnum {
623    type Err = Box<dyn std::error::Error + Send + Sync>;
624
625    fn from_str(s: &str) -> Result<Self, Self::Err> {
626        match s {
627            "TRUE" => Ok(Self::True),
628            "FALSE" => Ok(Self::False),
629            other => Err(format!("invalid MarginAccountNewOrderIsIsolatedEnum: {}", other).into()),
630        }
631    }
632}
633
634#[allow(non_camel_case_types)]
635#[derive(Debug, Clone, Serialize, Deserialize)]
636pub enum MarginAccountNewOrderNewOrderRespTypeEnum {
637    #[serde(rename = "ACK")]
638    Ack,
639    #[serde(rename = "RESULT")]
640    Result,
641    #[serde(rename = "FULL")]
642    Full,
643}
644
645impl MarginAccountNewOrderNewOrderRespTypeEnum {
646    #[must_use]
647    pub fn as_str(&self) -> &'static str {
648        match self {
649            Self::Ack => "ACK",
650            Self::Result => "RESULT",
651            Self::Full => "FULL",
652        }
653    }
654}
655
656impl std::str::FromStr for MarginAccountNewOrderNewOrderRespTypeEnum {
657    type Err = Box<dyn std::error::Error + Send + Sync>;
658
659    fn from_str(s: &str) -> Result<Self, Self::Err> {
660        match s {
661            "ACK" => Ok(Self::Ack),
662            "RESULT" => Ok(Self::Result),
663            "FULL" => Ok(Self::Full),
664            other => Err(format!(
665                "invalid MarginAccountNewOrderNewOrderRespTypeEnum: {}",
666                other
667            )
668            .into()),
669        }
670    }
671}
672
673#[allow(non_camel_case_types)]
674#[derive(Debug, Clone, Serialize, Deserialize)]
675pub enum MarginAccountNewOrderSideEffectTypeEnum {
676    #[serde(rename = "NO_SIDE_EFFECT")]
677    NoSideEffect,
678    #[serde(rename = "MARGIN_BUY")]
679    MarginBuy,
680    #[serde(rename = "AUTO_REPAY")]
681    AutoRepay,
682    #[serde(rename = "AUTO_BORROW_REPAY")]
683    AutoBorrowRepay,
684}
685
686impl MarginAccountNewOrderSideEffectTypeEnum {
687    #[must_use]
688    pub fn as_str(&self) -> &'static str {
689        match self {
690            Self::NoSideEffect => "NO_SIDE_EFFECT",
691            Self::MarginBuy => "MARGIN_BUY",
692            Self::AutoRepay => "AUTO_REPAY",
693            Self::AutoBorrowRepay => "AUTO_BORROW_REPAY",
694        }
695    }
696}
697
698impl std::str::FromStr for MarginAccountNewOrderSideEffectTypeEnum {
699    type Err = Box<dyn std::error::Error + Send + Sync>;
700
701    fn from_str(s: &str) -> Result<Self, Self::Err> {
702        match s {
703            "NO_SIDE_EFFECT" => Ok(Self::NoSideEffect),
704            "MARGIN_BUY" => Ok(Self::MarginBuy),
705            "AUTO_REPAY" => Ok(Self::AutoRepay),
706            "AUTO_BORROW_REPAY" => Ok(Self::AutoBorrowRepay),
707            other => {
708                Err(format!("invalid MarginAccountNewOrderSideEffectTypeEnum: {}", other).into())
709            }
710        }
711    }
712}
713
714#[allow(non_camel_case_types)]
715#[derive(Debug, Clone, Serialize, Deserialize)]
716pub enum MarginAccountNewOrderTimeInForceEnum {
717    #[serde(rename = "GTC")]
718    Gtc,
719    #[serde(rename = "IOC")]
720    Ioc,
721    #[serde(rename = "FOK")]
722    Fok,
723}
724
725impl MarginAccountNewOrderTimeInForceEnum {
726    #[must_use]
727    pub fn as_str(&self) -> &'static str {
728        match self {
729            Self::Gtc => "GTC",
730            Self::Ioc => "IOC",
731            Self::Fok => "FOK",
732        }
733    }
734}
735
736impl std::str::FromStr for MarginAccountNewOrderTimeInForceEnum {
737    type Err = Box<dyn std::error::Error + Send + Sync>;
738
739    fn from_str(s: &str) -> Result<Self, Self::Err> {
740        match s {
741            "GTC" => Ok(Self::Gtc),
742            "IOC" => Ok(Self::Ioc),
743            "FOK" => Ok(Self::Fok),
744            other => Err(format!("invalid MarginAccountNewOrderTimeInForceEnum: {}", other).into()),
745        }
746    }
747}
748
749#[allow(non_camel_case_types)]
750#[derive(Debug, Clone, Serialize, Deserialize)]
751pub enum MarginAccountNewOrderSelfTradePreventionModeEnum {
752    #[serde(rename = "EXPIRE_TAKER")]
753    ExpireTaker,
754    #[serde(rename = "EXPIRE_MAKER")]
755    ExpireMaker,
756    #[serde(rename = "EXPIRE_BOTH")]
757    ExpireBoth,
758    #[serde(rename = "NONE")]
759    None,
760}
761
762impl MarginAccountNewOrderSelfTradePreventionModeEnum {
763    #[must_use]
764    pub fn as_str(&self) -> &'static str {
765        match self {
766            Self::ExpireTaker => "EXPIRE_TAKER",
767            Self::ExpireMaker => "EXPIRE_MAKER",
768            Self::ExpireBoth => "EXPIRE_BOTH",
769            Self::None => "NONE",
770        }
771    }
772}
773
774impl std::str::FromStr for MarginAccountNewOrderSelfTradePreventionModeEnum {
775    type Err = Box<dyn std::error::Error + Send + Sync>;
776
777    fn from_str(s: &str) -> Result<Self, Self::Err> {
778        match s {
779            "EXPIRE_TAKER" => Ok(Self::ExpireTaker),
780            "EXPIRE_MAKER" => Ok(Self::ExpireMaker),
781            "EXPIRE_BOTH" => Ok(Self::ExpireBoth),
782            "NONE" => Ok(Self::None),
783            other => Err(format!(
784                "invalid MarginAccountNewOrderSelfTradePreventionModeEnum: {}",
785                other
786            )
787            .into()),
788        }
789    }
790}
791
792#[allow(non_camel_case_types)]
793#[derive(Debug, Clone, Serialize, Deserialize)]
794pub enum MarginAccountNewOtoWorkingTypeEnum {
795    #[serde(rename = "LIMIT")]
796    Limit,
797    #[serde(rename = "LIMIT_MAKER")]
798    LimitMaker,
799}
800
801impl MarginAccountNewOtoWorkingTypeEnum {
802    #[must_use]
803    pub fn as_str(&self) -> &'static str {
804        match self {
805            Self::Limit => "LIMIT",
806            Self::LimitMaker => "LIMIT_MAKER",
807        }
808    }
809}
810
811impl std::str::FromStr for MarginAccountNewOtoWorkingTypeEnum {
812    type Err = Box<dyn std::error::Error + Send + Sync>;
813
814    fn from_str(s: &str) -> Result<Self, Self::Err> {
815        match s {
816            "LIMIT" => Ok(Self::Limit),
817            "LIMIT_MAKER" => Ok(Self::LimitMaker),
818            other => Err(format!("invalid MarginAccountNewOtoWorkingTypeEnum: {}", other).into()),
819        }
820    }
821}
822
823#[allow(non_camel_case_types)]
824#[derive(Debug, Clone, Serialize, Deserialize)]
825pub enum MarginAccountNewOtoWorkingSideEnum {
826    #[serde(rename = "BUY")]
827    Buy,
828    #[serde(rename = "SELL")]
829    Sell,
830}
831
832impl MarginAccountNewOtoWorkingSideEnum {
833    #[must_use]
834    pub fn as_str(&self) -> &'static str {
835        match self {
836            Self::Buy => "BUY",
837            Self::Sell => "SELL",
838        }
839    }
840}
841
842impl std::str::FromStr for MarginAccountNewOtoWorkingSideEnum {
843    type Err = Box<dyn std::error::Error + Send + Sync>;
844
845    fn from_str(s: &str) -> Result<Self, Self::Err> {
846        match s {
847            "BUY" => Ok(Self::Buy),
848            "SELL" => Ok(Self::Sell),
849            other => Err(format!("invalid MarginAccountNewOtoWorkingSideEnum: {}", other).into()),
850        }
851    }
852}
853
854#[allow(non_camel_case_types)]
855#[derive(Debug, Clone, Serialize, Deserialize)]
856pub enum MarginAccountNewOtoPendingTypeEnum {
857    #[serde(rename = "LIMIT")]
858    Limit,
859    #[serde(rename = "MARKET")]
860    Market,
861    #[serde(rename = "STOP_LOSS")]
862    StopLoss,
863    #[serde(rename = "STOP_LOSS_LIMIT")]
864    StopLossLimit,
865    #[serde(rename = "TAKE_PROFIT")]
866    TakeProfit,
867    #[serde(rename = "TAKE_PROFIT_LIMIT")]
868    TakeProfitLimit,
869    #[serde(rename = "LIMIT_MAKER")]
870    LimitMaker,
871}
872
873impl MarginAccountNewOtoPendingTypeEnum {
874    #[must_use]
875    pub fn as_str(&self) -> &'static str {
876        match self {
877            Self::Limit => "LIMIT",
878            Self::Market => "MARKET",
879            Self::StopLoss => "STOP_LOSS",
880            Self::StopLossLimit => "STOP_LOSS_LIMIT",
881            Self::TakeProfit => "TAKE_PROFIT",
882            Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
883            Self::LimitMaker => "LIMIT_MAKER",
884        }
885    }
886}
887
888impl std::str::FromStr for MarginAccountNewOtoPendingTypeEnum {
889    type Err = Box<dyn std::error::Error + Send + Sync>;
890
891    fn from_str(s: &str) -> Result<Self, Self::Err> {
892        match s {
893            "LIMIT" => Ok(Self::Limit),
894            "MARKET" => Ok(Self::Market),
895            "STOP_LOSS" => Ok(Self::StopLoss),
896            "STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
897            "TAKE_PROFIT" => Ok(Self::TakeProfit),
898            "TAKE_PROFIT_LIMIT" => Ok(Self::TakeProfitLimit),
899            "LIMIT_MAKER" => Ok(Self::LimitMaker),
900            other => Err(format!("invalid MarginAccountNewOtoPendingTypeEnum: {}", other).into()),
901        }
902    }
903}
904
905#[allow(non_camel_case_types)]
906#[derive(Debug, Clone, Serialize, Deserialize)]
907pub enum MarginAccountNewOtoPendingSideEnum {
908    #[serde(rename = "BUY")]
909    Buy,
910    #[serde(rename = "SELL")]
911    Sell,
912}
913
914impl MarginAccountNewOtoPendingSideEnum {
915    #[must_use]
916    pub fn as_str(&self) -> &'static str {
917        match self {
918            Self::Buy => "BUY",
919            Self::Sell => "SELL",
920        }
921    }
922}
923
924impl std::str::FromStr for MarginAccountNewOtoPendingSideEnum {
925    type Err = Box<dyn std::error::Error + Send + Sync>;
926
927    fn from_str(s: &str) -> Result<Self, Self::Err> {
928        match s {
929            "BUY" => Ok(Self::Buy),
930            "SELL" => Ok(Self::Sell),
931            other => Err(format!("invalid MarginAccountNewOtoPendingSideEnum: {}", other).into()),
932        }
933    }
934}
935
936#[allow(non_camel_case_types)]
937#[derive(Debug, Clone, Serialize, Deserialize)]
938pub enum MarginAccountNewOtoIsIsolatedEnum {
939    #[serde(rename = "TRUE")]
940    True,
941    #[serde(rename = "FALSE")]
942    False,
943}
944
945impl MarginAccountNewOtoIsIsolatedEnum {
946    #[must_use]
947    pub fn as_str(&self) -> &'static str {
948        match self {
949            Self::True => "TRUE",
950            Self::False => "FALSE",
951        }
952    }
953}
954
955impl std::str::FromStr for MarginAccountNewOtoIsIsolatedEnum {
956    type Err = Box<dyn std::error::Error + Send + Sync>;
957
958    fn from_str(s: &str) -> Result<Self, Self::Err> {
959        match s {
960            "TRUE" => Ok(Self::True),
961            "FALSE" => Ok(Self::False),
962            other => Err(format!("invalid MarginAccountNewOtoIsIsolatedEnum: {}", other).into()),
963        }
964    }
965}
966
967#[allow(non_camel_case_types)]
968#[derive(Debug, Clone, Serialize, Deserialize)]
969pub enum MarginAccountNewOtoNewOrderRespTypeEnum {
970    #[serde(rename = "ACK")]
971    Ack,
972    #[serde(rename = "RESULT")]
973    Result,
974    #[serde(rename = "FULL")]
975    Full,
976}
977
978impl MarginAccountNewOtoNewOrderRespTypeEnum {
979    #[must_use]
980    pub fn as_str(&self) -> &'static str {
981        match self {
982            Self::Ack => "ACK",
983            Self::Result => "RESULT",
984            Self::Full => "FULL",
985        }
986    }
987}
988
989impl std::str::FromStr for MarginAccountNewOtoNewOrderRespTypeEnum {
990    type Err = Box<dyn std::error::Error + Send + Sync>;
991
992    fn from_str(s: &str) -> Result<Self, Self::Err> {
993        match s {
994            "ACK" => Ok(Self::Ack),
995            "RESULT" => Ok(Self::Result),
996            "FULL" => Ok(Self::Full),
997            other => {
998                Err(format!("invalid MarginAccountNewOtoNewOrderRespTypeEnum: {}", other).into())
999            }
1000        }
1001    }
1002}
1003
1004#[allow(non_camel_case_types)]
1005#[derive(Debug, Clone, Serialize, Deserialize)]
1006pub enum MarginAccountNewOtoSideEffectTypeEnum {
1007    #[serde(rename = "NO_SIDE_EFFECT")]
1008    NoSideEffect,
1009    #[serde(rename = "MARGIN_BUY")]
1010    MarginBuy,
1011    #[serde(rename = "AUTO_BORROW_REPAY")]
1012    AutoBorrowRepay,
1013}
1014
1015impl MarginAccountNewOtoSideEffectTypeEnum {
1016    #[must_use]
1017    pub fn as_str(&self) -> &'static str {
1018        match self {
1019            Self::NoSideEffect => "NO_SIDE_EFFECT",
1020            Self::MarginBuy => "MARGIN_BUY",
1021            Self::AutoBorrowRepay => "AUTO_BORROW_REPAY",
1022        }
1023    }
1024}
1025
1026impl std::str::FromStr for MarginAccountNewOtoSideEffectTypeEnum {
1027    type Err = Box<dyn std::error::Error + Send + Sync>;
1028
1029    fn from_str(s: &str) -> Result<Self, Self::Err> {
1030        match s {
1031            "NO_SIDE_EFFECT" => Ok(Self::NoSideEffect),
1032            "MARGIN_BUY" => Ok(Self::MarginBuy),
1033            "AUTO_BORROW_REPAY" => Ok(Self::AutoBorrowRepay),
1034            other => {
1035                Err(format!("invalid MarginAccountNewOtoSideEffectTypeEnum: {}", other).into())
1036            }
1037        }
1038    }
1039}
1040
1041#[allow(non_camel_case_types)]
1042#[derive(Debug, Clone, Serialize, Deserialize)]
1043pub enum MarginAccountNewOtoSelfTradePreventionModeEnum {
1044    #[serde(rename = "EXPIRE_TAKER")]
1045    ExpireTaker,
1046    #[serde(rename = "EXPIRE_MAKER")]
1047    ExpireMaker,
1048    #[serde(rename = "EXPIRE_BOTH")]
1049    ExpireBoth,
1050    #[serde(rename = "NONE")]
1051    None,
1052}
1053
1054impl MarginAccountNewOtoSelfTradePreventionModeEnum {
1055    #[must_use]
1056    pub fn as_str(&self) -> &'static str {
1057        match self {
1058            Self::ExpireTaker => "EXPIRE_TAKER",
1059            Self::ExpireMaker => "EXPIRE_MAKER",
1060            Self::ExpireBoth => "EXPIRE_BOTH",
1061            Self::None => "NONE",
1062        }
1063    }
1064}
1065
1066impl std::str::FromStr for MarginAccountNewOtoSelfTradePreventionModeEnum {
1067    type Err = Box<dyn std::error::Error + Send + Sync>;
1068
1069    fn from_str(s: &str) -> Result<Self, Self::Err> {
1070        match s {
1071            "EXPIRE_TAKER" => Ok(Self::ExpireTaker),
1072            "EXPIRE_MAKER" => Ok(Self::ExpireMaker),
1073            "EXPIRE_BOTH" => Ok(Self::ExpireBoth),
1074            "NONE" => Ok(Self::None),
1075            other => Err(format!(
1076                "invalid MarginAccountNewOtoSelfTradePreventionModeEnum: {}",
1077                other
1078            )
1079            .into()),
1080        }
1081    }
1082}
1083
1084#[allow(non_camel_case_types)]
1085#[derive(Debug, Clone, Serialize, Deserialize)]
1086pub enum MarginAccountNewOtoWorkingTimeInForceEnum {
1087    #[serde(rename = "GTC")]
1088    Gtc,
1089    #[serde(rename = "IOC")]
1090    Ioc,
1091    #[serde(rename = "FOK")]
1092    Fok,
1093}
1094
1095impl MarginAccountNewOtoWorkingTimeInForceEnum {
1096    #[must_use]
1097    pub fn as_str(&self) -> &'static str {
1098        match self {
1099            Self::Gtc => "GTC",
1100            Self::Ioc => "IOC",
1101            Self::Fok => "FOK",
1102        }
1103    }
1104}
1105
1106impl std::str::FromStr for MarginAccountNewOtoWorkingTimeInForceEnum {
1107    type Err = Box<dyn std::error::Error + Send + Sync>;
1108
1109    fn from_str(s: &str) -> Result<Self, Self::Err> {
1110        match s {
1111            "GTC" => Ok(Self::Gtc),
1112            "IOC" => Ok(Self::Ioc),
1113            "FOK" => Ok(Self::Fok),
1114            other => Err(format!(
1115                "invalid MarginAccountNewOtoWorkingTimeInForceEnum: {}",
1116                other
1117            )
1118            .into()),
1119        }
1120    }
1121}
1122
1123#[allow(non_camel_case_types)]
1124#[derive(Debug, Clone, Serialize, Deserialize)]
1125pub enum MarginAccountNewOtoPendingTimeInForceEnum {
1126    #[serde(rename = "GTC")]
1127    Gtc,
1128    #[serde(rename = "IOC")]
1129    Ioc,
1130    #[serde(rename = "FOK")]
1131    Fok,
1132}
1133
1134impl MarginAccountNewOtoPendingTimeInForceEnum {
1135    #[must_use]
1136    pub fn as_str(&self) -> &'static str {
1137        match self {
1138            Self::Gtc => "GTC",
1139            Self::Ioc => "IOC",
1140            Self::Fok => "FOK",
1141        }
1142    }
1143}
1144
1145impl std::str::FromStr for MarginAccountNewOtoPendingTimeInForceEnum {
1146    type Err = Box<dyn std::error::Error + Send + Sync>;
1147
1148    fn from_str(s: &str) -> Result<Self, Self::Err> {
1149        match s {
1150            "GTC" => Ok(Self::Gtc),
1151            "IOC" => Ok(Self::Ioc),
1152            "FOK" => Ok(Self::Fok),
1153            other => Err(format!(
1154                "invalid MarginAccountNewOtoPendingTimeInForceEnum: {}",
1155                other
1156            )
1157            .into()),
1158        }
1159    }
1160}
1161
1162#[allow(non_camel_case_types)]
1163#[derive(Debug, Clone, Serialize, Deserialize)]
1164pub enum MarginAccountNewOtocoWorkingTypeEnum {
1165    #[serde(rename = "LIMIT")]
1166    Limit,
1167    #[serde(rename = "LIMIT_MAKER")]
1168    LimitMaker,
1169}
1170
1171impl MarginAccountNewOtocoWorkingTypeEnum {
1172    #[must_use]
1173    pub fn as_str(&self) -> &'static str {
1174        match self {
1175            Self::Limit => "LIMIT",
1176            Self::LimitMaker => "LIMIT_MAKER",
1177        }
1178    }
1179}
1180
1181impl std::str::FromStr for MarginAccountNewOtocoWorkingTypeEnum {
1182    type Err = Box<dyn std::error::Error + Send + Sync>;
1183
1184    fn from_str(s: &str) -> Result<Self, Self::Err> {
1185        match s {
1186            "LIMIT" => Ok(Self::Limit),
1187            "LIMIT_MAKER" => Ok(Self::LimitMaker),
1188            other => Err(format!("invalid MarginAccountNewOtocoWorkingTypeEnum: {}", other).into()),
1189        }
1190    }
1191}
1192
1193#[allow(non_camel_case_types)]
1194#[derive(Debug, Clone, Serialize, Deserialize)]
1195pub enum MarginAccountNewOtocoWorkingSideEnum {
1196    #[serde(rename = "BUY")]
1197    Buy,
1198    #[serde(rename = "SELL")]
1199    Sell,
1200}
1201
1202impl MarginAccountNewOtocoWorkingSideEnum {
1203    #[must_use]
1204    pub fn as_str(&self) -> &'static str {
1205        match self {
1206            Self::Buy => "BUY",
1207            Self::Sell => "SELL",
1208        }
1209    }
1210}
1211
1212impl std::str::FromStr for MarginAccountNewOtocoWorkingSideEnum {
1213    type Err = Box<dyn std::error::Error + Send + Sync>;
1214
1215    fn from_str(s: &str) -> Result<Self, Self::Err> {
1216        match s {
1217            "BUY" => Ok(Self::Buy),
1218            "SELL" => Ok(Self::Sell),
1219            other => Err(format!("invalid MarginAccountNewOtocoWorkingSideEnum: {}", other).into()),
1220        }
1221    }
1222}
1223
1224#[allow(non_camel_case_types)]
1225#[derive(Debug, Clone, Serialize, Deserialize)]
1226pub enum MarginAccountNewOtocoPendingSideEnum {
1227    #[serde(rename = "BUY")]
1228    Buy,
1229    #[serde(rename = "SELL")]
1230    Sell,
1231}
1232
1233impl MarginAccountNewOtocoPendingSideEnum {
1234    #[must_use]
1235    pub fn as_str(&self) -> &'static str {
1236        match self {
1237            Self::Buy => "BUY",
1238            Self::Sell => "SELL",
1239        }
1240    }
1241}
1242
1243impl std::str::FromStr for MarginAccountNewOtocoPendingSideEnum {
1244    type Err = Box<dyn std::error::Error + Send + Sync>;
1245
1246    fn from_str(s: &str) -> Result<Self, Self::Err> {
1247        match s {
1248            "BUY" => Ok(Self::Buy),
1249            "SELL" => Ok(Self::Sell),
1250            other => Err(format!("invalid MarginAccountNewOtocoPendingSideEnum: {}", other).into()),
1251        }
1252    }
1253}
1254
1255#[allow(non_camel_case_types)]
1256#[derive(Debug, Clone, Serialize, Deserialize)]
1257pub enum MarginAccountNewOtocoPendingAboveTypeEnum {
1258    #[serde(rename = "LIMIT_MAKER")]
1259    LimitMaker,
1260    #[serde(rename = "STOP_LOSS")]
1261    StopLoss,
1262    #[serde(rename = "STOP_LOSS_LIMIT")]
1263    StopLossLimit,
1264}
1265
1266impl MarginAccountNewOtocoPendingAboveTypeEnum {
1267    #[must_use]
1268    pub fn as_str(&self) -> &'static str {
1269        match self {
1270            Self::LimitMaker => "LIMIT_MAKER",
1271            Self::StopLoss => "STOP_LOSS",
1272            Self::StopLossLimit => "STOP_LOSS_LIMIT",
1273        }
1274    }
1275}
1276
1277impl std::str::FromStr for MarginAccountNewOtocoPendingAboveTypeEnum {
1278    type Err = Box<dyn std::error::Error + Send + Sync>;
1279
1280    fn from_str(s: &str) -> Result<Self, Self::Err> {
1281        match s {
1282            "LIMIT_MAKER" => Ok(Self::LimitMaker),
1283            "STOP_LOSS" => Ok(Self::StopLoss),
1284            "STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
1285            other => Err(format!(
1286                "invalid MarginAccountNewOtocoPendingAboveTypeEnum: {}",
1287                other
1288            )
1289            .into()),
1290        }
1291    }
1292}
1293
1294#[allow(non_camel_case_types)]
1295#[derive(Debug, Clone, Serialize, Deserialize)]
1296pub enum MarginAccountNewOtocoIsIsolatedEnum {
1297    #[serde(rename = "TRUE")]
1298    True,
1299    #[serde(rename = "FALSE")]
1300    False,
1301}
1302
1303impl MarginAccountNewOtocoIsIsolatedEnum {
1304    #[must_use]
1305    pub fn as_str(&self) -> &'static str {
1306        match self {
1307            Self::True => "TRUE",
1308            Self::False => "FALSE",
1309        }
1310    }
1311}
1312
1313impl std::str::FromStr for MarginAccountNewOtocoIsIsolatedEnum {
1314    type Err = Box<dyn std::error::Error + Send + Sync>;
1315
1316    fn from_str(s: &str) -> Result<Self, Self::Err> {
1317        match s {
1318            "TRUE" => Ok(Self::True),
1319            "FALSE" => Ok(Self::False),
1320            other => Err(format!("invalid MarginAccountNewOtocoIsIsolatedEnum: {}", other).into()),
1321        }
1322    }
1323}
1324
1325#[allow(non_camel_case_types)]
1326#[derive(Debug, Clone, Serialize, Deserialize)]
1327pub enum MarginAccountNewOtocoSideEffectTypeEnum {
1328    #[serde(rename = "NO_SIDE_EFFECT")]
1329    NoSideEffect,
1330    #[serde(rename = "MARGIN_BUY")]
1331    MarginBuy,
1332    #[serde(rename = "AUTO_BORROW_REPAY")]
1333    AutoBorrowRepay,
1334}
1335
1336impl MarginAccountNewOtocoSideEffectTypeEnum {
1337    #[must_use]
1338    pub fn as_str(&self) -> &'static str {
1339        match self {
1340            Self::NoSideEffect => "NO_SIDE_EFFECT",
1341            Self::MarginBuy => "MARGIN_BUY",
1342            Self::AutoBorrowRepay => "AUTO_BORROW_REPAY",
1343        }
1344    }
1345}
1346
1347impl std::str::FromStr for MarginAccountNewOtocoSideEffectTypeEnum {
1348    type Err = Box<dyn std::error::Error + Send + Sync>;
1349
1350    fn from_str(s: &str) -> Result<Self, Self::Err> {
1351        match s {
1352            "NO_SIDE_EFFECT" => Ok(Self::NoSideEffect),
1353            "MARGIN_BUY" => Ok(Self::MarginBuy),
1354            "AUTO_BORROW_REPAY" => Ok(Self::AutoBorrowRepay),
1355            other => {
1356                Err(format!("invalid MarginAccountNewOtocoSideEffectTypeEnum: {}", other).into())
1357            }
1358        }
1359    }
1360}
1361
1362#[allow(non_camel_case_types)]
1363#[derive(Debug, Clone, Serialize, Deserialize)]
1364pub enum MarginAccountNewOtocoNewOrderRespTypeEnum {
1365    #[serde(rename = "ACK")]
1366    Ack,
1367    #[serde(rename = "RESULT")]
1368    Result,
1369    #[serde(rename = "FULL")]
1370    Full,
1371}
1372
1373impl MarginAccountNewOtocoNewOrderRespTypeEnum {
1374    #[must_use]
1375    pub fn as_str(&self) -> &'static str {
1376        match self {
1377            Self::Ack => "ACK",
1378            Self::Result => "RESULT",
1379            Self::Full => "FULL",
1380        }
1381    }
1382}
1383
1384impl std::str::FromStr for MarginAccountNewOtocoNewOrderRespTypeEnum {
1385    type Err = Box<dyn std::error::Error + Send + Sync>;
1386
1387    fn from_str(s: &str) -> Result<Self, Self::Err> {
1388        match s {
1389            "ACK" => Ok(Self::Ack),
1390            "RESULT" => Ok(Self::Result),
1391            "FULL" => Ok(Self::Full),
1392            other => Err(format!(
1393                "invalid MarginAccountNewOtocoNewOrderRespTypeEnum: {}",
1394                other
1395            )
1396            .into()),
1397        }
1398    }
1399}
1400
1401#[allow(non_camel_case_types)]
1402#[derive(Debug, Clone, Serialize, Deserialize)]
1403pub enum MarginAccountNewOtocoSelfTradePreventionModeEnum {
1404    #[serde(rename = "EXPIRE_TAKER")]
1405    ExpireTaker,
1406    #[serde(rename = "EXPIRE_MAKER")]
1407    ExpireMaker,
1408    #[serde(rename = "EXPIRE_BOTH")]
1409    ExpireBoth,
1410    #[serde(rename = "NONE")]
1411    None,
1412}
1413
1414impl MarginAccountNewOtocoSelfTradePreventionModeEnum {
1415    #[must_use]
1416    pub fn as_str(&self) -> &'static str {
1417        match self {
1418            Self::ExpireTaker => "EXPIRE_TAKER",
1419            Self::ExpireMaker => "EXPIRE_MAKER",
1420            Self::ExpireBoth => "EXPIRE_BOTH",
1421            Self::None => "NONE",
1422        }
1423    }
1424}
1425
1426impl std::str::FromStr for MarginAccountNewOtocoSelfTradePreventionModeEnum {
1427    type Err = Box<dyn std::error::Error + Send + Sync>;
1428
1429    fn from_str(s: &str) -> Result<Self, Self::Err> {
1430        match s {
1431            "EXPIRE_TAKER" => Ok(Self::ExpireTaker),
1432            "EXPIRE_MAKER" => Ok(Self::ExpireMaker),
1433            "EXPIRE_BOTH" => Ok(Self::ExpireBoth),
1434            "NONE" => Ok(Self::None),
1435            other => Err(format!(
1436                "invalid MarginAccountNewOtocoSelfTradePreventionModeEnum: {}",
1437                other
1438            )
1439            .into()),
1440        }
1441    }
1442}
1443
1444#[allow(non_camel_case_types)]
1445#[derive(Debug, Clone, Serialize, Deserialize)]
1446pub enum MarginAccountNewOtocoWorkingTimeInForceEnum {
1447    #[serde(rename = "GTC")]
1448    Gtc,
1449    #[serde(rename = "IOC")]
1450    Ioc,
1451    #[serde(rename = "FOK")]
1452    Fok,
1453}
1454
1455impl MarginAccountNewOtocoWorkingTimeInForceEnum {
1456    #[must_use]
1457    pub fn as_str(&self) -> &'static str {
1458        match self {
1459            Self::Gtc => "GTC",
1460            Self::Ioc => "IOC",
1461            Self::Fok => "FOK",
1462        }
1463    }
1464}
1465
1466impl std::str::FromStr for MarginAccountNewOtocoWorkingTimeInForceEnum {
1467    type Err = Box<dyn std::error::Error + Send + Sync>;
1468
1469    fn from_str(s: &str) -> Result<Self, Self::Err> {
1470        match s {
1471            "GTC" => Ok(Self::Gtc),
1472            "IOC" => Ok(Self::Ioc),
1473            "FOK" => Ok(Self::Fok),
1474            other => Err(format!(
1475                "invalid MarginAccountNewOtocoWorkingTimeInForceEnum: {}",
1476                other
1477            )
1478            .into()),
1479        }
1480    }
1481}
1482
1483#[allow(non_camel_case_types)]
1484#[derive(Debug, Clone, Serialize, Deserialize)]
1485pub enum MarginAccountNewOtocoPendingAboveTimeInForceEnum {
1486    #[serde(rename = "GTC")]
1487    Gtc,
1488    #[serde(rename = "IOC")]
1489    Ioc,
1490    #[serde(rename = "FOK")]
1491    Fok,
1492}
1493
1494impl MarginAccountNewOtocoPendingAboveTimeInForceEnum {
1495    #[must_use]
1496    pub fn as_str(&self) -> &'static str {
1497        match self {
1498            Self::Gtc => "GTC",
1499            Self::Ioc => "IOC",
1500            Self::Fok => "FOK",
1501        }
1502    }
1503}
1504
1505impl std::str::FromStr for MarginAccountNewOtocoPendingAboveTimeInForceEnum {
1506    type Err = Box<dyn std::error::Error + Send + Sync>;
1507
1508    fn from_str(s: &str) -> Result<Self, Self::Err> {
1509        match s {
1510            "GTC" => Ok(Self::Gtc),
1511            "IOC" => Ok(Self::Ioc),
1512            "FOK" => Ok(Self::Fok),
1513            other => Err(format!(
1514                "invalid MarginAccountNewOtocoPendingAboveTimeInForceEnum: {}",
1515                other
1516            )
1517            .into()),
1518        }
1519    }
1520}
1521
1522#[allow(non_camel_case_types)]
1523#[derive(Debug, Clone, Serialize, Deserialize)]
1524pub enum MarginAccountNewOtocoPendingBelowTypeEnum {
1525    #[serde(rename = "LIMIT_MAKER")]
1526    LimitMaker,
1527    #[serde(rename = "STOP_LOSS")]
1528    StopLoss,
1529    #[serde(rename = "STOP_LOSS_LIMIT")]
1530    StopLossLimit,
1531}
1532
1533impl MarginAccountNewOtocoPendingBelowTypeEnum {
1534    #[must_use]
1535    pub fn as_str(&self) -> &'static str {
1536        match self {
1537            Self::LimitMaker => "LIMIT_MAKER",
1538            Self::StopLoss => "STOP_LOSS",
1539            Self::StopLossLimit => "STOP_LOSS_LIMIT",
1540        }
1541    }
1542}
1543
1544impl std::str::FromStr for MarginAccountNewOtocoPendingBelowTypeEnum {
1545    type Err = Box<dyn std::error::Error + Send + Sync>;
1546
1547    fn from_str(s: &str) -> Result<Self, Self::Err> {
1548        match s {
1549            "LIMIT_MAKER" => Ok(Self::LimitMaker),
1550            "STOP_LOSS" => Ok(Self::StopLoss),
1551            "STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
1552            other => Err(format!(
1553                "invalid MarginAccountNewOtocoPendingBelowTypeEnum: {}",
1554                other
1555            )
1556            .into()),
1557        }
1558    }
1559}
1560
1561#[allow(non_camel_case_types)]
1562#[derive(Debug, Clone, Serialize, Deserialize)]
1563pub enum MarginAccountNewOtocoPendingBelowTimeInForceEnum {
1564    #[serde(rename = "GTC")]
1565    Gtc,
1566    #[serde(rename = "IOC")]
1567    Ioc,
1568    #[serde(rename = "FOK")]
1569    Fok,
1570}
1571
1572impl MarginAccountNewOtocoPendingBelowTimeInForceEnum {
1573    #[must_use]
1574    pub fn as_str(&self) -> &'static str {
1575        match self {
1576            Self::Gtc => "GTC",
1577            Self::Ioc => "IOC",
1578            Self::Fok => "FOK",
1579        }
1580    }
1581}
1582
1583impl std::str::FromStr for MarginAccountNewOtocoPendingBelowTimeInForceEnum {
1584    type Err = Box<dyn std::error::Error + Send + Sync>;
1585
1586    fn from_str(s: &str) -> Result<Self, Self::Err> {
1587        match s {
1588            "GTC" => Ok(Self::Gtc),
1589            "IOC" => Ok(Self::Ioc),
1590            "FOK" => Ok(Self::Fok),
1591            other => Err(format!(
1592                "invalid MarginAccountNewOtocoPendingBelowTimeInForceEnum: {}",
1593                other
1594            )
1595            .into()),
1596        }
1597    }
1598}
1599
1600#[allow(non_camel_case_types)]
1601#[derive(Debug, Clone, Serialize, Deserialize)]
1602pub enum MarginManualLiquidationTypeEnum {
1603    #[serde(rename = "MARGIN")]
1604    Margin,
1605    #[serde(rename = "ISOLATED")]
1606    Isolated,
1607}
1608
1609impl MarginManualLiquidationTypeEnum {
1610    #[must_use]
1611    pub fn as_str(&self) -> &'static str {
1612        match self {
1613            Self::Margin => "MARGIN",
1614            Self::Isolated => "ISOLATED",
1615        }
1616    }
1617}
1618
1619impl std::str::FromStr for MarginManualLiquidationTypeEnum {
1620    type Err = Box<dyn std::error::Error + Send + Sync>;
1621
1622    fn from_str(s: &str) -> Result<Self, Self::Err> {
1623        match s {
1624            "MARGIN" => Ok(Self::Margin),
1625            "ISOLATED" => Ok(Self::Isolated),
1626            other => Err(format!("invalid MarginManualLiquidationTypeEnum: {}", other).into()),
1627        }
1628    }
1629}
1630
1631#[allow(non_camel_case_types)]
1632#[derive(Debug, Clone, Serialize, Deserialize)]
1633pub enum QueryCurrentMarginOrderCountUsageIsIsolatedEnum {
1634    #[serde(rename = "TRUE")]
1635    True,
1636    #[serde(rename = "FALSE")]
1637    False,
1638}
1639
1640impl QueryCurrentMarginOrderCountUsageIsIsolatedEnum {
1641    #[must_use]
1642    pub fn as_str(&self) -> &'static str {
1643        match self {
1644            Self::True => "TRUE",
1645            Self::False => "FALSE",
1646        }
1647    }
1648}
1649
1650impl std::str::FromStr for QueryCurrentMarginOrderCountUsageIsIsolatedEnum {
1651    type Err = Box<dyn std::error::Error + Send + Sync>;
1652
1653    fn from_str(s: &str) -> Result<Self, Self::Err> {
1654        match s {
1655            "TRUE" => Ok(Self::True),
1656            "FALSE" => Ok(Self::False),
1657            other => Err(format!(
1658                "invalid QueryCurrentMarginOrderCountUsageIsIsolatedEnum: {}",
1659                other
1660            )
1661            .into()),
1662        }
1663    }
1664}
1665
1666#[allow(non_camel_case_types)]
1667#[derive(Debug, Clone, Serialize, Deserialize)]
1668pub enum QueryMarginAccountsAllOcoIsIsolatedEnum {
1669    #[serde(rename = "TRUE")]
1670    True,
1671    #[serde(rename = "FALSE")]
1672    False,
1673}
1674
1675impl QueryMarginAccountsAllOcoIsIsolatedEnum {
1676    #[must_use]
1677    pub fn as_str(&self) -> &'static str {
1678        match self {
1679            Self::True => "TRUE",
1680            Self::False => "FALSE",
1681        }
1682    }
1683}
1684
1685impl std::str::FromStr for QueryMarginAccountsAllOcoIsIsolatedEnum {
1686    type Err = Box<dyn std::error::Error + Send + Sync>;
1687
1688    fn from_str(s: &str) -> Result<Self, Self::Err> {
1689        match s {
1690            "TRUE" => Ok(Self::True),
1691            "FALSE" => Ok(Self::False),
1692            other => {
1693                Err(format!("invalid QueryMarginAccountsAllOcoIsIsolatedEnum: {}", other).into())
1694            }
1695        }
1696    }
1697}
1698
1699#[allow(non_camel_case_types)]
1700#[derive(Debug, Clone, Serialize, Deserialize)]
1701pub enum QueryMarginAccountsAllOrdersIsIsolatedEnum {
1702    #[serde(rename = "TRUE")]
1703    True,
1704    #[serde(rename = "FALSE")]
1705    False,
1706}
1707
1708impl QueryMarginAccountsAllOrdersIsIsolatedEnum {
1709    #[must_use]
1710    pub fn as_str(&self) -> &'static str {
1711        match self {
1712            Self::True => "TRUE",
1713            Self::False => "FALSE",
1714        }
1715    }
1716}
1717
1718impl std::str::FromStr for QueryMarginAccountsAllOrdersIsIsolatedEnum {
1719    type Err = Box<dyn std::error::Error + Send + Sync>;
1720
1721    fn from_str(s: &str) -> Result<Self, Self::Err> {
1722        match s {
1723            "TRUE" => Ok(Self::True),
1724            "FALSE" => Ok(Self::False),
1725            other => Err(format!(
1726                "invalid QueryMarginAccountsAllOrdersIsIsolatedEnum: {}",
1727                other
1728            )
1729            .into()),
1730        }
1731    }
1732}
1733
1734#[allow(non_camel_case_types)]
1735#[derive(Debug, Clone, Serialize, Deserialize)]
1736pub enum QueryMarginAccountsOcoIsIsolatedEnum {
1737    #[serde(rename = "TRUE")]
1738    True,
1739    #[serde(rename = "FALSE")]
1740    False,
1741}
1742
1743impl QueryMarginAccountsOcoIsIsolatedEnum {
1744    #[must_use]
1745    pub fn as_str(&self) -> &'static str {
1746        match self {
1747            Self::True => "TRUE",
1748            Self::False => "FALSE",
1749        }
1750    }
1751}
1752
1753impl std::str::FromStr for QueryMarginAccountsOcoIsIsolatedEnum {
1754    type Err = Box<dyn std::error::Error + Send + Sync>;
1755
1756    fn from_str(s: &str) -> Result<Self, Self::Err> {
1757        match s {
1758            "TRUE" => Ok(Self::True),
1759            "FALSE" => Ok(Self::False),
1760            other => Err(format!("invalid QueryMarginAccountsOcoIsIsolatedEnum: {}", other).into()),
1761        }
1762    }
1763}
1764
1765#[allow(non_camel_case_types)]
1766#[derive(Debug, Clone, Serialize, Deserialize)]
1767pub enum QueryMarginAccountsOpenOcoIsIsolatedEnum {
1768    #[serde(rename = "TRUE")]
1769    True,
1770    #[serde(rename = "FALSE")]
1771    False,
1772}
1773
1774impl QueryMarginAccountsOpenOcoIsIsolatedEnum {
1775    #[must_use]
1776    pub fn as_str(&self) -> &'static str {
1777        match self {
1778            Self::True => "TRUE",
1779            Self::False => "FALSE",
1780        }
1781    }
1782}
1783
1784impl std::str::FromStr for QueryMarginAccountsOpenOcoIsIsolatedEnum {
1785    type Err = Box<dyn std::error::Error + Send + Sync>;
1786
1787    fn from_str(s: &str) -> Result<Self, Self::Err> {
1788        match s {
1789            "TRUE" => Ok(Self::True),
1790            "FALSE" => Ok(Self::False),
1791            other => Err(format!(
1792                "invalid QueryMarginAccountsOpenOcoIsIsolatedEnum: {}",
1793                other
1794            )
1795            .into()),
1796        }
1797    }
1798}
1799
1800#[allow(non_camel_case_types)]
1801#[derive(Debug, Clone, Serialize, Deserialize)]
1802pub enum QueryMarginAccountsOpenOrdersIsIsolatedEnum {
1803    #[serde(rename = "TRUE")]
1804    True,
1805    #[serde(rename = "FALSE")]
1806    False,
1807}
1808
1809impl QueryMarginAccountsOpenOrdersIsIsolatedEnum {
1810    #[must_use]
1811    pub fn as_str(&self) -> &'static str {
1812        match self {
1813            Self::True => "TRUE",
1814            Self::False => "FALSE",
1815        }
1816    }
1817}
1818
1819impl std::str::FromStr for QueryMarginAccountsOpenOrdersIsIsolatedEnum {
1820    type Err = Box<dyn std::error::Error + Send + Sync>;
1821
1822    fn from_str(s: &str) -> Result<Self, Self::Err> {
1823        match s {
1824            "TRUE" => Ok(Self::True),
1825            "FALSE" => Ok(Self::False),
1826            other => Err(format!(
1827                "invalid QueryMarginAccountsOpenOrdersIsIsolatedEnum: {}",
1828                other
1829            )
1830            .into()),
1831        }
1832    }
1833}
1834
1835#[allow(non_camel_case_types)]
1836#[derive(Debug, Clone, Serialize, Deserialize)]
1837pub enum QueryMarginAccountsOrderIsIsolatedEnum {
1838    #[serde(rename = "TRUE")]
1839    True,
1840    #[serde(rename = "FALSE")]
1841    False,
1842}
1843
1844impl QueryMarginAccountsOrderIsIsolatedEnum {
1845    #[must_use]
1846    pub fn as_str(&self) -> &'static str {
1847        match self {
1848            Self::True => "TRUE",
1849            Self::False => "FALSE",
1850        }
1851    }
1852}
1853
1854impl std::str::FromStr for QueryMarginAccountsOrderIsIsolatedEnum {
1855    type Err = Box<dyn std::error::Error + Send + Sync>;
1856
1857    fn from_str(s: &str) -> Result<Self, Self::Err> {
1858        match s {
1859            "TRUE" => Ok(Self::True),
1860            "FALSE" => Ok(Self::False),
1861            other => {
1862                Err(format!("invalid QueryMarginAccountsOrderIsIsolatedEnum: {}", other).into())
1863            }
1864        }
1865    }
1866}
1867
1868#[allow(non_camel_case_types)]
1869#[derive(Debug, Clone, Serialize, Deserialize)]
1870pub enum QueryMarginAccountsTradeListIsIsolatedEnum {
1871    #[serde(rename = "TRUE")]
1872    True,
1873    #[serde(rename = "FALSE")]
1874    False,
1875}
1876
1877impl QueryMarginAccountsTradeListIsIsolatedEnum {
1878    #[must_use]
1879    pub fn as_str(&self) -> &'static str {
1880        match self {
1881            Self::True => "TRUE",
1882            Self::False => "FALSE",
1883        }
1884    }
1885}
1886
1887impl std::str::FromStr for QueryMarginAccountsTradeListIsIsolatedEnum {
1888    type Err = Box<dyn std::error::Error + Send + Sync>;
1889
1890    fn from_str(s: &str) -> Result<Self, Self::Err> {
1891        match s {
1892            "TRUE" => Ok(Self::True),
1893            "FALSE" => Ok(Self::False),
1894            other => Err(format!(
1895                "invalid QueryMarginAccountsTradeListIsIsolatedEnum: {}",
1896                other
1897            )
1898            .into()),
1899        }
1900    }
1901}
1902
1903#[allow(non_camel_case_types)]
1904#[derive(Debug, Clone, Serialize, Deserialize)]
1905pub enum QueryPreventedMatchesIsIsolatedEnum {
1906    #[serde(rename = "TRUE")]
1907    True,
1908    #[serde(rename = "FALSE")]
1909    False,
1910}
1911
1912impl QueryPreventedMatchesIsIsolatedEnum {
1913    #[must_use]
1914    pub fn as_str(&self) -> &'static str {
1915        match self {
1916            Self::True => "TRUE",
1917            Self::False => "FALSE",
1918        }
1919    }
1920}
1921
1922impl std::str::FromStr for QueryPreventedMatchesIsIsolatedEnum {
1923    type Err = Box<dyn std::error::Error + Send + Sync>;
1924
1925    fn from_str(s: &str) -> Result<Self, Self::Err> {
1926        match s {
1927            "TRUE" => Ok(Self::True),
1928            "FALSE" => Ok(Self::False),
1929            other => Err(format!("invalid QueryPreventedMatchesIsIsolatedEnum: {}", other).into()),
1930        }
1931    }
1932}
1933
1934/// Request parameters for the [`create_special_key`] operation.
1935///
1936/// This struct holds all of the inputs you can pass when calling
1937/// [`create_special_key`](#method.create_special_key).
1938#[derive(Clone, Debug, Builder, Deserialize)]
1939#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
1940pub struct CreateSpecialKeyParams {
1941    ///
1942    /// The `api_name` parameter.
1943    ///
1944    /// This field is **required.
1945    #[builder(setter(into))]
1946    #[serde(rename = "apiName")]
1947    pub api_name: String,
1948    ///
1949    /// The `symbol` parameter.
1950    ///
1951    /// This field is **optional.
1952    #[builder(setter(into), default)]
1953    #[serde(rename = "symbol", default)]
1954    pub symbol: Option<String>,
1955    /// Can be added in batches, separated by commas. Max 30 for an API key
1956    ///
1957    /// This field is **optional.
1958    #[builder(setter(into), default)]
1959    #[serde(rename = "ip", default)]
1960    pub ip: Option<String>,
1961    /// 1. If publicKey is inputted it will create an RSA or Ed25519
1962    /// key.
1963    ///
1964    /// 2. Need to be encoded to URL-encoded format
1965    ///
1966    /// This field is **optional.
1967    #[builder(setter(into), default)]
1968    #[serde(rename = "publicKey", default)]
1969    pub public_key: Option<String>,
1970    /// This parameter is only for the Ed25519 API key, and does not effact for other encryption methods. The value can be TRADE (TRADE for all permissions) or READ (READ for `USER_DATA`, `FIX_API_READ_ONLY`). The default value is TRADE.
1971    ///
1972    /// This field is **optional.
1973    #[builder(setter(into), default)]
1974    #[serde(rename = "permissionMode", default)]
1975    pub permission_mode: Option<CreateSpecialKeyPermissionModeEnum>,
1976    ///
1977    /// The `recv_window` parameter.
1978    ///
1979    /// This field is **optional.
1980    #[builder(setter(into), default)]
1981    #[serde(rename = "recvWindow", default)]
1982    pub recv_window: Option<i64>,
1983}
1984
1985impl CreateSpecialKeyParams {
1986    /// Create a builder for [`create_special_key`].
1987    ///
1988    /// Required parameters:
1989    ///
1990    /// * `api_name` — String
1991    ///
1992    #[must_use]
1993    pub fn builder(api_name: String) -> CreateSpecialKeyParamsBuilder {
1994        CreateSpecialKeyParamsBuilder::default().api_name(api_name)
1995    }
1996}
1997/// Request parameters for the [`delete_special_key`] operation.
1998///
1999/// This struct holds all of the inputs you can pass when calling
2000/// [`delete_special_key`](#method.delete_special_key).
2001#[derive(Clone, Debug, Builder, Deserialize, Default)]
2002#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2003pub struct DeleteSpecialKeyParams {
2004    ///
2005    /// The `api_name` parameter.
2006    ///
2007    /// This field is **optional.
2008    #[builder(setter(into), default)]
2009    #[serde(rename = "apiName", default)]
2010    pub api_name: Option<String>,
2011    ///
2012    /// The `symbol` parameter.
2013    ///
2014    /// This field is **optional.
2015    #[builder(setter(into), default)]
2016    #[serde(rename = "symbol", default)]
2017    pub symbol: Option<String>,
2018    ///
2019    /// The `recv_window` parameter.
2020    ///
2021    /// This field is **optional.
2022    #[builder(setter(into), default)]
2023    #[serde(rename = "recvWindow", default)]
2024    pub recv_window: Option<i64>,
2025}
2026
2027impl DeleteSpecialKeyParams {
2028    /// Create a builder for [`delete_special_key`].
2029    ///
2030    #[must_use]
2031    pub fn builder() -> DeleteSpecialKeyParamsBuilder {
2032        DeleteSpecialKeyParamsBuilder::default()
2033    }
2034}
2035/// Request parameters for the [`edit_ip_for_special_key`] operation.
2036///
2037/// This struct holds all of the inputs you can pass when calling
2038/// [`edit_ip_for_special_key`](#method.edit_ip_for_special_key).
2039#[derive(Clone, Debug, Builder, Deserialize)]
2040#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2041pub struct EditIpForSpecialKeyParams {
2042    /// Can be added in batches, separated by commas. Max 30 for an API key
2043    ///
2044    /// This field is **required.
2045    #[builder(setter(into))]
2046    #[serde(rename = "ip")]
2047    pub ip: String,
2048    /// isolated margin pair
2049    ///
2050    /// This field is **optional.
2051    #[builder(setter(into), default)]
2052    #[serde(rename = "symbol", default)]
2053    pub symbol: Option<String>,
2054    ///
2055    /// The `recv_window` parameter.
2056    ///
2057    /// This field is **optional.
2058    #[builder(setter(into), default)]
2059    #[serde(rename = "recvWindow", default)]
2060    pub recv_window: Option<i64>,
2061}
2062
2063impl EditIpForSpecialKeyParams {
2064    /// Create a builder for [`edit_ip_for_special_key`].
2065    ///
2066    /// Required parameters:
2067    ///
2068    /// * `ip` — Can be added in batches, separated by commas. Max 30 for an API key
2069    ///
2070    #[must_use]
2071    pub fn builder(ip: String) -> EditIpForSpecialKeyParamsBuilder {
2072        EditIpForSpecialKeyParamsBuilder::default().ip(ip)
2073    }
2074}
2075/// Request parameters for the [`exit_special_key_mode`] operation.
2076///
2077/// This struct holds all of the inputs you can pass when calling
2078/// [`exit_special_key_mode`](#method.exit_special_key_mode).
2079#[derive(Clone, Debug, Builder, Deserialize, Default)]
2080#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2081pub struct ExitSpecialKeyModeParams {
2082    /// The value cannot be greater than `60000`
2083    ///
2084    /// This field is **optional.
2085    #[builder(setter(into), default)]
2086    #[serde(rename = "recvWindow", default)]
2087    pub recv_window: Option<i64>,
2088}
2089
2090impl ExitSpecialKeyModeParams {
2091    /// Create a builder for [`exit_special_key_mode`].
2092    ///
2093    #[must_use]
2094    pub fn builder() -> ExitSpecialKeyModeParamsBuilder {
2095        ExitSpecialKeyModeParamsBuilder::default()
2096    }
2097}
2098/// Request parameters for the [`get_force_liquidation_record`] operation.
2099///
2100/// This struct holds all of the inputs you can pass when calling
2101/// [`get_force_liquidation_record`](#method.get_force_liquidation_record).
2102#[derive(Clone, Debug, Builder, Deserialize, Default)]
2103#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2104pub struct GetForceLiquidationRecordParams {
2105    ///
2106    /// The `start_time` parameter.
2107    ///
2108    /// This field is **optional.
2109    #[builder(setter(into), default)]
2110    #[serde(rename = "startTime", default)]
2111    pub start_time: Option<i64>,
2112    ///
2113    /// The `end_time` parameter.
2114    ///
2115    /// This field is **optional.
2116    #[builder(setter(into), default)]
2117    #[serde(rename = "endTime", default)]
2118    pub end_time: Option<i64>,
2119    ///
2120    /// The `isolated_symbol` parameter.
2121    ///
2122    /// This field is **optional.
2123    #[builder(setter(into), default)]
2124    #[serde(rename = "isolatedSymbol", default)]
2125    pub isolated_symbol: Option<String>,
2126    ///
2127    /// The `current` parameter.
2128    ///
2129    /// This field is **optional.
2130    #[builder(setter(into), default)]
2131    #[serde(rename = "current", default)]
2132    pub current: Option<i64>,
2133    ///
2134    /// The `size` parameter.
2135    ///
2136    /// This field is **optional.
2137    #[builder(setter(into), default)]
2138    #[serde(rename = "size", default)]
2139    pub size: Option<i64>,
2140    ///
2141    /// The `recv_window` parameter.
2142    ///
2143    /// This field is **optional.
2144    #[builder(setter(into), default)]
2145    #[serde(rename = "recvWindow", default)]
2146    pub recv_window: Option<i64>,
2147}
2148
2149impl GetForceLiquidationRecordParams {
2150    /// Create a builder for [`get_force_liquidation_record`].
2151    ///
2152    #[must_use]
2153    pub fn builder() -> GetForceLiquidationRecordParamsBuilder {
2154        GetForceLiquidationRecordParamsBuilder::default()
2155    }
2156}
2157/// Request parameters for the [`get_small_liability_exchange_coin_list`] operation.
2158///
2159/// This struct holds all of the inputs you can pass when calling
2160/// [`get_small_liability_exchange_coin_list`](#method.get_small_liability_exchange_coin_list).
2161#[derive(Clone, Debug, Builder, Deserialize, Default)]
2162#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2163pub struct GetSmallLiabilityExchangeCoinListParams {
2164    ///
2165    /// The `recv_window` parameter.
2166    ///
2167    /// This field is **optional.
2168    #[builder(setter(into), default)]
2169    #[serde(rename = "recvWindow", default)]
2170    pub recv_window: Option<i64>,
2171}
2172
2173impl GetSmallLiabilityExchangeCoinListParams {
2174    /// Create a builder for [`get_small_liability_exchange_coin_list`].
2175    ///
2176    #[must_use]
2177    pub fn builder() -> GetSmallLiabilityExchangeCoinListParamsBuilder {
2178        GetSmallLiabilityExchangeCoinListParamsBuilder::default()
2179    }
2180}
2181/// Request parameters for the [`get_small_liability_exchange_history`] operation.
2182///
2183/// This struct holds all of the inputs you can pass when calling
2184/// [`get_small_liability_exchange_history`](#method.get_small_liability_exchange_history).
2185#[derive(Clone, Debug, Builder, Deserialize)]
2186#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2187pub struct GetSmallLiabilityExchangeHistoryParams {
2188    ///
2189    /// The `current` parameter.
2190    ///
2191    /// This field is **required.
2192    #[builder(setter(into))]
2193    #[serde(rename = "current")]
2194    pub current: i64,
2195    ///
2196    /// The `size` parameter.
2197    ///
2198    /// This field is **required.
2199    #[builder(setter(into))]
2200    #[serde(rename = "size")]
2201    pub size: i64,
2202    ///
2203    /// The `start_time` parameter.
2204    ///
2205    /// This field is **optional.
2206    #[builder(setter(into), default)]
2207    #[serde(rename = "startTime", default)]
2208    pub start_time: Option<i64>,
2209    ///
2210    /// The `end_time` parameter.
2211    ///
2212    /// This field is **optional.
2213    #[builder(setter(into), default)]
2214    #[serde(rename = "endTime", default)]
2215    pub end_time: Option<i64>,
2216    ///
2217    /// The `recv_window` parameter.
2218    ///
2219    /// This field is **optional.
2220    #[builder(setter(into), default)]
2221    #[serde(rename = "recvWindow", default)]
2222    pub recv_window: Option<i64>,
2223}
2224
2225impl GetSmallLiabilityExchangeHistoryParams {
2226    /// Create a builder for [`get_small_liability_exchange_history`].
2227    ///
2228    /// Required parameters:
2229    ///
2230    /// * `current` — i64
2231    /// * `size` — i64
2232    ///
2233    #[must_use]
2234    pub fn builder(current: i64, size: i64) -> GetSmallLiabilityExchangeHistoryParamsBuilder {
2235        GetSmallLiabilityExchangeHistoryParamsBuilder::default()
2236            .current(current)
2237            .size(size)
2238    }
2239}
2240/// Request parameters for the [`liquidation_loan_repay`] operation.
2241///
2242/// This struct holds all of the inputs you can pass when calling
2243/// [`liquidation_loan_repay`](#method.liquidation_loan_repay).
2244#[derive(Clone, Debug, Builder, Deserialize)]
2245#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2246pub struct LiquidationLoanRepayParams {
2247    /// The asset to repay (e.g. USDT, USDC)
2248    ///
2249    /// This field is **required.
2250    #[builder(setter(into))]
2251    #[serde(rename = "asset")]
2252    pub asset: String,
2253    /// Repayment amount, must be greater than 0
2254    ///
2255    /// This field is **required.
2256    #[builder(setter(into))]
2257    #[serde(rename = "amount")]
2258    pub amount: rust_decimal::Decimal,
2259    ///
2260    /// The `recv_window` parameter.
2261    ///
2262    /// This field is **optional.
2263    #[builder(setter(into), default)]
2264    #[serde(rename = "recvWindow", default)]
2265    pub recv_window: Option<i64>,
2266}
2267
2268impl LiquidationLoanRepayParams {
2269    /// Create a builder for [`liquidation_loan_repay`].
2270    ///
2271    /// Required parameters:
2272    ///
2273    /// * `asset` — The asset to repay (e.g. USDT, USDC)
2274    /// * `amount` — Repayment amount, must be greater than 0
2275    ///
2276    #[must_use]
2277    pub fn builder(
2278        asset: String,
2279        amount: rust_decimal::Decimal,
2280    ) -> LiquidationLoanRepayParamsBuilder {
2281        LiquidationLoanRepayParamsBuilder::default()
2282            .asset(asset)
2283            .amount(amount)
2284    }
2285}
2286/// Request parameters for the [`margin_account_cancel_all_open_orders_on_a_symbol`] operation.
2287///
2288/// This struct holds all of the inputs you can pass when calling
2289/// [`margin_account_cancel_all_open_orders_on_a_symbol`](#method.margin_account_cancel_all_open_orders_on_a_symbol).
2290#[derive(Clone, Debug, Builder, Deserialize)]
2291#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2292pub struct MarginAccountCancelAllOpenOrdersOnASymbolParams {
2293    ///
2294    /// The `symbol` parameter.
2295    ///
2296    /// This field is **required.
2297    #[builder(setter(into))]
2298    #[serde(rename = "symbol")]
2299    pub symbol: String,
2300    ///
2301    /// The `is_isolated` parameter.
2302    ///
2303    /// This field is **optional.
2304    #[builder(setter(into), default)]
2305    #[serde(rename = "isIsolated", default)]
2306    pub is_isolated: Option<MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum>,
2307    ///
2308    /// The `recv_window` parameter.
2309    ///
2310    /// This field is **optional.
2311    #[builder(setter(into), default)]
2312    #[serde(rename = "recvWindow", default)]
2313    pub recv_window: Option<i64>,
2314}
2315
2316impl MarginAccountCancelAllOpenOrdersOnASymbolParams {
2317    /// Create a builder for [`margin_account_cancel_all_open_orders_on_a_symbol`].
2318    ///
2319    /// Required parameters:
2320    ///
2321    /// * `symbol` — String
2322    ///
2323    #[must_use]
2324    pub fn builder(symbol: String) -> MarginAccountCancelAllOpenOrdersOnASymbolParamsBuilder {
2325        MarginAccountCancelAllOpenOrdersOnASymbolParamsBuilder::default().symbol(symbol)
2326    }
2327}
2328/// Request parameters for the [`margin_account_cancel_oco`] operation.
2329///
2330/// This struct holds all of the inputs you can pass when calling
2331/// [`margin_account_cancel_oco`](#method.margin_account_cancel_oco).
2332#[derive(Clone, Debug, Builder, Deserialize)]
2333#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2334pub struct MarginAccountCancelOcoParams {
2335    ///
2336    /// The `symbol` parameter.
2337    ///
2338    /// This field is **required.
2339    #[builder(setter(into))]
2340    #[serde(rename = "symbol")]
2341    pub symbol: String,
2342    ///
2343    /// The `is_isolated` parameter.
2344    ///
2345    /// This field is **optional.
2346    #[builder(setter(into), default)]
2347    #[serde(rename = "isIsolated", default)]
2348    pub is_isolated: Option<MarginAccountCancelOcoIsIsolatedEnum>,
2349    ///
2350    /// The `order_list_id` parameter.
2351    ///
2352    /// This field is **optional.
2353    #[builder(setter(into), default)]
2354    #[serde(rename = "orderListId", default)]
2355    pub order_list_id: Option<i64>,
2356    ///
2357    /// The `list_client_order_id` parameter.
2358    ///
2359    /// This field is **optional.
2360    #[builder(setter(into), default)]
2361    #[serde(rename = "listClientOrderId", default)]
2362    pub list_client_order_id: Option<String>,
2363    ///
2364    /// The `new_client_order_id` parameter.
2365    ///
2366    /// This field is **optional.
2367    #[builder(setter(into), default)]
2368    #[serde(rename = "newClientOrderId", default)]
2369    pub new_client_order_id: Option<String>,
2370    ///
2371    /// The `recv_window` parameter.
2372    ///
2373    /// This field is **optional.
2374    #[builder(setter(into), default)]
2375    #[serde(rename = "recvWindow", default)]
2376    pub recv_window: Option<i64>,
2377}
2378
2379impl MarginAccountCancelOcoParams {
2380    /// Create a builder for [`margin_account_cancel_oco`].
2381    ///
2382    /// Required parameters:
2383    ///
2384    /// * `symbol` — String
2385    ///
2386    #[must_use]
2387    pub fn builder(symbol: String) -> MarginAccountCancelOcoParamsBuilder {
2388        MarginAccountCancelOcoParamsBuilder::default().symbol(symbol)
2389    }
2390}
2391/// Request parameters for the [`margin_account_cancel_order`] operation.
2392///
2393/// This struct holds all of the inputs you can pass when calling
2394/// [`margin_account_cancel_order`](#method.margin_account_cancel_order).
2395#[derive(Clone, Debug, Builder, Deserialize)]
2396#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2397pub struct MarginAccountCancelOrderParams {
2398    ///
2399    /// The `symbol` parameter.
2400    ///
2401    /// This field is **required.
2402    #[builder(setter(into))]
2403    #[serde(rename = "symbol")]
2404    pub symbol: String,
2405    ///
2406    /// The `is_isolated` parameter.
2407    ///
2408    /// This field is **optional.
2409    #[builder(setter(into), default)]
2410    #[serde(rename = "isIsolated", default)]
2411    pub is_isolated: Option<MarginAccountCancelOrderIsIsolatedEnum>,
2412    ///
2413    /// The `order_id` parameter.
2414    ///
2415    /// This field is **optional.
2416    #[builder(setter(into), default)]
2417    #[serde(rename = "orderId", default)]
2418    pub order_id: Option<i64>,
2419    ///
2420    /// The `orig_client_order_id` parameter.
2421    ///
2422    /// This field is **optional.
2423    #[builder(setter(into), default)]
2424    #[serde(rename = "origClientOrderId", default)]
2425    pub orig_client_order_id: Option<String>,
2426    ///
2427    /// The `new_client_order_id` parameter.
2428    ///
2429    /// This field is **optional.
2430    #[builder(setter(into), default)]
2431    #[serde(rename = "newClientOrderId", default)]
2432    pub new_client_order_id: Option<String>,
2433    ///
2434    /// The `recv_window` parameter.
2435    ///
2436    /// This field is **optional.
2437    #[builder(setter(into), default)]
2438    #[serde(rename = "recvWindow", default)]
2439    pub recv_window: Option<i64>,
2440}
2441
2442impl MarginAccountCancelOrderParams {
2443    /// Create a builder for [`margin_account_cancel_order`].
2444    ///
2445    /// Required parameters:
2446    ///
2447    /// * `symbol` — String
2448    ///
2449    #[must_use]
2450    pub fn builder(symbol: String) -> MarginAccountCancelOrderParamsBuilder {
2451        MarginAccountCancelOrderParamsBuilder::default().symbol(symbol)
2452    }
2453}
2454/// Request parameters for the [`margin_account_new_oco`] operation.
2455///
2456/// This struct holds all of the inputs you can pass when calling
2457/// [`margin_account_new_oco`](#method.margin_account_new_oco).
2458#[derive(Clone, Debug, Builder, Deserialize)]
2459#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2460pub struct MarginAccountNewOcoParams {
2461    ///
2462    /// The `symbol` parameter.
2463    ///
2464    /// This field is **required.
2465    #[builder(setter(into))]
2466    #[serde(rename = "symbol")]
2467    pub symbol: String,
2468    ///
2469    /// The `side` parameter.
2470    ///
2471    /// This field is **required.
2472    #[builder(setter(into))]
2473    #[serde(rename = "side")]
2474    pub side: MarginAccountNewOcoSideEnum,
2475    ///
2476    /// The `quantity` parameter.
2477    ///
2478    /// This field is **required.
2479    #[builder(setter(into))]
2480    #[serde(rename = "quantity")]
2481    pub quantity: rust_decimal::Decimal,
2482    ///
2483    /// The `price` parameter.
2484    ///
2485    /// This field is **required.
2486    #[builder(setter(into))]
2487    #[serde(rename = "price")]
2488    pub price: rust_decimal::Decimal,
2489    ///
2490    /// The `stop_price` parameter.
2491    ///
2492    /// This field is **required.
2493    #[builder(setter(into))]
2494    #[serde(rename = "stopPrice")]
2495    pub stop_price: rust_decimal::Decimal,
2496    ///
2497    /// The `is_isolated` parameter.
2498    ///
2499    /// This field is **optional.
2500    #[builder(setter(into), default)]
2501    #[serde(rename = "isIsolated", default)]
2502    pub is_isolated: Option<MarginAccountNewOcoIsIsolatedEnum>,
2503    /// A unique Id for the entire orderList
2504    ///
2505    /// This field is **optional.
2506    #[builder(setter(into), default)]
2507    #[serde(rename = "listClientOrderId", default)]
2508    pub list_client_order_id: Option<String>,
2509    /// A unique Id for the limit order
2510    ///
2511    /// This field is **optional.
2512    #[builder(setter(into), default)]
2513    #[serde(rename = "limitClientOrderId", default)]
2514    pub limit_client_order_id: Option<String>,
2515    ///
2516    /// The `limit_iceberg_qty` parameter.
2517    ///
2518    /// This field is **optional.
2519    #[builder(setter(into), default)]
2520    #[serde(rename = "limitIcebergQty", default)]
2521    pub limit_iceberg_qty: Option<rust_decimal::Decimal>,
2522    /// A unique Id for the stop loss/stop loss limit leg
2523    ///
2524    /// This field is **optional.
2525    #[builder(setter(into), default)]
2526    #[serde(rename = "stopClientOrderId", default)]
2527    pub stop_client_order_id: Option<String>,
2528    /// If provided, `stopLimitTimeInForce` is required.
2529    ///
2530    /// This field is **optional.
2531    #[builder(setter(into), default)]
2532    #[serde(rename = "stopLimitPrice", default)]
2533    pub stop_limit_price: Option<rust_decimal::Decimal>,
2534    ///
2535    /// The `stop_iceberg_qty` parameter.
2536    ///
2537    /// This field is **optional.
2538    #[builder(setter(into), default)]
2539    #[serde(rename = "stopIcebergQty", default)]
2540    pub stop_iceberg_qty: Option<rust_decimal::Decimal>,
2541    ///
2542    /// The `stop_limit_time_in_force` parameter.
2543    ///
2544    /// This field is **optional.
2545    #[builder(setter(into), default)]
2546    #[serde(rename = "stopLimitTimeInForce", default)]
2547    pub stop_limit_time_in_force: Option<MarginAccountNewOcoStopLimitTimeInForceEnum>,
2548    ///
2549    /// The `new_order_resp_type` parameter.
2550    ///
2551    /// This field is **optional.
2552    #[builder(setter(into), default)]
2553    #[serde(rename = "newOrderRespType", default)]
2554    pub new_order_resp_type: Option<MarginAccountNewOcoNewOrderRespTypeEnum>,
2555    ///
2556    /// The `side_effect_type` parameter.
2557    ///
2558    /// This field is **optional.
2559    #[builder(setter(into), default)]
2560    #[serde(rename = "sideEffectType", default)]
2561    pub side_effect_type: Option<MarginAccountNewOcoSideEffectTypeEnum>,
2562    ///
2563    /// The `self_trade_prevention_mode` parameter.
2564    ///
2565    /// This field is **optional.
2566    #[builder(setter(into), default)]
2567    #[serde(rename = "selfTradePreventionMode", default)]
2568    pub self_trade_prevention_mode: Option<MarginAccountNewOcoSelfTradePreventionModeEnum>,
2569    /// Only when `MARGIN_BUY` or `AUTO_BORROW_REPAY` order takes effect, true means that the debt generated by the order needs to be repay after the order is cancelled.
2570    ///
2571    /// This field is **optional.
2572    #[builder(setter(into), default)]
2573    #[serde(rename = "autoRepayAtCancel", default)]
2574    pub auto_repay_at_cancel: Option<bool>,
2575    ///
2576    /// The `recv_window` parameter.
2577    ///
2578    /// This field is **optional.
2579    #[builder(setter(into), default)]
2580    #[serde(rename = "recvWindow", default)]
2581    pub recv_window: Option<i64>,
2582}
2583
2584impl MarginAccountNewOcoParams {
2585    /// Create a builder for [`margin_account_new_oco`].
2586    ///
2587    /// Required parameters:
2588    ///
2589    /// * `symbol` — String
2590    /// * `side` — String
2591    /// * `quantity` — `rust_decimal::Decimal`
2592    /// * `price` — `rust_decimal::Decimal`
2593    /// * `stop_price` — `rust_decimal::Decimal`
2594    ///
2595    #[must_use]
2596    pub fn builder(
2597        symbol: String,
2598        side: MarginAccountNewOcoSideEnum,
2599        quantity: rust_decimal::Decimal,
2600        price: rust_decimal::Decimal,
2601        stop_price: rust_decimal::Decimal,
2602    ) -> MarginAccountNewOcoParamsBuilder {
2603        MarginAccountNewOcoParamsBuilder::default()
2604            .symbol(symbol)
2605            .side(side)
2606            .quantity(quantity)
2607            .price(price)
2608            .stop_price(stop_price)
2609    }
2610}
2611/// Request parameters for the [`margin_account_new_order`] operation.
2612///
2613/// This struct holds all of the inputs you can pass when calling
2614/// [`margin_account_new_order`](#method.margin_account_new_order).
2615#[derive(Clone, Debug, Builder, Deserialize)]
2616#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2617pub struct MarginAccountNewOrderParams {
2618    ///
2619    /// The `symbol` parameter.
2620    ///
2621    /// This field is **required.
2622    #[builder(setter(into))]
2623    #[serde(rename = "symbol")]
2624    pub symbol: String,
2625    ///
2626    /// The `side` parameter.
2627    ///
2628    /// This field is **required.
2629    #[builder(setter(into))]
2630    #[serde(rename = "side")]
2631    pub side: MarginAccountNewOrderSideEnum,
2632    ///
2633    /// The `r#type` parameter.
2634    ///
2635    /// This field is **required.
2636    #[builder(setter(into))]
2637    #[serde(rename = "type")]
2638    pub r#type: MarginAccountNewOrderTypeEnum,
2639    ///
2640    /// The `is_isolated` parameter.
2641    ///
2642    /// This field is **optional.
2643    #[builder(setter(into), default)]
2644    #[serde(rename = "isIsolated", default)]
2645    pub is_isolated: Option<MarginAccountNewOrderIsIsolatedEnum>,
2646    ///
2647    /// The `quantity` parameter.
2648    ///
2649    /// This field is **optional.
2650    #[builder(setter(into), default)]
2651    #[serde(rename = "quantity", default)]
2652    pub quantity: Option<rust_decimal::Decimal>,
2653    ///
2654    /// The `quote_order_qty` parameter.
2655    ///
2656    /// This field is **optional.
2657    #[builder(setter(into), default)]
2658    #[serde(rename = "quoteOrderQty", default)]
2659    pub quote_order_qty: Option<rust_decimal::Decimal>,
2660    ///
2661    /// The `price` parameter.
2662    ///
2663    /// This field is **optional.
2664    #[builder(setter(into), default)]
2665    #[serde(rename = "price", default)]
2666    pub price: Option<rust_decimal::Decimal>,
2667    /// Used with `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, and `TAKE_PROFIT_LIMIT` orders.
2668    ///
2669    /// This field is **optional.
2670    #[builder(setter(into), default)]
2671    #[serde(rename = "stopPrice", default)]
2672    pub stop_price: Option<rust_decimal::Decimal>,
2673    /// A unique id among open orders. Automatically generated if not sent.
2674    ///
2675    /// This field is **optional.
2676    #[builder(setter(into), default)]
2677    #[serde(rename = "newClientOrderId", default)]
2678    pub new_client_order_id: Option<String>,
2679    /// Used with `LIMIT`, `STOP_LOSS_LIMIT`, and `TAKE_PROFIT_LIMIT` to create an iceberg order.
2680    ///
2681    /// This field is **optional.
2682    #[builder(setter(into), default)]
2683    #[serde(rename = "icebergQty", default)]
2684    pub iceberg_qty: Option<rust_decimal::Decimal>,
2685    /// MARKET and LIMIT order types default to FULL, all other orders default to ACK.
2686    ///
2687    /// This field is **optional.
2688    #[builder(setter(into), default)]
2689    #[serde(rename = "newOrderRespType", default)]
2690    pub new_order_resp_type: Option<MarginAccountNewOrderNewOrderRespTypeEnum>,
2691    ///
2692    /// The `side_effect_type` parameter.
2693    ///
2694    /// This field is **optional.
2695    #[builder(setter(into), default)]
2696    #[serde(rename = "sideEffectType", default)]
2697    pub side_effect_type: Option<MarginAccountNewOrderSideEffectTypeEnum>,
2698    ///
2699    /// The `time_in_force` parameter.
2700    ///
2701    /// This field is **optional.
2702    #[builder(setter(into), default)]
2703    #[serde(rename = "timeInForce", default)]
2704    pub time_in_force: Option<MarginAccountNewOrderTimeInForceEnum>,
2705    ///
2706    /// The `self_trade_prevention_mode` parameter.
2707    ///
2708    /// This field is **optional.
2709    #[builder(setter(into), default)]
2710    #[serde(rename = "selfTradePreventionMode", default)]
2711    pub self_trade_prevention_mode: Option<MarginAccountNewOrderSelfTradePreventionModeEnum>,
2712    /// Used with `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, and `TAKE_PROFIT_LIMIT` orders.
2713    ///
2714    /// This field is **optional.
2715    #[builder(setter(into), default)]
2716    #[serde(rename = "trailingDelta", default)]
2717    pub trailing_delta: Option<i64>,
2718    /// Only when `MARGIN_BUY` or `AUTO_BORROW_REPAY` order takes effect, true means that the debt generated by the order needs to be repaid after the order is cancelled.
2719    ///
2720    /// This field is **optional.
2721    #[builder(setter(into), default)]
2722    #[serde(rename = "autoRepayAtCancel", default)]
2723    pub auto_repay_at_cancel: Option<bool>,
2724    ///
2725    /// The `recv_window` parameter.
2726    ///
2727    /// This field is **optional.
2728    #[builder(setter(into), default)]
2729    #[serde(rename = "recvWindow", default)]
2730    pub recv_window: Option<i64>,
2731}
2732
2733impl MarginAccountNewOrderParams {
2734    /// Create a builder for [`margin_account_new_order`].
2735    ///
2736    /// Required parameters:
2737    ///
2738    /// * `symbol` — String
2739    /// * `side` — String
2740    /// * `r#type` — String
2741    ///
2742    #[must_use]
2743    pub fn builder(
2744        symbol: String,
2745        side: MarginAccountNewOrderSideEnum,
2746        r#type: MarginAccountNewOrderTypeEnum,
2747    ) -> MarginAccountNewOrderParamsBuilder {
2748        MarginAccountNewOrderParamsBuilder::default()
2749            .symbol(symbol)
2750            .side(side)
2751            .r#type(r#type)
2752    }
2753}
2754/// Request parameters for the [`margin_account_new_oto`] operation.
2755///
2756/// This struct holds all of the inputs you can pass when calling
2757/// [`margin_account_new_oto`](#method.margin_account_new_oto).
2758#[derive(Clone, Debug, Builder, Deserialize)]
2759#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2760pub struct MarginAccountNewOtoParams {
2761    ///
2762    /// The `symbol` parameter.
2763    ///
2764    /// This field is **required.
2765    #[builder(setter(into))]
2766    #[serde(rename = "symbol")]
2767    pub symbol: String,
2768    ///
2769    /// The `working_type` parameter.
2770    ///
2771    /// This field is **required.
2772    #[builder(setter(into))]
2773    #[serde(rename = "workingType")]
2774    pub working_type: MarginAccountNewOtoWorkingTypeEnum,
2775    ///
2776    /// The `working_side` parameter.
2777    ///
2778    /// This field is **required.
2779    #[builder(setter(into))]
2780    #[serde(rename = "workingSide")]
2781    pub working_side: MarginAccountNewOtoWorkingSideEnum,
2782    ///
2783    /// The `working_price` parameter.
2784    ///
2785    /// This field is **required.
2786    #[builder(setter(into))]
2787    #[serde(rename = "workingPrice")]
2788    pub working_price: rust_decimal::Decimal,
2789    /// Sets the quantity for the working order.
2790    ///
2791    /// This field is **required.
2792    #[builder(setter(into))]
2793    #[serde(rename = "workingQuantity")]
2794    pub working_quantity: rust_decimal::Decimal,
2795    /// This can only be used if `workingTimeInForce` is `GTC`.
2796    ///
2797    /// This field is **required.
2798    #[builder(setter(into))]
2799    #[serde(rename = "workingIcebergQty")]
2800    pub working_iceberg_qty: rust_decimal::Decimal,
2801    ///
2802    /// The `pending_type` parameter.
2803    ///
2804    /// This field is **required.
2805    #[builder(setter(into))]
2806    #[serde(rename = "pendingType")]
2807    pub pending_type: MarginAccountNewOtoPendingTypeEnum,
2808    ///
2809    /// The `pending_side` parameter.
2810    ///
2811    /// This field is **required.
2812    #[builder(setter(into))]
2813    #[serde(rename = "pendingSide")]
2814    pub pending_side: MarginAccountNewOtoPendingSideEnum,
2815    /// Sets the quantity for the pending order.
2816    ///
2817    /// This field is **required.
2818    #[builder(setter(into))]
2819    #[serde(rename = "pendingQuantity")]
2820    pub pending_quantity: rust_decimal::Decimal,
2821    ///
2822    /// The `is_isolated` parameter.
2823    ///
2824    /// This field is **optional.
2825    #[builder(setter(into), default)]
2826    #[serde(rename = "isIsolated", default)]
2827    pub is_isolated: Option<MarginAccountNewOtoIsIsolatedEnum>,
2828    /// Arbitrary unique ID among open order lists. Automatically generated if not sent.<br/>A new order list with the same listClientOrderId is accepted only when the previous one is filled or completely expired.<br/>`listClientOrderId` is distinct from the `workingClientOrderId` and the `pendingClientOrderId`.
2829    ///
2830    /// This field is **optional.
2831    #[builder(setter(into), default)]
2832    #[serde(rename = "listClientOrderId", default)]
2833    pub list_client_order_id: Option<String>,
2834    /// MARKET and LIMIT order types default to FULL, all other orders default to ACK.
2835    ///
2836    /// This field is **optional.
2837    #[builder(setter(into), default)]
2838    #[serde(rename = "newOrderRespType", default)]
2839    pub new_order_resp_type: Option<MarginAccountNewOtoNewOrderRespTypeEnum>,
2840    ///
2841    /// The `side_effect_type` parameter.
2842    ///
2843    /// This field is **optional.
2844    #[builder(setter(into), default)]
2845    #[serde(rename = "sideEffectType", default)]
2846    pub side_effect_type: Option<MarginAccountNewOtoSideEffectTypeEnum>,
2847    ///
2848    /// The `self_trade_prevention_mode` parameter.
2849    ///
2850    /// This field is **optional.
2851    #[builder(setter(into), default)]
2852    #[serde(rename = "selfTradePreventionMode", default)]
2853    pub self_trade_prevention_mode: Option<MarginAccountNewOtoSelfTradePreventionModeEnum>,
2854    /// Only when `MARGIN_BUY` order takes effect, true means that the debt generated by the order needs to be repaid after the order is cancelled.
2855    ///
2856    /// This field is **optional.
2857    #[builder(setter(into), default)]
2858    #[serde(rename = "autoRepayAtCancel", default)]
2859    pub auto_repay_at_cancel: Option<bool>,
2860    /// Arbitrary unique ID among open orders for the working order. Automatically generated if not sent.
2861    ///
2862    /// This field is **optional.
2863    #[builder(setter(into), default)]
2864    #[serde(rename = "workingClientOrderId", default)]
2865    pub working_client_order_id: Option<String>,
2866    ///
2867    /// The `working_time_in_force` parameter.
2868    ///
2869    /// This field is **optional.
2870    #[builder(setter(into), default)]
2871    #[serde(rename = "workingTimeInForce", default)]
2872    pub working_time_in_force: Option<MarginAccountNewOtoWorkingTimeInForceEnum>,
2873    /// Arbitrary unique ID among open orders for the pending order. Automatically generated if not sent.
2874    ///
2875    /// This field is **optional.
2876    #[builder(setter(into), default)]
2877    #[serde(rename = "pendingClientOrderId", default)]
2878    pub pending_client_order_id: Option<String>,
2879    ///
2880    /// The `pending_price` parameter.
2881    ///
2882    /// This field is **optional.
2883    #[builder(setter(into), default)]
2884    #[serde(rename = "pendingPrice", default)]
2885    pub pending_price: Option<rust_decimal::Decimal>,
2886    ///
2887    /// The `pending_stop_price` parameter.
2888    ///
2889    /// This field is **optional.
2890    #[builder(setter(into), default)]
2891    #[serde(rename = "pendingStopPrice", default)]
2892    pub pending_stop_price: Option<rust_decimal::Decimal>,
2893    ///
2894    /// The `pending_trailing_delta` parameter.
2895    ///
2896    /// This field is **optional.
2897    #[builder(setter(into), default)]
2898    #[serde(rename = "pendingTrailingDelta", default)]
2899    pub pending_trailing_delta: Option<rust_decimal::Decimal>,
2900    /// This can only be used if `pendingTimeInForce` is `GTC`.
2901    ///
2902    /// This field is **optional.
2903    #[builder(setter(into), default)]
2904    #[serde(rename = "pendingIcebergQty", default)]
2905    pub pending_iceberg_qty: Option<rust_decimal::Decimal>,
2906    ///
2907    /// The `pending_time_in_force` parameter.
2908    ///
2909    /// This field is **optional.
2910    #[builder(setter(into), default)]
2911    #[serde(rename = "pendingTimeInForce", default)]
2912    pub pending_time_in_force: Option<MarginAccountNewOtoPendingTimeInForceEnum>,
2913}
2914
2915impl MarginAccountNewOtoParams {
2916    /// Create a builder for [`margin_account_new_oto`].
2917    ///
2918    /// Required parameters:
2919    ///
2920    /// * `symbol` — String
2921    /// * `working_type` — String
2922    /// * `working_side` — String
2923    /// * `working_price` — `rust_decimal::Decimal`
2924    /// * `working_quantity` — Sets the quantity for the working order.
2925    /// * `working_iceberg_qty` — This can only be used if `workingTimeInForce` is `GTC`.
2926    /// * `pending_type` — String
2927    /// * `pending_side` — String
2928    /// * `pending_quantity` — Sets the quantity for the pending order.
2929    ///
2930    #[must_use]
2931    pub fn builder(
2932        symbol: String,
2933        working_type: MarginAccountNewOtoWorkingTypeEnum,
2934        working_side: MarginAccountNewOtoWorkingSideEnum,
2935        working_price: rust_decimal::Decimal,
2936        working_quantity: rust_decimal::Decimal,
2937        working_iceberg_qty: rust_decimal::Decimal,
2938        pending_type: MarginAccountNewOtoPendingTypeEnum,
2939        pending_side: MarginAccountNewOtoPendingSideEnum,
2940        pending_quantity: rust_decimal::Decimal,
2941    ) -> MarginAccountNewOtoParamsBuilder {
2942        MarginAccountNewOtoParamsBuilder::default()
2943            .symbol(symbol)
2944            .working_type(working_type)
2945            .working_side(working_side)
2946            .working_price(working_price)
2947            .working_quantity(working_quantity)
2948            .working_iceberg_qty(working_iceberg_qty)
2949            .pending_type(pending_type)
2950            .pending_side(pending_side)
2951            .pending_quantity(pending_quantity)
2952    }
2953}
2954/// Request parameters for the [`margin_account_new_otoco`] operation.
2955///
2956/// This struct holds all of the inputs you can pass when calling
2957/// [`margin_account_new_otoco`](#method.margin_account_new_otoco).
2958#[derive(Clone, Debug, Builder, Deserialize)]
2959#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
2960pub struct MarginAccountNewOtocoParams {
2961    ///
2962    /// The `symbol` parameter.
2963    ///
2964    /// This field is **required.
2965    #[builder(setter(into))]
2966    #[serde(rename = "symbol")]
2967    pub symbol: String,
2968    ///
2969    /// The `working_type` parameter.
2970    ///
2971    /// This field is **required.
2972    #[builder(setter(into))]
2973    #[serde(rename = "workingType")]
2974    pub working_type: MarginAccountNewOtocoWorkingTypeEnum,
2975    ///
2976    /// The `working_side` parameter.
2977    ///
2978    /// This field is **required.
2979    #[builder(setter(into))]
2980    #[serde(rename = "workingSide")]
2981    pub working_side: MarginAccountNewOtocoWorkingSideEnum,
2982    ///
2983    /// The `working_price` parameter.
2984    ///
2985    /// This field is **required.
2986    #[builder(setter(into))]
2987    #[serde(rename = "workingPrice")]
2988    pub working_price: rust_decimal::Decimal,
2989    ///
2990    /// The `working_quantity` parameter.
2991    ///
2992    /// This field is **required.
2993    #[builder(setter(into))]
2994    #[serde(rename = "workingQuantity")]
2995    pub working_quantity: rust_decimal::Decimal,
2996    ///
2997    /// The `pending_side` parameter.
2998    ///
2999    /// This field is **required.
3000    #[builder(setter(into))]
3001    #[serde(rename = "pendingSide")]
3002    pub pending_side: MarginAccountNewOtocoPendingSideEnum,
3003    ///
3004    /// The `pending_quantity` parameter.
3005    ///
3006    /// This field is **required.
3007    #[builder(setter(into))]
3008    #[serde(rename = "pendingQuantity")]
3009    pub pending_quantity: rust_decimal::Decimal,
3010    ///
3011    /// The `pending_above_type` parameter.
3012    ///
3013    /// This field is **required.
3014    #[builder(setter(into))]
3015    #[serde(rename = "pendingAboveType")]
3016    pub pending_above_type: MarginAccountNewOtocoPendingAboveTypeEnum,
3017    ///
3018    /// The `is_isolated` parameter.
3019    ///
3020    /// This field is **optional.
3021    #[builder(setter(into), default)]
3022    #[serde(rename = "isIsolated", default)]
3023    pub is_isolated: Option<MarginAccountNewOtocoIsIsolatedEnum>,
3024    ///
3025    /// The `side_effect_type` parameter.
3026    ///
3027    /// This field is **optional.
3028    #[builder(setter(into), default)]
3029    #[serde(rename = "sideEffectType", default)]
3030    pub side_effect_type: Option<MarginAccountNewOtocoSideEffectTypeEnum>,
3031    /// Only when `MARGIN_BUY` order takes effect, true means that the debt generated by the order needs to be repaid after the order is cancelled.
3032    ///
3033    /// This field is **optional.
3034    #[builder(setter(into), default)]
3035    #[serde(rename = "autoRepayAtCancel", default)]
3036    pub auto_repay_at_cancel: Option<bool>,
3037    /// Arbitrary unique ID among open order lists. Automatically generated if not sent. A new order list with the same listClientOrderId is accepted only when the previous one is filled or completely expired. `listClientOrderId` is distinct from the `workingClientOrderId`, `pendingAboveClientOrderId`, and the `pendingBelowClientOrderId`.
3038    ///
3039    /// This field is **optional.
3040    #[builder(setter(into), default)]
3041    #[serde(rename = "listClientOrderId", default)]
3042    pub list_client_order_id: Option<String>,
3043    ///
3044    /// The `new_order_resp_type` parameter.
3045    ///
3046    /// This field is **optional.
3047    #[builder(setter(into), default)]
3048    #[serde(rename = "newOrderRespType", default)]
3049    pub new_order_resp_type: Option<MarginAccountNewOtocoNewOrderRespTypeEnum>,
3050    ///
3051    /// The `self_trade_prevention_mode` parameter.
3052    ///
3053    /// This field is **optional.
3054    #[builder(setter(into), default)]
3055    #[serde(rename = "selfTradePreventionMode", default)]
3056    pub self_trade_prevention_mode: Option<MarginAccountNewOtocoSelfTradePreventionModeEnum>,
3057    /// Arbitrary unique ID among open orders for the working order. Automatically generated if not sent.
3058    ///
3059    /// This field is **optional.
3060    #[builder(setter(into), default)]
3061    #[serde(rename = "workingClientOrderId", default)]
3062    pub working_client_order_id: Option<String>,
3063    /// This can only be used if `workingTimeInForce` is `GTC`.
3064    ///
3065    /// This field is **optional.
3066    #[builder(setter(into), default)]
3067    #[serde(rename = "workingIcebergQty", default)]
3068    pub working_iceberg_qty: Option<rust_decimal::Decimal>,
3069    ///
3070    /// The `working_time_in_force` parameter.
3071    ///
3072    /// This field is **optional.
3073    #[builder(setter(into), default)]
3074    #[serde(rename = "workingTimeInForce", default)]
3075    pub working_time_in_force: Option<MarginAccountNewOtocoWorkingTimeInForceEnum>,
3076    /// Arbitrary unique ID among open orders for the pending above order. Automatically generated if not sent.
3077    ///
3078    /// This field is **optional.
3079    #[builder(setter(into), default)]
3080    #[serde(rename = "pendingAboveClientOrderId", default)]
3081    pub pending_above_client_order_id: Option<String>,
3082    ///
3083    /// The `pending_above_price` parameter.
3084    ///
3085    /// This field is **optional.
3086    #[builder(setter(into), default)]
3087    #[serde(rename = "pendingAbovePrice", default)]
3088    pub pending_above_price: Option<rust_decimal::Decimal>,
3089    ///
3090    /// The `pending_above_stop_price` parameter.
3091    ///
3092    /// This field is **optional.
3093    #[builder(setter(into), default)]
3094    #[serde(rename = "pendingAboveStopPrice", default)]
3095    pub pending_above_stop_price: Option<rust_decimal::Decimal>,
3096    ///
3097    /// The `pending_above_trailing_delta` parameter.
3098    ///
3099    /// This field is **optional.
3100    #[builder(setter(into), default)]
3101    #[serde(rename = "pendingAboveTrailingDelta", default)]
3102    pub pending_above_trailing_delta: Option<rust_decimal::Decimal>,
3103    /// This can only be used if `pendingAboveTimeInForce` is `GTC`.
3104    ///
3105    /// This field is **optional.
3106    #[builder(setter(into), default)]
3107    #[serde(rename = "pendingAboveIcebergQty", default)]
3108    pub pending_above_iceberg_qty: Option<rust_decimal::Decimal>,
3109    ///
3110    /// The `pending_above_time_in_force` parameter.
3111    ///
3112    /// This field is **optional.
3113    #[builder(setter(into), default)]
3114    #[serde(rename = "pendingAboveTimeInForce", default)]
3115    pub pending_above_time_in_force: Option<MarginAccountNewOtocoPendingAboveTimeInForceEnum>,
3116    ///
3117    /// The `pending_below_type` parameter.
3118    ///
3119    /// This field is **optional.
3120    #[builder(setter(into), default)]
3121    #[serde(rename = "pendingBelowType", default)]
3122    pub pending_below_type: Option<MarginAccountNewOtocoPendingBelowTypeEnum>,
3123    /// Arbitrary unique ID among open orders for the pending below order. Automatically generated if not sent.
3124    ///
3125    /// This field is **optional.
3126    #[builder(setter(into), default)]
3127    #[serde(rename = "pendingBelowClientOrderId", default)]
3128    pub pending_below_client_order_id: Option<String>,
3129    ///
3130    /// The `pending_below_price` parameter.
3131    ///
3132    /// This field is **optional.
3133    #[builder(setter(into), default)]
3134    #[serde(rename = "pendingBelowPrice", default)]
3135    pub pending_below_price: Option<rust_decimal::Decimal>,
3136    ///
3137    /// The `pending_below_stop_price` parameter.
3138    ///
3139    /// This field is **optional.
3140    #[builder(setter(into), default)]
3141    #[serde(rename = "pendingBelowStopPrice", default)]
3142    pub pending_below_stop_price: Option<rust_decimal::Decimal>,
3143    ///
3144    /// The `pending_below_trailing_delta` parameter.
3145    ///
3146    /// This field is **optional.
3147    #[builder(setter(into), default)]
3148    #[serde(rename = "pendingBelowTrailingDelta", default)]
3149    pub pending_below_trailing_delta: Option<rust_decimal::Decimal>,
3150    /// This can only be used if `pendingBelowTimeInForce` is `GTC`.
3151    ///
3152    /// This field is **optional.
3153    #[builder(setter(into), default)]
3154    #[serde(rename = "pendingBelowIcebergQty", default)]
3155    pub pending_below_iceberg_qty: Option<rust_decimal::Decimal>,
3156    ///
3157    /// The `pending_below_time_in_force` parameter.
3158    ///
3159    /// This field is **optional.
3160    #[builder(setter(into), default)]
3161    #[serde(rename = "pendingBelowTimeInForce", default)]
3162    pub pending_below_time_in_force: Option<MarginAccountNewOtocoPendingBelowTimeInForceEnum>,
3163}
3164
3165impl MarginAccountNewOtocoParams {
3166    /// Create a builder for [`margin_account_new_otoco`].
3167    ///
3168    /// Required parameters:
3169    ///
3170    /// * `symbol` — String
3171    /// * `working_type` — String
3172    /// * `working_side` — String
3173    /// * `working_price` — `rust_decimal::Decimal`
3174    /// * `working_quantity` — `rust_decimal::Decimal`
3175    /// * `pending_side` — String
3176    /// * `pending_quantity` — `rust_decimal::Decimal`
3177    /// * `pending_above_type` — String
3178    ///
3179    #[must_use]
3180    pub fn builder(
3181        symbol: String,
3182        working_type: MarginAccountNewOtocoWorkingTypeEnum,
3183        working_side: MarginAccountNewOtocoWorkingSideEnum,
3184        working_price: rust_decimal::Decimal,
3185        working_quantity: rust_decimal::Decimal,
3186        pending_side: MarginAccountNewOtocoPendingSideEnum,
3187        pending_quantity: rust_decimal::Decimal,
3188        pending_above_type: MarginAccountNewOtocoPendingAboveTypeEnum,
3189    ) -> MarginAccountNewOtocoParamsBuilder {
3190        MarginAccountNewOtocoParamsBuilder::default()
3191            .symbol(symbol)
3192            .working_type(working_type)
3193            .working_side(working_side)
3194            .working_price(working_price)
3195            .working_quantity(working_quantity)
3196            .pending_side(pending_side)
3197            .pending_quantity(pending_quantity)
3198            .pending_above_type(pending_above_type)
3199    }
3200}
3201/// Request parameters for the [`margin_manual_liquidation`] operation.
3202///
3203/// This struct holds all of the inputs you can pass when calling
3204/// [`margin_manual_liquidation`](#method.margin_manual_liquidation).
3205#[derive(Clone, Debug, Builder, Deserialize)]
3206#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3207pub struct MarginManualLiquidationParams {
3208    ///
3209    /// The `r#type` parameter.
3210    ///
3211    /// This field is **required.
3212    #[builder(setter(into))]
3213    #[serde(rename = "type")]
3214    pub r#type: MarginManualLiquidationTypeEnum,
3215    /// When type selects `ISOLATED`, `symbol` must be filled in
3216    ///
3217    /// This field is **optional.
3218    #[builder(setter(into), default)]
3219    #[serde(rename = "symbol", default)]
3220    pub symbol: Option<String>,
3221    ///
3222    /// The `recv_window` parameter.
3223    ///
3224    /// This field is **optional.
3225    #[builder(setter(into), default)]
3226    #[serde(rename = "recvWindow", default)]
3227    pub recv_window: Option<i64>,
3228}
3229
3230impl MarginManualLiquidationParams {
3231    /// Create a builder for [`margin_manual_liquidation`].
3232    ///
3233    /// Required parameters:
3234    ///
3235    /// * `r#type` — String
3236    ///
3237    #[must_use]
3238    pub fn builder(
3239        r#type: MarginManualLiquidationTypeEnum,
3240    ) -> MarginManualLiquidationParamsBuilder {
3241        MarginManualLiquidationParamsBuilder::default().r#type(r#type)
3242    }
3243}
3244/// Request parameters for the [`query_current_margin_order_count_usage`] operation.
3245///
3246/// This struct holds all of the inputs you can pass when calling
3247/// [`query_current_margin_order_count_usage`](#method.query_current_margin_order_count_usage).
3248#[derive(Clone, Debug, Builder, Deserialize, Default)]
3249#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3250pub struct QueryCurrentMarginOrderCountUsageParams {
3251    ///
3252    /// The `is_isolated` parameter.
3253    ///
3254    /// This field is **optional.
3255    #[builder(setter(into), default)]
3256    #[serde(rename = "isIsolated", default)]
3257    pub is_isolated: Option<QueryCurrentMarginOrderCountUsageIsIsolatedEnum>,
3258    ///
3259    /// The `symbol` parameter.
3260    ///
3261    /// This field is **optional.
3262    #[builder(setter(into), default)]
3263    #[serde(rename = "symbol", default)]
3264    pub symbol: Option<String>,
3265    ///
3266    /// The `recv_window` parameter.
3267    ///
3268    /// This field is **optional.
3269    #[builder(setter(into), default)]
3270    #[serde(rename = "recvWindow", default)]
3271    pub recv_window: Option<i64>,
3272}
3273
3274impl QueryCurrentMarginOrderCountUsageParams {
3275    /// Create a builder for [`query_current_margin_order_count_usage`].
3276    ///
3277    #[must_use]
3278    pub fn builder() -> QueryCurrentMarginOrderCountUsageParamsBuilder {
3279        QueryCurrentMarginOrderCountUsageParamsBuilder::default()
3280    }
3281}
3282/// Request parameters for the [`query_liquidation_loan`] operation.
3283///
3284/// This struct holds all of the inputs you can pass when calling
3285/// [`query_liquidation_loan`](#method.query_liquidation_loan).
3286#[derive(Clone, Debug, Builder, Deserialize, Default)]
3287#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3288pub struct QueryLiquidationLoanParams {
3289    ///
3290    /// The `recv_window` parameter.
3291    ///
3292    /// This field is **optional.
3293    #[builder(setter(into), default)]
3294    #[serde(rename = "recvWindow", default)]
3295    pub recv_window: Option<i64>,
3296}
3297
3298impl QueryLiquidationLoanParams {
3299    /// Create a builder for [`query_liquidation_loan`].
3300    ///
3301    #[must_use]
3302    pub fn builder() -> QueryLiquidationLoanParamsBuilder {
3303        QueryLiquidationLoanParamsBuilder::default()
3304    }
3305}
3306/// Request parameters for the [`query_liquidation_loan_repay_history`] operation.
3307///
3308/// This struct holds all of the inputs you can pass when calling
3309/// [`query_liquidation_loan_repay_history`](#method.query_liquidation_loan_repay_history).
3310#[derive(Clone, Debug, Builder, Deserialize, Default)]
3311#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3312pub struct QueryLiquidationLoanRepayHistoryParams {
3313    /// Start time in Unix timestamp (milliseconds). Defaults to 7 days ago if not specified
3314    ///
3315    /// This field is **optional.
3316    #[builder(setter(into), default)]
3317    #[serde(rename = "startTime", default)]
3318    pub start_time: Option<i64>,
3319    /// End time in Unix timestamp (milliseconds). Defaults to now if not specified
3320    ///
3321    /// This field is **optional.
3322    #[builder(setter(into), default)]
3323    #[serde(rename = "endTime", default)]
3324    pub end_time: Option<i64>,
3325    /// Current page number, default `1`
3326    ///
3327    /// This field is **optional.
3328    #[builder(setter(into), default)]
3329    #[serde(rename = "current", default)]
3330    pub current: Option<i64>,
3331    /// Page size, default `50`
3332    ///
3333    /// This field is **optional.
3334    #[builder(setter(into), default)]
3335    #[serde(rename = "size", default)]
3336    pub size: Option<i64>,
3337    ///
3338    /// The `recv_window` parameter.
3339    ///
3340    /// This field is **optional.
3341    #[builder(setter(into), default)]
3342    #[serde(rename = "recvWindow", default)]
3343    pub recv_window: Option<i64>,
3344}
3345
3346impl QueryLiquidationLoanRepayHistoryParams {
3347    /// Create a builder for [`query_liquidation_loan_repay_history`].
3348    ///
3349    #[must_use]
3350    pub fn builder() -> QueryLiquidationLoanRepayHistoryParamsBuilder {
3351        QueryLiquidationLoanRepayHistoryParamsBuilder::default()
3352    }
3353}
3354/// Request parameters for the [`query_margin_accounts_all_oco`] operation.
3355///
3356/// This struct holds all of the inputs you can pass when calling
3357/// [`query_margin_accounts_all_oco`](#method.query_margin_accounts_all_oco).
3358#[derive(Clone, Debug, Builder, Deserialize, Default)]
3359#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3360pub struct QueryMarginAccountsAllOcoParams {
3361    ///
3362    /// The `is_isolated` parameter.
3363    ///
3364    /// This field is **optional.
3365    #[builder(setter(into), default)]
3366    #[serde(rename = "isIsolated", default)]
3367    pub is_isolated: Option<QueryMarginAccountsAllOcoIsIsolatedEnum>,
3368    ///
3369    /// The `symbol` parameter.
3370    ///
3371    /// This field is **optional.
3372    #[builder(setter(into), default)]
3373    #[serde(rename = "symbol", default)]
3374    pub symbol: Option<String>,
3375    ///
3376    /// The `from_id` parameter.
3377    ///
3378    /// This field is **optional.
3379    #[builder(setter(into), default)]
3380    #[serde(rename = "fromId", default)]
3381    pub from_id: Option<i64>,
3382    ///
3383    /// The `start_time` parameter.
3384    ///
3385    /// This field is **optional.
3386    #[builder(setter(into), default)]
3387    #[serde(rename = "startTime", default)]
3388    pub start_time: Option<i64>,
3389    ///
3390    /// The `end_time` parameter.
3391    ///
3392    /// This field is **optional.
3393    #[builder(setter(into), default)]
3394    #[serde(rename = "endTime", default)]
3395    pub end_time: Option<i64>,
3396    ///
3397    /// The `limit` parameter.
3398    ///
3399    /// This field is **optional.
3400    #[builder(setter(into), default)]
3401    #[serde(rename = "limit", default)]
3402    pub limit: Option<i64>,
3403    ///
3404    /// The `recv_window` parameter.
3405    ///
3406    /// This field is **optional.
3407    #[builder(setter(into), default)]
3408    #[serde(rename = "recvWindow", default)]
3409    pub recv_window: Option<i64>,
3410}
3411
3412impl QueryMarginAccountsAllOcoParams {
3413    /// Create a builder for [`query_margin_accounts_all_oco`].
3414    ///
3415    #[must_use]
3416    pub fn builder() -> QueryMarginAccountsAllOcoParamsBuilder {
3417        QueryMarginAccountsAllOcoParamsBuilder::default()
3418    }
3419}
3420/// Request parameters for the [`query_margin_accounts_all_orders`] operation.
3421///
3422/// This struct holds all of the inputs you can pass when calling
3423/// [`query_margin_accounts_all_orders`](#method.query_margin_accounts_all_orders).
3424#[derive(Clone, Debug, Builder, Deserialize)]
3425#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3426pub struct QueryMarginAccountsAllOrdersParams {
3427    ///
3428    /// The `symbol` parameter.
3429    ///
3430    /// This field is **required.
3431    #[builder(setter(into))]
3432    #[serde(rename = "symbol")]
3433    pub symbol: String,
3434    ///
3435    /// The `is_isolated` parameter.
3436    ///
3437    /// This field is **optional.
3438    #[builder(setter(into), default)]
3439    #[serde(rename = "isIsolated", default)]
3440    pub is_isolated: Option<QueryMarginAccountsAllOrdersIsIsolatedEnum>,
3441    ///
3442    /// The `order_id` parameter.
3443    ///
3444    /// This field is **optional.
3445    #[builder(setter(into), default)]
3446    #[serde(rename = "orderId", default)]
3447    pub order_id: Option<i64>,
3448    ///
3449    /// The `start_time` parameter.
3450    ///
3451    /// This field is **optional.
3452    #[builder(setter(into), default)]
3453    #[serde(rename = "startTime", default)]
3454    pub start_time: Option<i64>,
3455    ///
3456    /// The `end_time` parameter.
3457    ///
3458    /// This field is **optional.
3459    #[builder(setter(into), default)]
3460    #[serde(rename = "endTime", default)]
3461    pub end_time: Option<i64>,
3462    ///
3463    /// The `limit` parameter.
3464    ///
3465    /// This field is **optional.
3466    #[builder(setter(into), default)]
3467    #[serde(rename = "limit", default)]
3468    pub limit: Option<i64>,
3469    ///
3470    /// The `recv_window` parameter.
3471    ///
3472    /// This field is **optional.
3473    #[builder(setter(into), default)]
3474    #[serde(rename = "recvWindow", default)]
3475    pub recv_window: Option<i64>,
3476}
3477
3478impl QueryMarginAccountsAllOrdersParams {
3479    /// Create a builder for [`query_margin_accounts_all_orders`].
3480    ///
3481    /// Required parameters:
3482    ///
3483    /// * `symbol` — String
3484    ///
3485    #[must_use]
3486    pub fn builder(symbol: String) -> QueryMarginAccountsAllOrdersParamsBuilder {
3487        QueryMarginAccountsAllOrdersParamsBuilder::default().symbol(symbol)
3488    }
3489}
3490/// Request parameters for the [`query_margin_accounts_oco`] operation.
3491///
3492/// This struct holds all of the inputs you can pass when calling
3493/// [`query_margin_accounts_oco`](#method.query_margin_accounts_oco).
3494#[derive(Clone, Debug, Builder, Deserialize, Default)]
3495#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3496pub struct QueryMarginAccountsOcoParams {
3497    ///
3498    /// The `is_isolated` parameter.
3499    ///
3500    /// This field is **optional.
3501    #[builder(setter(into), default)]
3502    #[serde(rename = "isIsolated", default)]
3503    pub is_isolated: Option<QueryMarginAccountsOcoIsIsolatedEnum>,
3504    ///
3505    /// The `symbol` parameter.
3506    ///
3507    /// This field is **optional.
3508    #[builder(setter(into), default)]
3509    #[serde(rename = "symbol", default)]
3510    pub symbol: Option<String>,
3511    ///
3512    /// The `order_list_id` parameter.
3513    ///
3514    /// This field is **optional.
3515    #[builder(setter(into), default)]
3516    #[serde(rename = "orderListId", default)]
3517    pub order_list_id: Option<i64>,
3518    ///
3519    /// The `orig_client_order_id` parameter.
3520    ///
3521    /// This field is **optional.
3522    #[builder(setter(into), default)]
3523    #[serde(rename = "origClientOrderId", default)]
3524    pub orig_client_order_id: Option<String>,
3525    ///
3526    /// The `recv_window` parameter.
3527    ///
3528    /// This field is **optional.
3529    #[builder(setter(into), default)]
3530    #[serde(rename = "recvWindow", default)]
3531    pub recv_window: Option<i64>,
3532}
3533
3534impl QueryMarginAccountsOcoParams {
3535    /// Create a builder for [`query_margin_accounts_oco`].
3536    ///
3537    #[must_use]
3538    pub fn builder() -> QueryMarginAccountsOcoParamsBuilder {
3539        QueryMarginAccountsOcoParamsBuilder::default()
3540    }
3541}
3542/// Request parameters for the [`query_margin_accounts_open_oco`] operation.
3543///
3544/// This struct holds all of the inputs you can pass when calling
3545/// [`query_margin_accounts_open_oco`](#method.query_margin_accounts_open_oco).
3546#[derive(Clone, Debug, Builder, Deserialize, Default)]
3547#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3548pub struct QueryMarginAccountsOpenOcoParams {
3549    ///
3550    /// The `is_isolated` parameter.
3551    ///
3552    /// This field is **optional.
3553    #[builder(setter(into), default)]
3554    #[serde(rename = "isIsolated", default)]
3555    pub is_isolated: Option<QueryMarginAccountsOpenOcoIsIsolatedEnum>,
3556    ///
3557    /// The `symbol` parameter.
3558    ///
3559    /// This field is **optional.
3560    #[builder(setter(into), default)]
3561    #[serde(rename = "symbol", default)]
3562    pub symbol: Option<String>,
3563    ///
3564    /// The `recv_window` parameter.
3565    ///
3566    /// This field is **optional.
3567    #[builder(setter(into), default)]
3568    #[serde(rename = "recvWindow", default)]
3569    pub recv_window: Option<i64>,
3570}
3571
3572impl QueryMarginAccountsOpenOcoParams {
3573    /// Create a builder for [`query_margin_accounts_open_oco`].
3574    ///
3575    #[must_use]
3576    pub fn builder() -> QueryMarginAccountsOpenOcoParamsBuilder {
3577        QueryMarginAccountsOpenOcoParamsBuilder::default()
3578    }
3579}
3580/// Request parameters for the [`query_margin_accounts_open_orders`] operation.
3581///
3582/// This struct holds all of the inputs you can pass when calling
3583/// [`query_margin_accounts_open_orders`](#method.query_margin_accounts_open_orders).
3584#[derive(Clone, Debug, Builder, Deserialize, Default)]
3585#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3586pub struct QueryMarginAccountsOpenOrdersParams {
3587    /// isolated margin pair
3588    ///
3589    /// This field is **optional.
3590    #[builder(setter(into), default)]
3591    #[serde(rename = "symbol", default)]
3592    pub symbol: Option<String>,
3593    ///
3594    /// The `is_isolated` parameter.
3595    ///
3596    /// This field is **optional.
3597    #[builder(setter(into), default)]
3598    #[serde(rename = "isIsolated", default)]
3599    pub is_isolated: Option<QueryMarginAccountsOpenOrdersIsIsolatedEnum>,
3600    ///
3601    /// The `recv_window` parameter.
3602    ///
3603    /// This field is **optional.
3604    #[builder(setter(into), default)]
3605    #[serde(rename = "recvWindow", default)]
3606    pub recv_window: Option<i64>,
3607}
3608
3609impl QueryMarginAccountsOpenOrdersParams {
3610    /// Create a builder for [`query_margin_accounts_open_orders`].
3611    ///
3612    #[must_use]
3613    pub fn builder() -> QueryMarginAccountsOpenOrdersParamsBuilder {
3614        QueryMarginAccountsOpenOrdersParamsBuilder::default()
3615    }
3616}
3617/// Request parameters for the [`query_margin_accounts_order`] operation.
3618///
3619/// This struct holds all of the inputs you can pass when calling
3620/// [`query_margin_accounts_order`](#method.query_margin_accounts_order).
3621#[derive(Clone, Debug, Builder, Deserialize)]
3622#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3623pub struct QueryMarginAccountsOrderParams {
3624    ///
3625    /// The `symbol` parameter.
3626    ///
3627    /// This field is **required.
3628    #[builder(setter(into))]
3629    #[serde(rename = "symbol")]
3630    pub symbol: String,
3631    ///
3632    /// The `is_isolated` parameter.
3633    ///
3634    /// This field is **optional.
3635    #[builder(setter(into), default)]
3636    #[serde(rename = "isIsolated", default)]
3637    pub is_isolated: Option<QueryMarginAccountsOrderIsIsolatedEnum>,
3638    ///
3639    /// The `order_id` parameter.
3640    ///
3641    /// This field is **optional.
3642    #[builder(setter(into), default)]
3643    #[serde(rename = "orderId", default)]
3644    pub order_id: Option<i64>,
3645    ///
3646    /// The `orig_client_order_id` parameter.
3647    ///
3648    /// This field is **optional.
3649    #[builder(setter(into), default)]
3650    #[serde(rename = "origClientOrderId", default)]
3651    pub orig_client_order_id: Option<String>,
3652    ///
3653    /// The `recv_window` parameter.
3654    ///
3655    /// This field is **optional.
3656    #[builder(setter(into), default)]
3657    #[serde(rename = "recvWindow", default)]
3658    pub recv_window: Option<i64>,
3659}
3660
3661impl QueryMarginAccountsOrderParams {
3662    /// Create a builder for [`query_margin_accounts_order`].
3663    ///
3664    /// Required parameters:
3665    ///
3666    /// * `symbol` — String
3667    ///
3668    #[must_use]
3669    pub fn builder(symbol: String) -> QueryMarginAccountsOrderParamsBuilder {
3670        QueryMarginAccountsOrderParamsBuilder::default().symbol(symbol)
3671    }
3672}
3673/// Request parameters for the [`query_margin_accounts_trade_list`] operation.
3674///
3675/// This struct holds all of the inputs you can pass when calling
3676/// [`query_margin_accounts_trade_list`](#method.query_margin_accounts_trade_list).
3677#[derive(Clone, Debug, Builder, Deserialize)]
3678#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3679pub struct QueryMarginAccountsTradeListParams {
3680    ///
3681    /// The `symbol` parameter.
3682    ///
3683    /// This field is **required.
3684    #[builder(setter(into))]
3685    #[serde(rename = "symbol")]
3686    pub symbol: String,
3687    ///
3688    /// The `is_isolated` parameter.
3689    ///
3690    /// This field is **optional.
3691    #[builder(setter(into), default)]
3692    #[serde(rename = "isIsolated", default)]
3693    pub is_isolated: Option<QueryMarginAccountsTradeListIsIsolatedEnum>,
3694    ///
3695    /// The `order_id` parameter.
3696    ///
3697    /// This field is **optional.
3698    #[builder(setter(into), default)]
3699    #[serde(rename = "orderId", default)]
3700    pub order_id: Option<i64>,
3701    ///
3702    /// The `start_time` parameter.
3703    ///
3704    /// This field is **optional.
3705    #[builder(setter(into), default)]
3706    #[serde(rename = "startTime", default)]
3707    pub start_time: Option<i64>,
3708    ///
3709    /// The `end_time` parameter.
3710    ///
3711    /// This field is **optional.
3712    #[builder(setter(into), default)]
3713    #[serde(rename = "endTime", default)]
3714    pub end_time: Option<i64>,
3715    ///
3716    /// The `from_id` parameter.
3717    ///
3718    /// This field is **optional.
3719    #[builder(setter(into), default)]
3720    #[serde(rename = "fromId", default)]
3721    pub from_id: Option<i64>,
3722    ///
3723    /// The `limit` parameter.
3724    ///
3725    /// This field is **optional.
3726    #[builder(setter(into), default)]
3727    #[serde(rename = "limit", default)]
3728    pub limit: Option<i64>,
3729    ///
3730    /// The `recv_window` parameter.
3731    ///
3732    /// This field is **optional.
3733    #[builder(setter(into), default)]
3734    #[serde(rename = "recvWindow", default)]
3735    pub recv_window: Option<i64>,
3736}
3737
3738impl QueryMarginAccountsTradeListParams {
3739    /// Create a builder for [`query_margin_accounts_trade_list`].
3740    ///
3741    /// Required parameters:
3742    ///
3743    /// * `symbol` — String
3744    ///
3745    #[must_use]
3746    pub fn builder(symbol: String) -> QueryMarginAccountsTradeListParamsBuilder {
3747        QueryMarginAccountsTradeListParamsBuilder::default().symbol(symbol)
3748    }
3749}
3750/// Request parameters for the [`query_prevented_matches`] operation.
3751///
3752/// This struct holds all of the inputs you can pass when calling
3753/// [`query_prevented_matches`](#method.query_prevented_matches).
3754#[derive(Clone, Debug, Builder, Deserialize)]
3755#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3756pub struct QueryPreventedMatchesParams {
3757    ///
3758    /// The `symbol` parameter.
3759    ///
3760    /// This field is **required.
3761    #[builder(setter(into))]
3762    #[serde(rename = "symbol")]
3763    pub symbol: String,
3764    ///
3765    /// The `prevented_match_id` parameter.
3766    ///
3767    /// This field is **optional.
3768    #[builder(setter(into), default)]
3769    #[serde(rename = "preventedMatchId", default)]
3770    pub prevented_match_id: Option<i64>,
3771    ///
3772    /// The `order_id` parameter.
3773    ///
3774    /// This field is **optional.
3775    #[builder(setter(into), default)]
3776    #[serde(rename = "orderId", default)]
3777    pub order_id: Option<i64>,
3778    ///
3779    /// The `from_prevented_match_id` parameter.
3780    ///
3781    /// This field is **optional.
3782    #[builder(setter(into), default)]
3783    #[serde(rename = "fromPreventedMatchId", default)]
3784    pub from_prevented_match_id: Option<i64>,
3785    ///
3786    /// The `is_isolated` parameter.
3787    ///
3788    /// This field is **optional.
3789    #[builder(setter(into), default)]
3790    #[serde(rename = "isIsolated", default)]
3791    pub is_isolated: Option<QueryPreventedMatchesIsIsolatedEnum>,
3792    ///
3793    /// The `recv_window` parameter.
3794    ///
3795    /// This field is **optional.
3796    #[builder(setter(into), default)]
3797    #[serde(rename = "recvWindow", default)]
3798    pub recv_window: Option<i64>,
3799}
3800
3801impl QueryPreventedMatchesParams {
3802    /// Create a builder for [`query_prevented_matches`].
3803    ///
3804    /// Required parameters:
3805    ///
3806    /// * `symbol` — String
3807    ///
3808    #[must_use]
3809    pub fn builder(symbol: String) -> QueryPreventedMatchesParamsBuilder {
3810        QueryPreventedMatchesParamsBuilder::default().symbol(symbol)
3811    }
3812}
3813/// Request parameters for the [`query_special_key`] operation.
3814///
3815/// This struct holds all of the inputs you can pass when calling
3816/// [`query_special_key`](#method.query_special_key).
3817#[derive(Clone, Debug, Builder, Deserialize, Default)]
3818#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3819pub struct QuerySpecialKeyParams {
3820    ///
3821    /// The `symbol` parameter.
3822    ///
3823    /// This field is **optional.
3824    #[builder(setter(into), default)]
3825    #[serde(rename = "symbol", default)]
3826    pub symbol: Option<String>,
3827    ///
3828    /// The `recv_window` parameter.
3829    ///
3830    /// This field is **optional.
3831    #[builder(setter(into), default)]
3832    #[serde(rename = "recvWindow", default)]
3833    pub recv_window: Option<i64>,
3834}
3835
3836impl QuerySpecialKeyParams {
3837    /// Create a builder for [`query_special_key`].
3838    ///
3839    #[must_use]
3840    pub fn builder() -> QuerySpecialKeyParamsBuilder {
3841        QuerySpecialKeyParamsBuilder::default()
3842    }
3843}
3844/// Request parameters for the [`query_special_key_list`] operation.
3845///
3846/// This struct holds all of the inputs you can pass when calling
3847/// [`query_special_key_list`](#method.query_special_key_list).
3848#[derive(Clone, Debug, Builder, Deserialize, Default)]
3849#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3850pub struct QuerySpecialKeyListParams {
3851    ///
3852    /// The `symbol` parameter.
3853    ///
3854    /// This field is **optional.
3855    #[builder(setter(into), default)]
3856    #[serde(rename = "symbol", default)]
3857    pub symbol: Option<String>,
3858    ///
3859    /// The `recv_window` parameter.
3860    ///
3861    /// This field is **optional.
3862    #[builder(setter(into), default)]
3863    #[serde(rename = "recvWindow", default)]
3864    pub recv_window: Option<i64>,
3865}
3866
3867impl QuerySpecialKeyListParams {
3868    /// Create a builder for [`query_special_key_list`].
3869    ///
3870    #[must_use]
3871    pub fn builder() -> QuerySpecialKeyListParamsBuilder {
3872        QuerySpecialKeyListParamsBuilder::default()
3873    }
3874}
3875/// Request parameters for the [`small_liability_exchange`] operation.
3876///
3877/// This struct holds all of the inputs you can pass when calling
3878/// [`small_liability_exchange`](#method.small_liability_exchange).
3879#[derive(Clone, Debug, Builder, Deserialize)]
3880#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
3881pub struct SmallLiabilityExchangeParams {
3882    /// The assets list of small liability exchange
3883    ///
3884    /// This field is **required.
3885    #[builder(setter(into))]
3886    #[serde(rename = "assetNames")]
3887    pub asset_names: String,
3888    ///
3889    /// The `recv_window` parameter.
3890    ///
3891    /// This field is **optional.
3892    #[builder(setter(into), default)]
3893    #[serde(rename = "recvWindow", default)]
3894    pub recv_window: Option<i64>,
3895}
3896
3897impl SmallLiabilityExchangeParams {
3898    /// Create a builder for [`small_liability_exchange`].
3899    ///
3900    /// Required parameters:
3901    ///
3902    /// * `asset_names` — The assets list of small liability exchange
3903    ///
3904    #[must_use]
3905    pub fn builder(asset_names: String) -> SmallLiabilityExchangeParamsBuilder {
3906        SmallLiabilityExchangeParamsBuilder::default().asset_names(asset_names)
3907    }
3908}
3909
3910#[async_trait]
3911impl TradeApi for TradeApiClient {
3912    async fn create_special_key(
3913        &self,
3914        params: CreateSpecialKeyParams,
3915    ) -> anyhow::Result<RestApiResponse<models::CreateSpecialKeyResponse>> {
3916        let CreateSpecialKeyParams {
3917            api_name,
3918            symbol,
3919            ip,
3920            public_key,
3921            permission_mode,
3922            recv_window,
3923        } = params;
3924
3925        let mut query_params = BTreeMap::new();
3926        let body_params = BTreeMap::new();
3927
3928        query_params.insert("apiName".to_string(), json!(api_name));
3929
3930        if let Some(rw) = symbol {
3931            query_params.insert("symbol".to_string(), json!(rw));
3932        }
3933
3934        if let Some(rw) = ip {
3935            query_params.insert("ip".to_string(), json!(rw));
3936        }
3937
3938        if let Some(rw) = public_key {
3939            query_params.insert("publicKey".to_string(), json!(rw));
3940        }
3941
3942        if let Some(rw) = permission_mode {
3943            query_params.insert("permissionMode".to_string(), json!(rw));
3944        }
3945
3946        if let Some(rw) = recv_window {
3947            query_params.insert("recvWindow".to_string(), json!(rw));
3948        }
3949
3950        send_request::<models::CreateSpecialKeyResponse>(
3951            &self.configuration,
3952            "/sapi/v1/margin/apiKey",
3953            reqwest::Method::POST,
3954            query_params,
3955            body_params,
3956            if HAS_TIME_UNIT {
3957                self.configuration.time_unit
3958            } else {
3959                None
3960            },
3961            true,
3962        )
3963        .await
3964    }
3965
3966    async fn delete_special_key(
3967        &self,
3968        params: DeleteSpecialKeyParams,
3969    ) -> anyhow::Result<RestApiResponse<Value>> {
3970        let DeleteSpecialKeyParams {
3971            api_name,
3972            symbol,
3973            recv_window,
3974        } = params;
3975
3976        let mut query_params = BTreeMap::new();
3977        let body_params = BTreeMap::new();
3978
3979        if let Some(rw) = api_name {
3980            query_params.insert("apiName".to_string(), json!(rw));
3981        }
3982
3983        if let Some(rw) = symbol {
3984            query_params.insert("symbol".to_string(), json!(rw));
3985        }
3986
3987        if let Some(rw) = recv_window {
3988            query_params.insert("recvWindow".to_string(), json!(rw));
3989        }
3990
3991        send_request::<Value>(
3992            &self.configuration,
3993            "/sapi/v1/margin/apiKey",
3994            reqwest::Method::DELETE,
3995            query_params,
3996            body_params,
3997            if HAS_TIME_UNIT {
3998                self.configuration.time_unit
3999            } else {
4000                None
4001            },
4002            true,
4003        )
4004        .await
4005    }
4006
4007    async fn edit_ip_for_special_key(
4008        &self,
4009        params: EditIpForSpecialKeyParams,
4010    ) -> anyhow::Result<RestApiResponse<Value>> {
4011        let EditIpForSpecialKeyParams {
4012            ip,
4013            symbol,
4014            recv_window,
4015        } = params;
4016
4017        let mut query_params = BTreeMap::new();
4018        let body_params = BTreeMap::new();
4019
4020        if let Some(rw) = symbol {
4021            query_params.insert("symbol".to_string(), json!(rw));
4022        }
4023
4024        query_params.insert("ip".to_string(), json!(ip));
4025
4026        if let Some(rw) = recv_window {
4027            query_params.insert("recvWindow".to_string(), json!(rw));
4028        }
4029
4030        send_request::<Value>(
4031            &self.configuration,
4032            "/sapi/v1/margin/apiKey/ip",
4033            reqwest::Method::PUT,
4034            query_params,
4035            body_params,
4036            if HAS_TIME_UNIT {
4037                self.configuration.time_unit
4038            } else {
4039                None
4040            },
4041            true,
4042        )
4043        .await
4044    }
4045
4046    async fn exit_special_key_mode(
4047        &self,
4048        params: ExitSpecialKeyModeParams,
4049    ) -> anyhow::Result<RestApiResponse<serde_json::Value>> {
4050        let ExitSpecialKeyModeParams { recv_window } = params;
4051
4052        let mut query_params = BTreeMap::new();
4053        let body_params = BTreeMap::new();
4054
4055        if let Some(rw) = recv_window {
4056            query_params.insert("recvWindow".to_string(), json!(rw));
4057        }
4058
4059        send_request::<serde_json::Value>(
4060            &self.configuration,
4061            "/sapi/v1/margin/exit-special-key-mode",
4062            reqwest::Method::POST,
4063            query_params,
4064            body_params,
4065            if HAS_TIME_UNIT {
4066                self.configuration.time_unit
4067            } else {
4068                None
4069            },
4070            true,
4071        )
4072        .await
4073    }
4074
4075    async fn get_force_liquidation_record(
4076        &self,
4077        params: GetForceLiquidationRecordParams,
4078    ) -> anyhow::Result<RestApiResponse<models::GetForceLiquidationRecordResponse>> {
4079        let GetForceLiquidationRecordParams {
4080            start_time,
4081            end_time,
4082            isolated_symbol,
4083            current,
4084            size,
4085            recv_window,
4086        } = params;
4087
4088        let mut query_params = BTreeMap::new();
4089        let body_params = BTreeMap::new();
4090
4091        if let Some(rw) = start_time {
4092            query_params.insert("startTime".to_string(), json!(rw));
4093        }
4094
4095        if let Some(rw) = end_time {
4096            query_params.insert("endTime".to_string(), json!(rw));
4097        }
4098
4099        if let Some(rw) = isolated_symbol {
4100            query_params.insert("isolatedSymbol".to_string(), json!(rw));
4101        }
4102
4103        if let Some(rw) = current {
4104            query_params.insert("current".to_string(), json!(rw));
4105        }
4106
4107        if let Some(rw) = size {
4108            query_params.insert("size".to_string(), json!(rw));
4109        }
4110
4111        if let Some(rw) = recv_window {
4112            query_params.insert("recvWindow".to_string(), json!(rw));
4113        }
4114
4115        send_request::<models::GetForceLiquidationRecordResponse>(
4116            &self.configuration,
4117            "/sapi/v1/margin/forceLiquidationRec",
4118            reqwest::Method::GET,
4119            query_params,
4120            body_params,
4121            if HAS_TIME_UNIT {
4122                self.configuration.time_unit
4123            } else {
4124                None
4125            },
4126            true,
4127        )
4128        .await
4129    }
4130
4131    async fn get_small_liability_exchange_coin_list(
4132        &self,
4133        params: GetSmallLiabilityExchangeCoinListParams,
4134    ) -> anyhow::Result<RestApiResponse<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>>
4135    {
4136        let GetSmallLiabilityExchangeCoinListParams { recv_window } = params;
4137
4138        let mut query_params = BTreeMap::new();
4139        let body_params = BTreeMap::new();
4140
4141        if let Some(rw) = recv_window {
4142            query_params.insert("recvWindow".to_string(), json!(rw));
4143        }
4144
4145        send_request::<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>(
4146            &self.configuration,
4147            "/sapi/v1/margin/exchange-small-liability",
4148            reqwest::Method::GET,
4149            query_params,
4150            body_params,
4151            if HAS_TIME_UNIT {
4152                self.configuration.time_unit
4153            } else {
4154                None
4155            },
4156            true,
4157        )
4158        .await
4159    }
4160
4161    async fn get_small_liability_exchange_history(
4162        &self,
4163        params: GetSmallLiabilityExchangeHistoryParams,
4164    ) -> anyhow::Result<RestApiResponse<models::GetSmallLiabilityExchangeHistoryResponse>> {
4165        let GetSmallLiabilityExchangeHistoryParams {
4166            current,
4167            size,
4168            start_time,
4169            end_time,
4170            recv_window,
4171        } = params;
4172
4173        let mut query_params = BTreeMap::new();
4174        let body_params = BTreeMap::new();
4175
4176        query_params.insert("current".to_string(), json!(current));
4177
4178        query_params.insert("size".to_string(), json!(size));
4179
4180        if let Some(rw) = start_time {
4181            query_params.insert("startTime".to_string(), json!(rw));
4182        }
4183
4184        if let Some(rw) = end_time {
4185            query_params.insert("endTime".to_string(), json!(rw));
4186        }
4187
4188        if let Some(rw) = recv_window {
4189            query_params.insert("recvWindow".to_string(), json!(rw));
4190        }
4191
4192        send_request::<models::GetSmallLiabilityExchangeHistoryResponse>(
4193            &self.configuration,
4194            "/sapi/v1/margin/exchange-small-liability-history",
4195            reqwest::Method::GET,
4196            query_params,
4197            body_params,
4198            if HAS_TIME_UNIT {
4199                self.configuration.time_unit
4200            } else {
4201                None
4202            },
4203            true,
4204        )
4205        .await
4206    }
4207
4208    async fn liquidation_loan_repay(
4209        &self,
4210        params: LiquidationLoanRepayParams,
4211    ) -> anyhow::Result<RestApiResponse<models::LiquidationLoanRepayResponse>> {
4212        let LiquidationLoanRepayParams {
4213            asset,
4214            amount,
4215            recv_window,
4216        } = params;
4217
4218        let mut query_params = BTreeMap::new();
4219        let body_params = BTreeMap::new();
4220
4221        query_params.insert("asset".to_string(), json!(asset));
4222
4223        query_params.insert("amount".to_string(), json!(amount));
4224
4225        if let Some(rw) = recv_window {
4226            query_params.insert("recvWindow".to_string(), json!(rw));
4227        }
4228
4229        send_request::<models::LiquidationLoanRepayResponse>(
4230            &self.configuration,
4231            "/sapi/v1/margin/liquidation-loan/repay",
4232            reqwest::Method::POST,
4233            query_params,
4234            body_params,
4235            if HAS_TIME_UNIT {
4236                self.configuration.time_unit
4237            } else {
4238                None
4239            },
4240            true,
4241        )
4242        .await
4243    }
4244
4245    async fn margin_account_cancel_all_open_orders_on_a_symbol(
4246        &self,
4247        params: MarginAccountCancelAllOpenOrdersOnASymbolParams,
4248    ) -> anyhow::Result<
4249        RestApiResponse<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>,
4250    > {
4251        let MarginAccountCancelAllOpenOrdersOnASymbolParams {
4252            symbol,
4253            is_isolated,
4254            recv_window,
4255        } = params;
4256
4257        let mut query_params = BTreeMap::new();
4258        let body_params = BTreeMap::new();
4259
4260        query_params.insert("symbol".to_string(), json!(symbol));
4261
4262        if let Some(rw) = is_isolated {
4263            query_params.insert("isIsolated".to_string(), json!(rw));
4264        }
4265
4266        if let Some(rw) = recv_window {
4267            query_params.insert("recvWindow".to_string(), json!(rw));
4268        }
4269
4270        send_request::<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>(
4271            &self.configuration,
4272            "/sapi/v1/margin/openOrders",
4273            reqwest::Method::DELETE,
4274            query_params,
4275            body_params,
4276            if HAS_TIME_UNIT {
4277                self.configuration.time_unit
4278            } else {
4279                None
4280            },
4281            true,
4282        )
4283        .await
4284    }
4285
4286    async fn margin_account_cancel_oco(
4287        &self,
4288        params: MarginAccountCancelOcoParams,
4289    ) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOcoResponse>> {
4290        let MarginAccountCancelOcoParams {
4291            symbol,
4292            is_isolated,
4293            order_list_id,
4294            list_client_order_id,
4295            new_client_order_id,
4296            recv_window,
4297        } = params;
4298
4299        let mut query_params = BTreeMap::new();
4300        let body_params = BTreeMap::new();
4301
4302        query_params.insert("symbol".to_string(), json!(symbol));
4303
4304        if let Some(rw) = is_isolated {
4305            query_params.insert("isIsolated".to_string(), json!(rw));
4306        }
4307
4308        if let Some(rw) = order_list_id {
4309            query_params.insert("orderListId".to_string(), json!(rw));
4310        }
4311
4312        if let Some(rw) = list_client_order_id {
4313            query_params.insert("listClientOrderId".to_string(), json!(rw));
4314        }
4315
4316        if let Some(rw) = new_client_order_id {
4317            query_params.insert("newClientOrderId".to_string(), json!(rw));
4318        }
4319
4320        if let Some(rw) = recv_window {
4321            query_params.insert("recvWindow".to_string(), json!(rw));
4322        }
4323
4324        send_request::<models::MarginAccountCancelOcoResponse>(
4325            &self.configuration,
4326            "/sapi/v1/margin/orderList",
4327            reqwest::Method::DELETE,
4328            query_params,
4329            body_params,
4330            if HAS_TIME_UNIT {
4331                self.configuration.time_unit
4332            } else {
4333                None
4334            },
4335            true,
4336        )
4337        .await
4338    }
4339
4340    async fn margin_account_cancel_order(
4341        &self,
4342        params: MarginAccountCancelOrderParams,
4343    ) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOrderResponse>> {
4344        let MarginAccountCancelOrderParams {
4345            symbol,
4346            is_isolated,
4347            order_id,
4348            orig_client_order_id,
4349            new_client_order_id,
4350            recv_window,
4351        } = params;
4352
4353        let mut query_params = BTreeMap::new();
4354        let body_params = BTreeMap::new();
4355
4356        query_params.insert("symbol".to_string(), json!(symbol));
4357
4358        if let Some(rw) = is_isolated {
4359            query_params.insert("isIsolated".to_string(), json!(rw));
4360        }
4361
4362        if let Some(rw) = order_id {
4363            query_params.insert("orderId".to_string(), json!(rw));
4364        }
4365
4366        if let Some(rw) = orig_client_order_id {
4367            query_params.insert("origClientOrderId".to_string(), json!(rw));
4368        }
4369
4370        if let Some(rw) = new_client_order_id {
4371            query_params.insert("newClientOrderId".to_string(), json!(rw));
4372        }
4373
4374        if let Some(rw) = recv_window {
4375            query_params.insert("recvWindow".to_string(), json!(rw));
4376        }
4377
4378        send_request::<models::MarginAccountCancelOrderResponse>(
4379            &self.configuration,
4380            "/sapi/v1/margin/order",
4381            reqwest::Method::DELETE,
4382            query_params,
4383            body_params,
4384            if HAS_TIME_UNIT {
4385                self.configuration.time_unit
4386            } else {
4387                None
4388            },
4389            true,
4390        )
4391        .await
4392    }
4393
4394    async fn margin_account_new_oco(
4395        &self,
4396        params: MarginAccountNewOcoParams,
4397    ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOcoResponse>> {
4398        let MarginAccountNewOcoParams {
4399            symbol,
4400            side,
4401            quantity,
4402            price,
4403            stop_price,
4404            is_isolated,
4405            list_client_order_id,
4406            limit_client_order_id,
4407            limit_iceberg_qty,
4408            stop_client_order_id,
4409            stop_limit_price,
4410            stop_iceberg_qty,
4411            stop_limit_time_in_force,
4412            new_order_resp_type,
4413            side_effect_type,
4414            self_trade_prevention_mode,
4415            auto_repay_at_cancel,
4416            recv_window,
4417        } = params;
4418
4419        let mut query_params = BTreeMap::new();
4420        let body_params = BTreeMap::new();
4421
4422        query_params.insert("symbol".to_string(), json!(symbol));
4423
4424        if let Some(rw) = is_isolated {
4425            query_params.insert("isIsolated".to_string(), json!(rw));
4426        }
4427
4428        if let Some(rw) = list_client_order_id {
4429            query_params.insert("listClientOrderId".to_string(), json!(rw));
4430        }
4431
4432        query_params.insert("side".to_string(), json!(side));
4433
4434        query_params.insert("quantity".to_string(), json!(quantity));
4435
4436        if let Some(rw) = limit_client_order_id {
4437            query_params.insert("limitClientOrderId".to_string(), json!(rw));
4438        }
4439
4440        query_params.insert("price".to_string(), json!(price));
4441
4442        if let Some(rw) = limit_iceberg_qty {
4443            query_params.insert("limitIcebergQty".to_string(), json!(rw));
4444        }
4445
4446        if let Some(rw) = stop_client_order_id {
4447            query_params.insert("stopClientOrderId".to_string(), json!(rw));
4448        }
4449
4450        query_params.insert("stopPrice".to_string(), json!(stop_price));
4451
4452        if let Some(rw) = stop_limit_price {
4453            query_params.insert("stopLimitPrice".to_string(), json!(rw));
4454        }
4455
4456        if let Some(rw) = stop_iceberg_qty {
4457            query_params.insert("stopIcebergQty".to_string(), json!(rw));
4458        }
4459
4460        if let Some(rw) = stop_limit_time_in_force {
4461            query_params.insert("stopLimitTimeInForce".to_string(), json!(rw));
4462        }
4463
4464        if let Some(rw) = new_order_resp_type {
4465            query_params.insert("newOrderRespType".to_string(), json!(rw));
4466        }
4467
4468        if let Some(rw) = side_effect_type {
4469            query_params.insert("sideEffectType".to_string(), json!(rw));
4470        }
4471
4472        if let Some(rw) = self_trade_prevention_mode {
4473            query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
4474        }
4475
4476        if let Some(rw) = auto_repay_at_cancel {
4477            query_params.insert("autoRepayAtCancel".to_string(), json!(rw));
4478        }
4479
4480        if let Some(rw) = recv_window {
4481            query_params.insert("recvWindow".to_string(), json!(rw));
4482        }
4483
4484        send_request::<models::MarginAccountNewOcoResponse>(
4485            &self.configuration,
4486            "/sapi/v1/margin/order/oco",
4487            reqwest::Method::POST,
4488            query_params,
4489            body_params,
4490            if HAS_TIME_UNIT {
4491                self.configuration.time_unit
4492            } else {
4493                None
4494            },
4495            true,
4496        )
4497        .await
4498    }
4499
4500    async fn margin_account_new_order(
4501        &self,
4502        params: MarginAccountNewOrderParams,
4503    ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOrderResponse>> {
4504        let MarginAccountNewOrderParams {
4505            symbol,
4506            side,
4507            r#type,
4508            is_isolated,
4509            quantity,
4510            quote_order_qty,
4511            price,
4512            stop_price,
4513            new_client_order_id,
4514            iceberg_qty,
4515            new_order_resp_type,
4516            side_effect_type,
4517            time_in_force,
4518            self_trade_prevention_mode,
4519            trailing_delta,
4520            auto_repay_at_cancel,
4521            recv_window,
4522        } = params;
4523
4524        let mut query_params = BTreeMap::new();
4525        let body_params = BTreeMap::new();
4526
4527        query_params.insert("symbol".to_string(), json!(symbol));
4528
4529        if let Some(rw) = is_isolated {
4530            query_params.insert("isIsolated".to_string(), json!(rw));
4531        }
4532
4533        query_params.insert("side".to_string(), json!(side));
4534
4535        query_params.insert("type".to_string(), json!(r#type));
4536
4537        if let Some(rw) = quantity {
4538            query_params.insert("quantity".to_string(), json!(rw));
4539        }
4540
4541        if let Some(rw) = quote_order_qty {
4542            query_params.insert("quoteOrderQty".to_string(), json!(rw));
4543        }
4544
4545        if let Some(rw) = price {
4546            query_params.insert("price".to_string(), json!(rw));
4547        }
4548
4549        if let Some(rw) = stop_price {
4550            query_params.insert("stopPrice".to_string(), json!(rw));
4551        }
4552
4553        if let Some(rw) = new_client_order_id {
4554            query_params.insert("newClientOrderId".to_string(), json!(rw));
4555        }
4556
4557        if let Some(rw) = iceberg_qty {
4558            query_params.insert("icebergQty".to_string(), json!(rw));
4559        }
4560
4561        if let Some(rw) = new_order_resp_type {
4562            query_params.insert("newOrderRespType".to_string(), json!(rw));
4563        }
4564
4565        if let Some(rw) = side_effect_type {
4566            query_params.insert("sideEffectType".to_string(), json!(rw));
4567        }
4568
4569        if let Some(rw) = time_in_force {
4570            query_params.insert("timeInForce".to_string(), json!(rw));
4571        }
4572
4573        if let Some(rw) = self_trade_prevention_mode {
4574            query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
4575        }
4576
4577        if let Some(rw) = trailing_delta {
4578            query_params.insert("trailingDelta".to_string(), json!(rw));
4579        }
4580
4581        if let Some(rw) = auto_repay_at_cancel {
4582            query_params.insert("autoRepayAtCancel".to_string(), json!(rw));
4583        }
4584
4585        if let Some(rw) = recv_window {
4586            query_params.insert("recvWindow".to_string(), json!(rw));
4587        }
4588
4589        send_request::<models::MarginAccountNewOrderResponse>(
4590            &self.configuration,
4591            "/sapi/v1/margin/order",
4592            reqwest::Method::POST,
4593            query_params,
4594            body_params,
4595            if HAS_TIME_UNIT {
4596                self.configuration.time_unit
4597            } else {
4598                None
4599            },
4600            true,
4601        )
4602        .await
4603    }
4604
4605    async fn margin_account_new_oto(
4606        &self,
4607        params: MarginAccountNewOtoParams,
4608    ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtoResponse>> {
4609        let MarginAccountNewOtoParams {
4610            symbol,
4611            working_type,
4612            working_side,
4613            working_price,
4614            working_quantity,
4615            working_iceberg_qty,
4616            pending_type,
4617            pending_side,
4618            pending_quantity,
4619            is_isolated,
4620            list_client_order_id,
4621            new_order_resp_type,
4622            side_effect_type,
4623            self_trade_prevention_mode,
4624            auto_repay_at_cancel,
4625            working_client_order_id,
4626            working_time_in_force,
4627            pending_client_order_id,
4628            pending_price,
4629            pending_stop_price,
4630            pending_trailing_delta,
4631            pending_iceberg_qty,
4632            pending_time_in_force,
4633        } = params;
4634
4635        let mut query_params = BTreeMap::new();
4636        let body_params = BTreeMap::new();
4637
4638        query_params.insert("symbol".to_string(), json!(symbol));
4639
4640        if let Some(rw) = is_isolated {
4641            query_params.insert("isIsolated".to_string(), json!(rw));
4642        }
4643
4644        if let Some(rw) = list_client_order_id {
4645            query_params.insert("listClientOrderId".to_string(), json!(rw));
4646        }
4647
4648        if let Some(rw) = new_order_resp_type {
4649            query_params.insert("newOrderRespType".to_string(), json!(rw));
4650        }
4651
4652        if let Some(rw) = side_effect_type {
4653            query_params.insert("sideEffectType".to_string(), json!(rw));
4654        }
4655
4656        if let Some(rw) = self_trade_prevention_mode {
4657            query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
4658        }
4659
4660        if let Some(rw) = auto_repay_at_cancel {
4661            query_params.insert("autoRepayAtCancel".to_string(), json!(rw));
4662        }
4663
4664        query_params.insert("workingType".to_string(), json!(working_type));
4665
4666        query_params.insert("workingSide".to_string(), json!(working_side));
4667
4668        if let Some(rw) = working_client_order_id {
4669            query_params.insert("workingClientOrderId".to_string(), json!(rw));
4670        }
4671
4672        query_params.insert("workingPrice".to_string(), json!(working_price));
4673
4674        query_params.insert("workingQuantity".to_string(), json!(working_quantity));
4675
4676        query_params.insert("workingIcebergQty".to_string(), json!(working_iceberg_qty));
4677
4678        if let Some(rw) = working_time_in_force {
4679            query_params.insert("workingTimeInForce".to_string(), json!(rw));
4680        }
4681
4682        query_params.insert("pendingType".to_string(), json!(pending_type));
4683
4684        query_params.insert("pendingSide".to_string(), json!(pending_side));
4685
4686        if let Some(rw) = pending_client_order_id {
4687            query_params.insert("pendingClientOrderId".to_string(), json!(rw));
4688        }
4689
4690        if let Some(rw) = pending_price {
4691            query_params.insert("pendingPrice".to_string(), json!(rw));
4692        }
4693
4694        if let Some(rw) = pending_stop_price {
4695            query_params.insert("pendingStopPrice".to_string(), json!(rw));
4696        }
4697
4698        if let Some(rw) = pending_trailing_delta {
4699            query_params.insert("pendingTrailingDelta".to_string(), json!(rw));
4700        }
4701
4702        query_params.insert("pendingQuantity".to_string(), json!(pending_quantity));
4703
4704        if let Some(rw) = pending_iceberg_qty {
4705            query_params.insert("pendingIcebergQty".to_string(), json!(rw));
4706        }
4707
4708        if let Some(rw) = pending_time_in_force {
4709            query_params.insert("pendingTimeInForce".to_string(), json!(rw));
4710        }
4711
4712        send_request::<models::MarginAccountNewOtoResponse>(
4713            &self.configuration,
4714            "/sapi/v1/margin/order/oto",
4715            reqwest::Method::POST,
4716            query_params,
4717            body_params,
4718            if HAS_TIME_UNIT {
4719                self.configuration.time_unit
4720            } else {
4721                None
4722            },
4723            true,
4724        )
4725        .await
4726    }
4727
4728    async fn margin_account_new_otoco(
4729        &self,
4730        params: MarginAccountNewOtocoParams,
4731    ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtocoResponse>> {
4732        let MarginAccountNewOtocoParams {
4733            symbol,
4734            working_type,
4735            working_side,
4736            working_price,
4737            working_quantity,
4738            pending_side,
4739            pending_quantity,
4740            pending_above_type,
4741            is_isolated,
4742            side_effect_type,
4743            auto_repay_at_cancel,
4744            list_client_order_id,
4745            new_order_resp_type,
4746            self_trade_prevention_mode,
4747            working_client_order_id,
4748            working_iceberg_qty,
4749            working_time_in_force,
4750            pending_above_client_order_id,
4751            pending_above_price,
4752            pending_above_stop_price,
4753            pending_above_trailing_delta,
4754            pending_above_iceberg_qty,
4755            pending_above_time_in_force,
4756            pending_below_type,
4757            pending_below_client_order_id,
4758            pending_below_price,
4759            pending_below_stop_price,
4760            pending_below_trailing_delta,
4761            pending_below_iceberg_qty,
4762            pending_below_time_in_force,
4763        } = params;
4764
4765        let mut query_params = BTreeMap::new();
4766        let body_params = BTreeMap::new();
4767
4768        query_params.insert("symbol".to_string(), json!(symbol));
4769
4770        if let Some(rw) = is_isolated {
4771            query_params.insert("isIsolated".to_string(), json!(rw));
4772        }
4773
4774        if let Some(rw) = side_effect_type {
4775            query_params.insert("sideEffectType".to_string(), json!(rw));
4776        }
4777
4778        if let Some(rw) = auto_repay_at_cancel {
4779            query_params.insert("autoRepayAtCancel".to_string(), json!(rw));
4780        }
4781
4782        if let Some(rw) = list_client_order_id {
4783            query_params.insert("listClientOrderId".to_string(), json!(rw));
4784        }
4785
4786        if let Some(rw) = new_order_resp_type {
4787            query_params.insert("newOrderRespType".to_string(), json!(rw));
4788        }
4789
4790        if let Some(rw) = self_trade_prevention_mode {
4791            query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
4792        }
4793
4794        query_params.insert("workingType".to_string(), json!(working_type));
4795
4796        query_params.insert("workingSide".to_string(), json!(working_side));
4797
4798        if let Some(rw) = working_client_order_id {
4799            query_params.insert("workingClientOrderId".to_string(), json!(rw));
4800        }
4801
4802        query_params.insert("workingPrice".to_string(), json!(working_price));
4803
4804        query_params.insert("workingQuantity".to_string(), json!(working_quantity));
4805
4806        if let Some(rw) = working_iceberg_qty {
4807            query_params.insert("workingIcebergQty".to_string(), json!(rw));
4808        }
4809
4810        if let Some(rw) = working_time_in_force {
4811            query_params.insert("workingTimeInForce".to_string(), json!(rw));
4812        }
4813
4814        query_params.insert("pendingSide".to_string(), json!(pending_side));
4815
4816        query_params.insert("pendingQuantity".to_string(), json!(pending_quantity));
4817
4818        query_params.insert("pendingAboveType".to_string(), json!(pending_above_type));
4819
4820        if let Some(rw) = pending_above_client_order_id {
4821            query_params.insert("pendingAboveClientOrderId".to_string(), json!(rw));
4822        }
4823
4824        if let Some(rw) = pending_above_price {
4825            query_params.insert("pendingAbovePrice".to_string(), json!(rw));
4826        }
4827
4828        if let Some(rw) = pending_above_stop_price {
4829            query_params.insert("pendingAboveStopPrice".to_string(), json!(rw));
4830        }
4831
4832        if let Some(rw) = pending_above_trailing_delta {
4833            query_params.insert("pendingAboveTrailingDelta".to_string(), json!(rw));
4834        }
4835
4836        if let Some(rw) = pending_above_iceberg_qty {
4837            query_params.insert("pendingAboveIcebergQty".to_string(), json!(rw));
4838        }
4839
4840        if let Some(rw) = pending_above_time_in_force {
4841            query_params.insert("pendingAboveTimeInForce".to_string(), json!(rw));
4842        }
4843
4844        if let Some(rw) = pending_below_type {
4845            query_params.insert("pendingBelowType".to_string(), json!(rw));
4846        }
4847
4848        if let Some(rw) = pending_below_client_order_id {
4849            query_params.insert("pendingBelowClientOrderId".to_string(), json!(rw));
4850        }
4851
4852        if let Some(rw) = pending_below_price {
4853            query_params.insert("pendingBelowPrice".to_string(), json!(rw));
4854        }
4855
4856        if let Some(rw) = pending_below_stop_price {
4857            query_params.insert("pendingBelowStopPrice".to_string(), json!(rw));
4858        }
4859
4860        if let Some(rw) = pending_below_trailing_delta {
4861            query_params.insert("pendingBelowTrailingDelta".to_string(), json!(rw));
4862        }
4863
4864        if let Some(rw) = pending_below_iceberg_qty {
4865            query_params.insert("pendingBelowIcebergQty".to_string(), json!(rw));
4866        }
4867
4868        if let Some(rw) = pending_below_time_in_force {
4869            query_params.insert("pendingBelowTimeInForce".to_string(), json!(rw));
4870        }
4871
4872        send_request::<models::MarginAccountNewOtocoResponse>(
4873            &self.configuration,
4874            "/sapi/v1/margin/order/otoco",
4875            reqwest::Method::POST,
4876            query_params,
4877            body_params,
4878            if HAS_TIME_UNIT {
4879                self.configuration.time_unit
4880            } else {
4881                None
4882            },
4883            true,
4884        )
4885        .await
4886    }
4887
4888    async fn margin_manual_liquidation(
4889        &self,
4890        params: MarginManualLiquidationParams,
4891    ) -> anyhow::Result<RestApiResponse<models::MarginManualLiquidationResponse>> {
4892        let MarginManualLiquidationParams {
4893            r#type,
4894            symbol,
4895            recv_window,
4896        } = params;
4897
4898        let mut query_params = BTreeMap::new();
4899        let body_params = BTreeMap::new();
4900
4901        query_params.insert("type".to_string(), json!(r#type));
4902
4903        if let Some(rw) = symbol {
4904            query_params.insert("symbol".to_string(), json!(rw));
4905        }
4906
4907        if let Some(rw) = recv_window {
4908            query_params.insert("recvWindow".to_string(), json!(rw));
4909        }
4910
4911        send_request::<models::MarginManualLiquidationResponse>(
4912            &self.configuration,
4913            "/sapi/v1/margin/manual-liquidation",
4914            reqwest::Method::POST,
4915            query_params,
4916            body_params,
4917            if HAS_TIME_UNIT {
4918                self.configuration.time_unit
4919            } else {
4920                None
4921            },
4922            true,
4923        )
4924        .await
4925    }
4926
4927    async fn query_current_margin_order_count_usage(
4928        &self,
4929        params: QueryCurrentMarginOrderCountUsageParams,
4930    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>>
4931    {
4932        let QueryCurrentMarginOrderCountUsageParams {
4933            is_isolated,
4934            symbol,
4935            recv_window,
4936        } = params;
4937
4938        let mut query_params = BTreeMap::new();
4939        let body_params = BTreeMap::new();
4940
4941        if let Some(rw) = is_isolated {
4942            query_params.insert("isIsolated".to_string(), json!(rw));
4943        }
4944
4945        if let Some(rw) = symbol {
4946            query_params.insert("symbol".to_string(), json!(rw));
4947        }
4948
4949        if let Some(rw) = recv_window {
4950            query_params.insert("recvWindow".to_string(), json!(rw));
4951        }
4952
4953        send_request::<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>(
4954            &self.configuration,
4955            "/sapi/v1/margin/rateLimit/order",
4956            reqwest::Method::GET,
4957            query_params,
4958            body_params,
4959            if HAS_TIME_UNIT {
4960                self.configuration.time_unit
4961            } else {
4962                None
4963            },
4964            true,
4965        )
4966        .await
4967    }
4968
4969    async fn query_liquidation_loan(
4970        &self,
4971        params: QueryLiquidationLoanParams,
4972    ) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanResponse>> {
4973        let QueryLiquidationLoanParams { recv_window } = params;
4974
4975        let mut query_params = BTreeMap::new();
4976        let body_params = BTreeMap::new();
4977
4978        if let Some(rw) = recv_window {
4979            query_params.insert("recvWindow".to_string(), json!(rw));
4980        }
4981
4982        send_request::<models::QueryLiquidationLoanResponse>(
4983            &self.configuration,
4984            "/sapi/v1/margin/liquidation-loan",
4985            reqwest::Method::GET,
4986            query_params,
4987            body_params,
4988            if HAS_TIME_UNIT {
4989                self.configuration.time_unit
4990            } else {
4991                None
4992            },
4993            true,
4994        )
4995        .await
4996    }
4997
4998    async fn query_liquidation_loan_repay_history(
4999        &self,
5000        params: QueryLiquidationLoanRepayHistoryParams,
5001    ) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanRepayHistoryResponse>> {
5002        let QueryLiquidationLoanRepayHistoryParams {
5003            start_time,
5004            end_time,
5005            current,
5006            size,
5007            recv_window,
5008        } = params;
5009
5010        let mut query_params = BTreeMap::new();
5011        let body_params = BTreeMap::new();
5012
5013        if let Some(rw) = start_time {
5014            query_params.insert("startTime".to_string(), json!(rw));
5015        }
5016
5017        if let Some(rw) = end_time {
5018            query_params.insert("endTime".to_string(), json!(rw));
5019        }
5020
5021        if let Some(rw) = current {
5022            query_params.insert("current".to_string(), json!(rw));
5023        }
5024
5025        if let Some(rw) = size {
5026            query_params.insert("size".to_string(), json!(rw));
5027        }
5028
5029        if let Some(rw) = recv_window {
5030            query_params.insert("recvWindow".to_string(), json!(rw));
5031        }
5032
5033        send_request::<models::QueryLiquidationLoanRepayHistoryResponse>(
5034            &self.configuration,
5035            "/sapi/v1/margin/liquidation-loan/repay-history",
5036            reqwest::Method::GET,
5037            query_params,
5038            body_params,
5039            if HAS_TIME_UNIT {
5040                self.configuration.time_unit
5041            } else {
5042                None
5043            },
5044            true,
5045        )
5046        .await
5047    }
5048
5049    async fn query_margin_accounts_all_oco(
5050        &self,
5051        params: QueryMarginAccountsAllOcoParams,
5052    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>> {
5053        let QueryMarginAccountsAllOcoParams {
5054            is_isolated,
5055            symbol,
5056            from_id,
5057            start_time,
5058            end_time,
5059            limit,
5060            recv_window,
5061        } = params;
5062
5063        let mut query_params = BTreeMap::new();
5064        let body_params = BTreeMap::new();
5065
5066        if let Some(rw) = is_isolated {
5067            query_params.insert("isIsolated".to_string(), json!(rw));
5068        }
5069
5070        if let Some(rw) = symbol {
5071            query_params.insert("symbol".to_string(), json!(rw));
5072        }
5073
5074        if let Some(rw) = from_id {
5075            query_params.insert("fromId".to_string(), json!(rw));
5076        }
5077
5078        if let Some(rw) = start_time {
5079            query_params.insert("startTime".to_string(), json!(rw));
5080        }
5081
5082        if let Some(rw) = end_time {
5083            query_params.insert("endTime".to_string(), json!(rw));
5084        }
5085
5086        if let Some(rw) = limit {
5087            query_params.insert("limit".to_string(), json!(rw));
5088        }
5089
5090        if let Some(rw) = recv_window {
5091            query_params.insert("recvWindow".to_string(), json!(rw));
5092        }
5093
5094        send_request::<Vec<models::QueryMarginAccountsAllOcoResponseInner>>(
5095            &self.configuration,
5096            "/sapi/v1/margin/allOrderList",
5097            reqwest::Method::GET,
5098            query_params,
5099            body_params,
5100            if HAS_TIME_UNIT {
5101                self.configuration.time_unit
5102            } else {
5103                None
5104            },
5105            true,
5106        )
5107        .await
5108    }
5109
5110    async fn query_margin_accounts_all_orders(
5111        &self,
5112        params: QueryMarginAccountsAllOrdersParams,
5113    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>>
5114    {
5115        let QueryMarginAccountsAllOrdersParams {
5116            symbol,
5117            is_isolated,
5118            order_id,
5119            start_time,
5120            end_time,
5121            limit,
5122            recv_window,
5123        } = params;
5124
5125        let mut query_params = BTreeMap::new();
5126        let body_params = BTreeMap::new();
5127
5128        query_params.insert("symbol".to_string(), json!(symbol));
5129
5130        if let Some(rw) = is_isolated {
5131            query_params.insert("isIsolated".to_string(), json!(rw));
5132        }
5133
5134        if let Some(rw) = order_id {
5135            query_params.insert("orderId".to_string(), json!(rw));
5136        }
5137
5138        if let Some(rw) = start_time {
5139            query_params.insert("startTime".to_string(), json!(rw));
5140        }
5141
5142        if let Some(rw) = end_time {
5143            query_params.insert("endTime".to_string(), json!(rw));
5144        }
5145
5146        if let Some(rw) = limit {
5147            query_params.insert("limit".to_string(), json!(rw));
5148        }
5149
5150        if let Some(rw) = recv_window {
5151            query_params.insert("recvWindow".to_string(), json!(rw));
5152        }
5153
5154        send_request::<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>(
5155            &self.configuration,
5156            "/sapi/v1/margin/allOrders",
5157            reqwest::Method::GET,
5158            query_params,
5159            body_params,
5160            if HAS_TIME_UNIT {
5161                self.configuration.time_unit
5162            } else {
5163                None
5164            },
5165            true,
5166        )
5167        .await
5168    }
5169
5170    async fn query_margin_accounts_oco(
5171        &self,
5172        params: QueryMarginAccountsOcoParams,
5173    ) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOcoResponse>> {
5174        let QueryMarginAccountsOcoParams {
5175            is_isolated,
5176            symbol,
5177            order_list_id,
5178            orig_client_order_id,
5179            recv_window,
5180        } = params;
5181
5182        let mut query_params = BTreeMap::new();
5183        let body_params = BTreeMap::new();
5184
5185        if let Some(rw) = is_isolated {
5186            query_params.insert("isIsolated".to_string(), json!(rw));
5187        }
5188
5189        if let Some(rw) = symbol {
5190            query_params.insert("symbol".to_string(), json!(rw));
5191        }
5192
5193        if let Some(rw) = order_list_id {
5194            query_params.insert("orderListId".to_string(), json!(rw));
5195        }
5196
5197        if let Some(rw) = orig_client_order_id {
5198            query_params.insert("origClientOrderId".to_string(), json!(rw));
5199        }
5200
5201        if let Some(rw) = recv_window {
5202            query_params.insert("recvWindow".to_string(), json!(rw));
5203        }
5204
5205        send_request::<models::QueryMarginAccountsOcoResponse>(
5206            &self.configuration,
5207            "/sapi/v1/margin/orderList",
5208            reqwest::Method::GET,
5209            query_params,
5210            body_params,
5211            if HAS_TIME_UNIT {
5212                self.configuration.time_unit
5213            } else {
5214                None
5215            },
5216            true,
5217        )
5218        .await
5219    }
5220
5221    async fn query_margin_accounts_open_oco(
5222        &self,
5223        params: QueryMarginAccountsOpenOcoParams,
5224    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>> {
5225        let QueryMarginAccountsOpenOcoParams {
5226            is_isolated,
5227            symbol,
5228            recv_window,
5229        } = params;
5230
5231        let mut query_params = BTreeMap::new();
5232        let body_params = BTreeMap::new();
5233
5234        if let Some(rw) = is_isolated {
5235            query_params.insert("isIsolated".to_string(), json!(rw));
5236        }
5237
5238        if let Some(rw) = symbol {
5239            query_params.insert("symbol".to_string(), json!(rw));
5240        }
5241
5242        if let Some(rw) = recv_window {
5243            query_params.insert("recvWindow".to_string(), json!(rw));
5244        }
5245
5246        send_request::<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>(
5247            &self.configuration,
5248            "/sapi/v1/margin/openOrderList",
5249            reqwest::Method::GET,
5250            query_params,
5251            body_params,
5252            if HAS_TIME_UNIT {
5253                self.configuration.time_unit
5254            } else {
5255                None
5256            },
5257            true,
5258        )
5259        .await
5260    }
5261
5262    async fn query_margin_accounts_open_orders(
5263        &self,
5264        params: QueryMarginAccountsOpenOrdersParams,
5265    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>>
5266    {
5267        let QueryMarginAccountsOpenOrdersParams {
5268            symbol,
5269            is_isolated,
5270            recv_window,
5271        } = params;
5272
5273        let mut query_params = BTreeMap::new();
5274        let body_params = BTreeMap::new();
5275
5276        if let Some(rw) = symbol {
5277            query_params.insert("symbol".to_string(), json!(rw));
5278        }
5279
5280        if let Some(rw) = is_isolated {
5281            query_params.insert("isIsolated".to_string(), json!(rw));
5282        }
5283
5284        if let Some(rw) = recv_window {
5285            query_params.insert("recvWindow".to_string(), json!(rw));
5286        }
5287
5288        send_request::<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>(
5289            &self.configuration,
5290            "/sapi/v1/margin/openOrders",
5291            reqwest::Method::GET,
5292            query_params,
5293            body_params,
5294            if HAS_TIME_UNIT {
5295                self.configuration.time_unit
5296            } else {
5297                None
5298            },
5299            true,
5300        )
5301        .await
5302    }
5303
5304    async fn query_margin_accounts_order(
5305        &self,
5306        params: QueryMarginAccountsOrderParams,
5307    ) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOrderResponse>> {
5308        let QueryMarginAccountsOrderParams {
5309            symbol,
5310            is_isolated,
5311            order_id,
5312            orig_client_order_id,
5313            recv_window,
5314        } = params;
5315
5316        let mut query_params = BTreeMap::new();
5317        let body_params = BTreeMap::new();
5318
5319        query_params.insert("symbol".to_string(), json!(symbol));
5320
5321        if let Some(rw) = is_isolated {
5322            query_params.insert("isIsolated".to_string(), json!(rw));
5323        }
5324
5325        if let Some(rw) = order_id {
5326            query_params.insert("orderId".to_string(), json!(rw));
5327        }
5328
5329        if let Some(rw) = orig_client_order_id {
5330            query_params.insert("origClientOrderId".to_string(), json!(rw));
5331        }
5332
5333        if let Some(rw) = recv_window {
5334            query_params.insert("recvWindow".to_string(), json!(rw));
5335        }
5336
5337        send_request::<models::QueryMarginAccountsOrderResponse>(
5338            &self.configuration,
5339            "/sapi/v1/margin/order",
5340            reqwest::Method::GET,
5341            query_params,
5342            body_params,
5343            if HAS_TIME_UNIT {
5344                self.configuration.time_unit
5345            } else {
5346                None
5347            },
5348            true,
5349        )
5350        .await
5351    }
5352
5353    async fn query_margin_accounts_trade_list(
5354        &self,
5355        params: QueryMarginAccountsTradeListParams,
5356    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsTradeListResponseInner>>>
5357    {
5358        let QueryMarginAccountsTradeListParams {
5359            symbol,
5360            is_isolated,
5361            order_id,
5362            start_time,
5363            end_time,
5364            from_id,
5365            limit,
5366            recv_window,
5367        } = params;
5368
5369        let mut query_params = BTreeMap::new();
5370        let body_params = BTreeMap::new();
5371
5372        query_params.insert("symbol".to_string(), json!(symbol));
5373
5374        if let Some(rw) = is_isolated {
5375            query_params.insert("isIsolated".to_string(), json!(rw));
5376        }
5377
5378        if let Some(rw) = order_id {
5379            query_params.insert("orderId".to_string(), json!(rw));
5380        }
5381
5382        if let Some(rw) = start_time {
5383            query_params.insert("startTime".to_string(), json!(rw));
5384        }
5385
5386        if let Some(rw) = end_time {
5387            query_params.insert("endTime".to_string(), json!(rw));
5388        }
5389
5390        if let Some(rw) = from_id {
5391            query_params.insert("fromId".to_string(), json!(rw));
5392        }
5393
5394        if let Some(rw) = limit {
5395            query_params.insert("limit".to_string(), json!(rw));
5396        }
5397
5398        if let Some(rw) = recv_window {
5399            query_params.insert("recvWindow".to_string(), json!(rw));
5400        }
5401
5402        send_request::<Vec<models::QueryMarginAccountsTradeListResponseInner>>(
5403            &self.configuration,
5404            "/sapi/v1/margin/myTrades",
5405            reqwest::Method::GET,
5406            query_params,
5407            body_params,
5408            if HAS_TIME_UNIT {
5409                self.configuration.time_unit
5410            } else {
5411                None
5412            },
5413            true,
5414        )
5415        .await
5416    }
5417
5418    async fn query_prevented_matches(
5419        &self,
5420        params: QueryPreventedMatchesParams,
5421    ) -> anyhow::Result<RestApiResponse<Vec<models::QueryPreventedMatchesResponseInner>>> {
5422        let QueryPreventedMatchesParams {
5423            symbol,
5424            prevented_match_id,
5425            order_id,
5426            from_prevented_match_id,
5427            is_isolated,
5428            recv_window,
5429        } = params;
5430
5431        let mut query_params = BTreeMap::new();
5432        let body_params = BTreeMap::new();
5433
5434        query_params.insert("symbol".to_string(), json!(symbol));
5435
5436        if let Some(rw) = prevented_match_id {
5437            query_params.insert("preventedMatchId".to_string(), json!(rw));
5438        }
5439
5440        if let Some(rw) = order_id {
5441            query_params.insert("orderId".to_string(), json!(rw));
5442        }
5443
5444        if let Some(rw) = from_prevented_match_id {
5445            query_params.insert("fromPreventedMatchId".to_string(), json!(rw));
5446        }
5447
5448        if let Some(rw) = is_isolated {
5449            query_params.insert("isIsolated".to_string(), json!(rw));
5450        }
5451
5452        if let Some(rw) = recv_window {
5453            query_params.insert("recvWindow".to_string(), json!(rw));
5454        }
5455
5456        send_request::<Vec<models::QueryPreventedMatchesResponseInner>>(
5457            &self.configuration,
5458            "/sapi/v1/margin/myPreventedMatches",
5459            reqwest::Method::GET,
5460            query_params,
5461            body_params,
5462            if HAS_TIME_UNIT {
5463                self.configuration.time_unit
5464            } else {
5465                None
5466            },
5467            true,
5468        )
5469        .await
5470    }
5471
5472    async fn query_special_key(
5473        &self,
5474        params: QuerySpecialKeyParams,
5475    ) -> anyhow::Result<RestApiResponse<models::QuerySpecialKeyResponse>> {
5476        let QuerySpecialKeyParams {
5477            symbol,
5478            recv_window,
5479        } = params;
5480
5481        let mut query_params = BTreeMap::new();
5482        let body_params = BTreeMap::new();
5483
5484        if let Some(rw) = symbol {
5485            query_params.insert("symbol".to_string(), json!(rw));
5486        }
5487
5488        if let Some(rw) = recv_window {
5489            query_params.insert("recvWindow".to_string(), json!(rw));
5490        }
5491
5492        send_request::<models::QuerySpecialKeyResponse>(
5493            &self.configuration,
5494            "/sapi/v1/margin/apiKey",
5495            reqwest::Method::GET,
5496            query_params,
5497            body_params,
5498            if HAS_TIME_UNIT {
5499                self.configuration.time_unit
5500            } else {
5501                None
5502            },
5503            true,
5504        )
5505        .await
5506    }
5507
5508    async fn query_special_key_list(
5509        &self,
5510        params: QuerySpecialKeyListParams,
5511    ) -> anyhow::Result<RestApiResponse<Vec<models::QuerySpecialKeyListResponseInner>>> {
5512        let QuerySpecialKeyListParams {
5513            symbol,
5514            recv_window,
5515        } = params;
5516
5517        let mut query_params = BTreeMap::new();
5518        let body_params = BTreeMap::new();
5519
5520        if let Some(rw) = symbol {
5521            query_params.insert("symbol".to_string(), json!(rw));
5522        }
5523
5524        if let Some(rw) = recv_window {
5525            query_params.insert("recvWindow".to_string(), json!(rw));
5526        }
5527
5528        send_request::<Vec<models::QuerySpecialKeyListResponseInner>>(
5529            &self.configuration,
5530            "/sapi/v1/margin/api-key-list",
5531            reqwest::Method::GET,
5532            query_params,
5533            body_params,
5534            if HAS_TIME_UNIT {
5535                self.configuration.time_unit
5536            } else {
5537                None
5538            },
5539            true,
5540        )
5541        .await
5542    }
5543
5544    async fn small_liability_exchange(
5545        &self,
5546        params: SmallLiabilityExchangeParams,
5547    ) -> anyhow::Result<RestApiResponse<Value>> {
5548        let SmallLiabilityExchangeParams {
5549            asset_names,
5550            recv_window,
5551        } = params;
5552
5553        let mut query_params = BTreeMap::new();
5554        let body_params = BTreeMap::new();
5555
5556        query_params.insert("assetNames".to_string(), json!(asset_names));
5557
5558        if let Some(rw) = recv_window {
5559            query_params.insert("recvWindow".to_string(), json!(rw));
5560        }
5561
5562        send_request::<Value>(
5563            &self.configuration,
5564            "/sapi/v1/margin/exchange-small-liability",
5565            reqwest::Method::POST,
5566            query_params,
5567            body_params,
5568            if HAS_TIME_UNIT {
5569                self.configuration.time_unit
5570            } else {
5571                None
5572            },
5573            true,
5574        )
5575        .await
5576    }
5577}
5578
5579#[cfg(all(test, feature = "margin_trading"))]
5580mod tests {
5581    use super::*;
5582    use crate::TOKIO_SHARED_RT;
5583    use crate::{errors::ConnectorError, models::DataFuture, models::RestApiRateLimit};
5584    use async_trait::async_trait;
5585    use std::collections::HashMap;
5586
5587    struct DummyRestApiResponse<T> {
5588        inner: Box<dyn FnOnce() -> DataFuture<Result<T, ConnectorError>> + Send + Sync>,
5589        status: u16,
5590        headers: HashMap<String, String>,
5591        rate_limits: Option<Vec<RestApiRateLimit>>,
5592    }
5593
5594    impl<T> From<DummyRestApiResponse<T>> for RestApiResponse<T> {
5595        fn from(dummy: DummyRestApiResponse<T>) -> Self {
5596            Self {
5597                data_fn: dummy.inner,
5598                status: dummy.status,
5599                headers: dummy.headers,
5600                rate_limits: dummy.rate_limits,
5601            }
5602        }
5603    }
5604
5605    struct MockTradeApiClient {
5606        force_error: bool,
5607    }
5608
5609    #[async_trait]
5610    impl TradeApi for MockTradeApiClient {
5611        async fn create_special_key(
5612            &self,
5613            _params: CreateSpecialKeyParams,
5614        ) -> anyhow::Result<RestApiResponse<models::CreateSpecialKeyResponse>> {
5615            if self.force_error {
5616                return Err(ConnectorError::ConnectorClientError {
5617                    msg: "ResponseError".to_string(),
5618                    code: None,
5619                }
5620                .into());
5621            }
5622
5623            let resp_json: Value = serde_json::from_str(r#"{"apiKey":"npOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoGx","secretKey":"87ssWB7azoy6ACRfyp6OVOL5U3rtZptX31QWw2kWjl1jHEYRbyM1pd6qykRBQw8p","type":"HMAC_SHA256"}"#).unwrap_or_else(|_| serde_json::json!({}));
5624            let dummy_response: models::CreateSpecialKeyResponse =
5625                serde_json::from_value(resp_json.clone())
5626                    .expect("should parse into models::CreateSpecialKeyResponse");
5627
5628            let dummy = DummyRestApiResponse {
5629                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5630                status: 200,
5631                headers: HashMap::new(),
5632                rate_limits: None,
5633            };
5634
5635            Ok(dummy.into())
5636        }
5637
5638        async fn delete_special_key(
5639            &self,
5640            _params: DeleteSpecialKeyParams,
5641        ) -> anyhow::Result<RestApiResponse<Value>> {
5642            if self.force_error {
5643                return Err(ConnectorError::ConnectorClientError {
5644                    msg: "ResponseError".to_string(),
5645                    code: None,
5646                }
5647                .into());
5648            }
5649
5650            let dummy_response = Value::Null;
5651
5652            let dummy = DummyRestApiResponse {
5653                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5654                status: 200,
5655                headers: HashMap::new(),
5656                rate_limits: None,
5657            };
5658
5659            Ok(dummy.into())
5660        }
5661
5662        async fn edit_ip_for_special_key(
5663            &self,
5664            _params: EditIpForSpecialKeyParams,
5665        ) -> anyhow::Result<RestApiResponse<Value>> {
5666            if self.force_error {
5667                return Err(ConnectorError::ConnectorClientError {
5668                    msg: "ResponseError".to_string(),
5669                    code: None,
5670                }
5671                .into());
5672            }
5673
5674            let dummy_response = Value::Null;
5675
5676            let dummy = DummyRestApiResponse {
5677                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5678                status: 200,
5679                headers: HashMap::new(),
5680                rate_limits: None,
5681            };
5682
5683            Ok(dummy.into())
5684        }
5685
5686        async fn exit_special_key_mode(
5687            &self,
5688            _params: ExitSpecialKeyModeParams,
5689        ) -> anyhow::Result<RestApiResponse<serde_json::Value>> {
5690            if self.force_error {
5691                return Err(ConnectorError::ConnectorClientError {
5692                    msg: "ResponseError".to_string(),
5693                    code: None,
5694                }
5695                .into());
5696            }
5697
5698            let resp_json: Value =
5699                serde_json::from_str(r"").unwrap_or_else(|_| serde_json::json!({}));
5700            let dummy_response: serde_json::Value = serde_json::from_value(resp_json.clone())
5701                .expect("should parse into serde_json::Value");
5702
5703            let dummy = DummyRestApiResponse {
5704                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5705                status: 200,
5706                headers: HashMap::new(),
5707                rate_limits: None,
5708            };
5709
5710            Ok(dummy.into())
5711        }
5712
5713        async fn get_force_liquidation_record(
5714            &self,
5715            _params: GetForceLiquidationRecordParams,
5716        ) -> anyhow::Result<RestApiResponse<models::GetForceLiquidationRecordResponse>> {
5717            if self.force_error {
5718                return Err(ConnectorError::ConnectorClientError {
5719                    msg: "ResponseError".to_string(),
5720                    code: None,
5721                }
5722                .into());
5723            }
5724
5725            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"avgPrice":"0.00388359","executedQty":"31.39000000","orderId":180015097,"price":"0.00388110","qty":"31.39000000","side":"SELL","symbol":"BNBBTC","timeInForce":"GTC","isIsolated":true,"updatedTime":1558941374745}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
5726            let dummy_response: models::GetForceLiquidationRecordResponse =
5727                serde_json::from_value(resp_json.clone())
5728                    .expect("should parse into models::GetForceLiquidationRecordResponse");
5729
5730            let dummy = DummyRestApiResponse {
5731                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5732                status: 200,
5733                headers: HashMap::new(),
5734                rate_limits: None,
5735            };
5736
5737            Ok(dummy.into())
5738        }
5739
5740        async fn get_small_liability_exchange_coin_list(
5741            &self,
5742            _params: GetSmallLiabilityExchangeCoinListParams,
5743        ) -> anyhow::Result<
5744            RestApiResponse<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>,
5745        > {
5746            if self.force_error {
5747                return Err(ConnectorError::ConnectorClientError {
5748                    msg: "ResponseError".to_string(),
5749                    code: None,
5750                }
5751                .into());
5752            }
5753
5754            let resp_json: Value = serde_json::from_str(r#"[{"asset":"ETH","interest":"0.00083334","principal":"0.001","liabilityAsset":"USDT","liabilityQty":0.3552}]"#).unwrap_or_else(|_| serde_json::json!({}));
5755            let dummy_response: Vec<models::GetSmallLiabilityExchangeCoinListResponseInner> =
5756                serde_json::from_value(resp_json.clone()).expect(
5757                    "should parse into Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>",
5758                );
5759
5760            let dummy = DummyRestApiResponse {
5761                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5762                status: 200,
5763                headers: HashMap::new(),
5764                rate_limits: None,
5765            };
5766
5767            Ok(dummy.into())
5768        }
5769
5770        async fn get_small_liability_exchange_history(
5771            &self,
5772            _params: GetSmallLiabilityExchangeHistoryParams,
5773        ) -> anyhow::Result<RestApiResponse<models::GetSmallLiabilityExchangeHistoryResponse>>
5774        {
5775            if self.force_error {
5776                return Err(ConnectorError::ConnectorClientError {
5777                    msg: "ResponseError".to_string(),
5778                    code: None,
5779                }
5780                .into());
5781            }
5782
5783            let resp_json: Value = serde_json::from_str(r#"{"total":1,"rows":[{"asset":"ETH","amount":"0.00083434","targetAsset":"BUSD","targetAmount":"1.37576819","bizType":"EXCHANGE_SMALL_LIABILITY","timestamp":1672801339253}]}"#).unwrap_or_else(|_| serde_json::json!({}));
5784            let dummy_response: models::GetSmallLiabilityExchangeHistoryResponse =
5785                serde_json::from_value(resp_json.clone())
5786                    .expect("should parse into models::GetSmallLiabilityExchangeHistoryResponse");
5787
5788            let dummy = DummyRestApiResponse {
5789                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5790                status: 200,
5791                headers: HashMap::new(),
5792                rate_limits: None,
5793            };
5794
5795            Ok(dummy.into())
5796        }
5797
5798        async fn liquidation_loan_repay(
5799            &self,
5800            _params: LiquidationLoanRepayParams,
5801        ) -> anyhow::Result<RestApiResponse<models::LiquidationLoanRepayResponse>> {
5802            if self.force_error {
5803                return Err(ConnectorError::ConnectorClientError {
5804                    msg: "ResponseError".to_string(),
5805                    code: None,
5806                }
5807                .into());
5808            }
5809
5810            let resp_json: Value = serde_json::from_str(r#"{"repayId":12345678,"asset":"USDT","amount":"300.00000000","status":"SUCCESS","createTime":1714492800000}"#).unwrap_or_else(|_| serde_json::json!({}));
5811            let dummy_response: models::LiquidationLoanRepayResponse =
5812                serde_json::from_value(resp_json.clone())
5813                    .expect("should parse into models::LiquidationLoanRepayResponse");
5814
5815            let dummy = DummyRestApiResponse {
5816                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5817                status: 200,
5818                headers: HashMap::new(),
5819                rate_limits: None,
5820            };
5821
5822            Ok(dummy.into())
5823        }
5824
5825        async fn margin_account_cancel_all_open_orders_on_a_symbol(
5826            &self,
5827            _params: MarginAccountCancelAllOpenOrdersOnASymbolParams,
5828        ) -> anyhow::Result<
5829            RestApiResponse<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>,
5830        > {
5831            if self.force_error {
5832                return Err(ConnectorError::ConnectorClientError {
5833                    msg: "ResponseError".to_string(),
5834                    code: None,
5835                }
5836                .into());
5837            }
5838
5839            let resp_json: Value = serde_json::from_str(r#"[{"symbol":"BTCUSDT","isIsolated":true,"origClientOrderId":"E6APeyTJvkMvLMYMqu1KQ4","orderId":11,"orderListId":-1,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","price":"0.089853","origQty":"0.178622","executedQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE","contingencyType":"OCO","listStatusType":"ALL_DONE","listOrderStatus":"ALL_DONE","listClientOrderId":"2inzWQdDvZLHbbAmAozX2N","transactionTime":1585230948299,"orders":[{"symbol":"BTCUSDT","orderId":20,"clientOrderId":"CwOOIPHSmYywx6jZX77TdL"}],"orderReports":[{"symbol":"BTCUSDT","origClientOrderId":"CwOOIPHSmYywx6jZX77TdL","orderId":20,"orderListId":1929,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","price":"0.668611","origQty":"0.690354","executedQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"BUY","stopPrice":"0.378131","icebergQty":"0.017083"}]}]"#).unwrap_or_else(|_| serde_json::json!({}));
5840            let dummy_response : Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>");
5841
5842            let dummy = DummyRestApiResponse {
5843                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5844                status: 200,
5845                headers: HashMap::new(),
5846                rate_limits: None,
5847            };
5848
5849            Ok(dummy.into())
5850        }
5851
5852        async fn margin_account_cancel_oco(
5853            &self,
5854            _params: MarginAccountCancelOcoParams,
5855        ) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOcoResponse>> {
5856            if self.force_error {
5857                return Err(ConnectorError::ConnectorClientError {
5858                    msg: "ResponseError".to_string(),
5859                    code: None,
5860                }
5861                .into());
5862            }
5863
5864            let resp_json: Value = serde_json::from_str(r#"{"orderListId":0,"contingencyType":"OCO","listStatusType":"ALL_DONE","listOrderStatus":"ALL_DONE","listClientOrderId":"C3wyj4WVEktd7u9aVBRXcN","transactionTime":1574040868128,"symbol":"LTCBTC","isIsolated":false,"orders":[{"symbol":"LTCBTC","orderId":2,"clientOrderId":"pO9ufTiFGg3nw2fOdgeOXa"}],"orderReports":[{"symbol":"LTCBTC","origClientOrderId":"pO9ufTiFGg3nw2fOdgeOXa","orderId":2,"orderListId":0,"clientOrderId":"unfWT8ig8i0uj6lPuYLez6","price":"1.00000000","origQty":"10.00000000","executedQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"1.00000000","selfTradePreventionMode":"NONE"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
5865            let dummy_response: models::MarginAccountCancelOcoResponse =
5866                serde_json::from_value(resp_json.clone())
5867                    .expect("should parse into models::MarginAccountCancelOcoResponse");
5868
5869            let dummy = DummyRestApiResponse {
5870                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5871                status: 200,
5872                headers: HashMap::new(),
5873                rate_limits: None,
5874            };
5875
5876            Ok(dummy.into())
5877        }
5878
5879        async fn margin_account_cancel_order(
5880            &self,
5881            _params: MarginAccountCancelOrderParams,
5882        ) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOrderResponse>> {
5883            if self.force_error {
5884                return Err(ConnectorError::ConnectorClientError {
5885                    msg: "ResponseError".to_string(),
5886                    code: None,
5887                }
5888                .into());
5889            }
5890
5891            let resp_json: Value = serde_json::from_str(r#"{"symbol":"LTCBTC","orderId":"28","origClientOrderId":"myOrder1","clientOrderId":"cancelMyOrder1","price":"1.00000000","origQty":"10.00000000","executedQty":"8.00000000","cummulativeQuoteQty":"8.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"SELL","isIsolated":true}"#).unwrap_or_else(|_| serde_json::json!({}));
5892            let dummy_response: models::MarginAccountCancelOrderResponse =
5893                serde_json::from_value(resp_json.clone())
5894                    .expect("should parse into models::MarginAccountCancelOrderResponse");
5895
5896            let dummy = DummyRestApiResponse {
5897                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5898                status: 200,
5899                headers: HashMap::new(),
5900                rate_limits: None,
5901            };
5902
5903            Ok(dummy.into())
5904        }
5905
5906        async fn margin_account_new_oco(
5907            &self,
5908            _params: MarginAccountNewOcoParams,
5909        ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOcoResponse>> {
5910            if self.force_error {
5911                return Err(ConnectorError::ConnectorClientError {
5912                    msg: "ResponseError".to_string(),
5913                    code: None,
5914                }
5915                .into());
5916            }
5917
5918            let resp_json: Value = serde_json::from_str(r#"{"orderListId":0,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"JYVpp3F0f5CAG15DhtrqLp","transactionTime":1563417480525,"symbol":"LTCBTC","marginBuyBorrowAmount":"5","marginBuyBorrowAsset":"BTC","isIsolated":false,"orders":[{"symbol":"LTCBTC","orderId":2,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos"}],"orderReports":[{"symbol":"LTCBTC","orderId":2,"orderListId":0,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos","transactTime":1563417480525,"price":"0.000000","origQty":"0.624363","executedQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"NEW","timeInForce":"GTC","type":"STOP_LOSS","side":"BUY","stopPrice":"0.960664","selfTradePreventionMode":"NONE"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
5919            let dummy_response: models::MarginAccountNewOcoResponse =
5920                serde_json::from_value(resp_json.clone())
5921                    .expect("should parse into models::MarginAccountNewOcoResponse");
5922
5923            let dummy = DummyRestApiResponse {
5924                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5925                status: 200,
5926                headers: HashMap::new(),
5927                rate_limits: None,
5928            };
5929
5930            Ok(dummy.into())
5931        }
5932
5933        async fn margin_account_new_order(
5934            &self,
5935            _params: MarginAccountNewOrderParams,
5936        ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOrderResponse>> {
5937            if self.force_error {
5938                return Err(ConnectorError::ConnectorClientError {
5939                    msg: "ResponseError".to_string(),
5940                    code: None,
5941                }
5942                .into());
5943            }
5944
5945            let resp_json: Value = serde_json::from_str(r#"{"symbol":"BTCUSDT","orderId":26769564559,"clientOrderId":"E156O3KP4gOif65bjuUK5V","isIsolated":false,"transactTime":1713873075893,"price":"0","origQty":"0.001","executedQty":"0.001","cummulativeQuoteQty":"65.98253","status":"FILLED","timeInForce":"GTC","type":"MARKET","side":"SELL","selfTradePreventionMode":"EXPIRE_MAKER","marginBuyBorrowAmount":5,"marginBuyBorrowAsset":"BTC","fills":[{"price":"65982.53","qty":"0.001","commission":"0.06598253","commissionAsset":"USDT","tradeId":3570680726}]}"#).unwrap_or_else(|_| serde_json::json!({}));
5946            let dummy_response: models::MarginAccountNewOrderResponse =
5947                serde_json::from_value(resp_json.clone())
5948                    .expect("should parse into models::MarginAccountNewOrderResponse");
5949
5950            let dummy = DummyRestApiResponse {
5951                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5952                status: 200,
5953                headers: HashMap::new(),
5954                rate_limits: None,
5955            };
5956
5957            Ok(dummy.into())
5958        }
5959
5960        async fn margin_account_new_oto(
5961            &self,
5962            _params: MarginAccountNewOtoParams,
5963        ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtoResponse>> {
5964            if self.force_error {
5965                return Err(ConnectorError::ConnectorClientError {
5966                    msg: "ResponseError".to_string(),
5967                    code: None,
5968                }
5969                .into());
5970            }
5971
5972            let resp_json: Value = serde_json::from_str(r#"{"orderListId":13551,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"JDuOrsu0Ge8GTyvx8J7VTD","transactionTime":1725521998054,"symbol":"BTCUSDT","isIsolated":false,"orders":[{"symbol":"BTCUSDT","orderId":29896699,"clientOrderId":"y8RB6tQEMuHUXybqbtzTxk"}],"orderReports":[{"symbol":"BTCUSDT","orderId":29896699,"orderListId":13551,"clientOrderId":"y8RB6tQEMuHUXybqbtzTxk","transactTime":1725521998054,"price":"80000.00000000","origQty":"0.02000000","executedQty":"0","cummulativeQuoteQty":"0","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","selfTradePreventionMode":"NONE"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
5973            let dummy_response: models::MarginAccountNewOtoResponse =
5974                serde_json::from_value(resp_json.clone())
5975                    .expect("should parse into models::MarginAccountNewOtoResponse");
5976
5977            let dummy = DummyRestApiResponse {
5978                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
5979                status: 200,
5980                headers: HashMap::new(),
5981                rate_limits: None,
5982            };
5983
5984            Ok(dummy.into())
5985        }
5986
5987        async fn margin_account_new_otoco(
5988            &self,
5989            _params: MarginAccountNewOtocoParams,
5990        ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtocoResponse>> {
5991            if self.force_error {
5992                return Err(ConnectorError::ConnectorClientError {
5993                    msg: "ResponseError".to_string(),
5994                    code: None,
5995                }
5996                .into());
5997            }
5998
5999            let resp_json: Value = serde_json::from_str(r#"{"orderListId":13509,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"u2AUo48LLef5qVenRtwJZy","transactionTime":1725521881300,"symbol":"BNBUSDT","isIsolated":false,"orders":[{"symbol":"BNBUSDT","orderId":28282534,"clientOrderId":"IfYDxvrZI4kiyqYpRH13iI"}],"orderReports":[{"symbol":"BNBUSDT","orderId":28282534,"orderListId":13509,"clientOrderId":"IfYDxvrZI4kiyqYpRH13iI","transactTime":1725521881300,"price":"300.00000000","origQty":"1.00000000","executedQty":"0","cummulativeQuoteQty":"0","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE","stopPrice":"299.00000000"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
6000            let dummy_response: models::MarginAccountNewOtocoResponse =
6001                serde_json::from_value(resp_json.clone())
6002                    .expect("should parse into models::MarginAccountNewOtocoResponse");
6003
6004            let dummy = DummyRestApiResponse {
6005                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6006                status: 200,
6007                headers: HashMap::new(),
6008                rate_limits: None,
6009            };
6010
6011            Ok(dummy.into())
6012        }
6013
6014        async fn margin_manual_liquidation(
6015            &self,
6016            _params: MarginManualLiquidationParams,
6017        ) -> anyhow::Result<RestApiResponse<models::MarginManualLiquidationResponse>> {
6018            if self.force_error {
6019                return Err(ConnectorError::ConnectorClientError {
6020                    msg: "ResponseError".to_string(),
6021                    code: None,
6022                }
6023                .into());
6024            }
6025
6026            let resp_json: Value = serde_json::from_str(r#"{"asset":"ETH","interest":"0.00083334","principal":"0.001","liabilityAsset":"USDT","liabilityQty":0.3552}"#).unwrap_or_else(|_| serde_json::json!({}));
6027            let dummy_response: models::MarginManualLiquidationResponse =
6028                serde_json::from_value(resp_json.clone())
6029                    .expect("should parse into models::MarginManualLiquidationResponse");
6030
6031            let dummy = DummyRestApiResponse {
6032                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6033                status: 200,
6034                headers: HashMap::new(),
6035                rate_limits: None,
6036            };
6037
6038            Ok(dummy.into())
6039        }
6040
6041        async fn query_current_margin_order_count_usage(
6042            &self,
6043            _params: QueryCurrentMarginOrderCountUsageParams,
6044        ) -> anyhow::Result<
6045            RestApiResponse<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>,
6046        > {
6047            if self.force_error {
6048                return Err(ConnectorError::ConnectorClientError {
6049                    msg: "ResponseError".to_string(),
6050                    code: None,
6051                }
6052                .into());
6053            }
6054
6055            let resp_json: Value = serde_json::from_str(r#"[{"rateLimitType":"ORDERS","interval":"SECOND","intervalNum":10,"limit":10000,"count":0}]"#).unwrap_or_else(|_| serde_json::json!({}));
6056            let dummy_response: Vec<models::QueryCurrentMarginOrderCountUsageResponseInner> =
6057                serde_json::from_value(resp_json.clone()).expect(
6058                    "should parse into Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>",
6059                );
6060
6061            let dummy = DummyRestApiResponse {
6062                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6063                status: 200,
6064                headers: HashMap::new(),
6065                rate_limits: None,
6066            };
6067
6068            Ok(dummy.into())
6069        }
6070
6071        async fn query_liquidation_loan(
6072            &self,
6073            _params: QueryLiquidationLoanParams,
6074        ) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanResponse>> {
6075            if self.force_error {
6076                return Err(ConnectorError::ConnectorClientError {
6077                    msg: "ResponseError".to_string(),
6078                    code: None,
6079                }
6080                .into());
6081            }
6082
6083            let resp_json: Value = serde_json::from_str(r#"{"asset":"USDC","amount":"1000.00000000","repaidAmount":"300.00000000","remainingAmount":"700.00000000"}"#).unwrap_or_else(|_| serde_json::json!({}));
6084            let dummy_response: models::QueryLiquidationLoanResponse =
6085                serde_json::from_value(resp_json.clone())
6086                    .expect("should parse into models::QueryLiquidationLoanResponse");
6087
6088            let dummy = DummyRestApiResponse {
6089                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6090                status: 200,
6091                headers: HashMap::new(),
6092                rate_limits: None,
6093            };
6094
6095            Ok(dummy.into())
6096        }
6097
6098        async fn query_liquidation_loan_repay_history(
6099            &self,
6100            _params: QueryLiquidationLoanRepayHistoryParams,
6101        ) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanRepayHistoryResponse>>
6102        {
6103            if self.force_error {
6104                return Err(ConnectorError::ConnectorClientError {
6105                    msg: "ResponseError".to_string(),
6106                    code: None,
6107                }
6108                .into());
6109            }
6110
6111            let resp_json: Value = serde_json::from_str(r#"{"total":2,"rows":[{"repayId":12345678,"asset":"USDC","amount":"300.00000000","status":"SUCCESS","createTime":1714492800000}]}"#).unwrap_or_else(|_| serde_json::json!({}));
6112            let dummy_response: models::QueryLiquidationLoanRepayHistoryResponse =
6113                serde_json::from_value(resp_json.clone())
6114                    .expect("should parse into models::QueryLiquidationLoanRepayHistoryResponse");
6115
6116            let dummy = DummyRestApiResponse {
6117                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6118                status: 200,
6119                headers: HashMap::new(),
6120                rate_limits: None,
6121            };
6122
6123            Ok(dummy.into())
6124        }
6125
6126        async fn query_margin_accounts_all_oco(
6127            &self,
6128            _params: QueryMarginAccountsAllOcoParams,
6129        ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>>
6130        {
6131            if self.force_error {
6132                return Err(ConnectorError::ConnectorClientError {
6133                    msg: "ResponseError".to_string(),
6134                    code: None,
6135                }
6136                .into());
6137            }
6138
6139            let resp_json: Value = serde_json::from_str(r#"[{"orderListId":29,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"amEEAXryFzFwYF1FeRpUoZ","transactionTime":1565245913483,"symbol":"LTCBTC","isIsolated":true,"orders":[{"symbol":"LTCBTC","orderId":4,"clientOrderId":"oD7aesZqjEGlZrbtRpy5zB"}]}]"#).unwrap_or_else(|_| serde_json::json!({}));
6140            let dummy_response: Vec<models::QueryMarginAccountsAllOcoResponseInner> =
6141                serde_json::from_value(resp_json.clone()).expect(
6142                    "should parse into Vec<models::QueryMarginAccountsAllOcoResponseInner>",
6143                );
6144
6145            let dummy = DummyRestApiResponse {
6146                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6147                status: 200,
6148                headers: HashMap::new(),
6149                rate_limits: None,
6150            };
6151
6152            Ok(dummy.into())
6153        }
6154
6155        async fn query_margin_accounts_all_orders(
6156            &self,
6157            _params: QueryMarginAccountsAllOrdersParams,
6158        ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>>
6159        {
6160            if self.force_error {
6161                return Err(ConnectorError::ConnectorClientError {
6162                    msg: "ResponseError".to_string(),
6163                    code: None,
6164                }
6165                .into());
6166            }
6167
6168            let resp_json: Value = serde_json::from_str(r#"[{"clientOrderId":"D2KDy4DIeS56PvkM13f8cP","cummulativeQuoteQty":"0.00000000","executedQty":"0.00000000","icebergQty":"0.00000000","isWorking":false,"orderId":41295,"origQty":"5.31000000","price":"0.22500000","side":"SELL","status":"CANCELED","stopPrice":"0.18000000","symbol":"BNBBTC","isIsolated":false,"time":1565769338806,"timeInForce":"GTC","type":"TAKE_PROFIT_LIMIT","selfTradePreventionMode":"NONE","updateTime":1565769342148}]"#).unwrap_or_else(|_| serde_json::json!({}));
6169            let dummy_response: Vec<models::QueryMarginAccountsAllOrdersResponseInner> =
6170                serde_json::from_value(resp_json.clone()).expect(
6171                    "should parse into Vec<models::QueryMarginAccountsAllOrdersResponseInner>",
6172                );
6173
6174            let dummy = DummyRestApiResponse {
6175                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6176                status: 200,
6177                headers: HashMap::new(),
6178                rate_limits: None,
6179            };
6180
6181            Ok(dummy.into())
6182        }
6183
6184        async fn query_margin_accounts_oco(
6185            &self,
6186            _params: QueryMarginAccountsOcoParams,
6187        ) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOcoResponse>> {
6188            if self.force_error {
6189                return Err(ConnectorError::ConnectorClientError {
6190                    msg: "ResponseError".to_string(),
6191                    code: None,
6192                }
6193                .into());
6194            }
6195
6196            let resp_json: Value = serde_json::from_str(r#"{"orderListId":27,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"h2USkA5YQpaXHPIrkd96xE","transactionTime":1565245656253,"symbol":"LTCBTC","isIsolated":true,"orders":[{"symbol":"LTCBTC","orderId":4,"clientOrderId":"qD1gy3kc3Gx0rihm9Y3xwS"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
6197            let dummy_response: models::QueryMarginAccountsOcoResponse =
6198                serde_json::from_value(resp_json.clone())
6199                    .expect("should parse into models::QueryMarginAccountsOcoResponse");
6200
6201            let dummy = DummyRestApiResponse {
6202                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6203                status: 200,
6204                headers: HashMap::new(),
6205                rate_limits: None,
6206            };
6207
6208            Ok(dummy.into())
6209        }
6210
6211        async fn query_margin_accounts_open_oco(
6212            &self,
6213            _params: QueryMarginAccountsOpenOcoParams,
6214        ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>>
6215        {
6216            if self.force_error {
6217                return Err(ConnectorError::ConnectorClientError {
6218                    msg: "ResponseError".to_string(),
6219                    code: None,
6220                }
6221                .into());
6222            }
6223
6224            let resp_json: Value = serde_json::from_str(r#"[{"orderListId":31,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"wuB13fmulKj3YjdqWEcsnp","transactionTime":1565246080644,"symbol":"LTCBTC","isIsolated":true,"orders":[{"symbol":"LTCBTC","orderId":4,"clientOrderId":"r3EH2N76dHfLoSZWIUw1bT"}]}]"#).unwrap_or_else(|_| serde_json::json!({}));
6225            let dummy_response: Vec<models::QueryMarginAccountsOpenOcoResponseInner> =
6226                serde_json::from_value(resp_json.clone()).expect(
6227                    "should parse into Vec<models::QueryMarginAccountsOpenOcoResponseInner>",
6228                );
6229
6230            let dummy = DummyRestApiResponse {
6231                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6232                status: 200,
6233                headers: HashMap::new(),
6234                rate_limits: None,
6235            };
6236
6237            Ok(dummy.into())
6238        }
6239
6240        async fn query_margin_accounts_open_orders(
6241            &self,
6242            _params: QueryMarginAccountsOpenOrdersParams,
6243        ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>>
6244        {
6245            if self.force_error {
6246                return Err(ConnectorError::ConnectorClientError {
6247                    msg: "ResponseError".to_string(),
6248                    code: None,
6249                }
6250                .into());
6251            }
6252
6253            let resp_json: Value = serde_json::from_str(r#"[{"clientOrderId":"qhcZw71gAkCCTv0t0k8LUK","cummulativeQuoteQty":"0.00000000","executedQty":"0.00000000","icebergQty":"0.00000000","isWorking":true,"orderId":211842552,"origQty":"0.30000000","price":"0.00475010","side":"SELL","status":"NEW","stopPrice":"0.00000000","symbol":"BNBBTC","isIsolated":true,"time":1562040170089,"timeInForce":"GTC","type":"LIMIT","selfTradePreventionMode":"NONE","updateTime":1562040170089}]"#).unwrap_or_else(|_| serde_json::json!({}));
6254            let dummy_response: Vec<models::QueryMarginAccountsOpenOrdersResponseInner> =
6255                serde_json::from_value(resp_json.clone()).expect(
6256                    "should parse into Vec<models::QueryMarginAccountsOpenOrdersResponseInner>",
6257                );
6258
6259            let dummy = DummyRestApiResponse {
6260                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6261                status: 200,
6262                headers: HashMap::new(),
6263                rate_limits: None,
6264            };
6265
6266            Ok(dummy.into())
6267        }
6268
6269        async fn query_margin_accounts_order(
6270            &self,
6271            _params: QueryMarginAccountsOrderParams,
6272        ) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOrderResponse>> {
6273            if self.force_error {
6274                return Err(ConnectorError::ConnectorClientError {
6275                    msg: "ResponseError".to_string(),
6276                    code: None,
6277                }
6278                .into());
6279            }
6280
6281            let resp_json: Value = serde_json::from_str(r#"{"clientOrderId":"ZwfQzuDIGpceVhKW5DvCmO","cummulativeQuoteQty":"0.00000000","executedQty":"0.00000000","icebergQty":"0.00000000","isWorking":true,"orderId":213205622,"origQty":"0.30000000","price":"0.00493630","side":"SELL","status":"NEW","stopPrice":"0.00000000","symbol":"BNBBTC","isIsolated":true,"time":1562133008725,"timeInForce":"GTC","type":"LIMIT","selfTradePreventionMode":"NONE","updateTime":1562133008725}"#).unwrap_or_else(|_| serde_json::json!({}));
6282            let dummy_response: models::QueryMarginAccountsOrderResponse =
6283                serde_json::from_value(resp_json.clone())
6284                    .expect("should parse into models::QueryMarginAccountsOrderResponse");
6285
6286            let dummy = DummyRestApiResponse {
6287                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6288                status: 200,
6289                headers: HashMap::new(),
6290                rate_limits: None,
6291            };
6292
6293            Ok(dummy.into())
6294        }
6295
6296        async fn query_margin_accounts_trade_list(
6297            &self,
6298            _params: QueryMarginAccountsTradeListParams,
6299        ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsTradeListResponseInner>>>
6300        {
6301            if self.force_error {
6302                return Err(ConnectorError::ConnectorClientError {
6303                    msg: "ResponseError".to_string(),
6304                    code: None,
6305                }
6306                .into());
6307            }
6308
6309            let resp_json: Value = serde_json::from_str(r#"[{"commission":"0.00006000","commissionAsset":"BTC","id":34,"isBestMatch":true,"isBuyer":false,"isMaker":false,"orderId":39324,"price":"0.02000000","qty":"3.00000000","symbol":"BNBBTC","isIsolated":false,"time":1561973357171}]"#).unwrap_or_else(|_| serde_json::json!({}));
6310            let dummy_response: Vec<models::QueryMarginAccountsTradeListResponseInner> =
6311                serde_json::from_value(resp_json.clone()).expect(
6312                    "should parse into Vec<models::QueryMarginAccountsTradeListResponseInner>",
6313                );
6314
6315            let dummy = DummyRestApiResponse {
6316                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6317                status: 200,
6318                headers: HashMap::new(),
6319                rate_limits: None,
6320            };
6321
6322            Ok(dummy.into())
6323        }
6324
6325        async fn query_prevented_matches(
6326            &self,
6327            _params: QueryPreventedMatchesParams,
6328        ) -> anyhow::Result<RestApiResponse<Vec<models::QueryPreventedMatchesResponseInner>>>
6329        {
6330            if self.force_error {
6331                return Err(ConnectorError::ConnectorClientError {
6332                    msg: "ResponseError".to_string(),
6333                    code: None,
6334                }
6335                .into());
6336            }
6337
6338            let resp_json: Value = serde_json::from_str(r#"[{"symbol":"BTCUSDT","preventedMatchId":1,"takerOrderId":5,"makerSymbol":"BTCUSDT","makerOrderId":3,"tradeGroupId":1,"selfTradePreventionMode":"EXPIRE_MAKER","price":"1.100000","makerPreventedQuantity":"1.300000","transactTime":1669101687094}]"#).unwrap_or_else(|_| serde_json::json!({}));
6339            let dummy_response: Vec<models::QueryPreventedMatchesResponseInner> =
6340                serde_json::from_value(resp_json.clone())
6341                    .expect("should parse into Vec<models::QueryPreventedMatchesResponseInner>");
6342
6343            let dummy = DummyRestApiResponse {
6344                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6345                status: 200,
6346                headers: HashMap::new(),
6347                rate_limits: None,
6348            };
6349
6350            Ok(dummy.into())
6351        }
6352
6353        async fn query_special_key(
6354            &self,
6355            _params: QuerySpecialKeyParams,
6356        ) -> anyhow::Result<RestApiResponse<models::QuerySpecialKeyResponse>> {
6357            if self.force_error {
6358                return Err(ConnectorError::ConnectorClientError {
6359                    msg: "ResponseError".to_string(),
6360                    code: None,
6361                }
6362                .into());
6363            }
6364
6365            let resp_json: Value = serde_json::from_str(r#"{"apiKey":"npOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoGx","ip":"0.0.0.0,192.168.0.1,192.168.0.2","apiName":"testName","type":"RSA","permissionMode":"TRADE"}"#).unwrap_or_else(|_| serde_json::json!({}));
6366            let dummy_response: models::QuerySpecialKeyResponse =
6367                serde_json::from_value(resp_json.clone())
6368                    .expect("should parse into models::QuerySpecialKeyResponse");
6369
6370            let dummy = DummyRestApiResponse {
6371                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6372                status: 200,
6373                headers: HashMap::new(),
6374                rate_limits: None,
6375            };
6376
6377            Ok(dummy.into())
6378        }
6379
6380        async fn query_special_key_list(
6381            &self,
6382            _params: QuerySpecialKeyListParams,
6383        ) -> anyhow::Result<RestApiResponse<Vec<models::QuerySpecialKeyListResponseInner>>>
6384        {
6385            if self.force_error {
6386                return Err(ConnectorError::ConnectorClientError {
6387                    msg: "ResponseError".to_string(),
6388                    code: None,
6389                }
6390                .into());
6391            }
6392
6393            let resp_json: Value = serde_json::from_str(r#"[{"apiName":"testName1","apiKey":"znpOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoG","ip":"192.168.0.1,192.168.0.2","type":"RSA","permissionMode":"TRADE"}]"#).unwrap_or_else(|_| serde_json::json!({}));
6394            let dummy_response: Vec<models::QuerySpecialKeyListResponseInner> =
6395                serde_json::from_value(resp_json.clone())
6396                    .expect("should parse into Vec<models::QuerySpecialKeyListResponseInner>");
6397
6398            let dummy = DummyRestApiResponse {
6399                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6400                status: 200,
6401                headers: HashMap::new(),
6402                rate_limits: None,
6403            };
6404
6405            Ok(dummy.into())
6406        }
6407
6408        async fn small_liability_exchange(
6409            &self,
6410            _params: SmallLiabilityExchangeParams,
6411        ) -> anyhow::Result<RestApiResponse<Value>> {
6412            if self.force_error {
6413                return Err(ConnectorError::ConnectorClientError {
6414                    msg: "ResponseError".to_string(),
6415                    code: None,
6416                }
6417                .into());
6418            }
6419
6420            let dummy_response = Value::Null;
6421
6422            let dummy = DummyRestApiResponse {
6423                inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
6424                status: 200,
6425                headers: HashMap::new(),
6426                rate_limits: None,
6427            };
6428
6429            Ok(dummy.into())
6430        }
6431    }
6432
6433    #[test]
6434    fn create_special_key_required_params_success() {
6435        TOKIO_SHARED_RT.block_on(async {
6436            let client = MockTradeApiClient { force_error: false };
6437
6438            let params = CreateSpecialKeyParams::builder("apiName".to_string(),).build().unwrap();
6439
6440            let resp_json: Value = serde_json::from_str(r#"{"apiKey":"npOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoGx","secretKey":"87ssWB7azoy6ACRfyp6OVOL5U3rtZptX31QWw2kWjl1jHEYRbyM1pd6qykRBQw8p","type":"HMAC_SHA256"}"#).unwrap_or_else(|_| serde_json::json!({}));
6441            let expected_response : models::CreateSpecialKeyResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::CreateSpecialKeyResponse");
6442
6443            let resp = client.create_special_key(params).await.expect("Expected a response");
6444            let data_future = resp.data();
6445            let actual_response = data_future.await.unwrap();
6446            assert_eq!(actual_response, expected_response);
6447        });
6448    }
6449
6450    #[test]
6451    fn create_special_key_optional_params_success() {
6452        TOKIO_SHARED_RT.block_on(async {
6453            let client = MockTradeApiClient { force_error: false };
6454
6455            let params = CreateSpecialKeyParams::builder("apiName".to_string(),).symbol("BTCUSDT".to_string()).ip("69.210.67.14,69.210.67.15".to_string()).public_key("publicKey".to_string()).permission_mode(CreateSpecialKeyPermissionModeEnum::Trade).recv_window(5000).build().unwrap();
6456
6457            let resp_json: Value = serde_json::from_str(r#"{"apiKey":"npOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoGx","secretKey":"87ssWB7azoy6ACRfyp6OVOL5U3rtZptX31QWw2kWjl1jHEYRbyM1pd6qykRBQw8p","type":"HMAC_SHA256"}"#).unwrap_or_else(|_| serde_json::json!({}));
6458            let expected_response : models::CreateSpecialKeyResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::CreateSpecialKeyResponse");
6459
6460            let resp = client.create_special_key(params).await.expect("Expected a response");
6461            let data_future = resp.data();
6462            let actual_response = data_future.await.unwrap();
6463            assert_eq!(actual_response, expected_response);
6464        });
6465    }
6466
6467    #[test]
6468    fn create_special_key_response_error() {
6469        TOKIO_SHARED_RT.block_on(async {
6470            let client = MockTradeApiClient { force_error: true };
6471
6472            let params = CreateSpecialKeyParams::builder("apiName".to_string())
6473                .build()
6474                .unwrap();
6475
6476            match client.create_special_key(params).await {
6477                Ok(_) => panic!("Expected an error"),
6478                Err(err) => {
6479                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
6480                }
6481            }
6482        });
6483    }
6484
6485    #[test]
6486    fn delete_special_key_required_params_success() {
6487        TOKIO_SHARED_RT.block_on(async {
6488            let client = MockTradeApiClient { force_error: false };
6489
6490            let params = DeleteSpecialKeyParams::builder().build().unwrap();
6491
6492            let expected_response = Value::Null;
6493
6494            let resp = client
6495                .delete_special_key(params)
6496                .await
6497                .expect("Expected a response");
6498            let data_future = resp.data();
6499            let actual_response = data_future.await.unwrap();
6500            assert_eq!(actual_response, expected_response);
6501        });
6502    }
6503
6504    #[test]
6505    fn delete_special_key_optional_params_success() {
6506        TOKIO_SHARED_RT.block_on(async {
6507            let client = MockTradeApiClient { force_error: false };
6508
6509            let params = DeleteSpecialKeyParams::builder()
6510                .api_name("apiName".to_string())
6511                .symbol("BTCUSDT".to_string())
6512                .recv_window(5000)
6513                .build()
6514                .unwrap();
6515
6516            let expected_response = Value::Null;
6517
6518            let resp = client
6519                .delete_special_key(params)
6520                .await
6521                .expect("Expected a response");
6522            let data_future = resp.data();
6523            let actual_response = data_future.await.unwrap();
6524            assert_eq!(actual_response, expected_response);
6525        });
6526    }
6527
6528    #[test]
6529    fn delete_special_key_response_error() {
6530        TOKIO_SHARED_RT.block_on(async {
6531            let client = MockTradeApiClient { force_error: true };
6532
6533            let params = DeleteSpecialKeyParams::builder().build().unwrap();
6534
6535            match client.delete_special_key(params).await {
6536                Ok(_) => panic!("Expected an error"),
6537                Err(err) => {
6538                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
6539                }
6540            }
6541        });
6542    }
6543
6544    #[test]
6545    fn edit_ip_for_special_key_required_params_success() {
6546        TOKIO_SHARED_RT.block_on(async {
6547            let client = MockTradeApiClient { force_error: false };
6548
6549            let params = EditIpForSpecialKeyParams::builder("24.156.99.202".to_string())
6550                .build()
6551                .unwrap();
6552
6553            let expected_response = Value::Null;
6554
6555            let resp = client
6556                .edit_ip_for_special_key(params)
6557                .await
6558                .expect("Expected a response");
6559            let data_future = resp.data();
6560            let actual_response = data_future.await.unwrap();
6561            assert_eq!(actual_response, expected_response);
6562        });
6563    }
6564
6565    #[test]
6566    fn edit_ip_for_special_key_optional_params_success() {
6567        TOKIO_SHARED_RT.block_on(async {
6568            let client = MockTradeApiClient { force_error: false };
6569
6570            let params = EditIpForSpecialKeyParams::builder("24.156.99.202".to_string())
6571                .symbol("BTCUSDT".to_string())
6572                .recv_window(5000)
6573                .build()
6574                .unwrap();
6575
6576            let expected_response = Value::Null;
6577
6578            let resp = client
6579                .edit_ip_for_special_key(params)
6580                .await
6581                .expect("Expected a response");
6582            let data_future = resp.data();
6583            let actual_response = data_future.await.unwrap();
6584            assert_eq!(actual_response, expected_response);
6585        });
6586    }
6587
6588    #[test]
6589    fn edit_ip_for_special_key_response_error() {
6590        TOKIO_SHARED_RT.block_on(async {
6591            let client = MockTradeApiClient { force_error: true };
6592
6593            let params = EditIpForSpecialKeyParams::builder("24.156.99.202".to_string())
6594                .build()
6595                .unwrap();
6596
6597            match client.edit_ip_for_special_key(params).await {
6598                Ok(_) => panic!("Expected an error"),
6599                Err(err) => {
6600                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
6601                }
6602            }
6603        });
6604    }
6605
6606    #[test]
6607    fn exit_special_key_mode_required_params_success() {
6608        TOKIO_SHARED_RT.block_on(async {
6609            let client = MockTradeApiClient { force_error: false };
6610
6611            let params = ExitSpecialKeyModeParams::builder().build().unwrap();
6612
6613            let resp_json: Value =
6614                serde_json::from_str(r"").unwrap_or_else(|_| serde_json::json!({}));
6615            let expected_response: serde_json::Value = serde_json::from_value(resp_json.clone())
6616                .expect("should parse into serde_json::Value");
6617
6618            let resp = client
6619                .exit_special_key_mode(params)
6620                .await
6621                .expect("Expected a response");
6622            let data_future = resp.data();
6623            let actual_response = data_future.await.unwrap();
6624            assert_eq!(actual_response, expected_response);
6625        });
6626    }
6627
6628    #[test]
6629    fn exit_special_key_mode_optional_params_success() {
6630        TOKIO_SHARED_RT.block_on(async {
6631            let client = MockTradeApiClient { force_error: false };
6632
6633            let params = ExitSpecialKeyModeParams::builder()
6634                .recv_window(5000)
6635                .build()
6636                .unwrap();
6637
6638            let resp_json: Value =
6639                serde_json::from_str(r"").unwrap_or_else(|_| serde_json::json!({}));
6640            let expected_response: serde_json::Value = serde_json::from_value(resp_json.clone())
6641                .expect("should parse into serde_json::Value");
6642
6643            let resp = client
6644                .exit_special_key_mode(params)
6645                .await
6646                .expect("Expected a response");
6647            let data_future = resp.data();
6648            let actual_response = data_future.await.unwrap();
6649            assert_eq!(actual_response, expected_response);
6650        });
6651    }
6652
6653    #[test]
6654    fn exit_special_key_mode_response_error() {
6655        TOKIO_SHARED_RT.block_on(async {
6656            let client = MockTradeApiClient { force_error: true };
6657
6658            let params = ExitSpecialKeyModeParams::builder().build().unwrap();
6659
6660            match client.exit_special_key_mode(params).await {
6661                Ok(_) => panic!("Expected an error"),
6662                Err(err) => {
6663                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
6664                }
6665            }
6666        });
6667    }
6668
6669    #[test]
6670    fn get_force_liquidation_record_required_params_success() {
6671        TOKIO_SHARED_RT.block_on(async {
6672            let client = MockTradeApiClient { force_error: false };
6673
6674            let params = GetForceLiquidationRecordParams::builder().build().unwrap();
6675
6676            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"avgPrice":"0.00388359","executedQty":"31.39000000","orderId":180015097,"price":"0.00388110","qty":"31.39000000","side":"SELL","symbol":"BNBBTC","timeInForce":"GTC","isIsolated":true,"updatedTime":1558941374745}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
6677            let expected_response : models::GetForceLiquidationRecordResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetForceLiquidationRecordResponse");
6678
6679            let resp = client.get_force_liquidation_record(params).await.expect("Expected a response");
6680            let data_future = resp.data();
6681            let actual_response = data_future.await.unwrap();
6682            assert_eq!(actual_response, expected_response);
6683        });
6684    }
6685
6686    #[test]
6687    fn get_force_liquidation_record_optional_params_success() {
6688        TOKIO_SHARED_RT.block_on(async {
6689            let client = MockTradeApiClient { force_error: false };
6690
6691            let params = GetForceLiquidationRecordParams::builder().start_time(1623319461670).end_time(1641782889000).isolated_symbol("BTCUSDT".to_string()).current(1).size(10).recv_window(5000).build().unwrap();
6692
6693            let resp_json: Value = serde_json::from_str(r#"{"rows":[{"avgPrice":"0.00388359","executedQty":"31.39000000","orderId":180015097,"price":"0.00388110","qty":"31.39000000","side":"SELL","symbol":"BNBBTC","timeInForce":"GTC","isIsolated":true,"updatedTime":1558941374745}],"total":1}"#).unwrap_or_else(|_| serde_json::json!({}));
6694            let expected_response : models::GetForceLiquidationRecordResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetForceLiquidationRecordResponse");
6695
6696            let resp = client.get_force_liquidation_record(params).await.expect("Expected a response");
6697            let data_future = resp.data();
6698            let actual_response = data_future.await.unwrap();
6699            assert_eq!(actual_response, expected_response);
6700        });
6701    }
6702
6703    #[test]
6704    fn get_force_liquidation_record_response_error() {
6705        TOKIO_SHARED_RT.block_on(async {
6706            let client = MockTradeApiClient { force_error: true };
6707
6708            let params = GetForceLiquidationRecordParams::builder().build().unwrap();
6709
6710            match client.get_force_liquidation_record(params).await {
6711                Ok(_) => panic!("Expected an error"),
6712                Err(err) => {
6713                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
6714                }
6715            }
6716        });
6717    }
6718
6719    #[test]
6720    fn get_small_liability_exchange_coin_list_required_params_success() {
6721        TOKIO_SHARED_RT.block_on(async {
6722            let client = MockTradeApiClient { force_error: false };
6723
6724            let params = GetSmallLiabilityExchangeCoinListParams::builder().build().unwrap();
6725
6726            let resp_json: Value = serde_json::from_str(r#"[{"asset":"ETH","interest":"0.00083334","principal":"0.001","liabilityAsset":"USDT","liabilityQty":0.3552}]"#).unwrap_or_else(|_| serde_json::json!({}));
6727            let expected_response : Vec<models::GetSmallLiabilityExchangeCoinListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>");
6728
6729            let resp = client.get_small_liability_exchange_coin_list(params).await.expect("Expected a response");
6730            let data_future = resp.data();
6731            let actual_response = data_future.await.unwrap();
6732            assert_eq!(actual_response, expected_response);
6733        });
6734    }
6735
6736    #[test]
6737    fn get_small_liability_exchange_coin_list_optional_params_success() {
6738        TOKIO_SHARED_RT.block_on(async {
6739            let client = MockTradeApiClient { force_error: false };
6740
6741            let params = GetSmallLiabilityExchangeCoinListParams::builder().recv_window(5000).build().unwrap();
6742
6743            let resp_json: Value = serde_json::from_str(r#"[{"asset":"ETH","interest":"0.00083334","principal":"0.001","liabilityAsset":"USDT","liabilityQty":0.3552}]"#).unwrap_or_else(|_| serde_json::json!({}));
6744            let expected_response : Vec<models::GetSmallLiabilityExchangeCoinListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>");
6745
6746            let resp = client.get_small_liability_exchange_coin_list(params).await.expect("Expected a response");
6747            let data_future = resp.data();
6748            let actual_response = data_future.await.unwrap();
6749            assert_eq!(actual_response, expected_response);
6750        });
6751    }
6752
6753    #[test]
6754    fn get_small_liability_exchange_coin_list_response_error() {
6755        TOKIO_SHARED_RT.block_on(async {
6756            let client = MockTradeApiClient { force_error: true };
6757
6758            let params = GetSmallLiabilityExchangeCoinListParams::builder()
6759                .build()
6760                .unwrap();
6761
6762            match client.get_small_liability_exchange_coin_list(params).await {
6763                Ok(_) => panic!("Expected an error"),
6764                Err(err) => {
6765                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
6766                }
6767            }
6768        });
6769    }
6770
6771    #[test]
6772    fn get_small_liability_exchange_history_required_params_success() {
6773        TOKIO_SHARED_RT.block_on(async {
6774            let client = MockTradeApiClient { force_error: false };
6775
6776            let params = GetSmallLiabilityExchangeHistoryParams::builder(1,10,).build().unwrap();
6777
6778            let resp_json: Value = serde_json::from_str(r#"{"total":1,"rows":[{"asset":"ETH","amount":"0.00083434","targetAsset":"BUSD","targetAmount":"1.37576819","bizType":"EXCHANGE_SMALL_LIABILITY","timestamp":1672801339253}]}"#).unwrap_or_else(|_| serde_json::json!({}));
6779            let expected_response : models::GetSmallLiabilityExchangeHistoryResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetSmallLiabilityExchangeHistoryResponse");
6780
6781            let resp = client.get_small_liability_exchange_history(params).await.expect("Expected a response");
6782            let data_future = resp.data();
6783            let actual_response = data_future.await.unwrap();
6784            assert_eq!(actual_response, expected_response);
6785        });
6786    }
6787
6788    #[test]
6789    fn get_small_liability_exchange_history_optional_params_success() {
6790        TOKIO_SHARED_RT.block_on(async {
6791            let client = MockTradeApiClient { force_error: false };
6792
6793            let params = GetSmallLiabilityExchangeHistoryParams::builder(1,10,).start_time(1623319461670).end_time(1641782889000).recv_window(5000).build().unwrap();
6794
6795            let resp_json: Value = serde_json::from_str(r#"{"total":1,"rows":[{"asset":"ETH","amount":"0.00083434","targetAsset":"BUSD","targetAmount":"1.37576819","bizType":"EXCHANGE_SMALL_LIABILITY","timestamp":1672801339253}]}"#).unwrap_or_else(|_| serde_json::json!({}));
6796            let expected_response : models::GetSmallLiabilityExchangeHistoryResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetSmallLiabilityExchangeHistoryResponse");
6797
6798            let resp = client.get_small_liability_exchange_history(params).await.expect("Expected a response");
6799            let data_future = resp.data();
6800            let actual_response = data_future.await.unwrap();
6801            assert_eq!(actual_response, expected_response);
6802        });
6803    }
6804
6805    #[test]
6806    fn get_small_liability_exchange_history_response_error() {
6807        TOKIO_SHARED_RT.block_on(async {
6808            let client = MockTradeApiClient { force_error: true };
6809
6810            let params = GetSmallLiabilityExchangeHistoryParams::builder(1, 10)
6811                .build()
6812                .unwrap();
6813
6814            match client.get_small_liability_exchange_history(params).await {
6815                Ok(_) => panic!("Expected an error"),
6816                Err(err) => {
6817                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
6818                }
6819            }
6820        });
6821    }
6822
6823    #[test]
6824    fn liquidation_loan_repay_required_params_success() {
6825        TOKIO_SHARED_RT.block_on(async {
6826            let client = MockTradeApiClient { force_error: false };
6827
6828            let params = LiquidationLoanRepayParams::builder("USDT".to_string(),dec!(300.00),).build().unwrap();
6829
6830            let resp_json: Value = serde_json::from_str(r#"{"repayId":12345678,"asset":"USDT","amount":"300.00000000","status":"SUCCESS","createTime":1714492800000}"#).unwrap_or_else(|_| serde_json::json!({}));
6831            let expected_response : models::LiquidationLoanRepayResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::LiquidationLoanRepayResponse");
6832
6833            let resp = client.liquidation_loan_repay(params).await.expect("Expected a response");
6834            let data_future = resp.data();
6835            let actual_response = data_future.await.unwrap();
6836            assert_eq!(actual_response, expected_response);
6837        });
6838    }
6839
6840    #[test]
6841    fn liquidation_loan_repay_optional_params_success() {
6842        TOKIO_SHARED_RT.block_on(async {
6843            let client = MockTradeApiClient { force_error: false };
6844
6845            let params = LiquidationLoanRepayParams::builder("USDT".to_string(),dec!(300.00),).recv_window(5000).build().unwrap();
6846
6847            let resp_json: Value = serde_json::from_str(r#"{"repayId":12345678,"asset":"USDT","amount":"300.00000000","status":"SUCCESS","createTime":1714492800000}"#).unwrap_or_else(|_| serde_json::json!({}));
6848            let expected_response : models::LiquidationLoanRepayResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::LiquidationLoanRepayResponse");
6849
6850            let resp = client.liquidation_loan_repay(params).await.expect("Expected a response");
6851            let data_future = resp.data();
6852            let actual_response = data_future.await.unwrap();
6853            assert_eq!(actual_response, expected_response);
6854        });
6855    }
6856
6857    #[test]
6858    fn liquidation_loan_repay_response_error() {
6859        TOKIO_SHARED_RT.block_on(async {
6860            let client = MockTradeApiClient { force_error: true };
6861
6862            let params = LiquidationLoanRepayParams::builder("USDT".to_string(), dec!(300.00))
6863                .build()
6864                .unwrap();
6865
6866            match client.liquidation_loan_repay(params).await {
6867                Ok(_) => panic!("Expected an error"),
6868                Err(err) => {
6869                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
6870                }
6871            }
6872        });
6873    }
6874
6875    #[test]
6876    fn margin_account_cancel_all_open_orders_on_a_symbol_required_params_success() {
6877        TOKIO_SHARED_RT.block_on(async {
6878            let client = MockTradeApiClient { force_error: false };
6879
6880            let params = MarginAccountCancelAllOpenOrdersOnASymbolParams::builder("BTCUSDT".to_string(),).build().unwrap();
6881
6882            let resp_json: Value = serde_json::from_str(r#"[{"symbol":"BTCUSDT","isIsolated":true,"origClientOrderId":"E6APeyTJvkMvLMYMqu1KQ4","orderId":11,"orderListId":-1,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","price":"0.089853","origQty":"0.178622","executedQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE","contingencyType":"OCO","listStatusType":"ALL_DONE","listOrderStatus":"ALL_DONE","listClientOrderId":"2inzWQdDvZLHbbAmAozX2N","transactionTime":1585230948299,"orders":[{"symbol":"BTCUSDT","orderId":20,"clientOrderId":"CwOOIPHSmYywx6jZX77TdL"}],"orderReports":[{"symbol":"BTCUSDT","origClientOrderId":"CwOOIPHSmYywx6jZX77TdL","orderId":20,"orderListId":1929,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","price":"0.668611","origQty":"0.690354","executedQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"BUY","stopPrice":"0.378131","icebergQty":"0.017083"}]}]"#).unwrap_or_else(|_| serde_json::json!({}));
6883            let expected_response : Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>");
6884
6885            let resp = client.margin_account_cancel_all_open_orders_on_a_symbol(params).await.expect("Expected a response");
6886            let data_future = resp.data();
6887            let actual_response = data_future.await.unwrap();
6888            assert_eq!(actual_response, expected_response);
6889        });
6890    }
6891
6892    #[test]
6893    fn margin_account_cancel_all_open_orders_on_a_symbol_optional_params_success() {
6894        TOKIO_SHARED_RT.block_on(async {
6895            let client = MockTradeApiClient { force_error: false };
6896
6897            let params = MarginAccountCancelAllOpenOrdersOnASymbolParams::builder("BTCUSDT".to_string(),).is_isolated(MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum::True).recv_window(5000).build().unwrap();
6898
6899            let resp_json: Value = serde_json::from_str(r#"[{"symbol":"BTCUSDT","isIsolated":true,"origClientOrderId":"E6APeyTJvkMvLMYMqu1KQ4","orderId":11,"orderListId":-1,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","price":"0.089853","origQty":"0.178622","executedQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE","contingencyType":"OCO","listStatusType":"ALL_DONE","listOrderStatus":"ALL_DONE","listClientOrderId":"2inzWQdDvZLHbbAmAozX2N","transactionTime":1585230948299,"orders":[{"symbol":"BTCUSDT","orderId":20,"clientOrderId":"CwOOIPHSmYywx6jZX77TdL"}],"orderReports":[{"symbol":"BTCUSDT","origClientOrderId":"CwOOIPHSmYywx6jZX77TdL","orderId":20,"orderListId":1929,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","price":"0.668611","origQty":"0.690354","executedQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"BUY","stopPrice":"0.378131","icebergQty":"0.017083"}]}]"#).unwrap_or_else(|_| serde_json::json!({}));
6900            let expected_response : Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>");
6901
6902            let resp = client.margin_account_cancel_all_open_orders_on_a_symbol(params).await.expect("Expected a response");
6903            let data_future = resp.data();
6904            let actual_response = data_future.await.unwrap();
6905            assert_eq!(actual_response, expected_response);
6906        });
6907    }
6908
6909    #[test]
6910    fn margin_account_cancel_all_open_orders_on_a_symbol_response_error() {
6911        TOKIO_SHARED_RT.block_on(async {
6912            let client = MockTradeApiClient { force_error: true };
6913
6914            let params =
6915                MarginAccountCancelAllOpenOrdersOnASymbolParams::builder("BTCUSDT".to_string())
6916                    .build()
6917                    .unwrap();
6918
6919            match client
6920                .margin_account_cancel_all_open_orders_on_a_symbol(params)
6921                .await
6922            {
6923                Ok(_) => panic!("Expected an error"),
6924                Err(err) => {
6925                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
6926                }
6927            }
6928        });
6929    }
6930
6931    #[test]
6932    fn margin_account_cancel_oco_required_params_success() {
6933        TOKIO_SHARED_RT.block_on(async {
6934            let client = MockTradeApiClient { force_error: false };
6935
6936            let params = MarginAccountCancelOcoParams::builder("BTCUSDT".to_string(),).build().unwrap();
6937
6938            let resp_json: Value = serde_json::from_str(r#"{"orderListId":0,"contingencyType":"OCO","listStatusType":"ALL_DONE","listOrderStatus":"ALL_DONE","listClientOrderId":"C3wyj4WVEktd7u9aVBRXcN","transactionTime":1574040868128,"symbol":"LTCBTC","isIsolated":false,"orders":[{"symbol":"LTCBTC","orderId":2,"clientOrderId":"pO9ufTiFGg3nw2fOdgeOXa"}],"orderReports":[{"symbol":"LTCBTC","origClientOrderId":"pO9ufTiFGg3nw2fOdgeOXa","orderId":2,"orderListId":0,"clientOrderId":"unfWT8ig8i0uj6lPuYLez6","price":"1.00000000","origQty":"10.00000000","executedQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"1.00000000","selfTradePreventionMode":"NONE"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
6939            let expected_response : models::MarginAccountCancelOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountCancelOcoResponse");
6940
6941            let resp = client.margin_account_cancel_oco(params).await.expect("Expected a response");
6942            let data_future = resp.data();
6943            let actual_response = data_future.await.unwrap();
6944            assert_eq!(actual_response, expected_response);
6945        });
6946    }
6947
6948    #[test]
6949    fn margin_account_cancel_oco_optional_params_success() {
6950        TOKIO_SHARED_RT.block_on(async {
6951            let client = MockTradeApiClient { force_error: false };
6952
6953            let params = MarginAccountCancelOcoParams::builder("BTCUSDT".to_string(),).is_isolated(MarginAccountCancelOcoIsIsolatedEnum::True).order_list_id(1).list_client_order_id("1".to_string()).new_client_order_id("1".to_string()).recv_window(5000).build().unwrap();
6954
6955            let resp_json: Value = serde_json::from_str(r#"{"orderListId":0,"contingencyType":"OCO","listStatusType":"ALL_DONE","listOrderStatus":"ALL_DONE","listClientOrderId":"C3wyj4WVEktd7u9aVBRXcN","transactionTime":1574040868128,"symbol":"LTCBTC","isIsolated":false,"orders":[{"symbol":"LTCBTC","orderId":2,"clientOrderId":"pO9ufTiFGg3nw2fOdgeOXa"}],"orderReports":[{"symbol":"LTCBTC","origClientOrderId":"pO9ufTiFGg3nw2fOdgeOXa","orderId":2,"orderListId":0,"clientOrderId":"unfWT8ig8i0uj6lPuYLez6","price":"1.00000000","origQty":"10.00000000","executedQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"1.00000000","selfTradePreventionMode":"NONE"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
6956            let expected_response : models::MarginAccountCancelOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountCancelOcoResponse");
6957
6958            let resp = client.margin_account_cancel_oco(params).await.expect("Expected a response");
6959            let data_future = resp.data();
6960            let actual_response = data_future.await.unwrap();
6961            assert_eq!(actual_response, expected_response);
6962        });
6963    }
6964
6965    #[test]
6966    fn margin_account_cancel_oco_response_error() {
6967        TOKIO_SHARED_RT.block_on(async {
6968            let client = MockTradeApiClient { force_error: true };
6969
6970            let params = MarginAccountCancelOcoParams::builder("BTCUSDT".to_string())
6971                .build()
6972                .unwrap();
6973
6974            match client.margin_account_cancel_oco(params).await {
6975                Ok(_) => panic!("Expected an error"),
6976                Err(err) => {
6977                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
6978                }
6979            }
6980        });
6981    }
6982
6983    #[test]
6984    fn margin_account_cancel_order_required_params_success() {
6985        TOKIO_SHARED_RT.block_on(async {
6986            let client = MockTradeApiClient { force_error: false };
6987
6988            let params = MarginAccountCancelOrderParams::builder("LTCBTC".to_string(),).build().unwrap();
6989
6990            let resp_json: Value = serde_json::from_str(r#"{"symbol":"LTCBTC","orderId":"28","origClientOrderId":"myOrder1","clientOrderId":"cancelMyOrder1","price":"1.00000000","origQty":"10.00000000","executedQty":"8.00000000","cummulativeQuoteQty":"8.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"SELL","isIsolated":true}"#).unwrap_or_else(|_| serde_json::json!({}));
6991            let expected_response : models::MarginAccountCancelOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountCancelOrderResponse");
6992
6993            let resp = client.margin_account_cancel_order(params).await.expect("Expected a response");
6994            let data_future = resp.data();
6995            let actual_response = data_future.await.unwrap();
6996            assert_eq!(actual_response, expected_response);
6997        });
6998    }
6999
7000    #[test]
7001    fn margin_account_cancel_order_optional_params_success() {
7002        TOKIO_SHARED_RT.block_on(async {
7003            let client = MockTradeApiClient { force_error: false };
7004
7005            let params = MarginAccountCancelOrderParams::builder("LTCBTC".to_string(),).is_isolated(MarginAccountCancelOrderIsIsolatedEnum::True).order_id(1).orig_client_order_id("1".to_string()).new_client_order_id("1".to_string()).recv_window(5000).build().unwrap();
7006
7007            let resp_json: Value = serde_json::from_str(r#"{"symbol":"LTCBTC","orderId":"28","origClientOrderId":"myOrder1","clientOrderId":"cancelMyOrder1","price":"1.00000000","origQty":"10.00000000","executedQty":"8.00000000","cummulativeQuoteQty":"8.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"SELL","isIsolated":true}"#).unwrap_or_else(|_| serde_json::json!({}));
7008            let expected_response : models::MarginAccountCancelOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountCancelOrderResponse");
7009
7010            let resp = client.margin_account_cancel_order(params).await.expect("Expected a response");
7011            let data_future = resp.data();
7012            let actual_response = data_future.await.unwrap();
7013            assert_eq!(actual_response, expected_response);
7014        });
7015    }
7016
7017    #[test]
7018    fn margin_account_cancel_order_response_error() {
7019        TOKIO_SHARED_RT.block_on(async {
7020            let client = MockTradeApiClient { force_error: true };
7021
7022            let params = MarginAccountCancelOrderParams::builder("LTCBTC".to_string())
7023                .build()
7024                .unwrap();
7025
7026            match client.margin_account_cancel_order(params).await {
7027                Ok(_) => panic!("Expected an error"),
7028                Err(err) => {
7029                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7030                }
7031            }
7032        });
7033    }
7034
7035    #[test]
7036    fn margin_account_new_oco_required_params_success() {
7037        TOKIO_SHARED_RT.block_on(async {
7038            let client = MockTradeApiClient { force_error: false };
7039
7040            let params = MarginAccountNewOcoParams::builder("LTCBTC".to_string(),MarginAccountNewOcoSideEnum::Buy,dec!(1.0),dec!(1.0),dec!(1.0),).build().unwrap();
7041
7042            let resp_json: Value = serde_json::from_str(r#"{"orderListId":0,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"JYVpp3F0f5CAG15DhtrqLp","transactionTime":1563417480525,"symbol":"LTCBTC","marginBuyBorrowAmount":"5","marginBuyBorrowAsset":"BTC","isIsolated":false,"orders":[{"symbol":"LTCBTC","orderId":2,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos"}],"orderReports":[{"symbol":"LTCBTC","orderId":2,"orderListId":0,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos","transactTime":1563417480525,"price":"0.000000","origQty":"0.624363","executedQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"NEW","timeInForce":"GTC","type":"STOP_LOSS","side":"BUY","stopPrice":"0.960664","selfTradePreventionMode":"NONE"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7043            let expected_response : models::MarginAccountNewOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOcoResponse");
7044
7045            let resp = client.margin_account_new_oco(params).await.expect("Expected a response");
7046            let data_future = resp.data();
7047            let actual_response = data_future.await.unwrap();
7048            assert_eq!(actual_response, expected_response);
7049        });
7050    }
7051
7052    #[test]
7053    fn margin_account_new_oco_optional_params_success() {
7054        TOKIO_SHARED_RT.block_on(async {
7055            let client = MockTradeApiClient { force_error: false };
7056
7057            let params = MarginAccountNewOcoParams::builder("LTCBTC".to_string(),MarginAccountNewOcoSideEnum::Buy,dec!(1.0),dec!(1.0),dec!(1.0),).is_isolated(MarginAccountNewOcoIsIsolatedEnum::True).list_client_order_id("1".to_string()).limit_client_order_id("1".to_string()).limit_iceberg_qty(dec!(1.0)).stop_client_order_id("1".to_string()).stop_limit_price(dec!(1.0)).stop_iceberg_qty(dec!(1.0)).stop_limit_time_in_force(MarginAccountNewOcoStopLimitTimeInForceEnum::Gtc).new_order_resp_type(MarginAccountNewOcoNewOrderRespTypeEnum::Ack).side_effect_type(MarginAccountNewOcoSideEffectTypeEnum::NoSideEffect).self_trade_prevention_mode(MarginAccountNewOcoSelfTradePreventionModeEnum::ExpireTaker).auto_repay_at_cancel(false).recv_window(5000).build().unwrap();
7058
7059            let resp_json: Value = serde_json::from_str(r#"{"orderListId":0,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"JYVpp3F0f5CAG15DhtrqLp","transactionTime":1563417480525,"symbol":"LTCBTC","marginBuyBorrowAmount":"5","marginBuyBorrowAsset":"BTC","isIsolated":false,"orders":[{"symbol":"LTCBTC","orderId":2,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos"}],"orderReports":[{"symbol":"LTCBTC","orderId":2,"orderListId":0,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos","transactTime":1563417480525,"price":"0.000000","origQty":"0.624363","executedQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"NEW","timeInForce":"GTC","type":"STOP_LOSS","side":"BUY","stopPrice":"0.960664","selfTradePreventionMode":"NONE"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7060            let expected_response : models::MarginAccountNewOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOcoResponse");
7061
7062            let resp = client.margin_account_new_oco(params).await.expect("Expected a response");
7063            let data_future = resp.data();
7064            let actual_response = data_future.await.unwrap();
7065            assert_eq!(actual_response, expected_response);
7066        });
7067    }
7068
7069    #[test]
7070    fn margin_account_new_oco_response_error() {
7071        TOKIO_SHARED_RT.block_on(async {
7072            let client = MockTradeApiClient { force_error: true };
7073
7074            let params = MarginAccountNewOcoParams::builder(
7075                "LTCBTC".to_string(),
7076                MarginAccountNewOcoSideEnum::Buy,
7077                dec!(1.0),
7078                dec!(1.0),
7079                dec!(1.0),
7080            )
7081            .build()
7082            .unwrap();
7083
7084            match client.margin_account_new_oco(params).await {
7085                Ok(_) => panic!("Expected an error"),
7086                Err(err) => {
7087                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7088                }
7089            }
7090        });
7091    }
7092
7093    #[test]
7094    fn margin_account_new_order_required_params_success() {
7095        TOKIO_SHARED_RT.block_on(async {
7096            let client = MockTradeApiClient { force_error: false };
7097
7098            let params = MarginAccountNewOrderParams::builder("BTCUSDT".to_string(),MarginAccountNewOrderSideEnum::Buy,MarginAccountNewOrderTypeEnum::Limit,).build().unwrap();
7099
7100            let resp_json: Value = serde_json::from_str(r#"{"symbol":"BTCUSDT","orderId":26769564559,"clientOrderId":"E156O3KP4gOif65bjuUK5V","isIsolated":false,"transactTime":1713873075893,"price":"0","origQty":"0.001","executedQty":"0.001","cummulativeQuoteQty":"65.98253","status":"FILLED","timeInForce":"GTC","type":"MARKET","side":"SELL","selfTradePreventionMode":"EXPIRE_MAKER","marginBuyBorrowAmount":5,"marginBuyBorrowAsset":"BTC","fills":[{"price":"65982.53","qty":"0.001","commission":"0.06598253","commissionAsset":"USDT","tradeId":3570680726}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7101            let expected_response : models::MarginAccountNewOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOrderResponse");
7102
7103            let resp = client.margin_account_new_order(params).await.expect("Expected a response");
7104            let data_future = resp.data();
7105            let actual_response = data_future.await.unwrap();
7106            assert_eq!(actual_response, expected_response);
7107        });
7108    }
7109
7110    #[test]
7111    fn margin_account_new_order_optional_params_success() {
7112        TOKIO_SHARED_RT.block_on(async {
7113            let client = MockTradeApiClient { force_error: false };
7114
7115            let params = MarginAccountNewOrderParams::builder("BTCUSDT".to_string(),MarginAccountNewOrderSideEnum::Buy,MarginAccountNewOrderTypeEnum::Limit,).is_isolated(MarginAccountNewOrderIsIsolatedEnum::True).quantity(dec!(1.0)).quote_order_qty(dec!(1.0)).price(dec!(1.0)).stop_price(dec!(1.0)).new_client_order_id("1".to_string()).iceberg_qty(dec!(1.0)).new_order_resp_type(MarginAccountNewOrderNewOrderRespTypeEnum::Ack).side_effect_type(MarginAccountNewOrderSideEffectTypeEnum::NoSideEffect).time_in_force(MarginAccountNewOrderTimeInForceEnum::Gtc).self_trade_prevention_mode(MarginAccountNewOrderSelfTradePreventionModeEnum::ExpireTaker).trailing_delta(100).auto_repay_at_cancel(true).recv_window(5000).build().unwrap();
7116
7117            let resp_json: Value = serde_json::from_str(r#"{"symbol":"BTCUSDT","orderId":26769564559,"clientOrderId":"E156O3KP4gOif65bjuUK5V","isIsolated":false,"transactTime":1713873075893,"price":"0","origQty":"0.001","executedQty":"0.001","cummulativeQuoteQty":"65.98253","status":"FILLED","timeInForce":"GTC","type":"MARKET","side":"SELL","selfTradePreventionMode":"EXPIRE_MAKER","marginBuyBorrowAmount":5,"marginBuyBorrowAsset":"BTC","fills":[{"price":"65982.53","qty":"0.001","commission":"0.06598253","commissionAsset":"USDT","tradeId":3570680726}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7118            let expected_response : models::MarginAccountNewOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOrderResponse");
7119
7120            let resp = client.margin_account_new_order(params).await.expect("Expected a response");
7121            let data_future = resp.data();
7122            let actual_response = data_future.await.unwrap();
7123            assert_eq!(actual_response, expected_response);
7124        });
7125    }
7126
7127    #[test]
7128    fn margin_account_new_order_response_error() {
7129        TOKIO_SHARED_RT.block_on(async {
7130            let client = MockTradeApiClient { force_error: true };
7131
7132            let params = MarginAccountNewOrderParams::builder(
7133                "BTCUSDT".to_string(),
7134                MarginAccountNewOrderSideEnum::Buy,
7135                MarginAccountNewOrderTypeEnum::Limit,
7136            )
7137            .build()
7138            .unwrap();
7139
7140            match client.margin_account_new_order(params).await {
7141                Ok(_) => panic!("Expected an error"),
7142                Err(err) => {
7143                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7144                }
7145            }
7146        });
7147    }
7148
7149    #[test]
7150    fn margin_account_new_oto_required_params_success() {
7151        TOKIO_SHARED_RT.block_on(async {
7152            let client = MockTradeApiClient { force_error: false };
7153
7154            let params = MarginAccountNewOtoParams::builder("BTCUSDT".to_string(),MarginAccountNewOtoWorkingTypeEnum::Limit,MarginAccountNewOtoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),dec!(1.0),MarginAccountNewOtoPendingTypeEnum::Limit,MarginAccountNewOtoPendingSideEnum::Buy,dec!(1.0),).build().unwrap();
7155
7156            let resp_json: Value = serde_json::from_str(r#"{"orderListId":13551,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"JDuOrsu0Ge8GTyvx8J7VTD","transactionTime":1725521998054,"symbol":"BTCUSDT","isIsolated":false,"orders":[{"symbol":"BTCUSDT","orderId":29896699,"clientOrderId":"y8RB6tQEMuHUXybqbtzTxk"}],"orderReports":[{"symbol":"BTCUSDT","orderId":29896699,"orderListId":13551,"clientOrderId":"y8RB6tQEMuHUXybqbtzTxk","transactTime":1725521998054,"price":"80000.00000000","origQty":"0.02000000","executedQty":"0","cummulativeQuoteQty":"0","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","selfTradePreventionMode":"NONE"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7157            let expected_response : models::MarginAccountNewOtoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOtoResponse");
7158
7159            let resp = client.margin_account_new_oto(params).await.expect("Expected a response");
7160            let data_future = resp.data();
7161            let actual_response = data_future.await.unwrap();
7162            assert_eq!(actual_response, expected_response);
7163        });
7164    }
7165
7166    #[test]
7167    fn margin_account_new_oto_optional_params_success() {
7168        TOKIO_SHARED_RT.block_on(async {
7169            let client = MockTradeApiClient { force_error: false };
7170
7171            let params = MarginAccountNewOtoParams::builder("BTCUSDT".to_string(),MarginAccountNewOtoWorkingTypeEnum::Limit,MarginAccountNewOtoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),dec!(1.0),MarginAccountNewOtoPendingTypeEnum::Limit,MarginAccountNewOtoPendingSideEnum::Buy,dec!(1.0),).is_isolated(MarginAccountNewOtoIsIsolatedEnum::True).list_client_order_id("1".to_string()).new_order_resp_type(MarginAccountNewOtoNewOrderRespTypeEnum::Ack).side_effect_type(MarginAccountNewOtoSideEffectTypeEnum::NoSideEffect).self_trade_prevention_mode(MarginAccountNewOtoSelfTradePreventionModeEnum::ExpireTaker).auto_repay_at_cancel(true).working_client_order_id("1".to_string()).working_time_in_force(MarginAccountNewOtoWorkingTimeInForceEnum::Gtc).pending_client_order_id("1".to_string()).pending_price(dec!(1.0)).pending_stop_price(dec!(1.0)).pending_trailing_delta(dec!(1.0)).pending_iceberg_qty(dec!(1.0)).pending_time_in_force(MarginAccountNewOtoPendingTimeInForceEnum::Gtc).build().unwrap();
7172
7173            let resp_json: Value = serde_json::from_str(r#"{"orderListId":13551,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"JDuOrsu0Ge8GTyvx8J7VTD","transactionTime":1725521998054,"symbol":"BTCUSDT","isIsolated":false,"orders":[{"symbol":"BTCUSDT","orderId":29896699,"clientOrderId":"y8RB6tQEMuHUXybqbtzTxk"}],"orderReports":[{"symbol":"BTCUSDT","orderId":29896699,"orderListId":13551,"clientOrderId":"y8RB6tQEMuHUXybqbtzTxk","transactTime":1725521998054,"price":"80000.00000000","origQty":"0.02000000","executedQty":"0","cummulativeQuoteQty":"0","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","selfTradePreventionMode":"NONE"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7174            let expected_response : models::MarginAccountNewOtoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOtoResponse");
7175
7176            let resp = client.margin_account_new_oto(params).await.expect("Expected a response");
7177            let data_future = resp.data();
7178            let actual_response = data_future.await.unwrap();
7179            assert_eq!(actual_response, expected_response);
7180        });
7181    }
7182
7183    #[test]
7184    fn margin_account_new_oto_response_error() {
7185        TOKIO_SHARED_RT.block_on(async {
7186            let client = MockTradeApiClient { force_error: true };
7187
7188            let params = MarginAccountNewOtoParams::builder(
7189                "BTCUSDT".to_string(),
7190                MarginAccountNewOtoWorkingTypeEnum::Limit,
7191                MarginAccountNewOtoWorkingSideEnum::Buy,
7192                dec!(1.0),
7193                dec!(1.0),
7194                dec!(1.0),
7195                MarginAccountNewOtoPendingTypeEnum::Limit,
7196                MarginAccountNewOtoPendingSideEnum::Buy,
7197                dec!(1.0),
7198            )
7199            .build()
7200            .unwrap();
7201
7202            match client.margin_account_new_oto(params).await {
7203                Ok(_) => panic!("Expected an error"),
7204                Err(err) => {
7205                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7206                }
7207            }
7208        });
7209    }
7210
7211    #[test]
7212    fn margin_account_new_otoco_required_params_success() {
7213        TOKIO_SHARED_RT.block_on(async {
7214            let client = MockTradeApiClient { force_error: false };
7215
7216            let params = MarginAccountNewOtocoParams::builder("BTCUSDT".to_string(),MarginAccountNewOtocoWorkingTypeEnum::Limit,MarginAccountNewOtocoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),MarginAccountNewOtocoPendingSideEnum::Buy,dec!(1.0),MarginAccountNewOtocoPendingAboveTypeEnum::LimitMaker,).build().unwrap();
7217
7218            let resp_json: Value = serde_json::from_str(r#"{"orderListId":13509,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"u2AUo48LLef5qVenRtwJZy","transactionTime":1725521881300,"symbol":"BNBUSDT","isIsolated":false,"orders":[{"symbol":"BNBUSDT","orderId":28282534,"clientOrderId":"IfYDxvrZI4kiyqYpRH13iI"}],"orderReports":[{"symbol":"BNBUSDT","orderId":28282534,"orderListId":13509,"clientOrderId":"IfYDxvrZI4kiyqYpRH13iI","transactTime":1725521881300,"price":"300.00000000","origQty":"1.00000000","executedQty":"0","cummulativeQuoteQty":"0","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE","stopPrice":"299.00000000"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7219            let expected_response : models::MarginAccountNewOtocoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOtocoResponse");
7220
7221            let resp = client.margin_account_new_otoco(params).await.expect("Expected a response");
7222            let data_future = resp.data();
7223            let actual_response = data_future.await.unwrap();
7224            assert_eq!(actual_response, expected_response);
7225        });
7226    }
7227
7228    #[test]
7229    fn margin_account_new_otoco_optional_params_success() {
7230        TOKIO_SHARED_RT.block_on(async {
7231            let client = MockTradeApiClient { force_error: false };
7232
7233            let params = MarginAccountNewOtocoParams::builder("BTCUSDT".to_string(),MarginAccountNewOtocoWorkingTypeEnum::Limit,MarginAccountNewOtocoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),MarginAccountNewOtocoPendingSideEnum::Buy,dec!(1.0),MarginAccountNewOtocoPendingAboveTypeEnum::LimitMaker,).is_isolated(MarginAccountNewOtocoIsIsolatedEnum::True).side_effect_type(MarginAccountNewOtocoSideEffectTypeEnum::NoSideEffect).auto_repay_at_cancel(true).list_client_order_id("1".to_string()).new_order_resp_type(MarginAccountNewOtocoNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(MarginAccountNewOtocoSelfTradePreventionModeEnum::ExpireTaker).working_client_order_id("1".to_string()).working_iceberg_qty(dec!(1.0)).working_time_in_force(MarginAccountNewOtocoWorkingTimeInForceEnum::Gtc).pending_above_client_order_id("1".to_string()).pending_above_price(dec!(1.0)).pending_above_stop_price(dec!(1.0)).pending_above_trailing_delta(dec!(1.0)).pending_above_iceberg_qty(dec!(1.0)).pending_above_time_in_force(MarginAccountNewOtocoPendingAboveTimeInForceEnum::Gtc).pending_below_type(MarginAccountNewOtocoPendingBelowTypeEnum::LimitMaker).pending_below_client_order_id("1".to_string()).pending_below_price(dec!(1.0)).pending_below_stop_price(dec!(1.0)).pending_below_trailing_delta(dec!(1.0)).pending_below_iceberg_qty(dec!(1.0)).pending_below_time_in_force(MarginAccountNewOtocoPendingBelowTimeInForceEnum::Gtc).build().unwrap();
7234
7235            let resp_json: Value = serde_json::from_str(r#"{"orderListId":13509,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"u2AUo48LLef5qVenRtwJZy","transactionTime":1725521881300,"symbol":"BNBUSDT","isIsolated":false,"orders":[{"symbol":"BNBUSDT","orderId":28282534,"clientOrderId":"IfYDxvrZI4kiyqYpRH13iI"}],"orderReports":[{"symbol":"BNBUSDT","orderId":28282534,"orderListId":13509,"clientOrderId":"IfYDxvrZI4kiyqYpRH13iI","transactTime":1725521881300,"price":"300.00000000","origQty":"1.00000000","executedQty":"0","cummulativeQuoteQty":"0","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE","stopPrice":"299.00000000"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7236            let expected_response : models::MarginAccountNewOtocoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOtocoResponse");
7237
7238            let resp = client.margin_account_new_otoco(params).await.expect("Expected a response");
7239            let data_future = resp.data();
7240            let actual_response = data_future.await.unwrap();
7241            assert_eq!(actual_response, expected_response);
7242        });
7243    }
7244
7245    #[test]
7246    fn margin_account_new_otoco_response_error() {
7247        TOKIO_SHARED_RT.block_on(async {
7248            let client = MockTradeApiClient { force_error: true };
7249
7250            let params = MarginAccountNewOtocoParams::builder(
7251                "BTCUSDT".to_string(),
7252                MarginAccountNewOtocoWorkingTypeEnum::Limit,
7253                MarginAccountNewOtocoWorkingSideEnum::Buy,
7254                dec!(1.0),
7255                dec!(1.0),
7256                MarginAccountNewOtocoPendingSideEnum::Buy,
7257                dec!(1.0),
7258                MarginAccountNewOtocoPendingAboveTypeEnum::LimitMaker,
7259            )
7260            .build()
7261            .unwrap();
7262
7263            match client.margin_account_new_otoco(params).await {
7264                Ok(_) => panic!("Expected an error"),
7265                Err(err) => {
7266                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7267                }
7268            }
7269        });
7270    }
7271
7272    #[test]
7273    fn margin_manual_liquidation_required_params_success() {
7274        TOKIO_SHARED_RT.block_on(async {
7275            let client = MockTradeApiClient { force_error: false };
7276
7277            let params = MarginManualLiquidationParams::builder(MarginManualLiquidationTypeEnum::Margin,).build().unwrap();
7278
7279            let resp_json: Value = serde_json::from_str(r#"{"asset":"ETH","interest":"0.00083334","principal":"0.001","liabilityAsset":"USDT","liabilityQty":0.3552}"#).unwrap_or_else(|_| serde_json::json!({}));
7280            let expected_response : models::MarginManualLiquidationResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginManualLiquidationResponse");
7281
7282            let resp = client.margin_manual_liquidation(params).await.expect("Expected a response");
7283            let data_future = resp.data();
7284            let actual_response = data_future.await.unwrap();
7285            assert_eq!(actual_response, expected_response);
7286        });
7287    }
7288
7289    #[test]
7290    fn margin_manual_liquidation_optional_params_success() {
7291        TOKIO_SHARED_RT.block_on(async {
7292            let client = MockTradeApiClient { force_error: false };
7293
7294            let params = MarginManualLiquidationParams::builder(MarginManualLiquidationTypeEnum::Margin,).symbol("ETHUSDT".to_string()).recv_window(5000).build().unwrap();
7295
7296            let resp_json: Value = serde_json::from_str(r#"{"asset":"ETH","interest":"0.00083334","principal":"0.001","liabilityAsset":"USDT","liabilityQty":0.3552}"#).unwrap_or_else(|_| serde_json::json!({}));
7297            let expected_response : models::MarginManualLiquidationResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginManualLiquidationResponse");
7298
7299            let resp = client.margin_manual_liquidation(params).await.expect("Expected a response");
7300            let data_future = resp.data();
7301            let actual_response = data_future.await.unwrap();
7302            assert_eq!(actual_response, expected_response);
7303        });
7304    }
7305
7306    #[test]
7307    fn margin_manual_liquidation_response_error() {
7308        TOKIO_SHARED_RT.block_on(async {
7309            let client = MockTradeApiClient { force_error: true };
7310
7311            let params =
7312                MarginManualLiquidationParams::builder(MarginManualLiquidationTypeEnum::Margin)
7313                    .build()
7314                    .unwrap();
7315
7316            match client.margin_manual_liquidation(params).await {
7317                Ok(_) => panic!("Expected an error"),
7318                Err(err) => {
7319                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7320                }
7321            }
7322        });
7323    }
7324
7325    #[test]
7326    fn query_current_margin_order_count_usage_required_params_success() {
7327        TOKIO_SHARED_RT.block_on(async {
7328            let client = MockTradeApiClient { force_error: false };
7329
7330            let params = QueryCurrentMarginOrderCountUsageParams::builder().build().unwrap();
7331
7332            let resp_json: Value = serde_json::from_str(r#"[{"rateLimitType":"ORDERS","interval":"SECOND","intervalNum":10,"limit":10000,"count":0}]"#).unwrap_or_else(|_| serde_json::json!({}));
7333            let expected_response : Vec<models::QueryCurrentMarginOrderCountUsageResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>");
7334
7335            let resp = client.query_current_margin_order_count_usage(params).await.expect("Expected a response");
7336            let data_future = resp.data();
7337            let actual_response = data_future.await.unwrap();
7338            assert_eq!(actual_response, expected_response);
7339        });
7340    }
7341
7342    #[test]
7343    fn query_current_margin_order_count_usage_optional_params_success() {
7344        TOKIO_SHARED_RT.block_on(async {
7345            let client = MockTradeApiClient { force_error: false };
7346
7347            let params = QueryCurrentMarginOrderCountUsageParams::builder().is_isolated(QueryCurrentMarginOrderCountUsageIsIsolatedEnum::True).symbol("BTCUSDT".to_string()).recv_window(5000).build().unwrap();
7348
7349            let resp_json: Value = serde_json::from_str(r#"[{"rateLimitType":"ORDERS","interval":"SECOND","intervalNum":10,"limit":10000,"count":0}]"#).unwrap_or_else(|_| serde_json::json!({}));
7350            let expected_response : Vec<models::QueryCurrentMarginOrderCountUsageResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>");
7351
7352            let resp = client.query_current_margin_order_count_usage(params).await.expect("Expected a response");
7353            let data_future = resp.data();
7354            let actual_response = data_future.await.unwrap();
7355            assert_eq!(actual_response, expected_response);
7356        });
7357    }
7358
7359    #[test]
7360    fn query_current_margin_order_count_usage_response_error() {
7361        TOKIO_SHARED_RT.block_on(async {
7362            let client = MockTradeApiClient { force_error: true };
7363
7364            let params = QueryCurrentMarginOrderCountUsageParams::builder()
7365                .build()
7366                .unwrap();
7367
7368            match client.query_current_margin_order_count_usage(params).await {
7369                Ok(_) => panic!("Expected an error"),
7370                Err(err) => {
7371                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7372                }
7373            }
7374        });
7375    }
7376
7377    #[test]
7378    fn query_liquidation_loan_required_params_success() {
7379        TOKIO_SHARED_RT.block_on(async {
7380            let client = MockTradeApiClient { force_error: false };
7381
7382            let params = QueryLiquidationLoanParams::builder().build().unwrap();
7383
7384            let resp_json: Value = serde_json::from_str(r#"{"asset":"USDC","amount":"1000.00000000","repaidAmount":"300.00000000","remainingAmount":"700.00000000"}"#).unwrap_or_else(|_| serde_json::json!({}));
7385            let expected_response : models::QueryLiquidationLoanResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryLiquidationLoanResponse");
7386
7387            let resp = client.query_liquidation_loan(params).await.expect("Expected a response");
7388            let data_future = resp.data();
7389            let actual_response = data_future.await.unwrap();
7390            assert_eq!(actual_response, expected_response);
7391        });
7392    }
7393
7394    #[test]
7395    fn query_liquidation_loan_optional_params_success() {
7396        TOKIO_SHARED_RT.block_on(async {
7397            let client = MockTradeApiClient { force_error: false };
7398
7399            let params = QueryLiquidationLoanParams::builder().recv_window(5000).build().unwrap();
7400
7401            let resp_json: Value = serde_json::from_str(r#"{"asset":"USDC","amount":"1000.00000000","repaidAmount":"300.00000000","remainingAmount":"700.00000000"}"#).unwrap_or_else(|_| serde_json::json!({}));
7402            let expected_response : models::QueryLiquidationLoanResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryLiquidationLoanResponse");
7403
7404            let resp = client.query_liquidation_loan(params).await.expect("Expected a response");
7405            let data_future = resp.data();
7406            let actual_response = data_future.await.unwrap();
7407            assert_eq!(actual_response, expected_response);
7408        });
7409    }
7410
7411    #[test]
7412    fn query_liquidation_loan_response_error() {
7413        TOKIO_SHARED_RT.block_on(async {
7414            let client = MockTradeApiClient { force_error: true };
7415
7416            let params = QueryLiquidationLoanParams::builder().build().unwrap();
7417
7418            match client.query_liquidation_loan(params).await {
7419                Ok(_) => panic!("Expected an error"),
7420                Err(err) => {
7421                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7422                }
7423            }
7424        });
7425    }
7426
7427    #[test]
7428    fn query_liquidation_loan_repay_history_required_params_success() {
7429        TOKIO_SHARED_RT.block_on(async {
7430            let client = MockTradeApiClient { force_error: false };
7431
7432            let params = QueryLiquidationLoanRepayHistoryParams::builder().build().unwrap();
7433
7434            let resp_json: Value = serde_json::from_str(r#"{"total":2,"rows":[{"repayId":12345678,"asset":"USDC","amount":"300.00000000","status":"SUCCESS","createTime":1714492800000}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7435            let expected_response : models::QueryLiquidationLoanRepayHistoryResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryLiquidationLoanRepayHistoryResponse");
7436
7437            let resp = client.query_liquidation_loan_repay_history(params).await.expect("Expected a response");
7438            let data_future = resp.data();
7439            let actual_response = data_future.await.unwrap();
7440            assert_eq!(actual_response, expected_response);
7441        });
7442    }
7443
7444    #[test]
7445    fn query_liquidation_loan_repay_history_optional_params_success() {
7446        TOKIO_SHARED_RT.block_on(async {
7447            let client = MockTradeApiClient { force_error: false };
7448
7449            let params = QueryLiquidationLoanRepayHistoryParams::builder().start_time(1714492800000).end_time(1714579200000).current(1).size(50).recv_window(5000).build().unwrap();
7450
7451            let resp_json: Value = serde_json::from_str(r#"{"total":2,"rows":[{"repayId":12345678,"asset":"USDC","amount":"300.00000000","status":"SUCCESS","createTime":1714492800000}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7452            let expected_response : models::QueryLiquidationLoanRepayHistoryResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryLiquidationLoanRepayHistoryResponse");
7453
7454            let resp = client.query_liquidation_loan_repay_history(params).await.expect("Expected a response");
7455            let data_future = resp.data();
7456            let actual_response = data_future.await.unwrap();
7457            assert_eq!(actual_response, expected_response);
7458        });
7459    }
7460
7461    #[test]
7462    fn query_liquidation_loan_repay_history_response_error() {
7463        TOKIO_SHARED_RT.block_on(async {
7464            let client = MockTradeApiClient { force_error: true };
7465
7466            let params = QueryLiquidationLoanRepayHistoryParams::builder()
7467                .build()
7468                .unwrap();
7469
7470            match client.query_liquidation_loan_repay_history(params).await {
7471                Ok(_) => panic!("Expected an error"),
7472                Err(err) => {
7473                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7474                }
7475            }
7476        });
7477    }
7478
7479    #[test]
7480    fn query_margin_accounts_all_oco_required_params_success() {
7481        TOKIO_SHARED_RT.block_on(async {
7482            let client = MockTradeApiClient { force_error: false };
7483
7484            let params = QueryMarginAccountsAllOcoParams::builder().build().unwrap();
7485
7486            let resp_json: Value = serde_json::from_str(r#"[{"orderListId":29,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"amEEAXryFzFwYF1FeRpUoZ","transactionTime":1565245913483,"symbol":"LTCBTC","isIsolated":true,"orders":[{"symbol":"LTCBTC","orderId":4,"clientOrderId":"oD7aesZqjEGlZrbtRpy5zB"}]}]"#).unwrap_or_else(|_| serde_json::json!({}));
7487            let expected_response : Vec<models::QueryMarginAccountsAllOcoResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsAllOcoResponseInner>");
7488
7489            let resp = client.query_margin_accounts_all_oco(params).await.expect("Expected a response");
7490            let data_future = resp.data();
7491            let actual_response = data_future.await.unwrap();
7492            assert_eq!(actual_response, expected_response);
7493        });
7494    }
7495
7496    #[test]
7497    fn query_margin_accounts_all_oco_optional_params_success() {
7498        TOKIO_SHARED_RT.block_on(async {
7499            let client = MockTradeApiClient { force_error: false };
7500
7501            let params = QueryMarginAccountsAllOcoParams::builder().is_isolated(QueryMarginAccountsAllOcoIsIsolatedEnum::True).symbol("LTCBTC".to_string()).from_id(1).start_time(1623319461670).end_time(1641782889000).limit(100).recv_window(5000).build().unwrap();
7502
7503            let resp_json: Value = serde_json::from_str(r#"[{"orderListId":29,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"amEEAXryFzFwYF1FeRpUoZ","transactionTime":1565245913483,"symbol":"LTCBTC","isIsolated":true,"orders":[{"symbol":"LTCBTC","orderId":4,"clientOrderId":"oD7aesZqjEGlZrbtRpy5zB"}]}]"#).unwrap_or_else(|_| serde_json::json!({}));
7504            let expected_response : Vec<models::QueryMarginAccountsAllOcoResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsAllOcoResponseInner>");
7505
7506            let resp = client.query_margin_accounts_all_oco(params).await.expect("Expected a response");
7507            let data_future = resp.data();
7508            let actual_response = data_future.await.unwrap();
7509            assert_eq!(actual_response, expected_response);
7510        });
7511    }
7512
7513    #[test]
7514    fn query_margin_accounts_all_oco_response_error() {
7515        TOKIO_SHARED_RT.block_on(async {
7516            let client = MockTradeApiClient { force_error: true };
7517
7518            let params = QueryMarginAccountsAllOcoParams::builder().build().unwrap();
7519
7520            match client.query_margin_accounts_all_oco(params).await {
7521                Ok(_) => panic!("Expected an error"),
7522                Err(err) => {
7523                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7524                }
7525            }
7526        });
7527    }
7528
7529    #[test]
7530    fn query_margin_accounts_all_orders_required_params_success() {
7531        TOKIO_SHARED_RT.block_on(async {
7532            let client = MockTradeApiClient { force_error: false };
7533
7534            let params = QueryMarginAccountsAllOrdersParams::builder("BNBBTC".to_string(),).build().unwrap();
7535
7536            let resp_json: Value = serde_json::from_str(r#"[{"clientOrderId":"D2KDy4DIeS56PvkM13f8cP","cummulativeQuoteQty":"0.00000000","executedQty":"0.00000000","icebergQty":"0.00000000","isWorking":false,"orderId":41295,"origQty":"5.31000000","price":"0.22500000","side":"SELL","status":"CANCELED","stopPrice":"0.18000000","symbol":"BNBBTC","isIsolated":false,"time":1565769338806,"timeInForce":"GTC","type":"TAKE_PROFIT_LIMIT","selfTradePreventionMode":"NONE","updateTime":1565769342148}]"#).unwrap_or_else(|_| serde_json::json!({}));
7537            let expected_response : Vec<models::QueryMarginAccountsAllOrdersResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsAllOrdersResponseInner>");
7538
7539            let resp = client.query_margin_accounts_all_orders(params).await.expect("Expected a response");
7540            let data_future = resp.data();
7541            let actual_response = data_future.await.unwrap();
7542            assert_eq!(actual_response, expected_response);
7543        });
7544    }
7545
7546    #[test]
7547    fn query_margin_accounts_all_orders_optional_params_success() {
7548        TOKIO_SHARED_RT.block_on(async {
7549            let client = MockTradeApiClient { force_error: false };
7550
7551            let params = QueryMarginAccountsAllOrdersParams::builder("BNBBTC".to_string(),).is_isolated(QueryMarginAccountsAllOrdersIsIsolatedEnum::True).order_id(1).start_time(1623319461670).end_time(1641782889000).limit(100).recv_window(5000).build().unwrap();
7552
7553            let resp_json: Value = serde_json::from_str(r#"[{"clientOrderId":"D2KDy4DIeS56PvkM13f8cP","cummulativeQuoteQty":"0.00000000","executedQty":"0.00000000","icebergQty":"0.00000000","isWorking":false,"orderId":41295,"origQty":"5.31000000","price":"0.22500000","side":"SELL","status":"CANCELED","stopPrice":"0.18000000","symbol":"BNBBTC","isIsolated":false,"time":1565769338806,"timeInForce":"GTC","type":"TAKE_PROFIT_LIMIT","selfTradePreventionMode":"NONE","updateTime":1565769342148}]"#).unwrap_or_else(|_| serde_json::json!({}));
7554            let expected_response : Vec<models::QueryMarginAccountsAllOrdersResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsAllOrdersResponseInner>");
7555
7556            let resp = client.query_margin_accounts_all_orders(params).await.expect("Expected a response");
7557            let data_future = resp.data();
7558            let actual_response = data_future.await.unwrap();
7559            assert_eq!(actual_response, expected_response);
7560        });
7561    }
7562
7563    #[test]
7564    fn query_margin_accounts_all_orders_response_error() {
7565        TOKIO_SHARED_RT.block_on(async {
7566            let client = MockTradeApiClient { force_error: true };
7567
7568            let params = QueryMarginAccountsAllOrdersParams::builder("BNBBTC".to_string())
7569                .build()
7570                .unwrap();
7571
7572            match client.query_margin_accounts_all_orders(params).await {
7573                Ok(_) => panic!("Expected an error"),
7574                Err(err) => {
7575                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7576                }
7577            }
7578        });
7579    }
7580
7581    #[test]
7582    fn query_margin_accounts_oco_required_params_success() {
7583        TOKIO_SHARED_RT.block_on(async {
7584            let client = MockTradeApiClient { force_error: false };
7585
7586            let params = QueryMarginAccountsOcoParams::builder().build().unwrap();
7587
7588            let resp_json: Value = serde_json::from_str(r#"{"orderListId":27,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"h2USkA5YQpaXHPIrkd96xE","transactionTime":1565245656253,"symbol":"LTCBTC","isIsolated":true,"orders":[{"symbol":"LTCBTC","orderId":4,"clientOrderId":"qD1gy3kc3Gx0rihm9Y3xwS"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7589            let expected_response : models::QueryMarginAccountsOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryMarginAccountsOcoResponse");
7590
7591            let resp = client.query_margin_accounts_oco(params).await.expect("Expected a response");
7592            let data_future = resp.data();
7593            let actual_response = data_future.await.unwrap();
7594            assert_eq!(actual_response, expected_response);
7595        });
7596    }
7597
7598    #[test]
7599    fn query_margin_accounts_oco_optional_params_success() {
7600        TOKIO_SHARED_RT.block_on(async {
7601            let client = MockTradeApiClient { force_error: false };
7602
7603            let params = QueryMarginAccountsOcoParams::builder().is_isolated(QueryMarginAccountsOcoIsIsolatedEnum::True).symbol("LTCBTC".to_string()).order_list_id(1).orig_client_order_id("1".to_string()).recv_window(5000).build().unwrap();
7604
7605            let resp_json: Value = serde_json::from_str(r#"{"orderListId":27,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"h2USkA5YQpaXHPIrkd96xE","transactionTime":1565245656253,"symbol":"LTCBTC","isIsolated":true,"orders":[{"symbol":"LTCBTC","orderId":4,"clientOrderId":"qD1gy3kc3Gx0rihm9Y3xwS"}]}"#).unwrap_or_else(|_| serde_json::json!({}));
7606            let expected_response : models::QueryMarginAccountsOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryMarginAccountsOcoResponse");
7607
7608            let resp = client.query_margin_accounts_oco(params).await.expect("Expected a response");
7609            let data_future = resp.data();
7610            let actual_response = data_future.await.unwrap();
7611            assert_eq!(actual_response, expected_response);
7612        });
7613    }
7614
7615    #[test]
7616    fn query_margin_accounts_oco_response_error() {
7617        TOKIO_SHARED_RT.block_on(async {
7618            let client = MockTradeApiClient { force_error: true };
7619
7620            let params = QueryMarginAccountsOcoParams::builder().build().unwrap();
7621
7622            match client.query_margin_accounts_oco(params).await {
7623                Ok(_) => panic!("Expected an error"),
7624                Err(err) => {
7625                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7626                }
7627            }
7628        });
7629    }
7630
7631    #[test]
7632    fn query_margin_accounts_open_oco_required_params_success() {
7633        TOKIO_SHARED_RT.block_on(async {
7634            let client = MockTradeApiClient { force_error: false };
7635
7636            let params = QueryMarginAccountsOpenOcoParams::builder().build().unwrap();
7637
7638            let resp_json: Value = serde_json::from_str(r#"[{"orderListId":31,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"wuB13fmulKj3YjdqWEcsnp","transactionTime":1565246080644,"symbol":"LTCBTC","isIsolated":true,"orders":[{"symbol":"LTCBTC","orderId":4,"clientOrderId":"r3EH2N76dHfLoSZWIUw1bT"}]}]"#).unwrap_or_else(|_| serde_json::json!({}));
7639            let expected_response : Vec<models::QueryMarginAccountsOpenOcoResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsOpenOcoResponseInner>");
7640
7641            let resp = client.query_margin_accounts_open_oco(params).await.expect("Expected a response");
7642            let data_future = resp.data();
7643            let actual_response = data_future.await.unwrap();
7644            assert_eq!(actual_response, expected_response);
7645        });
7646    }
7647
7648    #[test]
7649    fn query_margin_accounts_open_oco_optional_params_success() {
7650        TOKIO_SHARED_RT.block_on(async {
7651            let client = MockTradeApiClient { force_error: false };
7652
7653            let params = QueryMarginAccountsOpenOcoParams::builder().is_isolated(QueryMarginAccountsOpenOcoIsIsolatedEnum::True).symbol("LTCBTC".to_string()).recv_window(5000).build().unwrap();
7654
7655            let resp_json: Value = serde_json::from_str(r#"[{"orderListId":31,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"wuB13fmulKj3YjdqWEcsnp","transactionTime":1565246080644,"symbol":"LTCBTC","isIsolated":true,"orders":[{"symbol":"LTCBTC","orderId":4,"clientOrderId":"r3EH2N76dHfLoSZWIUw1bT"}]}]"#).unwrap_or_else(|_| serde_json::json!({}));
7656            let expected_response : Vec<models::QueryMarginAccountsOpenOcoResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsOpenOcoResponseInner>");
7657
7658            let resp = client.query_margin_accounts_open_oco(params).await.expect("Expected a response");
7659            let data_future = resp.data();
7660            let actual_response = data_future.await.unwrap();
7661            assert_eq!(actual_response, expected_response);
7662        });
7663    }
7664
7665    #[test]
7666    fn query_margin_accounts_open_oco_response_error() {
7667        TOKIO_SHARED_RT.block_on(async {
7668            let client = MockTradeApiClient { force_error: true };
7669
7670            let params = QueryMarginAccountsOpenOcoParams::builder().build().unwrap();
7671
7672            match client.query_margin_accounts_open_oco(params).await {
7673                Ok(_) => panic!("Expected an error"),
7674                Err(err) => {
7675                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7676                }
7677            }
7678        });
7679    }
7680
7681    #[test]
7682    fn query_margin_accounts_open_orders_required_params_success() {
7683        TOKIO_SHARED_RT.block_on(async {
7684            let client = MockTradeApiClient { force_error: false };
7685
7686            let params = QueryMarginAccountsOpenOrdersParams::builder().build().unwrap();
7687
7688            let resp_json: Value = serde_json::from_str(r#"[{"clientOrderId":"qhcZw71gAkCCTv0t0k8LUK","cummulativeQuoteQty":"0.00000000","executedQty":"0.00000000","icebergQty":"0.00000000","isWorking":true,"orderId":211842552,"origQty":"0.30000000","price":"0.00475010","side":"SELL","status":"NEW","stopPrice":"0.00000000","symbol":"BNBBTC","isIsolated":true,"time":1562040170089,"timeInForce":"GTC","type":"LIMIT","selfTradePreventionMode":"NONE","updateTime":1562040170089}]"#).unwrap_or_else(|_| serde_json::json!({}));
7689            let expected_response : Vec<models::QueryMarginAccountsOpenOrdersResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsOpenOrdersResponseInner>");
7690
7691            let resp = client.query_margin_accounts_open_orders(params).await.expect("Expected a response");
7692            let data_future = resp.data();
7693            let actual_response = data_future.await.unwrap();
7694            assert_eq!(actual_response, expected_response);
7695        });
7696    }
7697
7698    #[test]
7699    fn query_margin_accounts_open_orders_optional_params_success() {
7700        TOKIO_SHARED_RT.block_on(async {
7701            let client = MockTradeApiClient { force_error: false };
7702
7703            let params = QueryMarginAccountsOpenOrdersParams::builder().symbol("BNBBTC".to_string()).is_isolated(QueryMarginAccountsOpenOrdersIsIsolatedEnum::True).recv_window(5000).build().unwrap();
7704
7705            let resp_json: Value = serde_json::from_str(r#"[{"clientOrderId":"qhcZw71gAkCCTv0t0k8LUK","cummulativeQuoteQty":"0.00000000","executedQty":"0.00000000","icebergQty":"0.00000000","isWorking":true,"orderId":211842552,"origQty":"0.30000000","price":"0.00475010","side":"SELL","status":"NEW","stopPrice":"0.00000000","symbol":"BNBBTC","isIsolated":true,"time":1562040170089,"timeInForce":"GTC","type":"LIMIT","selfTradePreventionMode":"NONE","updateTime":1562040170089}]"#).unwrap_or_else(|_| serde_json::json!({}));
7706            let expected_response : Vec<models::QueryMarginAccountsOpenOrdersResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsOpenOrdersResponseInner>");
7707
7708            let resp = client.query_margin_accounts_open_orders(params).await.expect("Expected a response");
7709            let data_future = resp.data();
7710            let actual_response = data_future.await.unwrap();
7711            assert_eq!(actual_response, expected_response);
7712        });
7713    }
7714
7715    #[test]
7716    fn query_margin_accounts_open_orders_response_error() {
7717        TOKIO_SHARED_RT.block_on(async {
7718            let client = MockTradeApiClient { force_error: true };
7719
7720            let params = QueryMarginAccountsOpenOrdersParams::builder()
7721                .build()
7722                .unwrap();
7723
7724            match client.query_margin_accounts_open_orders(params).await {
7725                Ok(_) => panic!("Expected an error"),
7726                Err(err) => {
7727                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7728                }
7729            }
7730        });
7731    }
7732
7733    #[test]
7734    fn query_margin_accounts_order_required_params_success() {
7735        TOKIO_SHARED_RT.block_on(async {
7736            let client = MockTradeApiClient { force_error: false };
7737
7738            let params = QueryMarginAccountsOrderParams::builder("BNBBTC".to_string(),).build().unwrap();
7739
7740            let resp_json: Value = serde_json::from_str(r#"{"clientOrderId":"ZwfQzuDIGpceVhKW5DvCmO","cummulativeQuoteQty":"0.00000000","executedQty":"0.00000000","icebergQty":"0.00000000","isWorking":true,"orderId":213205622,"origQty":"0.30000000","price":"0.00493630","side":"SELL","status":"NEW","stopPrice":"0.00000000","symbol":"BNBBTC","isIsolated":true,"time":1562133008725,"timeInForce":"GTC","type":"LIMIT","selfTradePreventionMode":"NONE","updateTime":1562133008725}"#).unwrap_or_else(|_| serde_json::json!({}));
7741            let expected_response : models::QueryMarginAccountsOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryMarginAccountsOrderResponse");
7742
7743            let resp = client.query_margin_accounts_order(params).await.expect("Expected a response");
7744            let data_future = resp.data();
7745            let actual_response = data_future.await.unwrap();
7746            assert_eq!(actual_response, expected_response);
7747        });
7748    }
7749
7750    #[test]
7751    fn query_margin_accounts_order_optional_params_success() {
7752        TOKIO_SHARED_RT.block_on(async {
7753            let client = MockTradeApiClient { force_error: false };
7754
7755            let params = QueryMarginAccountsOrderParams::builder("BNBBTC".to_string(),).is_isolated(QueryMarginAccountsOrderIsIsolatedEnum::True).order_id(1).orig_client_order_id("1".to_string()).recv_window(5000).build().unwrap();
7756
7757            let resp_json: Value = serde_json::from_str(r#"{"clientOrderId":"ZwfQzuDIGpceVhKW5DvCmO","cummulativeQuoteQty":"0.00000000","executedQty":"0.00000000","icebergQty":"0.00000000","isWorking":true,"orderId":213205622,"origQty":"0.30000000","price":"0.00493630","side":"SELL","status":"NEW","stopPrice":"0.00000000","symbol":"BNBBTC","isIsolated":true,"time":1562133008725,"timeInForce":"GTC","type":"LIMIT","selfTradePreventionMode":"NONE","updateTime":1562133008725}"#).unwrap_or_else(|_| serde_json::json!({}));
7758            let expected_response : models::QueryMarginAccountsOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryMarginAccountsOrderResponse");
7759
7760            let resp = client.query_margin_accounts_order(params).await.expect("Expected a response");
7761            let data_future = resp.data();
7762            let actual_response = data_future.await.unwrap();
7763            assert_eq!(actual_response, expected_response);
7764        });
7765    }
7766
7767    #[test]
7768    fn query_margin_accounts_order_response_error() {
7769        TOKIO_SHARED_RT.block_on(async {
7770            let client = MockTradeApiClient { force_error: true };
7771
7772            let params = QueryMarginAccountsOrderParams::builder("BNBBTC".to_string())
7773                .build()
7774                .unwrap();
7775
7776            match client.query_margin_accounts_order(params).await {
7777                Ok(_) => panic!("Expected an error"),
7778                Err(err) => {
7779                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7780                }
7781            }
7782        });
7783    }
7784
7785    #[test]
7786    fn query_margin_accounts_trade_list_required_params_success() {
7787        TOKIO_SHARED_RT.block_on(async {
7788            let client = MockTradeApiClient { force_error: false };
7789
7790            let params = QueryMarginAccountsTradeListParams::builder("BNBBTC".to_string(),).build().unwrap();
7791
7792            let resp_json: Value = serde_json::from_str(r#"[{"commission":"0.00006000","commissionAsset":"BTC","id":34,"isBestMatch":true,"isBuyer":false,"isMaker":false,"orderId":39324,"price":"0.02000000","qty":"3.00000000","symbol":"BNBBTC","isIsolated":false,"time":1561973357171}]"#).unwrap_or_else(|_| serde_json::json!({}));
7793            let expected_response : Vec<models::QueryMarginAccountsTradeListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsTradeListResponseInner>");
7794
7795            let resp = client.query_margin_accounts_trade_list(params).await.expect("Expected a response");
7796            let data_future = resp.data();
7797            let actual_response = data_future.await.unwrap();
7798            assert_eq!(actual_response, expected_response);
7799        });
7800    }
7801
7802    #[test]
7803    fn query_margin_accounts_trade_list_optional_params_success() {
7804        TOKIO_SHARED_RT.block_on(async {
7805            let client = MockTradeApiClient { force_error: false };
7806
7807            let params = QueryMarginAccountsTradeListParams::builder("BNBBTC".to_string(),).is_isolated(QueryMarginAccountsTradeListIsIsolatedEnum::True).order_id(1).start_time(1623319461670).end_time(1641782889000).from_id(1).limit(500).recv_window(5000).build().unwrap();
7808
7809            let resp_json: Value = serde_json::from_str(r#"[{"commission":"0.00006000","commissionAsset":"BTC","id":34,"isBestMatch":true,"isBuyer":false,"isMaker":false,"orderId":39324,"price":"0.02000000","qty":"3.00000000","symbol":"BNBBTC","isIsolated":false,"time":1561973357171}]"#).unwrap_or_else(|_| serde_json::json!({}));
7810            let expected_response : Vec<models::QueryMarginAccountsTradeListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsTradeListResponseInner>");
7811
7812            let resp = client.query_margin_accounts_trade_list(params).await.expect("Expected a response");
7813            let data_future = resp.data();
7814            let actual_response = data_future.await.unwrap();
7815            assert_eq!(actual_response, expected_response);
7816        });
7817    }
7818
7819    #[test]
7820    fn query_margin_accounts_trade_list_response_error() {
7821        TOKIO_SHARED_RT.block_on(async {
7822            let client = MockTradeApiClient { force_error: true };
7823
7824            let params = QueryMarginAccountsTradeListParams::builder("BNBBTC".to_string())
7825                .build()
7826                .unwrap();
7827
7828            match client.query_margin_accounts_trade_list(params).await {
7829                Ok(_) => panic!("Expected an error"),
7830                Err(err) => {
7831                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7832                }
7833            }
7834        });
7835    }
7836
7837    #[test]
7838    fn query_prevented_matches_required_params_success() {
7839        TOKIO_SHARED_RT.block_on(async {
7840            let client = MockTradeApiClient { force_error: false };
7841
7842            let params = QueryPreventedMatchesParams::builder("BTCUSDT".to_string(),).build().unwrap();
7843
7844            let resp_json: Value = serde_json::from_str(r#"[{"symbol":"BTCUSDT","preventedMatchId":1,"takerOrderId":5,"makerSymbol":"BTCUSDT","makerOrderId":3,"tradeGroupId":1,"selfTradePreventionMode":"EXPIRE_MAKER","price":"1.100000","makerPreventedQuantity":"1.300000","transactTime":1669101687094}]"#).unwrap_or_else(|_| serde_json::json!({}));
7845            let expected_response : Vec<models::QueryPreventedMatchesResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryPreventedMatchesResponseInner>");
7846
7847            let resp = client.query_prevented_matches(params).await.expect("Expected a response");
7848            let data_future = resp.data();
7849            let actual_response = data_future.await.unwrap();
7850            assert_eq!(actual_response, expected_response);
7851        });
7852    }
7853
7854    #[test]
7855    fn query_prevented_matches_optional_params_success() {
7856        TOKIO_SHARED_RT.block_on(async {
7857            let client = MockTradeApiClient { force_error: false };
7858
7859            let params = QueryPreventedMatchesParams::builder("BTCUSDT".to_string(),).prevented_match_id(1).order_id(1).from_prevented_match_id(1).is_isolated(QueryPreventedMatchesIsIsolatedEnum::True).recv_window(5000).build().unwrap();
7860
7861            let resp_json: Value = serde_json::from_str(r#"[{"symbol":"BTCUSDT","preventedMatchId":1,"takerOrderId":5,"makerSymbol":"BTCUSDT","makerOrderId":3,"tradeGroupId":1,"selfTradePreventionMode":"EXPIRE_MAKER","price":"1.100000","makerPreventedQuantity":"1.300000","transactTime":1669101687094}]"#).unwrap_or_else(|_| serde_json::json!({}));
7862            let expected_response : Vec<models::QueryPreventedMatchesResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryPreventedMatchesResponseInner>");
7863
7864            let resp = client.query_prevented_matches(params).await.expect("Expected a response");
7865            let data_future = resp.data();
7866            let actual_response = data_future.await.unwrap();
7867            assert_eq!(actual_response, expected_response);
7868        });
7869    }
7870
7871    #[test]
7872    fn query_prevented_matches_response_error() {
7873        TOKIO_SHARED_RT.block_on(async {
7874            let client = MockTradeApiClient { force_error: true };
7875
7876            let params = QueryPreventedMatchesParams::builder("BTCUSDT".to_string())
7877                .build()
7878                .unwrap();
7879
7880            match client.query_prevented_matches(params).await {
7881                Ok(_) => panic!("Expected an error"),
7882                Err(err) => {
7883                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7884                }
7885            }
7886        });
7887    }
7888
7889    #[test]
7890    fn query_special_key_required_params_success() {
7891        TOKIO_SHARED_RT.block_on(async {
7892            let client = MockTradeApiClient { force_error: false };
7893
7894            let params = QuerySpecialKeyParams::builder().build().unwrap();
7895
7896            let resp_json: Value = serde_json::from_str(r#"{"apiKey":"npOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoGx","ip":"0.0.0.0,192.168.0.1,192.168.0.2","apiName":"testName","type":"RSA","permissionMode":"TRADE"}"#).unwrap_or_else(|_| serde_json::json!({}));
7897            let expected_response : models::QuerySpecialKeyResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QuerySpecialKeyResponse");
7898
7899            let resp = client.query_special_key(params).await.expect("Expected a response");
7900            let data_future = resp.data();
7901            let actual_response = data_future.await.unwrap();
7902            assert_eq!(actual_response, expected_response);
7903        });
7904    }
7905
7906    #[test]
7907    fn query_special_key_optional_params_success() {
7908        TOKIO_SHARED_RT.block_on(async {
7909            let client = MockTradeApiClient { force_error: false };
7910
7911            let params = QuerySpecialKeyParams::builder().symbol("BTCUSDT".to_string()).recv_window(5000).build().unwrap();
7912
7913            let resp_json: Value = serde_json::from_str(r#"{"apiKey":"npOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoGx","ip":"0.0.0.0,192.168.0.1,192.168.0.2","apiName":"testName","type":"RSA","permissionMode":"TRADE"}"#).unwrap_or_else(|_| serde_json::json!({}));
7914            let expected_response : models::QuerySpecialKeyResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QuerySpecialKeyResponse");
7915
7916            let resp = client.query_special_key(params).await.expect("Expected a response");
7917            let data_future = resp.data();
7918            let actual_response = data_future.await.unwrap();
7919            assert_eq!(actual_response, expected_response);
7920        });
7921    }
7922
7923    #[test]
7924    fn query_special_key_response_error() {
7925        TOKIO_SHARED_RT.block_on(async {
7926            let client = MockTradeApiClient { force_error: true };
7927
7928            let params = QuerySpecialKeyParams::builder().build().unwrap();
7929
7930            match client.query_special_key(params).await {
7931                Ok(_) => panic!("Expected an error"),
7932                Err(err) => {
7933                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7934                }
7935            }
7936        });
7937    }
7938
7939    #[test]
7940    fn query_special_key_list_required_params_success() {
7941        TOKIO_SHARED_RT.block_on(async {
7942            let client = MockTradeApiClient { force_error: false };
7943
7944            let params = QuerySpecialKeyListParams::builder().build().unwrap();
7945
7946            let resp_json: Value = serde_json::from_str(r#"[{"apiName":"testName1","apiKey":"znpOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoG","ip":"192.168.0.1,192.168.0.2","type":"RSA","permissionMode":"TRADE"}]"#).unwrap_or_else(|_| serde_json::json!({}));
7947            let expected_response : Vec<models::QuerySpecialKeyListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QuerySpecialKeyListResponseInner>");
7948
7949            let resp = client.query_special_key_list(params).await.expect("Expected a response");
7950            let data_future = resp.data();
7951            let actual_response = data_future.await.unwrap();
7952            assert_eq!(actual_response, expected_response);
7953        });
7954    }
7955
7956    #[test]
7957    fn query_special_key_list_optional_params_success() {
7958        TOKIO_SHARED_RT.block_on(async {
7959            let client = MockTradeApiClient { force_error: false };
7960
7961            let params = QuerySpecialKeyListParams::builder().symbol("BTCUSDT".to_string()).recv_window(5000).build().unwrap();
7962
7963            let resp_json: Value = serde_json::from_str(r#"[{"apiName":"testName1","apiKey":"znpOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoG","ip":"192.168.0.1,192.168.0.2","type":"RSA","permissionMode":"TRADE"}]"#).unwrap_or_else(|_| serde_json::json!({}));
7964            let expected_response : Vec<models::QuerySpecialKeyListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QuerySpecialKeyListResponseInner>");
7965
7966            let resp = client.query_special_key_list(params).await.expect("Expected a response");
7967            let data_future = resp.data();
7968            let actual_response = data_future.await.unwrap();
7969            assert_eq!(actual_response, expected_response);
7970        });
7971    }
7972
7973    #[test]
7974    fn query_special_key_list_response_error() {
7975        TOKIO_SHARED_RT.block_on(async {
7976            let client = MockTradeApiClient { force_error: true };
7977
7978            let params = QuerySpecialKeyListParams::builder().build().unwrap();
7979
7980            match client.query_special_key_list(params).await {
7981                Ok(_) => panic!("Expected an error"),
7982                Err(err) => {
7983                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
7984                }
7985            }
7986        });
7987    }
7988
7989    #[test]
7990    fn small_liability_exchange_required_params_success() {
7991        TOKIO_SHARED_RT.block_on(async {
7992            let client = MockTradeApiClient { force_error: false };
7993
7994            let params = SmallLiabilityExchangeParams::builder("BTC,ETH".to_string())
7995                .build()
7996                .unwrap();
7997
7998            let expected_response = Value::Null;
7999
8000            let resp = client
8001                .small_liability_exchange(params)
8002                .await
8003                .expect("Expected a response");
8004            let data_future = resp.data();
8005            let actual_response = data_future.await.unwrap();
8006            assert_eq!(actual_response, expected_response);
8007        });
8008    }
8009
8010    #[test]
8011    fn small_liability_exchange_optional_params_success() {
8012        TOKIO_SHARED_RT.block_on(async {
8013            let client = MockTradeApiClient { force_error: false };
8014
8015            let params = SmallLiabilityExchangeParams::builder("BTC,ETH".to_string())
8016                .recv_window(5000)
8017                .build()
8018                .unwrap();
8019
8020            let expected_response = Value::Null;
8021
8022            let resp = client
8023                .small_liability_exchange(params)
8024                .await
8025                .expect("Expected a response");
8026            let data_future = resp.data();
8027            let actual_response = data_future.await.unwrap();
8028            assert_eq!(actual_response, expected_response);
8029        });
8030    }
8031
8032    #[test]
8033    fn small_liability_exchange_response_error() {
8034        TOKIO_SHARED_RT.block_on(async {
8035            let client = MockTradeApiClient { force_error: true };
8036
8037            let params = SmallLiabilityExchangeParams::builder("BTC,ETH".to_string())
8038                .build()
8039                .unwrap();
8040
8041            match client.small_liability_exchange(params).await {
8042                Ok(_) => panic!("Expected an error"),
8043                Err(err) => {
8044                    assert_eq!(err.to_string(), "Connector client error: ResponseError");
8045                }
8046            }
8047        });
8048    }
8049}