/*
* Margin REST API
*
* Access account information, borrow and repay assets, and trade with Binance Margin.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#![allow(unused_imports)]
use async_trait::async_trait;
use derive_builder::Builder;
use reqwest;
use rust_decimal::prelude::*;
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use std::collections::BTreeMap;
use crate::common::{
config::ConfigurationRestApi,
models::{ParamBuildError, RestApiResponse},
utils::send_request,
};
use crate::margin_trading::rest_api::models;
const HAS_TIME_UNIT: bool = false;
#[async_trait]
pub trait TradeApi: Send + Sync {
async fn create_special_key(
&self,
params: CreateSpecialKeyParams,
) -> anyhow::Result<RestApiResponse<models::CreateSpecialKeyResponse>>;
async fn delete_special_key(
&self,
params: DeleteSpecialKeyParams,
) -> anyhow::Result<RestApiResponse<Value>>;
async fn edit_ip_for_special_key(
&self,
params: EditIpForSpecialKeyParams,
) -> anyhow::Result<RestApiResponse<Value>>;
async fn exit_special_key_mode(
&self,
params: ExitSpecialKeyModeParams,
) -> anyhow::Result<RestApiResponse<serde_json::Value>>;
async fn get_force_liquidation_record(
&self,
params: GetForceLiquidationRecordParams,
) -> anyhow::Result<RestApiResponse<models::GetForceLiquidationRecordResponse>>;
async fn get_small_liability_exchange_coin_list(
&self,
params: GetSmallLiabilityExchangeCoinListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>>;
async fn get_small_liability_exchange_history(
&self,
params: GetSmallLiabilityExchangeHistoryParams,
) -> anyhow::Result<RestApiResponse<models::GetSmallLiabilityExchangeHistoryResponse>>;
async fn liquidation_loan_repay(
&self,
params: LiquidationLoanRepayParams,
) -> anyhow::Result<RestApiResponse<models::LiquidationLoanRepayResponse>>;
async fn margin_account_cancel_all_open_orders_on_a_symbol(
&self,
params: MarginAccountCancelAllOpenOrdersOnASymbolParams,
) -> anyhow::Result<
RestApiResponse<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>,
>;
async fn margin_account_cancel_oco(
&self,
params: MarginAccountCancelOcoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOcoResponse>>;
async fn margin_account_cancel_order(
&self,
params: MarginAccountCancelOrderParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOrderResponse>>;
async fn margin_account_new_oco(
&self,
params: MarginAccountNewOcoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOcoResponse>>;
async fn margin_account_new_order(
&self,
params: MarginAccountNewOrderParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOrderResponse>>;
async fn margin_account_new_oto(
&self,
params: MarginAccountNewOtoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtoResponse>>;
async fn margin_account_new_otoco(
&self,
params: MarginAccountNewOtocoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtocoResponse>>;
async fn margin_manual_liquidation(
&self,
params: MarginManualLiquidationParams,
) -> anyhow::Result<RestApiResponse<models::MarginManualLiquidationResponse>>;
async fn query_current_margin_order_count_usage(
&self,
params: QueryCurrentMarginOrderCountUsageParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>>;
async fn query_liquidation_loan(
&self,
params: QueryLiquidationLoanParams,
) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanResponse>>;
async fn query_liquidation_loan_repay_history(
&self,
params: QueryLiquidationLoanRepayHistoryParams,
) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanRepayHistoryResponse>>;
async fn query_margin_accounts_all_oco(
&self,
params: QueryMarginAccountsAllOcoParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>>;
async fn query_margin_accounts_all_orders(
&self,
params: QueryMarginAccountsAllOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>>;
async fn query_margin_accounts_oco(
&self,
params: QueryMarginAccountsOcoParams,
) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOcoResponse>>;
async fn query_margin_accounts_open_oco(
&self,
params: QueryMarginAccountsOpenOcoParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>>;
async fn query_margin_accounts_open_orders(
&self,
params: QueryMarginAccountsOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>>;
async fn query_margin_accounts_order(
&self,
params: QueryMarginAccountsOrderParams,
) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOrderResponse>>;
async fn query_margin_accounts_trade_list(
&self,
params: QueryMarginAccountsTradeListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsTradeListResponseInner>>>;
async fn query_prevented_matches(
&self,
params: QueryPreventedMatchesParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryPreventedMatchesResponseInner>>>;
async fn query_special_key(
&self,
params: QuerySpecialKeyParams,
) -> anyhow::Result<RestApiResponse<models::QuerySpecialKeyResponse>>;
async fn query_special_key_list(
&self,
params: QuerySpecialKeyListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QuerySpecialKeyListResponseInner>>>;
async fn small_liability_exchange(
&self,
params: SmallLiabilityExchangeParams,
) -> anyhow::Result<RestApiResponse<Value>>;
}
#[derive(Debug, Clone)]
pub struct TradeApiClient {
configuration: ConfigurationRestApi,
}
impl TradeApiClient {
pub fn new(configuration: ConfigurationRestApi) -> Self {
Self { configuration }
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum CreateSpecialKeyPermissionModeEnum {
#[serde(rename = "TRADE")]
Trade,
#[serde(rename = "READ")]
Read,
}
impl CreateSpecialKeyPermissionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Trade => "TRADE",
Self::Read => "READ",
}
}
}
impl std::str::FromStr for CreateSpecialKeyPermissionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRADE" => Ok(Self::Trade),
"READ" => Ok(Self::Read),
other => Err(format!("invalid CreateSpecialKeyPermissionModeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!(
"invalid MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountCancelOcoIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl MarginAccountCancelOcoIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for MarginAccountCancelOcoIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!("invalid MarginAccountCancelOcoIsIsolatedEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountCancelOrderIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl MarginAccountCancelOrderIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for MarginAccountCancelOrderIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => {
Err(format!("invalid MarginAccountCancelOrderIsIsolatedEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOcoSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl MarginAccountNewOcoSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for MarginAccountNewOcoSideEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"BUY" => Ok(Self::Buy),
"SELL" => Ok(Self::Sell),
other => Err(format!("invalid MarginAccountNewOcoSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOcoIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl MarginAccountNewOcoIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for MarginAccountNewOcoIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!("invalid MarginAccountNewOcoIsIsolatedEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOcoStopLimitTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "FOK")]
Fok,
#[serde(rename = "IOC")]
Ioc,
}
impl MarginAccountNewOcoStopLimitTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Fok => "FOK",
Self::Ioc => "IOC",
}
}
}
impl std::str::FromStr for MarginAccountNewOcoStopLimitTimeInForceEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"GTC" => Ok(Self::Gtc),
"FOK" => Ok(Self::Fok),
"IOC" => Ok(Self::Ioc),
other => Err(format!(
"invalid MarginAccountNewOcoStopLimitTimeInForceEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOcoNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
}
impl MarginAccountNewOcoNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
}
}
}
impl std::str::FromStr for MarginAccountNewOcoNewOrderRespTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"ACK" => Ok(Self::Ack),
"RESULT" => Ok(Self::Result),
"FULL" => Ok(Self::Full),
other => {
Err(format!("invalid MarginAccountNewOcoNewOrderRespTypeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOcoSideEffectTypeEnum {
#[serde(rename = "NO_SIDE_EFFECT")]
NoSideEffect,
#[serde(rename = "MARGIN_BUY")]
MarginBuy,
#[serde(rename = "AUTO_REPAY")]
AutoRepay,
#[serde(rename = "AUTO_BORROW_REPAY")]
AutoBorrowRepay,
}
impl MarginAccountNewOcoSideEffectTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::NoSideEffect => "NO_SIDE_EFFECT",
Self::MarginBuy => "MARGIN_BUY",
Self::AutoRepay => "AUTO_REPAY",
Self::AutoBorrowRepay => "AUTO_BORROW_REPAY",
}
}
}
impl std::str::FromStr for MarginAccountNewOcoSideEffectTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NO_SIDE_EFFECT" => Ok(Self::NoSideEffect),
"MARGIN_BUY" => Ok(Self::MarginBuy),
"AUTO_REPAY" => Ok(Self::AutoRepay),
"AUTO_BORROW_REPAY" => Ok(Self::AutoBorrowRepay),
other => {
Err(format!("invalid MarginAccountNewOcoSideEffectTypeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOcoSelfTradePreventionModeEnum {
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "NONE")]
None,
}
impl MarginAccountNewOcoSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::None => "NONE",
}
}
}
impl std::str::FromStr for MarginAccountNewOcoSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"NONE" => Ok(Self::None),
other => Err(format!(
"invalid MarginAccountNewOcoSelfTradePreventionModeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOrderSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl MarginAccountNewOrderSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for MarginAccountNewOrderSideEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"BUY" => Ok(Self::Buy),
"SELL" => Ok(Self::Sell),
other => Err(format!("invalid MarginAccountNewOrderSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOrderTypeEnum {
#[serde(rename = "LIMIT")]
Limit,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "STOP_LOSS")]
StopLoss,
#[serde(rename = "STOP_LOSS_LIMIT")]
StopLossLimit,
#[serde(rename = "TAKE_PROFIT")]
TakeProfit,
#[serde(rename = "TAKE_PROFIT_LIMIT")]
TakeProfitLimit,
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
}
impl MarginAccountNewOrderTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Limit => "LIMIT",
Self::Market => "MARKET",
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
}
}
}
impl std::str::FromStr for MarginAccountNewOrderTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"LIMIT" => Ok(Self::Limit),
"MARKET" => Ok(Self::Market),
"STOP_LOSS" => Ok(Self::StopLoss),
"STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
"TAKE_PROFIT" => Ok(Self::TakeProfit),
"TAKE_PROFIT_LIMIT" => Ok(Self::TakeProfitLimit),
"LIMIT_MAKER" => Ok(Self::LimitMaker),
other => Err(format!("invalid MarginAccountNewOrderTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOrderIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl MarginAccountNewOrderIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for MarginAccountNewOrderIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!("invalid MarginAccountNewOrderIsIsolatedEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOrderNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
}
impl MarginAccountNewOrderNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
}
}
}
impl std::str::FromStr for MarginAccountNewOrderNewOrderRespTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"ACK" => Ok(Self::Ack),
"RESULT" => Ok(Self::Result),
"FULL" => Ok(Self::Full),
other => Err(format!(
"invalid MarginAccountNewOrderNewOrderRespTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOrderSideEffectTypeEnum {
#[serde(rename = "NO_SIDE_EFFECT")]
NoSideEffect,
#[serde(rename = "MARGIN_BUY")]
MarginBuy,
#[serde(rename = "AUTO_REPAY")]
AutoRepay,
#[serde(rename = "AUTO_BORROW_REPAY")]
AutoBorrowRepay,
}
impl MarginAccountNewOrderSideEffectTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::NoSideEffect => "NO_SIDE_EFFECT",
Self::MarginBuy => "MARGIN_BUY",
Self::AutoRepay => "AUTO_REPAY",
Self::AutoBorrowRepay => "AUTO_BORROW_REPAY",
}
}
}
impl std::str::FromStr for MarginAccountNewOrderSideEffectTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NO_SIDE_EFFECT" => Ok(Self::NoSideEffect),
"MARGIN_BUY" => Ok(Self::MarginBuy),
"AUTO_REPAY" => Ok(Self::AutoRepay),
"AUTO_BORROW_REPAY" => Ok(Self::AutoBorrowRepay),
other => {
Err(format!("invalid MarginAccountNewOrderSideEffectTypeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOrderTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl MarginAccountNewOrderTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Ioc => "IOC",
Self::Fok => "FOK",
}
}
}
impl std::str::FromStr for MarginAccountNewOrderTimeInForceEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"GTC" => Ok(Self::Gtc),
"IOC" => Ok(Self::Ioc),
"FOK" => Ok(Self::Fok),
other => Err(format!("invalid MarginAccountNewOrderTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOrderSelfTradePreventionModeEnum {
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "NONE")]
None,
}
impl MarginAccountNewOrderSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::None => "NONE",
}
}
}
impl std::str::FromStr for MarginAccountNewOrderSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"NONE" => Ok(Self::None),
other => Err(format!(
"invalid MarginAccountNewOrderSelfTradePreventionModeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtoWorkingTypeEnum {
#[serde(rename = "LIMIT")]
Limit,
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
}
impl MarginAccountNewOtoWorkingTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Limit => "LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
}
}
}
impl std::str::FromStr for MarginAccountNewOtoWorkingTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"LIMIT" => Ok(Self::Limit),
"LIMIT_MAKER" => Ok(Self::LimitMaker),
other => Err(format!("invalid MarginAccountNewOtoWorkingTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtoWorkingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl MarginAccountNewOtoWorkingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for MarginAccountNewOtoWorkingSideEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"BUY" => Ok(Self::Buy),
"SELL" => Ok(Self::Sell),
other => Err(format!("invalid MarginAccountNewOtoWorkingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtoPendingTypeEnum {
#[serde(rename = "LIMIT")]
Limit,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "STOP_LOSS")]
StopLoss,
#[serde(rename = "STOP_LOSS_LIMIT")]
StopLossLimit,
#[serde(rename = "TAKE_PROFIT")]
TakeProfit,
#[serde(rename = "TAKE_PROFIT_LIMIT")]
TakeProfitLimit,
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
}
impl MarginAccountNewOtoPendingTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Limit => "LIMIT",
Self::Market => "MARKET",
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
}
}
}
impl std::str::FromStr for MarginAccountNewOtoPendingTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"LIMIT" => Ok(Self::Limit),
"MARKET" => Ok(Self::Market),
"STOP_LOSS" => Ok(Self::StopLoss),
"STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
"TAKE_PROFIT" => Ok(Self::TakeProfit),
"TAKE_PROFIT_LIMIT" => Ok(Self::TakeProfitLimit),
"LIMIT_MAKER" => Ok(Self::LimitMaker),
other => Err(format!("invalid MarginAccountNewOtoPendingTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtoPendingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl MarginAccountNewOtoPendingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for MarginAccountNewOtoPendingSideEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"BUY" => Ok(Self::Buy),
"SELL" => Ok(Self::Sell),
other => Err(format!("invalid MarginAccountNewOtoPendingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtoIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl MarginAccountNewOtoIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for MarginAccountNewOtoIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!("invalid MarginAccountNewOtoIsIsolatedEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtoNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
}
impl MarginAccountNewOtoNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
}
}
}
impl std::str::FromStr for MarginAccountNewOtoNewOrderRespTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"ACK" => Ok(Self::Ack),
"RESULT" => Ok(Self::Result),
"FULL" => Ok(Self::Full),
other => {
Err(format!("invalid MarginAccountNewOtoNewOrderRespTypeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtoSideEffectTypeEnum {
#[serde(rename = "NO_SIDE_EFFECT")]
NoSideEffect,
#[serde(rename = "MARGIN_BUY")]
MarginBuy,
}
impl MarginAccountNewOtoSideEffectTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::NoSideEffect => "NO_SIDE_EFFECT",
Self::MarginBuy => "MARGIN_BUY",
}
}
}
impl std::str::FromStr for MarginAccountNewOtoSideEffectTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NO_SIDE_EFFECT" => Ok(Self::NoSideEffect),
"MARGIN_BUY" => Ok(Self::MarginBuy),
other => {
Err(format!("invalid MarginAccountNewOtoSideEffectTypeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtoSelfTradePreventionModeEnum {
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "NONE")]
None,
}
impl MarginAccountNewOtoSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::None => "NONE",
}
}
}
impl std::str::FromStr for MarginAccountNewOtoSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"NONE" => Ok(Self::None),
other => Err(format!(
"invalid MarginAccountNewOtoSelfTradePreventionModeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtoWorkingTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl MarginAccountNewOtoWorkingTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Ioc => "IOC",
Self::Fok => "FOK",
}
}
}
impl std::str::FromStr for MarginAccountNewOtoWorkingTimeInForceEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"GTC" => Ok(Self::Gtc),
"IOC" => Ok(Self::Ioc),
"FOK" => Ok(Self::Fok),
other => Err(format!(
"invalid MarginAccountNewOtoWorkingTimeInForceEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtoPendingTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl MarginAccountNewOtoPendingTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Ioc => "IOC",
Self::Fok => "FOK",
}
}
}
impl std::str::FromStr for MarginAccountNewOtoPendingTimeInForceEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"GTC" => Ok(Self::Gtc),
"IOC" => Ok(Self::Ioc),
"FOK" => Ok(Self::Fok),
other => Err(format!(
"invalid MarginAccountNewOtoPendingTimeInForceEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoWorkingTypeEnum {
#[serde(rename = "LIMIT")]
Limit,
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
}
impl MarginAccountNewOtocoWorkingTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Limit => "LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoWorkingTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"LIMIT" => Ok(Self::Limit),
"LIMIT_MAKER" => Ok(Self::LimitMaker),
other => Err(format!("invalid MarginAccountNewOtocoWorkingTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoWorkingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl MarginAccountNewOtocoWorkingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoWorkingSideEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"BUY" => Ok(Self::Buy),
"SELL" => Ok(Self::Sell),
other => Err(format!("invalid MarginAccountNewOtocoWorkingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoPendingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl MarginAccountNewOtocoPendingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoPendingSideEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"BUY" => Ok(Self::Buy),
"SELL" => Ok(Self::Sell),
other => Err(format!("invalid MarginAccountNewOtocoPendingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoPendingAboveTypeEnum {
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
#[serde(rename = "STOP_LOSS")]
StopLoss,
#[serde(rename = "STOP_LOSS_LIMIT")]
StopLossLimit,
}
impl MarginAccountNewOtocoPendingAboveTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::LimitMaker => "LIMIT_MAKER",
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoPendingAboveTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"LIMIT_MAKER" => Ok(Self::LimitMaker),
"STOP_LOSS" => Ok(Self::StopLoss),
"STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
other => Err(format!(
"invalid MarginAccountNewOtocoPendingAboveTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl MarginAccountNewOtocoIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!("invalid MarginAccountNewOtocoIsIsolatedEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoSideEffectTypeEnum {
#[serde(rename = "NO_SIDE_EFFECT")]
NoSideEffect,
#[serde(rename = "MARGIN_BUY")]
MarginBuy,
}
impl MarginAccountNewOtocoSideEffectTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::NoSideEffect => "NO_SIDE_EFFECT",
Self::MarginBuy => "MARGIN_BUY",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoSideEffectTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NO_SIDE_EFFECT" => Ok(Self::NoSideEffect),
"MARGIN_BUY" => Ok(Self::MarginBuy),
other => {
Err(format!("invalid MarginAccountNewOtocoSideEffectTypeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
}
impl MarginAccountNewOtocoNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoNewOrderRespTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"ACK" => Ok(Self::Ack),
"RESULT" => Ok(Self::Result),
"FULL" => Ok(Self::Full),
other => Err(format!(
"invalid MarginAccountNewOtocoNewOrderRespTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoSelfTradePreventionModeEnum {
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "NONE")]
None,
}
impl MarginAccountNewOtocoSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::None => "NONE",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"NONE" => Ok(Self::None),
other => Err(format!(
"invalid MarginAccountNewOtocoSelfTradePreventionModeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoWorkingTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl MarginAccountNewOtocoWorkingTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Ioc => "IOC",
Self::Fok => "FOK",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoWorkingTimeInForceEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"GTC" => Ok(Self::Gtc),
"IOC" => Ok(Self::Ioc),
"FOK" => Ok(Self::Fok),
other => Err(format!(
"invalid MarginAccountNewOtocoWorkingTimeInForceEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoPendingAboveTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl MarginAccountNewOtocoPendingAboveTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Ioc => "IOC",
Self::Fok => "FOK",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoPendingAboveTimeInForceEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"GTC" => Ok(Self::Gtc),
"IOC" => Ok(Self::Ioc),
"FOK" => Ok(Self::Fok),
other => Err(format!(
"invalid MarginAccountNewOtocoPendingAboveTimeInForceEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoPendingBelowTypeEnum {
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
#[serde(rename = "STOP_LOSS")]
StopLoss,
#[serde(rename = "STOP_LOSS_LIMIT")]
StopLossLimit,
}
impl MarginAccountNewOtocoPendingBelowTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::LimitMaker => "LIMIT_MAKER",
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoPendingBelowTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"LIMIT_MAKER" => Ok(Self::LimitMaker),
"STOP_LOSS" => Ok(Self::StopLoss),
"STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
other => Err(format!(
"invalid MarginAccountNewOtocoPendingBelowTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginAccountNewOtocoPendingBelowTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl MarginAccountNewOtocoPendingBelowTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Ioc => "IOC",
Self::Fok => "FOK",
}
}
}
impl std::str::FromStr for MarginAccountNewOtocoPendingBelowTimeInForceEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"GTC" => Ok(Self::Gtc),
"IOC" => Ok(Self::Ioc),
"FOK" => Ok(Self::Fok),
other => Err(format!(
"invalid MarginAccountNewOtocoPendingBelowTimeInForceEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MarginManualLiquidationTypeEnum {
#[serde(rename = "MARGIN")]
Margin,
#[serde(rename = "ISOLATED")]
Isolated,
}
impl MarginManualLiquidationTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Margin => "MARGIN",
Self::Isolated => "ISOLATED",
}
}
}
impl std::str::FromStr for MarginManualLiquidationTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"MARGIN" => Ok(Self::Margin),
"ISOLATED" => Ok(Self::Isolated),
other => Err(format!("invalid MarginManualLiquidationTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum QueryCurrentMarginOrderCountUsageIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl QueryCurrentMarginOrderCountUsageIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for QueryCurrentMarginOrderCountUsageIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!(
"invalid QueryCurrentMarginOrderCountUsageIsIsolatedEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum QueryMarginAccountsAllOcoIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl QueryMarginAccountsAllOcoIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for QueryMarginAccountsAllOcoIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => {
Err(format!("invalid QueryMarginAccountsAllOcoIsIsolatedEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum QueryMarginAccountsAllOrdersIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl QueryMarginAccountsAllOrdersIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for QueryMarginAccountsAllOrdersIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!(
"invalid QueryMarginAccountsAllOrdersIsIsolatedEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum QueryMarginAccountsOcoIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl QueryMarginAccountsOcoIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for QueryMarginAccountsOcoIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!("invalid QueryMarginAccountsOcoIsIsolatedEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum QueryMarginAccountsOpenOcoIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl QueryMarginAccountsOpenOcoIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for QueryMarginAccountsOpenOcoIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!(
"invalid QueryMarginAccountsOpenOcoIsIsolatedEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum QueryMarginAccountsOpenOrdersIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl QueryMarginAccountsOpenOrdersIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for QueryMarginAccountsOpenOrdersIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!(
"invalid QueryMarginAccountsOpenOrdersIsIsolatedEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum QueryMarginAccountsOrderIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl QueryMarginAccountsOrderIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for QueryMarginAccountsOrderIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => {
Err(format!("invalid QueryMarginAccountsOrderIsIsolatedEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum QueryMarginAccountsTradeListIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl QueryMarginAccountsTradeListIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for QueryMarginAccountsTradeListIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!(
"invalid QueryMarginAccountsTradeListIsIsolatedEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum QueryPreventedMatchesIsIsolatedEnum {
#[serde(rename = "TRUE")]
True,
#[serde(rename = "FALSE")]
False,
}
impl QueryPreventedMatchesIsIsolatedEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::True => "TRUE",
Self::False => "FALSE",
}
}
}
impl std::str::FromStr for QueryPreventedMatchesIsIsolatedEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"TRUE" => Ok(Self::True),
"FALSE" => Ok(Self::False),
other => Err(format!("invalid QueryPreventedMatchesIsIsolatedEnum: {}", other).into()),
}
}
}
/// Request parameters for the [`create_special_key`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`create_special_key`](#method.create_special_key).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct CreateSpecialKeyParams {
///
/// The `api_name` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "apiName")]
pub api_name: String,
///
/// The `symbol` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "symbol", default)]
pub symbol: Option<String>,
/// Can be added in batches, separated by commas. Max 30 for an API key
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "ip", default)]
pub ip: Option<String>,
/// 1. If publicKey is inputted it will create an RSA or Ed25519
/// key.
///
/// 2. Need to be encoded to URL-encoded format
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "publicKey", default)]
pub public_key: Option<String>,
/// 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.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "permissionMode", default)]
pub permission_mode: Option<CreateSpecialKeyPermissionModeEnum>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl CreateSpecialKeyParams {
/// Create a builder for [`create_special_key`].
///
/// Required parameters:
///
/// * `api_name` — String
///
#[must_use]
pub fn builder(api_name: String) -> CreateSpecialKeyParamsBuilder {
CreateSpecialKeyParamsBuilder::default().api_name(api_name)
}
}
/// Request parameters for the [`delete_special_key`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`delete_special_key`](#method.delete_special_key).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct DeleteSpecialKeyParams {
///
/// The `api_name` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "apiName", default)]
pub api_name: Option<String>,
///
/// The `symbol` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "symbol", default)]
pub symbol: Option<String>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl DeleteSpecialKeyParams {
/// Create a builder for [`delete_special_key`].
///
#[must_use]
pub fn builder() -> DeleteSpecialKeyParamsBuilder {
DeleteSpecialKeyParamsBuilder::default()
}
}
/// Request parameters for the [`edit_ip_for_special_key`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`edit_ip_for_special_key`](#method.edit_ip_for_special_key).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct EditIpForSpecialKeyParams {
/// Can be added in batches, separated by commas. Max 30 for an API key
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "ip")]
pub ip: String,
/// isolated margin pair
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "symbol", default)]
pub symbol: Option<String>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl EditIpForSpecialKeyParams {
/// Create a builder for [`edit_ip_for_special_key`].
///
/// Required parameters:
///
/// * `ip` — Can be added in batches, separated by commas. Max 30 for an API key
///
#[must_use]
pub fn builder(ip: String) -> EditIpForSpecialKeyParamsBuilder {
EditIpForSpecialKeyParamsBuilder::default().ip(ip)
}
}
/// Request parameters for the [`exit_special_key_mode`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`exit_special_key_mode`](#method.exit_special_key_mode).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct ExitSpecialKeyModeParams {
/// The value cannot be greater than `60000`
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl ExitSpecialKeyModeParams {
/// Create a builder for [`exit_special_key_mode`].
///
#[must_use]
pub fn builder() -> ExitSpecialKeyModeParamsBuilder {
ExitSpecialKeyModeParamsBuilder::default()
}
}
/// Request parameters for the [`get_force_liquidation_record`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`get_force_liquidation_record`](#method.get_force_liquidation_record).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct GetForceLiquidationRecordParams {
///
/// The `start_time` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "startTime", default)]
pub start_time: Option<i64>,
///
/// The `end_time` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "endTime", default)]
pub end_time: Option<i64>,
///
/// The `isolated_symbol` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isolatedSymbol", default)]
pub isolated_symbol: Option<String>,
///
/// The `current` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "current", default)]
pub current: Option<i64>,
///
/// The `size` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "size", default)]
pub size: Option<i64>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl GetForceLiquidationRecordParams {
/// Create a builder for [`get_force_liquidation_record`].
///
#[must_use]
pub fn builder() -> GetForceLiquidationRecordParamsBuilder {
GetForceLiquidationRecordParamsBuilder::default()
}
}
/// Request parameters for the [`get_small_liability_exchange_coin_list`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`get_small_liability_exchange_coin_list`](#method.get_small_liability_exchange_coin_list).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct GetSmallLiabilityExchangeCoinListParams {
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl GetSmallLiabilityExchangeCoinListParams {
/// Create a builder for [`get_small_liability_exchange_coin_list`].
///
#[must_use]
pub fn builder() -> GetSmallLiabilityExchangeCoinListParamsBuilder {
GetSmallLiabilityExchangeCoinListParamsBuilder::default()
}
}
/// Request parameters for the [`get_small_liability_exchange_history`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`get_small_liability_exchange_history`](#method.get_small_liability_exchange_history).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct GetSmallLiabilityExchangeHistoryParams {
///
/// The `current` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "current")]
pub current: i64,
///
/// The `size` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "size")]
pub size: i64,
///
/// The `start_time` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "startTime", default)]
pub start_time: Option<i64>,
///
/// The `end_time` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "endTime", default)]
pub end_time: Option<i64>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl GetSmallLiabilityExchangeHistoryParams {
/// Create a builder for [`get_small_liability_exchange_history`].
///
/// Required parameters:
///
/// * `current` — i64
/// * `size` — i64
///
#[must_use]
pub fn builder(current: i64, size: i64) -> GetSmallLiabilityExchangeHistoryParamsBuilder {
GetSmallLiabilityExchangeHistoryParamsBuilder::default()
.current(current)
.size(size)
}
}
/// Request parameters for the [`liquidation_loan_repay`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`liquidation_loan_repay`](#method.liquidation_loan_repay).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct LiquidationLoanRepayParams {
/// The asset to repay (e.g. USDT, USDC)
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "asset")]
pub asset: String,
/// Repayment amount, must be greater than 0
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "amount")]
pub amount: rust_decimal::Decimal,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl LiquidationLoanRepayParams {
/// Create a builder for [`liquidation_loan_repay`].
///
/// Required parameters:
///
/// * `asset` — The asset to repay (e.g. USDT, USDC)
/// * `amount` — Repayment amount, must be greater than 0
///
#[must_use]
pub fn builder(
asset: String,
amount: rust_decimal::Decimal,
) -> LiquidationLoanRepayParamsBuilder {
LiquidationLoanRepayParamsBuilder::default()
.asset(asset)
.amount(amount)
}
}
/// Request parameters for the [`margin_account_cancel_all_open_orders_on_a_symbol`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`margin_account_cancel_all_open_orders_on_a_symbol`](#method.margin_account_cancel_all_open_orders_on_a_symbol).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct MarginAccountCancelAllOpenOrdersOnASymbolParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "symbol")]
pub symbol: String,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl MarginAccountCancelAllOpenOrdersOnASymbolParams {
/// Create a builder for [`margin_account_cancel_all_open_orders_on_a_symbol`].
///
/// Required parameters:
///
/// * `symbol` — String
///
#[must_use]
pub fn builder(symbol: String) -> MarginAccountCancelAllOpenOrdersOnASymbolParamsBuilder {
MarginAccountCancelAllOpenOrdersOnASymbolParamsBuilder::default().symbol(symbol)
}
}
/// Request parameters for the [`margin_account_cancel_oco`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`margin_account_cancel_oco`](#method.margin_account_cancel_oco).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct MarginAccountCancelOcoParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "symbol")]
pub symbol: String,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<MarginAccountCancelOcoIsIsolatedEnum>,
///
/// The `order_list_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "orderListId", default)]
pub order_list_id: Option<i64>,
///
/// The `list_client_order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "listClientOrderId", default)]
pub list_client_order_id: Option<String>,
///
/// The `new_client_order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "newClientOrderId", default)]
pub new_client_order_id: Option<String>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl MarginAccountCancelOcoParams {
/// Create a builder for [`margin_account_cancel_oco`].
///
/// Required parameters:
///
/// * `symbol` — String
///
#[must_use]
pub fn builder(symbol: String) -> MarginAccountCancelOcoParamsBuilder {
MarginAccountCancelOcoParamsBuilder::default().symbol(symbol)
}
}
/// Request parameters for the [`margin_account_cancel_order`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`margin_account_cancel_order`](#method.margin_account_cancel_order).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct MarginAccountCancelOrderParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "symbol")]
pub symbol: String,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<MarginAccountCancelOrderIsIsolatedEnum>,
///
/// The `order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "orderId", default)]
pub order_id: Option<i64>,
///
/// The `orig_client_order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "origClientOrderId", default)]
pub orig_client_order_id: Option<String>,
///
/// The `new_client_order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "newClientOrderId", default)]
pub new_client_order_id: Option<String>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl MarginAccountCancelOrderParams {
/// Create a builder for [`margin_account_cancel_order`].
///
/// Required parameters:
///
/// * `symbol` — String
///
#[must_use]
pub fn builder(symbol: String) -> MarginAccountCancelOrderParamsBuilder {
MarginAccountCancelOrderParamsBuilder::default().symbol(symbol)
}
}
/// Request parameters for the [`margin_account_new_oco`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`margin_account_new_oco`](#method.margin_account_new_oco).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct MarginAccountNewOcoParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "symbol")]
pub symbol: String,
///
/// The `side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "side")]
pub side: MarginAccountNewOcoSideEnum,
///
/// The `quantity` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "quantity")]
pub quantity: rust_decimal::Decimal,
///
/// The `price` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "price")]
pub price: rust_decimal::Decimal,
///
/// The `stop_price` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "stopPrice")]
pub stop_price: rust_decimal::Decimal,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<MarginAccountNewOcoIsIsolatedEnum>,
/// A unique Id for the entire orderList
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "listClientOrderId", default)]
pub list_client_order_id: Option<String>,
/// A unique Id for the limit order
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "limitClientOrderId", default)]
pub limit_client_order_id: Option<String>,
///
/// The `limit_iceberg_qty` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "limitIcebergQty", default)]
pub limit_iceberg_qty: Option<rust_decimal::Decimal>,
/// A unique Id for the stop loss/stop loss limit leg
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "stopClientOrderId", default)]
pub stop_client_order_id: Option<String>,
/// If provided, `stopLimitTimeInForce` is required.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "stopLimitPrice", default)]
pub stop_limit_price: Option<rust_decimal::Decimal>,
///
/// The `stop_iceberg_qty` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "stopIcebergQty", default)]
pub stop_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `stop_limit_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "stopLimitTimeInForce", default)]
pub stop_limit_time_in_force: Option<MarginAccountNewOcoStopLimitTimeInForceEnum>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "newOrderRespType", default)]
pub new_order_resp_type: Option<MarginAccountNewOcoNewOrderRespTypeEnum>,
///
/// The `side_effect_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "sideEffectType", default)]
pub side_effect_type: Option<MarginAccountNewOcoSideEffectTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "selfTradePreventionMode", default)]
pub self_trade_prevention_mode: Option<MarginAccountNewOcoSelfTradePreventionModeEnum>,
/// 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.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "autoRepayAtCancel", default)]
pub auto_repay_at_cancel: Option<bool>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl MarginAccountNewOcoParams {
/// Create a builder for [`margin_account_new_oco`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `side` — String
/// * `quantity` — `rust_decimal::Decimal`
/// * `price` — `rust_decimal::Decimal`
/// * `stop_price` — `rust_decimal::Decimal`
///
#[must_use]
pub fn builder(
symbol: String,
side: MarginAccountNewOcoSideEnum,
quantity: rust_decimal::Decimal,
price: rust_decimal::Decimal,
stop_price: rust_decimal::Decimal,
) -> MarginAccountNewOcoParamsBuilder {
MarginAccountNewOcoParamsBuilder::default()
.symbol(symbol)
.side(side)
.quantity(quantity)
.price(price)
.stop_price(stop_price)
}
}
/// Request parameters for the [`margin_account_new_order`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`margin_account_new_order`](#method.margin_account_new_order).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct MarginAccountNewOrderParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "symbol")]
pub symbol: String,
///
/// The `side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "side")]
pub side: MarginAccountNewOrderSideEnum,
///
/// The `r#type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "type")]
pub r#type: MarginAccountNewOrderTypeEnum,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<MarginAccountNewOrderIsIsolatedEnum>,
///
/// The `quantity` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "quantity", default)]
pub quantity: Option<rust_decimal::Decimal>,
///
/// The `quote_order_qty` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "quoteOrderQty", default)]
pub quote_order_qty: Option<rust_decimal::Decimal>,
///
/// The `price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "price", default)]
pub price: Option<rust_decimal::Decimal>,
/// Used with `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, and `TAKE_PROFIT_LIMIT` orders.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "stopPrice", default)]
pub stop_price: Option<rust_decimal::Decimal>,
/// A unique id among open orders. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "newClientOrderId", default)]
pub new_client_order_id: Option<String>,
/// Used with `LIMIT`, `STOP_LOSS_LIMIT`, and `TAKE_PROFIT_LIMIT` to create an iceberg order.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "icebergQty", default)]
pub iceberg_qty: Option<rust_decimal::Decimal>,
/// MARKET and LIMIT order types default to FULL, all other orders default to ACK.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "newOrderRespType", default)]
pub new_order_resp_type: Option<MarginAccountNewOrderNewOrderRespTypeEnum>,
///
/// The `side_effect_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "sideEffectType", default)]
pub side_effect_type: Option<MarginAccountNewOrderSideEffectTypeEnum>,
///
/// The `time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "timeInForce", default)]
pub time_in_force: Option<MarginAccountNewOrderTimeInForceEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "selfTradePreventionMode", default)]
pub self_trade_prevention_mode: Option<MarginAccountNewOrderSelfTradePreventionModeEnum>,
/// Used with `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, and `TAKE_PROFIT_LIMIT` orders.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "trailingDelta", default)]
pub trailing_delta: Option<i64>,
/// 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.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "autoRepayAtCancel", default)]
pub auto_repay_at_cancel: Option<bool>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl MarginAccountNewOrderParams {
/// Create a builder for [`margin_account_new_order`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `side` — String
/// * `r#type` — String
///
#[must_use]
pub fn builder(
symbol: String,
side: MarginAccountNewOrderSideEnum,
r#type: MarginAccountNewOrderTypeEnum,
) -> MarginAccountNewOrderParamsBuilder {
MarginAccountNewOrderParamsBuilder::default()
.symbol(symbol)
.side(side)
.r#type(r#type)
}
}
/// Request parameters for the [`margin_account_new_oto`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`margin_account_new_oto`](#method.margin_account_new_oto).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct MarginAccountNewOtoParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "symbol")]
pub symbol: String,
///
/// The `working_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "workingType")]
pub working_type: MarginAccountNewOtoWorkingTypeEnum,
///
/// The `working_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "workingSide")]
pub working_side: MarginAccountNewOtoWorkingSideEnum,
///
/// The `working_price` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "workingPrice")]
pub working_price: rust_decimal::Decimal,
/// Sets the quantity for the working order.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "workingQuantity")]
pub working_quantity: rust_decimal::Decimal,
/// This can only be used if `workingTimeInForce` is `GTC`.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "workingIcebergQty")]
pub working_iceberg_qty: rust_decimal::Decimal,
///
/// The `pending_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "pendingType")]
pub pending_type: MarginAccountNewOtoPendingTypeEnum,
///
/// The `pending_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "pendingSide")]
pub pending_side: MarginAccountNewOtoPendingSideEnum,
/// Sets the quantity for the pending order.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "pendingQuantity")]
pub pending_quantity: rust_decimal::Decimal,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<MarginAccountNewOtoIsIsolatedEnum>,
/// 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`.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "listClientOrderId", default)]
pub list_client_order_id: Option<String>,
/// MARKET and LIMIT order types default to FULL, all other orders default to ACK.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "newOrderRespType", default)]
pub new_order_resp_type: Option<MarginAccountNewOtoNewOrderRespTypeEnum>,
///
/// The `side_effect_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "sideEffectType", default)]
pub side_effect_type: Option<MarginAccountNewOtoSideEffectTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "selfTradePreventionMode", default)]
pub self_trade_prevention_mode: Option<MarginAccountNewOtoSelfTradePreventionModeEnum>,
/// 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.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "autoRepayAtCancel", default)]
pub auto_repay_at_cancel: Option<bool>,
/// Arbitrary unique ID among open orders for the working order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "workingClientOrderId", default)]
pub working_client_order_id: Option<String>,
///
/// The `working_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "workingTimeInForce", default)]
pub working_time_in_force: Option<MarginAccountNewOtoWorkingTimeInForceEnum>,
/// Arbitrary unique ID among open orders for the pending order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingClientOrderId", default)]
pub pending_client_order_id: Option<String>,
///
/// The `pending_price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingPrice", default)]
pub pending_price: Option<rust_decimal::Decimal>,
///
/// The `pending_stop_price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingStopPrice", default)]
pub pending_stop_price: Option<rust_decimal::Decimal>,
///
/// The `pending_trailing_delta` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingTrailingDelta", default)]
pub pending_trailing_delta: Option<rust_decimal::Decimal>,
/// This can only be used if `pendingTimeInForce` is `GTC`.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingIcebergQty", default)]
pub pending_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `pending_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingTimeInForce", default)]
pub pending_time_in_force: Option<MarginAccountNewOtoPendingTimeInForceEnum>,
}
impl MarginAccountNewOtoParams {
/// Create a builder for [`margin_account_new_oto`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `working_type` — String
/// * `working_side` — String
/// * `working_price` — `rust_decimal::Decimal`
/// * `working_quantity` — Sets the quantity for the working order.
/// * `working_iceberg_qty` — This can only be used if `workingTimeInForce` is `GTC`.
/// * `pending_type` — String
/// * `pending_side` — String
/// * `pending_quantity` — Sets the quantity for the pending order.
///
#[must_use]
pub fn builder(
symbol: String,
working_type: MarginAccountNewOtoWorkingTypeEnum,
working_side: MarginAccountNewOtoWorkingSideEnum,
working_price: rust_decimal::Decimal,
working_quantity: rust_decimal::Decimal,
working_iceberg_qty: rust_decimal::Decimal,
pending_type: MarginAccountNewOtoPendingTypeEnum,
pending_side: MarginAccountNewOtoPendingSideEnum,
pending_quantity: rust_decimal::Decimal,
) -> MarginAccountNewOtoParamsBuilder {
MarginAccountNewOtoParamsBuilder::default()
.symbol(symbol)
.working_type(working_type)
.working_side(working_side)
.working_price(working_price)
.working_quantity(working_quantity)
.working_iceberg_qty(working_iceberg_qty)
.pending_type(pending_type)
.pending_side(pending_side)
.pending_quantity(pending_quantity)
}
}
/// Request parameters for the [`margin_account_new_otoco`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`margin_account_new_otoco`](#method.margin_account_new_otoco).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct MarginAccountNewOtocoParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "symbol")]
pub symbol: String,
///
/// The `working_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "workingType")]
pub working_type: MarginAccountNewOtocoWorkingTypeEnum,
///
/// The `working_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "workingSide")]
pub working_side: MarginAccountNewOtocoWorkingSideEnum,
///
/// The `working_price` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "workingPrice")]
pub working_price: rust_decimal::Decimal,
///
/// The `working_quantity` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "workingQuantity")]
pub working_quantity: rust_decimal::Decimal,
///
/// The `pending_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "pendingSide")]
pub pending_side: MarginAccountNewOtocoPendingSideEnum,
///
/// The `pending_quantity` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "pendingQuantity")]
pub pending_quantity: rust_decimal::Decimal,
///
/// The `pending_above_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "pendingAboveType")]
pub pending_above_type: MarginAccountNewOtocoPendingAboveTypeEnum,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<MarginAccountNewOtocoIsIsolatedEnum>,
///
/// The `side_effect_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "sideEffectType", default)]
pub side_effect_type: Option<MarginAccountNewOtocoSideEffectTypeEnum>,
/// 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.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "autoRepayAtCancel", default)]
pub auto_repay_at_cancel: Option<bool>,
/// 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`.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "listClientOrderId", default)]
pub list_client_order_id: Option<String>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "newOrderRespType", default)]
pub new_order_resp_type: Option<MarginAccountNewOtocoNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "selfTradePreventionMode", default)]
pub self_trade_prevention_mode: Option<MarginAccountNewOtocoSelfTradePreventionModeEnum>,
/// Arbitrary unique ID among open orders for the working order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "workingClientOrderId", default)]
pub working_client_order_id: Option<String>,
/// This can only be used if `workingTimeInForce` is `GTC`.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "workingIcebergQty", default)]
pub working_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `working_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "workingTimeInForce", default)]
pub working_time_in_force: Option<MarginAccountNewOtocoWorkingTimeInForceEnum>,
/// Arbitrary unique ID among open orders for the pending above order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingAboveClientOrderId", default)]
pub pending_above_client_order_id: Option<String>,
///
/// The `pending_above_price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingAbovePrice", default)]
pub pending_above_price: Option<rust_decimal::Decimal>,
///
/// The `pending_above_stop_price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingAboveStopPrice", default)]
pub pending_above_stop_price: Option<rust_decimal::Decimal>,
///
/// The `pending_above_trailing_delta` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingAboveTrailingDelta", default)]
pub pending_above_trailing_delta: Option<rust_decimal::Decimal>,
/// This can only be used if `pendingAboveTimeInForce` is `GTC`.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingAboveIcebergQty", default)]
pub pending_above_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `pending_above_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingAboveTimeInForce", default)]
pub pending_above_time_in_force: Option<MarginAccountNewOtocoPendingAboveTimeInForceEnum>,
///
/// The `pending_below_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingBelowType", default)]
pub pending_below_type: Option<MarginAccountNewOtocoPendingBelowTypeEnum>,
/// Arbitrary unique ID among open orders for the pending below order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingBelowClientOrderId", default)]
pub pending_below_client_order_id: Option<String>,
///
/// The `pending_below_price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingBelowPrice", default)]
pub pending_below_price: Option<rust_decimal::Decimal>,
///
/// The `pending_below_stop_price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingBelowStopPrice", default)]
pub pending_below_stop_price: Option<rust_decimal::Decimal>,
///
/// The `pending_below_trailing_delta` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingBelowTrailingDelta", default)]
pub pending_below_trailing_delta: Option<rust_decimal::Decimal>,
/// This can only be used if `pendingBelowTimeInForce` is `GTC`.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingBelowIcebergQty", default)]
pub pending_below_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `pending_below_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "pendingBelowTimeInForce", default)]
pub pending_below_time_in_force: Option<MarginAccountNewOtocoPendingBelowTimeInForceEnum>,
}
impl MarginAccountNewOtocoParams {
/// Create a builder for [`margin_account_new_otoco`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `working_type` — String
/// * `working_side` — String
/// * `working_price` — `rust_decimal::Decimal`
/// * `working_quantity` — `rust_decimal::Decimal`
/// * `pending_side` — String
/// * `pending_quantity` — `rust_decimal::Decimal`
/// * `pending_above_type` — String
///
#[must_use]
pub fn builder(
symbol: String,
working_type: MarginAccountNewOtocoWorkingTypeEnum,
working_side: MarginAccountNewOtocoWorkingSideEnum,
working_price: rust_decimal::Decimal,
working_quantity: rust_decimal::Decimal,
pending_side: MarginAccountNewOtocoPendingSideEnum,
pending_quantity: rust_decimal::Decimal,
pending_above_type: MarginAccountNewOtocoPendingAboveTypeEnum,
) -> MarginAccountNewOtocoParamsBuilder {
MarginAccountNewOtocoParamsBuilder::default()
.symbol(symbol)
.working_type(working_type)
.working_side(working_side)
.working_price(working_price)
.working_quantity(working_quantity)
.pending_side(pending_side)
.pending_quantity(pending_quantity)
.pending_above_type(pending_above_type)
}
}
/// Request parameters for the [`margin_manual_liquidation`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`margin_manual_liquidation`](#method.margin_manual_liquidation).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct MarginManualLiquidationParams {
///
/// The `r#type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "type")]
pub r#type: MarginManualLiquidationTypeEnum,
/// When type selects `ISOLATED`, `symbol` must be filled in
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "symbol", default)]
pub symbol: Option<String>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl MarginManualLiquidationParams {
/// Create a builder for [`margin_manual_liquidation`].
///
/// Required parameters:
///
/// * `r#type` — String
///
#[must_use]
pub fn builder(
r#type: MarginManualLiquidationTypeEnum,
) -> MarginManualLiquidationParamsBuilder {
MarginManualLiquidationParamsBuilder::default().r#type(r#type)
}
}
/// Request parameters for the [`query_current_margin_order_count_usage`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_current_margin_order_count_usage`](#method.query_current_margin_order_count_usage).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QueryCurrentMarginOrderCountUsageParams {
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<QueryCurrentMarginOrderCountUsageIsIsolatedEnum>,
///
/// The `symbol` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "symbol", default)]
pub symbol: Option<String>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QueryCurrentMarginOrderCountUsageParams {
/// Create a builder for [`query_current_margin_order_count_usage`].
///
#[must_use]
pub fn builder() -> QueryCurrentMarginOrderCountUsageParamsBuilder {
QueryCurrentMarginOrderCountUsageParamsBuilder::default()
}
}
/// Request parameters for the [`query_liquidation_loan`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_liquidation_loan`](#method.query_liquidation_loan).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QueryLiquidationLoanParams {
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QueryLiquidationLoanParams {
/// Create a builder for [`query_liquidation_loan`].
///
#[must_use]
pub fn builder() -> QueryLiquidationLoanParamsBuilder {
QueryLiquidationLoanParamsBuilder::default()
}
}
/// Request parameters for the [`query_liquidation_loan_repay_history`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_liquidation_loan_repay_history`](#method.query_liquidation_loan_repay_history).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QueryLiquidationLoanRepayHistoryParams {
/// Start time in Unix timestamp (milliseconds). Defaults to 7 days ago if not specified
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "startTime", default)]
pub start_time: Option<i64>,
/// End time in Unix timestamp (milliseconds). Defaults to now if not specified
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "endTime", default)]
pub end_time: Option<i64>,
/// Current page number, default `1`
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "current", default)]
pub current: Option<i64>,
/// Page size, default `50`
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "size", default)]
pub size: Option<i64>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QueryLiquidationLoanRepayHistoryParams {
/// Create a builder for [`query_liquidation_loan_repay_history`].
///
#[must_use]
pub fn builder() -> QueryLiquidationLoanRepayHistoryParamsBuilder {
QueryLiquidationLoanRepayHistoryParamsBuilder::default()
}
}
/// Request parameters for the [`query_margin_accounts_all_oco`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_margin_accounts_all_oco`](#method.query_margin_accounts_all_oco).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QueryMarginAccountsAllOcoParams {
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<QueryMarginAccountsAllOcoIsIsolatedEnum>,
///
/// The `symbol` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "symbol", default)]
pub symbol: Option<String>,
///
/// The `from_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "fromId", default)]
pub from_id: Option<i64>,
///
/// The `start_time` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "startTime", default)]
pub start_time: Option<i64>,
///
/// The `end_time` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "endTime", default)]
pub end_time: Option<i64>,
///
/// The `limit` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "limit", default)]
pub limit: Option<i64>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QueryMarginAccountsAllOcoParams {
/// Create a builder for [`query_margin_accounts_all_oco`].
///
#[must_use]
pub fn builder() -> QueryMarginAccountsAllOcoParamsBuilder {
QueryMarginAccountsAllOcoParamsBuilder::default()
}
}
/// Request parameters for the [`query_margin_accounts_all_orders`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_margin_accounts_all_orders`](#method.query_margin_accounts_all_orders).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QueryMarginAccountsAllOrdersParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "symbol")]
pub symbol: String,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<QueryMarginAccountsAllOrdersIsIsolatedEnum>,
///
/// The `order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "orderId", default)]
pub order_id: Option<i64>,
///
/// The `start_time` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "startTime", default)]
pub start_time: Option<i64>,
///
/// The `end_time` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "endTime", default)]
pub end_time: Option<i64>,
///
/// The `limit` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "limit", default)]
pub limit: Option<i64>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QueryMarginAccountsAllOrdersParams {
/// Create a builder for [`query_margin_accounts_all_orders`].
///
/// Required parameters:
///
/// * `symbol` — String
///
#[must_use]
pub fn builder(symbol: String) -> QueryMarginAccountsAllOrdersParamsBuilder {
QueryMarginAccountsAllOrdersParamsBuilder::default().symbol(symbol)
}
}
/// Request parameters for the [`query_margin_accounts_oco`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_margin_accounts_oco`](#method.query_margin_accounts_oco).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QueryMarginAccountsOcoParams {
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<QueryMarginAccountsOcoIsIsolatedEnum>,
///
/// The `symbol` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "symbol", default)]
pub symbol: Option<String>,
///
/// The `order_list_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "orderListId", default)]
pub order_list_id: Option<i64>,
///
/// The `orig_client_order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "origClientOrderId", default)]
pub orig_client_order_id: Option<String>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QueryMarginAccountsOcoParams {
/// Create a builder for [`query_margin_accounts_oco`].
///
#[must_use]
pub fn builder() -> QueryMarginAccountsOcoParamsBuilder {
QueryMarginAccountsOcoParamsBuilder::default()
}
}
/// Request parameters for the [`query_margin_accounts_open_oco`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_margin_accounts_open_oco`](#method.query_margin_accounts_open_oco).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QueryMarginAccountsOpenOcoParams {
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<QueryMarginAccountsOpenOcoIsIsolatedEnum>,
///
/// The `symbol` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "symbol", default)]
pub symbol: Option<String>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QueryMarginAccountsOpenOcoParams {
/// Create a builder for [`query_margin_accounts_open_oco`].
///
#[must_use]
pub fn builder() -> QueryMarginAccountsOpenOcoParamsBuilder {
QueryMarginAccountsOpenOcoParamsBuilder::default()
}
}
/// Request parameters for the [`query_margin_accounts_open_orders`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_margin_accounts_open_orders`](#method.query_margin_accounts_open_orders).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QueryMarginAccountsOpenOrdersParams {
/// isolated margin pair
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "symbol", default)]
pub symbol: Option<String>,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<QueryMarginAccountsOpenOrdersIsIsolatedEnum>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QueryMarginAccountsOpenOrdersParams {
/// Create a builder for [`query_margin_accounts_open_orders`].
///
#[must_use]
pub fn builder() -> QueryMarginAccountsOpenOrdersParamsBuilder {
QueryMarginAccountsOpenOrdersParamsBuilder::default()
}
}
/// Request parameters for the [`query_margin_accounts_order`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_margin_accounts_order`](#method.query_margin_accounts_order).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QueryMarginAccountsOrderParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "symbol")]
pub symbol: String,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<QueryMarginAccountsOrderIsIsolatedEnum>,
///
/// The `order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "orderId", default)]
pub order_id: Option<i64>,
///
/// The `orig_client_order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "origClientOrderId", default)]
pub orig_client_order_id: Option<String>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QueryMarginAccountsOrderParams {
/// Create a builder for [`query_margin_accounts_order`].
///
/// Required parameters:
///
/// * `symbol` — String
///
#[must_use]
pub fn builder(symbol: String) -> QueryMarginAccountsOrderParamsBuilder {
QueryMarginAccountsOrderParamsBuilder::default().symbol(symbol)
}
}
/// Request parameters for the [`query_margin_accounts_trade_list`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_margin_accounts_trade_list`](#method.query_margin_accounts_trade_list).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QueryMarginAccountsTradeListParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "symbol")]
pub symbol: String,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<QueryMarginAccountsTradeListIsIsolatedEnum>,
///
/// The `order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "orderId", default)]
pub order_id: Option<i64>,
///
/// The `start_time` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "startTime", default)]
pub start_time: Option<i64>,
///
/// The `end_time` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "endTime", default)]
pub end_time: Option<i64>,
///
/// The `from_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "fromId", default)]
pub from_id: Option<i64>,
///
/// The `limit` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "limit", default)]
pub limit: Option<i64>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QueryMarginAccountsTradeListParams {
/// Create a builder for [`query_margin_accounts_trade_list`].
///
/// Required parameters:
///
/// * `symbol` — String
///
#[must_use]
pub fn builder(symbol: String) -> QueryMarginAccountsTradeListParamsBuilder {
QueryMarginAccountsTradeListParamsBuilder::default().symbol(symbol)
}
}
/// Request parameters for the [`query_prevented_matches`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_prevented_matches`](#method.query_prevented_matches).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QueryPreventedMatchesParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "symbol")]
pub symbol: String,
///
/// The `prevented_match_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "preventedMatchId", default)]
pub prevented_match_id: Option<i64>,
///
/// The `order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "orderId", default)]
pub order_id: Option<i64>,
///
/// The `from_prevented_match_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "fromPreventedMatchId", default)]
pub from_prevented_match_id: Option<i64>,
///
/// The `is_isolated` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "isIsolated", default)]
pub is_isolated: Option<QueryPreventedMatchesIsIsolatedEnum>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QueryPreventedMatchesParams {
/// Create a builder for [`query_prevented_matches`].
///
/// Required parameters:
///
/// * `symbol` — String
///
#[must_use]
pub fn builder(symbol: String) -> QueryPreventedMatchesParamsBuilder {
QueryPreventedMatchesParamsBuilder::default().symbol(symbol)
}
}
/// Request parameters for the [`query_special_key`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_special_key`](#method.query_special_key).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QuerySpecialKeyParams {
///
/// The `symbol` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "symbol", default)]
pub symbol: Option<String>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QuerySpecialKeyParams {
/// Create a builder for [`query_special_key`].
///
#[must_use]
pub fn builder() -> QuerySpecialKeyParamsBuilder {
QuerySpecialKeyParamsBuilder::default()
}
}
/// Request parameters for the [`query_special_key_list`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`query_special_key_list`](#method.query_special_key_list).
#[derive(Clone, Debug, Builder, Deserialize, Default)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct QuerySpecialKeyListParams {
///
/// The `symbol` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "symbol", default)]
pub symbol: Option<String>,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl QuerySpecialKeyListParams {
/// Create a builder for [`query_special_key_list`].
///
#[must_use]
pub fn builder() -> QuerySpecialKeyListParamsBuilder {
QuerySpecialKeyListParamsBuilder::default()
}
}
/// Request parameters for the [`small_liability_exchange`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`small_liability_exchange`](#method.small_liability_exchange).
#[derive(Clone, Debug, Builder, Deserialize)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct SmallLiabilityExchangeParams {
/// The assets list of small liability exchange
///
/// This field is **required.
#[builder(setter(into))]
#[serde(rename = "assetNames")]
pub asset_names: String,
///
/// The `recv_window` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
#[serde(rename = "recvWindow", default)]
pub recv_window: Option<i64>,
}
impl SmallLiabilityExchangeParams {
/// Create a builder for [`small_liability_exchange`].
///
/// Required parameters:
///
/// * `asset_names` — The assets list of small liability exchange
///
#[must_use]
pub fn builder(asset_names: String) -> SmallLiabilityExchangeParamsBuilder {
SmallLiabilityExchangeParamsBuilder::default().asset_names(asset_names)
}
}
#[async_trait]
impl TradeApi for TradeApiClient {
async fn create_special_key(
&self,
params: CreateSpecialKeyParams,
) -> anyhow::Result<RestApiResponse<models::CreateSpecialKeyResponse>> {
let CreateSpecialKeyParams {
api_name,
symbol,
ip,
public_key,
permission_mode,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("apiName".to_string(), json!(api_name));
if let Some(rw) = symbol {
query_params.insert("symbol".to_string(), json!(rw));
}
if let Some(rw) = ip {
query_params.insert("ip".to_string(), json!(rw));
}
if let Some(rw) = public_key {
query_params.insert("publicKey".to_string(), json!(rw));
}
if let Some(rw) = permission_mode {
query_params.insert("permissionMode".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::CreateSpecialKeyResponse>(
&self.configuration,
"/sapi/v1/margin/apiKey",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn delete_special_key(
&self,
params: DeleteSpecialKeyParams,
) -> anyhow::Result<RestApiResponse<Value>> {
let DeleteSpecialKeyParams {
api_name,
symbol,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = api_name {
query_params.insert("apiName".to_string(), json!(rw));
}
if let Some(rw) = symbol {
query_params.insert("symbol".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Value>(
&self.configuration,
"/sapi/v1/margin/apiKey",
reqwest::Method::DELETE,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn edit_ip_for_special_key(
&self,
params: EditIpForSpecialKeyParams,
) -> anyhow::Result<RestApiResponse<Value>> {
let EditIpForSpecialKeyParams {
ip,
symbol,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = symbol {
query_params.insert("symbol".to_string(), json!(rw));
}
query_params.insert("ip".to_string(), json!(ip));
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Value>(
&self.configuration,
"/sapi/v1/margin/apiKey/ip",
reqwest::Method::PUT,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn exit_special_key_mode(
&self,
params: ExitSpecialKeyModeParams,
) -> anyhow::Result<RestApiResponse<serde_json::Value>> {
let ExitSpecialKeyModeParams { recv_window } = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<serde_json::Value>(
&self.configuration,
"/sapi/v1/margin/exit-special-key-mode",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn get_force_liquidation_record(
&self,
params: GetForceLiquidationRecordParams,
) -> anyhow::Result<RestApiResponse<models::GetForceLiquidationRecordResponse>> {
let GetForceLiquidationRecordParams {
start_time,
end_time,
isolated_symbol,
current,
size,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = start_time {
query_params.insert("startTime".to_string(), json!(rw));
}
if let Some(rw) = end_time {
query_params.insert("endTime".to_string(), json!(rw));
}
if let Some(rw) = isolated_symbol {
query_params.insert("isolatedSymbol".to_string(), json!(rw));
}
if let Some(rw) = current {
query_params.insert("current".to_string(), json!(rw));
}
if let Some(rw) = size {
query_params.insert("size".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::GetForceLiquidationRecordResponse>(
&self.configuration,
"/sapi/v1/margin/forceLiquidationRec",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn get_small_liability_exchange_coin_list(
&self,
params: GetSmallLiabilityExchangeCoinListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>>
{
let GetSmallLiabilityExchangeCoinListParams { recv_window } = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>(
&self.configuration,
"/sapi/v1/margin/exchange-small-liability",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn get_small_liability_exchange_history(
&self,
params: GetSmallLiabilityExchangeHistoryParams,
) -> anyhow::Result<RestApiResponse<models::GetSmallLiabilityExchangeHistoryResponse>> {
let GetSmallLiabilityExchangeHistoryParams {
current,
size,
start_time,
end_time,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("current".to_string(), json!(current));
query_params.insert("size".to_string(), json!(size));
if let Some(rw) = start_time {
query_params.insert("startTime".to_string(), json!(rw));
}
if let Some(rw) = end_time {
query_params.insert("endTime".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::GetSmallLiabilityExchangeHistoryResponse>(
&self.configuration,
"/sapi/v1/margin/exchange-small-liability-history",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn liquidation_loan_repay(
&self,
params: LiquidationLoanRepayParams,
) -> anyhow::Result<RestApiResponse<models::LiquidationLoanRepayResponse>> {
let LiquidationLoanRepayParams {
asset,
amount,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("asset".to_string(), json!(asset));
query_params.insert("amount".to_string(), json!(amount));
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::LiquidationLoanRepayResponse>(
&self.configuration,
"/sapi/v1/margin/liquidation-loan/repay",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn margin_account_cancel_all_open_orders_on_a_symbol(
&self,
params: MarginAccountCancelAllOpenOrdersOnASymbolParams,
) -> anyhow::Result<
RestApiResponse<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>,
> {
let MarginAccountCancelAllOpenOrdersOnASymbolParams {
symbol,
is_isolated,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>(
&self.configuration,
"/sapi/v1/margin/openOrders",
reqwest::Method::DELETE,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn margin_account_cancel_oco(
&self,
params: MarginAccountCancelOcoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOcoResponse>> {
let MarginAccountCancelOcoParams {
symbol,
is_isolated,
order_list_id,
list_client_order_id,
new_client_order_id,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = order_list_id {
query_params.insert("orderListId".to_string(), json!(rw));
}
if let Some(rw) = list_client_order_id {
query_params.insert("listClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = new_client_order_id {
query_params.insert("newClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::MarginAccountCancelOcoResponse>(
&self.configuration,
"/sapi/v1/margin/orderList",
reqwest::Method::DELETE,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn margin_account_cancel_order(
&self,
params: MarginAccountCancelOrderParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOrderResponse>> {
let MarginAccountCancelOrderParams {
symbol,
is_isolated,
order_id,
orig_client_order_id,
new_client_order_id,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = order_id {
query_params.insert("orderId".to_string(), json!(rw));
}
if let Some(rw) = orig_client_order_id {
query_params.insert("origClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = new_client_order_id {
query_params.insert("newClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::MarginAccountCancelOrderResponse>(
&self.configuration,
"/sapi/v1/margin/order",
reqwest::Method::DELETE,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn margin_account_new_oco(
&self,
params: MarginAccountNewOcoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOcoResponse>> {
let MarginAccountNewOcoParams {
symbol,
side,
quantity,
price,
stop_price,
is_isolated,
list_client_order_id,
limit_client_order_id,
limit_iceberg_qty,
stop_client_order_id,
stop_limit_price,
stop_iceberg_qty,
stop_limit_time_in_force,
new_order_resp_type,
side_effect_type,
self_trade_prevention_mode,
auto_repay_at_cancel,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = list_client_order_id {
query_params.insert("listClientOrderId".to_string(), json!(rw));
}
query_params.insert("side".to_string(), json!(side));
query_params.insert("quantity".to_string(), json!(quantity));
if let Some(rw) = limit_client_order_id {
query_params.insert("limitClientOrderId".to_string(), json!(rw));
}
query_params.insert("price".to_string(), json!(price));
if let Some(rw) = limit_iceberg_qty {
query_params.insert("limitIcebergQty".to_string(), json!(rw));
}
if let Some(rw) = stop_client_order_id {
query_params.insert("stopClientOrderId".to_string(), json!(rw));
}
query_params.insert("stopPrice".to_string(), json!(stop_price));
if let Some(rw) = stop_limit_price {
query_params.insert("stopLimitPrice".to_string(), json!(rw));
}
if let Some(rw) = stop_iceberg_qty {
query_params.insert("stopIcebergQty".to_string(), json!(rw));
}
if let Some(rw) = stop_limit_time_in_force {
query_params.insert("stopLimitTimeInForce".to_string(), json!(rw));
}
if let Some(rw) = new_order_resp_type {
query_params.insert("newOrderRespType".to_string(), json!(rw));
}
if let Some(rw) = side_effect_type {
query_params.insert("sideEffectType".to_string(), json!(rw));
}
if let Some(rw) = self_trade_prevention_mode {
query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
}
if let Some(rw) = auto_repay_at_cancel {
query_params.insert("autoRepayAtCancel".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::MarginAccountNewOcoResponse>(
&self.configuration,
"/sapi/v1/margin/order/oco",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn margin_account_new_order(
&self,
params: MarginAccountNewOrderParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOrderResponse>> {
let MarginAccountNewOrderParams {
symbol,
side,
r#type,
is_isolated,
quantity,
quote_order_qty,
price,
stop_price,
new_client_order_id,
iceberg_qty,
new_order_resp_type,
side_effect_type,
time_in_force,
self_trade_prevention_mode,
trailing_delta,
auto_repay_at_cancel,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
query_params.insert("side".to_string(), json!(side));
query_params.insert("type".to_string(), json!(r#type));
if let Some(rw) = quantity {
query_params.insert("quantity".to_string(), json!(rw));
}
if let Some(rw) = quote_order_qty {
query_params.insert("quoteOrderQty".to_string(), json!(rw));
}
if let Some(rw) = price {
query_params.insert("price".to_string(), json!(rw));
}
if let Some(rw) = stop_price {
query_params.insert("stopPrice".to_string(), json!(rw));
}
if let Some(rw) = new_client_order_id {
query_params.insert("newClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = iceberg_qty {
query_params.insert("icebergQty".to_string(), json!(rw));
}
if let Some(rw) = new_order_resp_type {
query_params.insert("newOrderRespType".to_string(), json!(rw));
}
if let Some(rw) = side_effect_type {
query_params.insert("sideEffectType".to_string(), json!(rw));
}
if let Some(rw) = time_in_force {
query_params.insert("timeInForce".to_string(), json!(rw));
}
if let Some(rw) = self_trade_prevention_mode {
query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
}
if let Some(rw) = trailing_delta {
query_params.insert("trailingDelta".to_string(), json!(rw));
}
if let Some(rw) = auto_repay_at_cancel {
query_params.insert("autoRepayAtCancel".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::MarginAccountNewOrderResponse>(
&self.configuration,
"/sapi/v1/margin/order",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn margin_account_new_oto(
&self,
params: MarginAccountNewOtoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtoResponse>> {
let MarginAccountNewOtoParams {
symbol,
working_type,
working_side,
working_price,
working_quantity,
working_iceberg_qty,
pending_type,
pending_side,
pending_quantity,
is_isolated,
list_client_order_id,
new_order_resp_type,
side_effect_type,
self_trade_prevention_mode,
auto_repay_at_cancel,
working_client_order_id,
working_time_in_force,
pending_client_order_id,
pending_price,
pending_stop_price,
pending_trailing_delta,
pending_iceberg_qty,
pending_time_in_force,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = list_client_order_id {
query_params.insert("listClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = new_order_resp_type {
query_params.insert("newOrderRespType".to_string(), json!(rw));
}
if let Some(rw) = side_effect_type {
query_params.insert("sideEffectType".to_string(), json!(rw));
}
if let Some(rw) = self_trade_prevention_mode {
query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
}
if let Some(rw) = auto_repay_at_cancel {
query_params.insert("autoRepayAtCancel".to_string(), json!(rw));
}
query_params.insert("workingType".to_string(), json!(working_type));
query_params.insert("workingSide".to_string(), json!(working_side));
if let Some(rw) = working_client_order_id {
query_params.insert("workingClientOrderId".to_string(), json!(rw));
}
query_params.insert("workingPrice".to_string(), json!(working_price));
query_params.insert("workingQuantity".to_string(), json!(working_quantity));
query_params.insert("workingIcebergQty".to_string(), json!(working_iceberg_qty));
if let Some(rw) = working_time_in_force {
query_params.insert("workingTimeInForce".to_string(), json!(rw));
}
query_params.insert("pendingType".to_string(), json!(pending_type));
query_params.insert("pendingSide".to_string(), json!(pending_side));
if let Some(rw) = pending_client_order_id {
query_params.insert("pendingClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = pending_price {
query_params.insert("pendingPrice".to_string(), json!(rw));
}
if let Some(rw) = pending_stop_price {
query_params.insert("pendingStopPrice".to_string(), json!(rw));
}
if let Some(rw) = pending_trailing_delta {
query_params.insert("pendingTrailingDelta".to_string(), json!(rw));
}
query_params.insert("pendingQuantity".to_string(), json!(pending_quantity));
if let Some(rw) = pending_iceberg_qty {
query_params.insert("pendingIcebergQty".to_string(), json!(rw));
}
if let Some(rw) = pending_time_in_force {
query_params.insert("pendingTimeInForce".to_string(), json!(rw));
}
send_request::<models::MarginAccountNewOtoResponse>(
&self.configuration,
"/sapi/v1/margin/order/oto",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn margin_account_new_otoco(
&self,
params: MarginAccountNewOtocoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtocoResponse>> {
let MarginAccountNewOtocoParams {
symbol,
working_type,
working_side,
working_price,
working_quantity,
pending_side,
pending_quantity,
pending_above_type,
is_isolated,
side_effect_type,
auto_repay_at_cancel,
list_client_order_id,
new_order_resp_type,
self_trade_prevention_mode,
working_client_order_id,
working_iceberg_qty,
working_time_in_force,
pending_above_client_order_id,
pending_above_price,
pending_above_stop_price,
pending_above_trailing_delta,
pending_above_iceberg_qty,
pending_above_time_in_force,
pending_below_type,
pending_below_client_order_id,
pending_below_price,
pending_below_stop_price,
pending_below_trailing_delta,
pending_below_iceberg_qty,
pending_below_time_in_force,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = side_effect_type {
query_params.insert("sideEffectType".to_string(), json!(rw));
}
if let Some(rw) = auto_repay_at_cancel {
query_params.insert("autoRepayAtCancel".to_string(), json!(rw));
}
if let Some(rw) = list_client_order_id {
query_params.insert("listClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = new_order_resp_type {
query_params.insert("newOrderRespType".to_string(), json!(rw));
}
if let Some(rw) = self_trade_prevention_mode {
query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
}
query_params.insert("workingType".to_string(), json!(working_type));
query_params.insert("workingSide".to_string(), json!(working_side));
if let Some(rw) = working_client_order_id {
query_params.insert("workingClientOrderId".to_string(), json!(rw));
}
query_params.insert("workingPrice".to_string(), json!(working_price));
query_params.insert("workingQuantity".to_string(), json!(working_quantity));
if let Some(rw) = working_iceberg_qty {
query_params.insert("workingIcebergQty".to_string(), json!(rw));
}
if let Some(rw) = working_time_in_force {
query_params.insert("workingTimeInForce".to_string(), json!(rw));
}
query_params.insert("pendingSide".to_string(), json!(pending_side));
query_params.insert("pendingQuantity".to_string(), json!(pending_quantity));
query_params.insert("pendingAboveType".to_string(), json!(pending_above_type));
if let Some(rw) = pending_above_client_order_id {
query_params.insert("pendingAboveClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = pending_above_price {
query_params.insert("pendingAbovePrice".to_string(), json!(rw));
}
if let Some(rw) = pending_above_stop_price {
query_params.insert("pendingAboveStopPrice".to_string(), json!(rw));
}
if let Some(rw) = pending_above_trailing_delta {
query_params.insert("pendingAboveTrailingDelta".to_string(), json!(rw));
}
if let Some(rw) = pending_above_iceberg_qty {
query_params.insert("pendingAboveIcebergQty".to_string(), json!(rw));
}
if let Some(rw) = pending_above_time_in_force {
query_params.insert("pendingAboveTimeInForce".to_string(), json!(rw));
}
if let Some(rw) = pending_below_type {
query_params.insert("pendingBelowType".to_string(), json!(rw));
}
if let Some(rw) = pending_below_client_order_id {
query_params.insert("pendingBelowClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = pending_below_price {
query_params.insert("pendingBelowPrice".to_string(), json!(rw));
}
if let Some(rw) = pending_below_stop_price {
query_params.insert("pendingBelowStopPrice".to_string(), json!(rw));
}
if let Some(rw) = pending_below_trailing_delta {
query_params.insert("pendingBelowTrailingDelta".to_string(), json!(rw));
}
if let Some(rw) = pending_below_iceberg_qty {
query_params.insert("pendingBelowIcebergQty".to_string(), json!(rw));
}
if let Some(rw) = pending_below_time_in_force {
query_params.insert("pendingBelowTimeInForce".to_string(), json!(rw));
}
send_request::<models::MarginAccountNewOtocoResponse>(
&self.configuration,
"/sapi/v1/margin/order/otoco",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn margin_manual_liquidation(
&self,
params: MarginManualLiquidationParams,
) -> anyhow::Result<RestApiResponse<models::MarginManualLiquidationResponse>> {
let MarginManualLiquidationParams {
r#type,
symbol,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("type".to_string(), json!(r#type));
if let Some(rw) = symbol {
query_params.insert("symbol".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::MarginManualLiquidationResponse>(
&self.configuration,
"/sapi/v1/margin/manual-liquidation",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_current_margin_order_count_usage(
&self,
params: QueryCurrentMarginOrderCountUsageParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>>
{
let QueryCurrentMarginOrderCountUsageParams {
is_isolated,
symbol,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = symbol {
query_params.insert("symbol".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>(
&self.configuration,
"/sapi/v1/margin/rateLimit/order",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_liquidation_loan(
&self,
params: QueryLiquidationLoanParams,
) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanResponse>> {
let QueryLiquidationLoanParams { recv_window } = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::QueryLiquidationLoanResponse>(
&self.configuration,
"/sapi/v1/margin/liquidation-loan",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_liquidation_loan_repay_history(
&self,
params: QueryLiquidationLoanRepayHistoryParams,
) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanRepayHistoryResponse>> {
let QueryLiquidationLoanRepayHistoryParams {
start_time,
end_time,
current,
size,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = start_time {
query_params.insert("startTime".to_string(), json!(rw));
}
if let Some(rw) = end_time {
query_params.insert("endTime".to_string(), json!(rw));
}
if let Some(rw) = current {
query_params.insert("current".to_string(), json!(rw));
}
if let Some(rw) = size {
query_params.insert("size".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::QueryLiquidationLoanRepayHistoryResponse>(
&self.configuration,
"/sapi/v1/margin/liquidation-loan/repay-history",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_margin_accounts_all_oco(
&self,
params: QueryMarginAccountsAllOcoParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>> {
let QueryMarginAccountsAllOcoParams {
is_isolated,
symbol,
from_id,
start_time,
end_time,
limit,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = symbol {
query_params.insert("symbol".to_string(), json!(rw));
}
if let Some(rw) = from_id {
query_params.insert("fromId".to_string(), json!(rw));
}
if let Some(rw) = start_time {
query_params.insert("startTime".to_string(), json!(rw));
}
if let Some(rw) = end_time {
query_params.insert("endTime".to_string(), json!(rw));
}
if let Some(rw) = limit {
query_params.insert("limit".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Vec<models::QueryMarginAccountsAllOcoResponseInner>>(
&self.configuration,
"/sapi/v1/margin/allOrderList",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_margin_accounts_all_orders(
&self,
params: QueryMarginAccountsAllOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>>
{
let QueryMarginAccountsAllOrdersParams {
symbol,
is_isolated,
order_id,
start_time,
end_time,
limit,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = order_id {
query_params.insert("orderId".to_string(), json!(rw));
}
if let Some(rw) = start_time {
query_params.insert("startTime".to_string(), json!(rw));
}
if let Some(rw) = end_time {
query_params.insert("endTime".to_string(), json!(rw));
}
if let Some(rw) = limit {
query_params.insert("limit".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>(
&self.configuration,
"/sapi/v1/margin/allOrders",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_margin_accounts_oco(
&self,
params: QueryMarginAccountsOcoParams,
) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOcoResponse>> {
let QueryMarginAccountsOcoParams {
is_isolated,
symbol,
order_list_id,
orig_client_order_id,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = symbol {
query_params.insert("symbol".to_string(), json!(rw));
}
if let Some(rw) = order_list_id {
query_params.insert("orderListId".to_string(), json!(rw));
}
if let Some(rw) = orig_client_order_id {
query_params.insert("origClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::QueryMarginAccountsOcoResponse>(
&self.configuration,
"/sapi/v1/margin/orderList",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_margin_accounts_open_oco(
&self,
params: QueryMarginAccountsOpenOcoParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>> {
let QueryMarginAccountsOpenOcoParams {
is_isolated,
symbol,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = symbol {
query_params.insert("symbol".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>(
&self.configuration,
"/sapi/v1/margin/openOrderList",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_margin_accounts_open_orders(
&self,
params: QueryMarginAccountsOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>>
{
let QueryMarginAccountsOpenOrdersParams {
symbol,
is_isolated,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = symbol {
query_params.insert("symbol".to_string(), json!(rw));
}
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>(
&self.configuration,
"/sapi/v1/margin/openOrders",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_margin_accounts_order(
&self,
params: QueryMarginAccountsOrderParams,
) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOrderResponse>> {
let QueryMarginAccountsOrderParams {
symbol,
is_isolated,
order_id,
orig_client_order_id,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = order_id {
query_params.insert("orderId".to_string(), json!(rw));
}
if let Some(rw) = orig_client_order_id {
query_params.insert("origClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::QueryMarginAccountsOrderResponse>(
&self.configuration,
"/sapi/v1/margin/order",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_margin_accounts_trade_list(
&self,
params: QueryMarginAccountsTradeListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsTradeListResponseInner>>>
{
let QueryMarginAccountsTradeListParams {
symbol,
is_isolated,
order_id,
start_time,
end_time,
from_id,
limit,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = order_id {
query_params.insert("orderId".to_string(), json!(rw));
}
if let Some(rw) = start_time {
query_params.insert("startTime".to_string(), json!(rw));
}
if let Some(rw) = end_time {
query_params.insert("endTime".to_string(), json!(rw));
}
if let Some(rw) = from_id {
query_params.insert("fromId".to_string(), json!(rw));
}
if let Some(rw) = limit {
query_params.insert("limit".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Vec<models::QueryMarginAccountsTradeListResponseInner>>(
&self.configuration,
"/sapi/v1/margin/myTrades",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_prevented_matches(
&self,
params: QueryPreventedMatchesParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryPreventedMatchesResponseInner>>> {
let QueryPreventedMatchesParams {
symbol,
prevented_match_id,
order_id,
from_prevented_match_id,
is_isolated,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
if let Some(rw) = prevented_match_id {
query_params.insert("preventedMatchId".to_string(), json!(rw));
}
if let Some(rw) = order_id {
query_params.insert("orderId".to_string(), json!(rw));
}
if let Some(rw) = from_prevented_match_id {
query_params.insert("fromPreventedMatchId".to_string(), json!(rw));
}
if let Some(rw) = is_isolated {
query_params.insert("isIsolated".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Vec<models::QueryPreventedMatchesResponseInner>>(
&self.configuration,
"/sapi/v1/margin/myPreventedMatches",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_special_key(
&self,
params: QuerySpecialKeyParams,
) -> anyhow::Result<RestApiResponse<models::QuerySpecialKeyResponse>> {
let QuerySpecialKeyParams {
symbol,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = symbol {
query_params.insert("symbol".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::QuerySpecialKeyResponse>(
&self.configuration,
"/sapi/v1/margin/apiKey",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn query_special_key_list(
&self,
params: QuerySpecialKeyListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QuerySpecialKeyListResponseInner>>> {
let QuerySpecialKeyListParams {
symbol,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = symbol {
query_params.insert("symbol".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Vec<models::QuerySpecialKeyListResponseInner>>(
&self.configuration,
"/sapi/v1/margin/api-key-list",
reqwest::Method::GET,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn small_liability_exchange(
&self,
params: SmallLiabilityExchangeParams,
) -> anyhow::Result<RestApiResponse<Value>> {
let SmallLiabilityExchangeParams {
asset_names,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("assetNames".to_string(), json!(asset_names));
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Value>(
&self.configuration,
"/sapi/v1/margin/exchange-small-liability",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
}
#[cfg(all(test, feature = "margin_trading"))]
mod tests {
use super::*;
use crate::TOKIO_SHARED_RT;
use crate::{errors::ConnectorError, models::DataFuture, models::RestApiRateLimit};
use async_trait::async_trait;
use std::collections::HashMap;
struct DummyRestApiResponse<T> {
inner: Box<dyn FnOnce() -> DataFuture<Result<T, ConnectorError>> + Send + Sync>,
status: u16,
headers: HashMap<String, String>,
rate_limits: Option<Vec<RestApiRateLimit>>,
}
impl<T> From<DummyRestApiResponse<T>> for RestApiResponse<T> {
fn from(dummy: DummyRestApiResponse<T>) -> Self {
Self {
data_fn: dummy.inner,
status: dummy.status,
headers: dummy.headers,
rate_limits: dummy.rate_limits,
}
}
}
struct MockTradeApiClient {
force_error: bool,
}
#[async_trait]
impl TradeApi for MockTradeApiClient {
async fn create_special_key(
&self,
_params: CreateSpecialKeyParams,
) -> anyhow::Result<RestApiResponse<models::CreateSpecialKeyResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
let resp_json: Value = serde_json::from_str(r#"{"apiKey":"npOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoGx","secretKey":"87ssWB7azoy6ACRfyp6OVOL5U3rtZptX31QWw2kWjl1jHEYRbyM1pd6qykRBQw8p","type":"HMAC_SHA256"}"#).unwrap_or_else(|_| serde_json::json!({}));
let dummy_response: models::CreateSpecialKeyResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::CreateSpecialKeyResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn delete_special_key(
&self,
_params: DeleteSpecialKeyParams,
) -> anyhow::Result<RestApiResponse<Value>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
let dummy_response = Value::Null;
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn edit_ip_for_special_key(
&self,
_params: EditIpForSpecialKeyParams,
) -> anyhow::Result<RestApiResponse<Value>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
let dummy_response = Value::Null;
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn exit_special_key_mode(
&self,
_params: ExitSpecialKeyModeParams,
) -> anyhow::Result<RestApiResponse<serde_json::Value>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
let resp_json: Value =
serde_json::from_str(r"").unwrap_or_else(|_| serde_json::json!({}));
let dummy_response: serde_json::Value = serde_json::from_value(resp_json.clone())
.expect("should parse into serde_json::Value");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn get_force_liquidation_record(
&self,
_params: GetForceLiquidationRecordParams,
) -> anyhow::Result<RestApiResponse<models::GetForceLiquidationRecordResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::GetForceLiquidationRecordResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::GetForceLiquidationRecordResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn get_small_liability_exchange_coin_list(
&self,
_params: GetSmallLiabilityExchangeCoinListParams,
) -> anyhow::Result<
RestApiResponse<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>,
> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: Vec<models::GetSmallLiabilityExchangeCoinListResponseInner> =
serde_json::from_value(resp_json.clone()).expect(
"should parse into Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>",
);
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn get_small_liability_exchange_history(
&self,
_params: GetSmallLiabilityExchangeHistoryParams,
) -> anyhow::Result<RestApiResponse<models::GetSmallLiabilityExchangeHistoryResponse>>
{
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::GetSmallLiabilityExchangeHistoryResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::GetSmallLiabilityExchangeHistoryResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn liquidation_loan_repay(
&self,
_params: LiquidationLoanRepayParams,
) -> anyhow::Result<RestApiResponse<models::LiquidationLoanRepayResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::LiquidationLoanRepayResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::LiquidationLoanRepayResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn margin_account_cancel_all_open_orders_on_a_symbol(
&self,
_params: MarginAccountCancelAllOpenOrdersOnASymbolParams,
) -> anyhow::Result<
RestApiResponse<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>,
> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response : Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn margin_account_cancel_oco(
&self,
_params: MarginAccountCancelOcoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOcoResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::MarginAccountCancelOcoResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::MarginAccountCancelOcoResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn margin_account_cancel_order(
&self,
_params: MarginAccountCancelOrderParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOrderResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::MarginAccountCancelOrderResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::MarginAccountCancelOrderResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn margin_account_new_oco(
&self,
_params: MarginAccountNewOcoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOcoResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::MarginAccountNewOcoResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::MarginAccountNewOcoResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn margin_account_new_order(
&self,
_params: MarginAccountNewOrderParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOrderResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::MarginAccountNewOrderResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::MarginAccountNewOrderResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn margin_account_new_oto(
&self,
_params: MarginAccountNewOtoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtoResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::MarginAccountNewOtoResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::MarginAccountNewOtoResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn margin_account_new_otoco(
&self,
_params: MarginAccountNewOtocoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtocoResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::MarginAccountNewOtocoResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::MarginAccountNewOtocoResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn margin_manual_liquidation(
&self,
_params: MarginManualLiquidationParams,
) -> anyhow::Result<RestApiResponse<models::MarginManualLiquidationResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::MarginManualLiquidationResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::MarginManualLiquidationResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_current_margin_order_count_usage(
&self,
_params: QueryCurrentMarginOrderCountUsageParams,
) -> anyhow::Result<
RestApiResponse<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>,
> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: Vec<models::QueryCurrentMarginOrderCountUsageResponseInner> =
serde_json::from_value(resp_json.clone()).expect(
"should parse into Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>",
);
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_liquidation_loan(
&self,
_params: QueryLiquidationLoanParams,
) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::QueryLiquidationLoanResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::QueryLiquidationLoanResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_liquidation_loan_repay_history(
&self,
_params: QueryLiquidationLoanRepayHistoryParams,
) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanRepayHistoryResponse>>
{
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::QueryLiquidationLoanRepayHistoryResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::QueryLiquidationLoanRepayHistoryResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_margin_accounts_all_oco(
&self,
_params: QueryMarginAccountsAllOcoParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>>
{
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: Vec<models::QueryMarginAccountsAllOcoResponseInner> =
serde_json::from_value(resp_json.clone()).expect(
"should parse into Vec<models::QueryMarginAccountsAllOcoResponseInner>",
);
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_margin_accounts_all_orders(
&self,
_params: QueryMarginAccountsAllOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>>
{
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: Vec<models::QueryMarginAccountsAllOrdersResponseInner> =
serde_json::from_value(resp_json.clone()).expect(
"should parse into Vec<models::QueryMarginAccountsAllOrdersResponseInner>",
);
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_margin_accounts_oco(
&self,
_params: QueryMarginAccountsOcoParams,
) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOcoResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::QueryMarginAccountsOcoResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::QueryMarginAccountsOcoResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_margin_accounts_open_oco(
&self,
_params: QueryMarginAccountsOpenOcoParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>>
{
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: Vec<models::QueryMarginAccountsOpenOcoResponseInner> =
serde_json::from_value(resp_json.clone()).expect(
"should parse into Vec<models::QueryMarginAccountsOpenOcoResponseInner>",
);
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_margin_accounts_open_orders(
&self,
_params: QueryMarginAccountsOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>>
{
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: Vec<models::QueryMarginAccountsOpenOrdersResponseInner> =
serde_json::from_value(resp_json.clone()).expect(
"should parse into Vec<models::QueryMarginAccountsOpenOrdersResponseInner>",
);
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_margin_accounts_order(
&self,
_params: QueryMarginAccountsOrderParams,
) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOrderResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::QueryMarginAccountsOrderResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::QueryMarginAccountsOrderResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_margin_accounts_trade_list(
&self,
_params: QueryMarginAccountsTradeListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsTradeListResponseInner>>>
{
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: Vec<models::QueryMarginAccountsTradeListResponseInner> =
serde_json::from_value(resp_json.clone()).expect(
"should parse into Vec<models::QueryMarginAccountsTradeListResponseInner>",
);
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_prevented_matches(
&self,
_params: QueryPreventedMatchesParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryPreventedMatchesResponseInner>>>
{
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: Vec<models::QueryPreventedMatchesResponseInner> =
serde_json::from_value(resp_json.clone())
.expect("should parse into Vec<models::QueryPreventedMatchesResponseInner>");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_special_key(
&self,
_params: QuerySpecialKeyParams,
) -> anyhow::Result<RestApiResponse<models::QuerySpecialKeyResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: models::QuerySpecialKeyResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::QuerySpecialKeyResponse");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn query_special_key_list(
&self,
_params: QuerySpecialKeyListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QuerySpecialKeyListResponseInner>>>
{
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
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!({}));
let dummy_response: Vec<models::QuerySpecialKeyListResponseInner> =
serde_json::from_value(resp_json.clone())
.expect("should parse into Vec<models::QuerySpecialKeyListResponseInner>");
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
async fn small_liability_exchange(
&self,
_params: SmallLiabilityExchangeParams,
) -> anyhow::Result<RestApiResponse<Value>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
let dummy_response = Value::Null;
let dummy = DummyRestApiResponse {
inner: Box::new(move || Box::pin(async move { Ok(dummy_response) })),
status: 200,
headers: HashMap::new(),
rate_limits: None,
};
Ok(dummy.into())
}
}
#[test]
fn create_special_key_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = CreateSpecialKeyParams::builder("apiName".to_string(),).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"apiKey":"npOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoGx","secretKey":"87ssWB7azoy6ACRfyp6OVOL5U3rtZptX31QWw2kWjl1jHEYRbyM1pd6qykRBQw8p","type":"HMAC_SHA256"}"#).unwrap_or_else(|_| serde_json::json!({}));
let expected_response : models::CreateSpecialKeyResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::CreateSpecialKeyResponse");
let resp = client.create_special_key(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn create_special_key_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
let resp_json: Value = serde_json::from_str(r#"{"apiKey":"npOzOAeLVgr2TuxWfNo43AaPWpBbJEoKezh1o8mSQb6ryE2odE11A4AoVlJbQoGx","secretKey":"87ssWB7azoy6ACRfyp6OVOL5U3rtZptX31QWw2kWjl1jHEYRbyM1pd6qykRBQw8p","type":"HMAC_SHA256"}"#).unwrap_or_else(|_| serde_json::json!({}));
let expected_response : models::CreateSpecialKeyResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::CreateSpecialKeyResponse");
let resp = client.create_special_key(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn create_special_key_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = CreateSpecialKeyParams::builder("apiName".to_string())
.build()
.unwrap();
match client.create_special_key(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn delete_special_key_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = DeleteSpecialKeyParams::builder().build().unwrap();
let expected_response = Value::Null;
let resp = client
.delete_special_key(params)
.await
.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn delete_special_key_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = DeleteSpecialKeyParams::builder()
.api_name("apiName".to_string())
.symbol("BTCUSDT".to_string())
.recv_window(5000)
.build()
.unwrap();
let expected_response = Value::Null;
let resp = client
.delete_special_key(params)
.await
.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn delete_special_key_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = DeleteSpecialKeyParams::builder().build().unwrap();
match client.delete_special_key(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn edit_ip_for_special_key_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = EditIpForSpecialKeyParams::builder("24.156.99.202".to_string())
.build()
.unwrap();
let expected_response = Value::Null;
let resp = client
.edit_ip_for_special_key(params)
.await
.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn edit_ip_for_special_key_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = EditIpForSpecialKeyParams::builder("24.156.99.202".to_string())
.symbol("BTCUSDT".to_string())
.recv_window(5000)
.build()
.unwrap();
let expected_response = Value::Null;
let resp = client
.edit_ip_for_special_key(params)
.await
.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn edit_ip_for_special_key_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = EditIpForSpecialKeyParams::builder("24.156.99.202".to_string())
.build()
.unwrap();
match client.edit_ip_for_special_key(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn exit_special_key_mode_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = ExitSpecialKeyModeParams::builder().build().unwrap();
let resp_json: Value =
serde_json::from_str(r"").unwrap_or_else(|_| serde_json::json!({}));
let expected_response: serde_json::Value = serde_json::from_value(resp_json.clone())
.expect("should parse into serde_json::Value");
let resp = client
.exit_special_key_mode(params)
.await
.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn exit_special_key_mode_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = ExitSpecialKeyModeParams::builder()
.recv_window(5000)
.build()
.unwrap();
let resp_json: Value =
serde_json::from_str(r"").unwrap_or_else(|_| serde_json::json!({}));
let expected_response: serde_json::Value = serde_json::from_value(resp_json.clone())
.expect("should parse into serde_json::Value");
let resp = client
.exit_special_key_mode(params)
.await
.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn exit_special_key_mode_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = ExitSpecialKeyModeParams::builder().build().unwrap();
match client.exit_special_key_mode(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn get_force_liquidation_record_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = GetForceLiquidationRecordParams::builder().build().unwrap();
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!({}));
let expected_response : models::GetForceLiquidationRecordResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetForceLiquidationRecordResponse");
let resp = client.get_force_liquidation_record(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn get_force_liquidation_record_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = GetForceLiquidationRecordParams::builder().start_time(1623319461670).end_time(1641782889000).isolated_symbol("BTCUSDT".to_string()).current(1).size(10).recv_window(5000).build().unwrap();
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!({}));
let expected_response : models::GetForceLiquidationRecordResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetForceLiquidationRecordResponse");
let resp = client.get_force_liquidation_record(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn get_force_liquidation_record_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = GetForceLiquidationRecordParams::builder().build().unwrap();
match client.get_force_liquidation_record(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn get_small_liability_exchange_coin_list_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = GetSmallLiabilityExchangeCoinListParams::builder().build().unwrap();
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!({}));
let expected_response : Vec<models::GetSmallLiabilityExchangeCoinListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>");
let resp = client.get_small_liability_exchange_coin_list(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn get_small_liability_exchange_coin_list_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = GetSmallLiabilityExchangeCoinListParams::builder().recv_window(5000).build().unwrap();
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!({}));
let expected_response : Vec<models::GetSmallLiabilityExchangeCoinListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>");
let resp = client.get_small_liability_exchange_coin_list(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn get_small_liability_exchange_coin_list_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = GetSmallLiabilityExchangeCoinListParams::builder()
.build()
.unwrap();
match client.get_small_liability_exchange_coin_list(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn get_small_liability_exchange_history_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = GetSmallLiabilityExchangeHistoryParams::builder(1,10,).build().unwrap();
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!({}));
let expected_response : models::GetSmallLiabilityExchangeHistoryResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetSmallLiabilityExchangeHistoryResponse");
let resp = client.get_small_liability_exchange_history(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn get_small_liability_exchange_history_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = GetSmallLiabilityExchangeHistoryParams::builder(1,10,).start_time(1623319461670).end_time(1641782889000).recv_window(5000).build().unwrap();
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!({}));
let expected_response : models::GetSmallLiabilityExchangeHistoryResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::GetSmallLiabilityExchangeHistoryResponse");
let resp = client.get_small_liability_exchange_history(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn get_small_liability_exchange_history_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = GetSmallLiabilityExchangeHistoryParams::builder(1, 10)
.build()
.unwrap();
match client.get_small_liability_exchange_history(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn liquidation_loan_repay_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = LiquidationLoanRepayParams::builder("USDT".to_string(),dec!(300.00),).build().unwrap();
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!({}));
let expected_response : models::LiquidationLoanRepayResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::LiquidationLoanRepayResponse");
let resp = client.liquidation_loan_repay(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn liquidation_loan_repay_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = LiquidationLoanRepayParams::builder("USDT".to_string(),dec!(300.00),).recv_window(5000).build().unwrap();
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!({}));
let expected_response : models::LiquidationLoanRepayResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::LiquidationLoanRepayResponse");
let resp = client.liquidation_loan_repay(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn liquidation_loan_repay_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = LiquidationLoanRepayParams::builder("USDT".to_string(), dec!(300.00))
.build()
.unwrap();
match client.liquidation_loan_repay(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn margin_account_cancel_all_open_orders_on_a_symbol_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = MarginAccountCancelAllOpenOrdersOnASymbolParams::builder("BTCUSDT".to_string(),).build().unwrap();
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!({}));
let expected_response : Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>");
let resp = client.margin_account_cancel_all_open_orders_on_a_symbol(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_cancel_all_open_orders_on_a_symbol_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = MarginAccountCancelAllOpenOrdersOnASymbolParams::builder("BTCUSDT".to_string(),).is_isolated(MarginAccountCancelAllOpenOrdersOnASymbolIsIsolatedEnum::True).recv_window(5000).build().unwrap();
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!({}));
let expected_response : Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>");
let resp = client.margin_account_cancel_all_open_orders_on_a_symbol(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_cancel_all_open_orders_on_a_symbol_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params =
MarginAccountCancelAllOpenOrdersOnASymbolParams::builder("BTCUSDT".to_string())
.build()
.unwrap();
match client
.margin_account_cancel_all_open_orders_on_a_symbol(params)
.await
{
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn margin_account_cancel_oco_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = MarginAccountCancelOcoParams::builder("BTCUSDT".to_string(),).build().unwrap();
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!({}));
let expected_response : models::MarginAccountCancelOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountCancelOcoResponse");
let resp = client.margin_account_cancel_oco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_cancel_oco_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : models::MarginAccountCancelOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountCancelOcoResponse");
let resp = client.margin_account_cancel_oco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_cancel_oco_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = MarginAccountCancelOcoParams::builder("BTCUSDT".to_string())
.build()
.unwrap();
match client.margin_account_cancel_oco(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn margin_account_cancel_order_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = MarginAccountCancelOrderParams::builder("LTCBTC".to_string(),).build().unwrap();
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!({}));
let expected_response : models::MarginAccountCancelOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountCancelOrderResponse");
let resp = client.margin_account_cancel_order(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_cancel_order_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : models::MarginAccountCancelOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountCancelOrderResponse");
let resp = client.margin_account_cancel_order(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_cancel_order_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = MarginAccountCancelOrderParams::builder("LTCBTC".to_string())
.build()
.unwrap();
match client.margin_account_cancel_order(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn margin_account_new_oco_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = MarginAccountNewOcoParams::builder("LTCBTC".to_string(),MarginAccountNewOcoSideEnum::Buy,dec!(1.0),dec!(1.0),dec!(1.0),).build().unwrap();
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!({}));
let expected_response : models::MarginAccountNewOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOcoResponse");
let resp = client.margin_account_new_oco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_new_oco_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : models::MarginAccountNewOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOcoResponse");
let resp = client.margin_account_new_oco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_new_oco_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = MarginAccountNewOcoParams::builder(
"LTCBTC".to_string(),
MarginAccountNewOcoSideEnum::Buy,
dec!(1.0),
dec!(1.0),
dec!(1.0),
)
.build()
.unwrap();
match client.margin_account_new_oco(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn margin_account_new_order_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = MarginAccountNewOrderParams::builder("BTCUSDT".to_string(),MarginAccountNewOrderSideEnum::Buy,MarginAccountNewOrderTypeEnum::Limit,).build().unwrap();
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!({}));
let expected_response : models::MarginAccountNewOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOrderResponse");
let resp = client.margin_account_new_order(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_new_order_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : models::MarginAccountNewOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOrderResponse");
let resp = client.margin_account_new_order(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_new_order_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = MarginAccountNewOrderParams::builder(
"BTCUSDT".to_string(),
MarginAccountNewOrderSideEnum::Buy,
MarginAccountNewOrderTypeEnum::Limit,
)
.build()
.unwrap();
match client.margin_account_new_order(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn margin_account_new_oto_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : models::MarginAccountNewOtoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOtoResponse");
let resp = client.margin_account_new_oto(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_new_oto_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : models::MarginAccountNewOtoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOtoResponse");
let resp = client.margin_account_new_oto(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_new_oto_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
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();
match client.margin_account_new_oto(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn margin_account_new_otoco_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : models::MarginAccountNewOtocoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOtocoResponse");
let resp = client.margin_account_new_otoco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_new_otoco_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : models::MarginAccountNewOtocoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginAccountNewOtocoResponse");
let resp = client.margin_account_new_otoco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_account_new_otoco_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
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();
match client.margin_account_new_otoco(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn margin_manual_liquidation_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = MarginManualLiquidationParams::builder(MarginManualLiquidationTypeEnum::Margin,).build().unwrap();
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!({}));
let expected_response : models::MarginManualLiquidationResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginManualLiquidationResponse");
let resp = client.margin_manual_liquidation(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_manual_liquidation_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = MarginManualLiquidationParams::builder(MarginManualLiquidationTypeEnum::Margin,).symbol("ETHUSDT".to_string()).recv_window(5000).build().unwrap();
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!({}));
let expected_response : models::MarginManualLiquidationResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::MarginManualLiquidationResponse");
let resp = client.margin_manual_liquidation(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn margin_manual_liquidation_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params =
MarginManualLiquidationParams::builder(MarginManualLiquidationTypeEnum::Margin)
.build()
.unwrap();
match client.margin_manual_liquidation(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_current_margin_order_count_usage_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryCurrentMarginOrderCountUsageParams::builder().build().unwrap();
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!({}));
let expected_response : Vec<models::QueryCurrentMarginOrderCountUsageResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>");
let resp = client.query_current_margin_order_count_usage(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_current_margin_order_count_usage_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryCurrentMarginOrderCountUsageParams::builder().is_isolated(QueryCurrentMarginOrderCountUsageIsIsolatedEnum::True).symbol("BTCUSDT".to_string()).recv_window(5000).build().unwrap();
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!({}));
let expected_response : Vec<models::QueryCurrentMarginOrderCountUsageResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>");
let resp = client.query_current_margin_order_count_usage(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_current_margin_order_count_usage_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QueryCurrentMarginOrderCountUsageParams::builder()
.build()
.unwrap();
match client.query_current_margin_order_count_usage(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_liquidation_loan_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryLiquidationLoanParams::builder().build().unwrap();
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!({}));
let expected_response : models::QueryLiquidationLoanResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryLiquidationLoanResponse");
let resp = client.query_liquidation_loan(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_liquidation_loan_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryLiquidationLoanParams::builder().recv_window(5000).build().unwrap();
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!({}));
let expected_response : models::QueryLiquidationLoanResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryLiquidationLoanResponse");
let resp = client.query_liquidation_loan(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_liquidation_loan_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QueryLiquidationLoanParams::builder().build().unwrap();
match client.query_liquidation_loan(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_liquidation_loan_repay_history_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryLiquidationLoanRepayHistoryParams::builder().build().unwrap();
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!({}));
let expected_response : models::QueryLiquidationLoanRepayHistoryResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryLiquidationLoanRepayHistoryResponse");
let resp = client.query_liquidation_loan_repay_history(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_liquidation_loan_repay_history_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryLiquidationLoanRepayHistoryParams::builder().start_time(1714492800000).end_time(1714579200000).current(1).size(50).recv_window(5000).build().unwrap();
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!({}));
let expected_response : models::QueryLiquidationLoanRepayHistoryResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryLiquidationLoanRepayHistoryResponse");
let resp = client.query_liquidation_loan_repay_history(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_liquidation_loan_repay_history_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QueryLiquidationLoanRepayHistoryParams::builder()
.build()
.unwrap();
match client.query_liquidation_loan_repay_history(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_margin_accounts_all_oco_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryMarginAccountsAllOcoParams::builder().build().unwrap();
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!({}));
let expected_response : Vec<models::QueryMarginAccountsAllOcoResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsAllOcoResponseInner>");
let resp = client.query_margin_accounts_all_oco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_all_oco_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : Vec<models::QueryMarginAccountsAllOcoResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsAllOcoResponseInner>");
let resp = client.query_margin_accounts_all_oco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_all_oco_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QueryMarginAccountsAllOcoParams::builder().build().unwrap();
match client.query_margin_accounts_all_oco(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_margin_accounts_all_orders_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryMarginAccountsAllOrdersParams::builder("BNBBTC".to_string(),).build().unwrap();
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!({}));
let expected_response : Vec<models::QueryMarginAccountsAllOrdersResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsAllOrdersResponseInner>");
let resp = client.query_margin_accounts_all_orders(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_all_orders_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : Vec<models::QueryMarginAccountsAllOrdersResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsAllOrdersResponseInner>");
let resp = client.query_margin_accounts_all_orders(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_all_orders_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QueryMarginAccountsAllOrdersParams::builder("BNBBTC".to_string())
.build()
.unwrap();
match client.query_margin_accounts_all_orders(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_margin_accounts_oco_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryMarginAccountsOcoParams::builder().build().unwrap();
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!({}));
let expected_response : models::QueryMarginAccountsOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryMarginAccountsOcoResponse");
let resp = client.query_margin_accounts_oco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_oco_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : models::QueryMarginAccountsOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryMarginAccountsOcoResponse");
let resp = client.query_margin_accounts_oco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_oco_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QueryMarginAccountsOcoParams::builder().build().unwrap();
match client.query_margin_accounts_oco(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_margin_accounts_open_oco_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryMarginAccountsOpenOcoParams::builder().build().unwrap();
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!({}));
let expected_response : Vec<models::QueryMarginAccountsOpenOcoResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsOpenOcoResponseInner>");
let resp = client.query_margin_accounts_open_oco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_open_oco_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryMarginAccountsOpenOcoParams::builder().is_isolated(QueryMarginAccountsOpenOcoIsIsolatedEnum::True).symbol("LTCBTC".to_string()).recv_window(5000).build().unwrap();
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!({}));
let expected_response : Vec<models::QueryMarginAccountsOpenOcoResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsOpenOcoResponseInner>");
let resp = client.query_margin_accounts_open_oco(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_open_oco_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QueryMarginAccountsOpenOcoParams::builder().build().unwrap();
match client.query_margin_accounts_open_oco(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_margin_accounts_open_orders_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryMarginAccountsOpenOrdersParams::builder().build().unwrap();
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!({}));
let expected_response : Vec<models::QueryMarginAccountsOpenOrdersResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsOpenOrdersResponseInner>");
let resp = client.query_margin_accounts_open_orders(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_open_orders_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryMarginAccountsOpenOrdersParams::builder().symbol("BNBBTC".to_string()).is_isolated(QueryMarginAccountsOpenOrdersIsIsolatedEnum::True).recv_window(5000).build().unwrap();
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!({}));
let expected_response : Vec<models::QueryMarginAccountsOpenOrdersResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsOpenOrdersResponseInner>");
let resp = client.query_margin_accounts_open_orders(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_open_orders_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QueryMarginAccountsOpenOrdersParams::builder()
.build()
.unwrap();
match client.query_margin_accounts_open_orders(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_margin_accounts_order_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryMarginAccountsOrderParams::builder("BNBBTC".to_string(),).build().unwrap();
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!({}));
let expected_response : models::QueryMarginAccountsOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryMarginAccountsOrderResponse");
let resp = client.query_margin_accounts_order(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_order_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : models::QueryMarginAccountsOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QueryMarginAccountsOrderResponse");
let resp = client.query_margin_accounts_order(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_order_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QueryMarginAccountsOrderParams::builder("BNBBTC".to_string())
.build()
.unwrap();
match client.query_margin_accounts_order(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_margin_accounts_trade_list_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryMarginAccountsTradeListParams::builder("BNBBTC".to_string(),).build().unwrap();
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!({}));
let expected_response : Vec<models::QueryMarginAccountsTradeListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsTradeListResponseInner>");
let resp = client.query_margin_accounts_trade_list(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_trade_list_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : Vec<models::QueryMarginAccountsTradeListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryMarginAccountsTradeListResponseInner>");
let resp = client.query_margin_accounts_trade_list(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_margin_accounts_trade_list_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QueryMarginAccountsTradeListParams::builder("BNBBTC".to_string())
.build()
.unwrap();
match client.query_margin_accounts_trade_list(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_prevented_matches_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QueryPreventedMatchesParams::builder("BTCUSDT".to_string(),).build().unwrap();
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!({}));
let expected_response : Vec<models::QueryPreventedMatchesResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryPreventedMatchesResponseInner>");
let resp = client.query_prevented_matches(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_prevented_matches_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
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();
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!({}));
let expected_response : Vec<models::QueryPreventedMatchesResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QueryPreventedMatchesResponseInner>");
let resp = client.query_prevented_matches(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_prevented_matches_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QueryPreventedMatchesParams::builder("BTCUSDT".to_string())
.build()
.unwrap();
match client.query_prevented_matches(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_special_key_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QuerySpecialKeyParams::builder().build().unwrap();
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!({}));
let expected_response : models::QuerySpecialKeyResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QuerySpecialKeyResponse");
let resp = client.query_special_key(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_special_key_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QuerySpecialKeyParams::builder().symbol("BTCUSDT".to_string()).recv_window(5000).build().unwrap();
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!({}));
let expected_response : models::QuerySpecialKeyResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::QuerySpecialKeyResponse");
let resp = client.query_special_key(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_special_key_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QuerySpecialKeyParams::builder().build().unwrap();
match client.query_special_key(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn query_special_key_list_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QuerySpecialKeyListParams::builder().build().unwrap();
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!({}));
let expected_response : Vec<models::QuerySpecialKeyListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QuerySpecialKeyListResponseInner>");
let resp = client.query_special_key_list(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_special_key_list_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = QuerySpecialKeyListParams::builder().symbol("BTCUSDT".to_string()).recv_window(5000).build().unwrap();
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!({}));
let expected_response : Vec<models::QuerySpecialKeyListResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::QuerySpecialKeyListResponseInner>");
let resp = client.query_special_key_list(params).await.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn query_special_key_list_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = QuerySpecialKeyListParams::builder().build().unwrap();
match client.query_special_key_list(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn small_liability_exchange_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = SmallLiabilityExchangeParams::builder("BTC,ETH".to_string())
.build()
.unwrap();
let expected_response = Value::Null;
let resp = client
.small_liability_exchange(params)
.await
.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn small_liability_exchange_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = SmallLiabilityExchangeParams::builder("BTC,ETH".to_string())
.recv_window(5000)
.build()
.unwrap();
let expected_response = Value::Null;
let resp = client
.small_liability_exchange(params)
.await
.expect("Expected a response");
let data_future = resp.data();
let actual_response = data_future.await.unwrap();
assert_eq!(actual_response, expected_response);
});
}
#[test]
fn small_liability_exchange_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = SmallLiabilityExchangeParams::builder("BTC,ETH".to_string())
.build()
.unwrap();
match client.small_liability_exchange(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
}