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