/*
* Binance Spot REST API
*
* OpenAPI Specifications for the Binance Spot REST API
*
* API documents:
* - [Github rest-api documentation file](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md)
* - [General API information for rest-api on website](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-api-information)
*
*
* 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::spot::rest_api::models;
const HAS_TIME_UNIT: bool = true;
#[async_trait]
pub trait TradeApi: Send + Sync {
async fn delete_open_orders(
&self,
params: DeleteOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::DeleteOpenOrdersResponseInner>>>;
async fn delete_order(
&self,
params: DeleteOrderParams,
) -> anyhow::Result<RestApiResponse<models::DeleteOrderResponse>>;
async fn delete_order_list(
&self,
params: DeleteOrderListParams,
) -> anyhow::Result<RestApiResponse<models::DeleteOrderListResponse>>;
async fn new_order(
&self,
params: NewOrderParams,
) -> anyhow::Result<RestApiResponse<models::NewOrderResponse>>;
async fn order_amend_keep_priority(
&self,
params: OrderAmendKeepPriorityParams,
) -> anyhow::Result<RestApiResponse<models::OrderAmendKeepPriorityResponse>>;
async fn order_cancel_replace(
&self,
params: OrderCancelReplaceParams,
) -> anyhow::Result<RestApiResponse<models::OrderCancelReplaceResponse>>;
async fn order_list_oco(
&self,
params: OrderListOcoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOcoResponse>>;
async fn order_list_opo(
&self,
params: OrderListOpoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOpoResponse>>;
async fn order_list_opoco(
&self,
params: OrderListOpocoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOpocoResponse>>;
async fn order_list_oto(
&self,
params: OrderListOtoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOtoResponse>>;
async fn order_list_otoco(
&self,
params: OrderListOtocoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOtocoResponse>>;
async fn order_oco(
&self,
params: OrderOcoParams,
) -> anyhow::Result<RestApiResponse<models::OrderOcoResponse>>;
async fn order_test(
&self,
params: OrderTestParams,
) -> anyhow::Result<RestApiResponse<models::OrderTestResponse>>;
async fn sor_order(
&self,
params: SorOrderParams,
) -> anyhow::Result<RestApiResponse<models::SorOrderResponse>>;
async fn sor_order_test(
&self,
params: SorOrderTestParams,
) -> anyhow::Result<RestApiResponse<models::SorOrderTestResponse>>;
}
#[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 DeleteOrderCancelRestrictionsEnum {
#[serde(rename = "ONLY_NEW")]
OnlyNew,
#[serde(rename = "NEW")]
New,
#[serde(rename = "ONLY_PARTIALLY_FILLED")]
OnlyPartiallyFilled,
#[serde(rename = "PARTIALLY_FILLED")]
PartiallyFilled,
}
impl DeleteOrderCancelRestrictionsEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::OnlyNew => "ONLY_NEW",
Self::New => "NEW",
Self::OnlyPartiallyFilled => "ONLY_PARTIALLY_FILLED",
Self::PartiallyFilled => "PARTIALLY_FILLED",
}
}
}
impl std::str::FromStr for DeleteOrderCancelRestrictionsEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"ONLY_NEW" => Ok(Self::OnlyNew),
"NEW" => Ok(Self::New),
"ONLY_PARTIALLY_FILLED" => Ok(Self::OnlyPartiallyFilled),
"PARTIALLY_FILLED" => Ok(Self::PartiallyFilled),
other => Err(format!("invalid DeleteOrderCancelRestrictionsEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum NewOrderSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl NewOrderSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for NewOrderSideEnum {
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 NewOrderSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum NewOrderTypeEnum {
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
#[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,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl NewOrderTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Market => "MARKET",
Self::Limit => "LIMIT",
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for NewOrderTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
"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),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid NewOrderTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum NewOrderTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl NewOrderTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Ioc => "IOC",
Self::Fok => "FOK",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for NewOrderTimeInForceEnum {
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),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid NewOrderTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum NewOrderNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
}
impl NewOrderNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
Self::Market => "MARKET",
Self::Limit => "LIMIT",
}
}
}
impl std::str::FromStr for NewOrderNewOrderRespTypeEnum {
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),
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
other => Err(format!("invalid NewOrderNewOrderRespTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum NewOrderSelfTradePreventionModeEnum {
#[serde(rename = "NONE")]
None,
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "DECREMENT")]
Decrement,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl NewOrderSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "NONE",
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::Decrement => "DECREMENT",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for NewOrderSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NONE" => Ok(Self::None),
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"DECREMENT" => Ok(Self::Decrement),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid NewOrderSelfTradePreventionModeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum NewOrderPegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl NewOrderPegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for NewOrderPegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid NewOrderPegPriceTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum NewOrderPegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl NewOrderPegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for NewOrderPegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid NewOrderPegOffsetTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderCancelReplaceSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderCancelReplaceSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderCancelReplaceSideEnum {
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 OrderCancelReplaceSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderCancelReplaceTypeEnum {
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
#[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,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderCancelReplaceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Market => "MARKET",
Self::Limit => "LIMIT",
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderCancelReplaceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
"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),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid OrderCancelReplaceTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderCancelReplaceCancelReplaceModeEnum {
#[serde(rename = "STOP_ON_FAILURE")]
StopOnFailure,
#[serde(rename = "ALLOW_FAILURE")]
AllowFailure,
}
impl OrderCancelReplaceCancelReplaceModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::StopOnFailure => "STOP_ON_FAILURE",
Self::AllowFailure => "ALLOW_FAILURE",
}
}
}
impl std::str::FromStr for OrderCancelReplaceCancelReplaceModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"STOP_ON_FAILURE" => Ok(Self::StopOnFailure),
"ALLOW_FAILURE" => Ok(Self::AllowFailure),
other => {
Err(format!("invalid OrderCancelReplaceCancelReplaceModeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderCancelReplaceTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderCancelReplaceTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Ioc => "IOC",
Self::Fok => "FOK",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderCancelReplaceTimeInForceEnum {
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),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid OrderCancelReplaceTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderCancelReplaceNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
}
impl OrderCancelReplaceNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
Self::Market => "MARKET",
Self::Limit => "LIMIT",
}
}
}
impl std::str::FromStr for OrderCancelReplaceNewOrderRespTypeEnum {
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),
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
other => {
Err(format!("invalid OrderCancelReplaceNewOrderRespTypeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderCancelReplaceSelfTradePreventionModeEnum {
#[serde(rename = "NONE")]
None,
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "DECREMENT")]
Decrement,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderCancelReplaceSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "NONE",
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::Decrement => "DECREMENT",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderCancelReplaceSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NONE" => Ok(Self::None),
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"DECREMENT" => Ok(Self::Decrement),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!(
"invalid OrderCancelReplaceSelfTradePreventionModeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderCancelReplaceCancelRestrictionsEnum {
#[serde(rename = "ONLY_NEW")]
OnlyNew,
#[serde(rename = "NEW")]
New,
#[serde(rename = "ONLY_PARTIALLY_FILLED")]
OnlyPartiallyFilled,
#[serde(rename = "PARTIALLY_FILLED")]
PartiallyFilled,
}
impl OrderCancelReplaceCancelRestrictionsEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::OnlyNew => "ONLY_NEW",
Self::New => "NEW",
Self::OnlyPartiallyFilled => "ONLY_PARTIALLY_FILLED",
Self::PartiallyFilled => "PARTIALLY_FILLED",
}
}
}
impl std::str::FromStr for OrderCancelReplaceCancelRestrictionsEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"ONLY_NEW" => Ok(Self::OnlyNew),
"NEW" => Ok(Self::New),
"ONLY_PARTIALLY_FILLED" => Ok(Self::OnlyPartiallyFilled),
"PARTIALLY_FILLED" => Ok(Self::PartiallyFilled),
other => Err(format!(
"invalid OrderCancelReplaceCancelRestrictionsEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderCancelReplaceOrderRateLimitExceededModeEnum {
#[serde(rename = "DO_NOTHING")]
DoNothing,
#[serde(rename = "CANCEL_ONLY")]
CancelOnly,
}
impl OrderCancelReplaceOrderRateLimitExceededModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::DoNothing => "DO_NOTHING",
Self::CancelOnly => "CANCEL_ONLY",
}
}
}
impl std::str::FromStr for OrderCancelReplaceOrderRateLimitExceededModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"DO_NOTHING" => Ok(Self::DoNothing),
"CANCEL_ONLY" => Ok(Self::CancelOnly),
other => Err(format!(
"invalid OrderCancelReplaceOrderRateLimitExceededModeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderCancelReplacePegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderCancelReplacePegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderCancelReplacePegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid OrderCancelReplacePegPriceTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderCancelReplacePegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderCancelReplacePegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderCancelReplacePegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid OrderCancelReplacePegOffsetTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOcoSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderListOcoSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderListOcoSideEnum {
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 OrderListOcoSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOcoAboveTypeEnum {
#[serde(rename = "STOP_LOSS_LIMIT")]
StopLossLimit,
#[serde(rename = "STOP_LOSS")]
StopLoss,
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
#[serde(rename = "TAKE_PROFIT")]
TakeProfit,
#[serde(rename = "TAKE_PROFIT_LIMIT")]
TakeProfitLimit,
}
impl OrderListOcoAboveTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::StopLoss => "STOP_LOSS",
Self::LimitMaker => "LIMIT_MAKER",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
}
}
}
impl std::str::FromStr for OrderListOcoAboveTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
"STOP_LOSS" => Ok(Self::StopLoss),
"LIMIT_MAKER" => Ok(Self::LimitMaker),
"TAKE_PROFIT" => Ok(Self::TakeProfit),
"TAKE_PROFIT_LIMIT" => Ok(Self::TakeProfitLimit),
other => Err(format!("invalid OrderListOcoAboveTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOcoBelowTypeEnum {
#[serde(rename = "STOP_LOSS")]
StopLoss,
#[serde(rename = "STOP_LOSS_LIMIT")]
StopLossLimit,
#[serde(rename = "TAKE_PROFIT")]
TakeProfit,
#[serde(rename = "TAKE_PROFIT_LIMIT")]
TakeProfitLimit,
}
impl OrderListOcoBelowTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
}
}
}
impl std::str::FromStr for OrderListOcoBelowTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"STOP_LOSS" => Ok(Self::StopLoss),
"STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
"TAKE_PROFIT" => Ok(Self::TakeProfit),
"TAKE_PROFIT_LIMIT" => Ok(Self::TakeProfitLimit),
other => Err(format!("invalid OrderListOcoBelowTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOcoAboveTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOcoAboveTimeInForceEnum {
#[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 OrderListOcoAboveTimeInForceEnum {
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 OrderListOcoAboveTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOcoAbovePegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOcoAbovePegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOcoAbovePegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => Err(format!("invalid OrderListOcoAbovePegPriceTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOcoAbovePegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOcoAbovePegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOcoAbovePegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => Err(format!("invalid OrderListOcoAbovePegOffsetTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOcoBelowTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOcoBelowTimeInForceEnum {
#[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 OrderListOcoBelowTimeInForceEnum {
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 OrderListOcoBelowTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOcoBelowPegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOcoBelowPegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOcoBelowPegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => Err(format!("invalid OrderListOcoBelowPegPriceTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOcoBelowPegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOcoBelowPegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOcoBelowPegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => Err(format!("invalid OrderListOcoBelowPegOffsetTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOcoNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
}
impl OrderListOcoNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
Self::Market => "MARKET",
Self::Limit => "LIMIT",
}
}
}
impl std::str::FromStr for OrderListOcoNewOrderRespTypeEnum {
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),
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
other => Err(format!("invalid OrderListOcoNewOrderRespTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOcoSelfTradePreventionModeEnum {
#[serde(rename = "NONE")]
None,
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "DECREMENT")]
Decrement,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderListOcoSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "NONE",
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::Decrement => "DECREMENT",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderListOcoSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NONE" => Ok(Self::None),
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"DECREMENT" => Ok(Self::Decrement),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => {
Err(format!("invalid OrderListOcoSelfTradePreventionModeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoWorkingTypeEnum {
#[serde(rename = "LIMIT")]
Limit,
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
}
impl OrderListOpoWorkingTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Limit => "LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
}
}
}
impl std::str::FromStr for OrderListOpoWorkingTypeEnum {
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 OrderListOpoWorkingTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoWorkingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderListOpoWorkingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderListOpoWorkingSideEnum {
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 OrderListOpoWorkingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoPendingTypeEnum {
#[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 OrderListOpoPendingTypeEnum {
#[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 OrderListOpoPendingTypeEnum {
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 OrderListOpoPendingTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoPendingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderListOpoPendingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderListOpoPendingSideEnum {
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 OrderListOpoPendingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
}
impl OrderListOpoNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
Self::Market => "MARKET",
Self::Limit => "LIMIT",
}
}
}
impl std::str::FromStr for OrderListOpoNewOrderRespTypeEnum {
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),
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
other => Err(format!("invalid OrderListOpoNewOrderRespTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoSelfTradePreventionModeEnum {
#[serde(rename = "NONE")]
None,
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "DECREMENT")]
Decrement,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderListOpoSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "NONE",
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::Decrement => "DECREMENT",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderListOpoSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NONE" => Ok(Self::None),
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"DECREMENT" => Ok(Self::Decrement),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => {
Err(format!("invalid OrderListOpoSelfTradePreventionModeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoWorkingTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOpoWorkingTimeInForceEnum {
#[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 OrderListOpoWorkingTimeInForceEnum {
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 OrderListOpoWorkingTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoWorkingPegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOpoWorkingPegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOpoWorkingPegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => Err(format!("invalid OrderListOpoWorkingPegPriceTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoWorkingPegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOpoWorkingPegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOpoWorkingPegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => Err(format!("invalid OrderListOpoWorkingPegOffsetTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoPendingTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOpoPendingTimeInForceEnum {
#[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 OrderListOpoPendingTimeInForceEnum {
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 OrderListOpoPendingTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoPendingPegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOpoPendingPegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOpoPendingPegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => Err(format!("invalid OrderListOpoPendingPegPriceTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpoPendingPegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOpoPendingPegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOpoPendingPegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => Err(format!("invalid OrderListOpoPendingPegOffsetTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoWorkingTypeEnum {
#[serde(rename = "LIMIT")]
Limit,
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
}
impl OrderListOpocoWorkingTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Limit => "LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
}
}
}
impl std::str::FromStr for OrderListOpocoWorkingTypeEnum {
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 OrderListOpocoWorkingTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoWorkingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderListOpocoWorkingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderListOpocoWorkingSideEnum {
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 OrderListOpocoWorkingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoPendingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderListOpocoPendingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderListOpocoPendingSideEnum {
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 OrderListOpocoPendingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoPendingAboveTypeEnum {
#[serde(rename = "STOP_LOSS_LIMIT")]
StopLossLimit,
#[serde(rename = "STOP_LOSS")]
StopLoss,
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
#[serde(rename = "TAKE_PROFIT")]
TakeProfit,
#[serde(rename = "TAKE_PROFIT_LIMIT")]
TakeProfitLimit,
}
impl OrderListOpocoPendingAboveTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::StopLoss => "STOP_LOSS",
Self::LimitMaker => "LIMIT_MAKER",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
}
}
}
impl std::str::FromStr for OrderListOpocoPendingAboveTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
"STOP_LOSS" => Ok(Self::StopLoss),
"LIMIT_MAKER" => Ok(Self::LimitMaker),
"TAKE_PROFIT" => Ok(Self::TakeProfit),
"TAKE_PROFIT_LIMIT" => Ok(Self::TakeProfitLimit),
other => Err(format!("invalid OrderListOpocoPendingAboveTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
}
impl OrderListOpocoNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
Self::Market => "MARKET",
Self::Limit => "LIMIT",
}
}
}
impl std::str::FromStr for OrderListOpocoNewOrderRespTypeEnum {
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),
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
other => Err(format!("invalid OrderListOpocoNewOrderRespTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoSelfTradePreventionModeEnum {
#[serde(rename = "NONE")]
None,
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "DECREMENT")]
Decrement,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderListOpocoSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "NONE",
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::Decrement => "DECREMENT",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderListOpocoSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NONE" => Ok(Self::None),
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"DECREMENT" => Ok(Self::Decrement),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!(
"invalid OrderListOpocoSelfTradePreventionModeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoWorkingTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOpocoWorkingTimeInForceEnum {
#[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 OrderListOpocoWorkingTimeInForceEnum {
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 OrderListOpocoWorkingTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoWorkingPegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOpocoWorkingPegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOpocoWorkingPegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => {
Err(format!("invalid OrderListOpocoWorkingPegPriceTypeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoWorkingPegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOpocoWorkingPegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOpocoWorkingPegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => {
Err(format!("invalid OrderListOpocoWorkingPegOffsetTypeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoPendingAboveTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOpocoPendingAboveTimeInForceEnum {
#[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 OrderListOpocoPendingAboveTimeInForceEnum {
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 OrderListOpocoPendingAboveTimeInForceEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoPendingAbovePegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOpocoPendingAbovePegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOpocoPendingAbovePegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => Err(format!(
"invalid OrderListOpocoPendingAbovePegPriceTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoPendingAbovePegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOpocoPendingAbovePegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOpocoPendingAbovePegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => Err(format!(
"invalid OrderListOpocoPendingAbovePegOffsetTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoPendingBelowTypeEnum {
#[serde(rename = "STOP_LOSS")]
StopLoss,
#[serde(rename = "STOP_LOSS_LIMIT")]
StopLossLimit,
#[serde(rename = "TAKE_PROFIT")]
TakeProfit,
#[serde(rename = "TAKE_PROFIT_LIMIT")]
TakeProfitLimit,
}
impl OrderListOpocoPendingBelowTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
}
}
}
impl std::str::FromStr for OrderListOpocoPendingBelowTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"STOP_LOSS" => Ok(Self::StopLoss),
"STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
"TAKE_PROFIT" => Ok(Self::TakeProfit),
"TAKE_PROFIT_LIMIT" => Ok(Self::TakeProfitLimit),
other => Err(format!("invalid OrderListOpocoPendingBelowTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoPendingBelowTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOpocoPendingBelowTimeInForceEnum {
#[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 OrderListOpocoPendingBelowTimeInForceEnum {
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 OrderListOpocoPendingBelowTimeInForceEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoPendingBelowPegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOpocoPendingBelowPegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOpocoPendingBelowPegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => Err(format!(
"invalid OrderListOpocoPendingBelowPegPriceTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOpocoPendingBelowPegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOpocoPendingBelowPegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOpocoPendingBelowPegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => Err(format!(
"invalid OrderListOpocoPendingBelowPegOffsetTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoWorkingTypeEnum {
#[serde(rename = "LIMIT")]
Limit,
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
}
impl OrderListOtoWorkingTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Limit => "LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
}
}
}
impl std::str::FromStr for OrderListOtoWorkingTypeEnum {
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 OrderListOtoWorkingTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoWorkingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderListOtoWorkingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderListOtoWorkingSideEnum {
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 OrderListOtoWorkingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoPendingTypeEnum {
#[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 OrderListOtoPendingTypeEnum {
#[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 OrderListOtoPendingTypeEnum {
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 OrderListOtoPendingTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoPendingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderListOtoPendingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderListOtoPendingSideEnum {
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 OrderListOtoPendingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
}
impl OrderListOtoNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
Self::Market => "MARKET",
Self::Limit => "LIMIT",
}
}
}
impl std::str::FromStr for OrderListOtoNewOrderRespTypeEnum {
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),
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
other => Err(format!("invalid OrderListOtoNewOrderRespTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoSelfTradePreventionModeEnum {
#[serde(rename = "NONE")]
None,
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "DECREMENT")]
Decrement,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderListOtoSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "NONE",
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::Decrement => "DECREMENT",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderListOtoSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NONE" => Ok(Self::None),
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"DECREMENT" => Ok(Self::Decrement),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => {
Err(format!("invalid OrderListOtoSelfTradePreventionModeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoWorkingTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOtoWorkingTimeInForceEnum {
#[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 OrderListOtoWorkingTimeInForceEnum {
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 OrderListOtoWorkingTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoWorkingPegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOtoWorkingPegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOtoWorkingPegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => Err(format!("invalid OrderListOtoWorkingPegPriceTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoWorkingPegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOtoWorkingPegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOtoWorkingPegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => Err(format!("invalid OrderListOtoWorkingPegOffsetTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoPendingTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOtoPendingTimeInForceEnum {
#[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 OrderListOtoPendingTimeInForceEnum {
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 OrderListOtoPendingTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoPendingPegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOtoPendingPegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOtoPendingPegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => Err(format!("invalid OrderListOtoPendingPegPriceTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtoPendingPegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOtoPendingPegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOtoPendingPegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => Err(format!("invalid OrderListOtoPendingPegOffsetTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoWorkingTypeEnum {
#[serde(rename = "LIMIT")]
Limit,
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
}
impl OrderListOtocoWorkingTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Limit => "LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
}
}
}
impl std::str::FromStr for OrderListOtocoWorkingTypeEnum {
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 OrderListOtocoWorkingTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoWorkingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderListOtocoWorkingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderListOtocoWorkingSideEnum {
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 OrderListOtocoWorkingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoPendingSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderListOtocoPendingSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderListOtocoPendingSideEnum {
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 OrderListOtocoPendingSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoPendingAboveTypeEnum {
#[serde(rename = "STOP_LOSS_LIMIT")]
StopLossLimit,
#[serde(rename = "STOP_LOSS")]
StopLoss,
#[serde(rename = "LIMIT_MAKER")]
LimitMaker,
#[serde(rename = "TAKE_PROFIT")]
TakeProfit,
#[serde(rename = "TAKE_PROFIT_LIMIT")]
TakeProfitLimit,
}
impl OrderListOtocoPendingAboveTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::StopLoss => "STOP_LOSS",
Self::LimitMaker => "LIMIT_MAKER",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
}
}
}
impl std::str::FromStr for OrderListOtocoPendingAboveTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
"STOP_LOSS" => Ok(Self::StopLoss),
"LIMIT_MAKER" => Ok(Self::LimitMaker),
"TAKE_PROFIT" => Ok(Self::TakeProfit),
"TAKE_PROFIT_LIMIT" => Ok(Self::TakeProfitLimit),
other => Err(format!("invalid OrderListOtocoPendingAboveTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
}
impl OrderListOtocoNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
Self::Market => "MARKET",
Self::Limit => "LIMIT",
}
}
}
impl std::str::FromStr for OrderListOtocoNewOrderRespTypeEnum {
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),
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
other => Err(format!("invalid OrderListOtocoNewOrderRespTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoSelfTradePreventionModeEnum {
#[serde(rename = "NONE")]
None,
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "DECREMENT")]
Decrement,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderListOtocoSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "NONE",
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::Decrement => "DECREMENT",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderListOtocoSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NONE" => Ok(Self::None),
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"DECREMENT" => Ok(Self::Decrement),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!(
"invalid OrderListOtocoSelfTradePreventionModeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoWorkingTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOtocoWorkingTimeInForceEnum {
#[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 OrderListOtocoWorkingTimeInForceEnum {
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 OrderListOtocoWorkingTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoWorkingPegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOtocoWorkingPegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOtocoWorkingPegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => {
Err(format!("invalid OrderListOtocoWorkingPegPriceTypeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoWorkingPegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOtocoWorkingPegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOtocoWorkingPegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => {
Err(format!("invalid OrderListOtocoWorkingPegOffsetTypeEnum: {}", other).into())
}
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoPendingAboveTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOtocoPendingAboveTimeInForceEnum {
#[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 OrderListOtocoPendingAboveTimeInForceEnum {
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 OrderListOtocoPendingAboveTimeInForceEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoPendingAbovePegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOtocoPendingAbovePegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOtocoPendingAbovePegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => Err(format!(
"invalid OrderListOtocoPendingAbovePegPriceTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoPendingAbovePegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOtocoPendingAbovePegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOtocoPendingAbovePegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => Err(format!(
"invalid OrderListOtocoPendingAbovePegOffsetTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoPendingBelowTypeEnum {
#[serde(rename = "STOP_LOSS")]
StopLoss,
#[serde(rename = "STOP_LOSS_LIMIT")]
StopLossLimit,
#[serde(rename = "TAKE_PROFIT")]
TakeProfit,
#[serde(rename = "TAKE_PROFIT_LIMIT")]
TakeProfitLimit,
}
impl OrderListOtocoPendingBelowTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
}
}
}
impl std::str::FromStr for OrderListOtocoPendingBelowTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"STOP_LOSS" => Ok(Self::StopLoss),
"STOP_LOSS_LIMIT" => Ok(Self::StopLossLimit),
"TAKE_PROFIT" => Ok(Self::TakeProfit),
"TAKE_PROFIT_LIMIT" => Ok(Self::TakeProfitLimit),
other => Err(format!("invalid OrderListOtocoPendingBelowTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoPendingBelowTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderListOtocoPendingBelowTimeInForceEnum {
#[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 OrderListOtocoPendingBelowTimeInForceEnum {
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 OrderListOtocoPendingBelowTimeInForceEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoPendingBelowPegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
}
impl OrderListOtocoPendingBelowPegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
}
}
}
impl std::str::FromStr for OrderListOtocoPendingBelowPegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
other => Err(format!(
"invalid OrderListOtocoPendingBelowPegPriceTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderListOtocoPendingBelowPegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
}
impl OrderListOtocoPendingBelowPegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
}
}
}
impl std::str::FromStr for OrderListOtocoPendingBelowPegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
other => Err(format!(
"invalid OrderListOtocoPendingBelowPegOffsetTypeEnum: {}",
other
)
.into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderOcoSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderOcoSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderOcoSideEnum {
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 OrderOcoSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderOcoStopLimitTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
}
impl OrderOcoStopLimitTimeInForceEnum {
#[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 OrderOcoStopLimitTimeInForceEnum {
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 OrderOcoStopLimitTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderOcoNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
}
impl OrderOcoNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
Self::Market => "MARKET",
Self::Limit => "LIMIT",
}
}
}
impl std::str::FromStr for OrderOcoNewOrderRespTypeEnum {
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),
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
other => Err(format!("invalid OrderOcoNewOrderRespTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderOcoSelfTradePreventionModeEnum {
#[serde(rename = "NONE")]
None,
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "DECREMENT")]
Decrement,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderOcoSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "NONE",
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::Decrement => "DECREMENT",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderOcoSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NONE" => Ok(Self::None),
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"DECREMENT" => Ok(Self::Decrement),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid OrderOcoSelfTradePreventionModeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderTestSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl OrderTestSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for OrderTestSideEnum {
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 OrderTestSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderTestTypeEnum {
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
#[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,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderTestTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Market => "MARKET",
Self::Limit => "LIMIT",
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderTestTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
"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),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid OrderTestTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderTestTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderTestTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Ioc => "IOC",
Self::Fok => "FOK",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderTestTimeInForceEnum {
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),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid OrderTestTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderTestNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
}
impl OrderTestNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
Self::Market => "MARKET",
Self::Limit => "LIMIT",
}
}
}
impl std::str::FromStr for OrderTestNewOrderRespTypeEnum {
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),
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
other => Err(format!("invalid OrderTestNewOrderRespTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderTestSelfTradePreventionModeEnum {
#[serde(rename = "NONE")]
None,
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "DECREMENT")]
Decrement,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderTestSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "NONE",
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::Decrement => "DECREMENT",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderTestSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NONE" => Ok(Self::None),
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"DECREMENT" => Ok(Self::Decrement),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid OrderTestSelfTradePreventionModeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderTestPegPriceTypeEnum {
#[serde(rename = "PRIMARY_PEG")]
PrimaryPeg,
#[serde(rename = "MARKET_PEG")]
MarketPeg,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderTestPegPriceTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PrimaryPeg => "PRIMARY_PEG",
Self::MarketPeg => "MARKET_PEG",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderTestPegPriceTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRIMARY_PEG" => Ok(Self::PrimaryPeg),
"MARKET_PEG" => Ok(Self::MarketPeg),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid OrderTestPegPriceTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum OrderTestPegOffsetTypeEnum {
#[serde(rename = "PRICE_LEVEL")]
PriceLevel,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl OrderTestPegOffsetTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::PriceLevel => "PRICE_LEVEL",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for OrderTestPegOffsetTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PRICE_LEVEL" => Ok(Self::PriceLevel),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid OrderTestPegOffsetTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SorOrderSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl SorOrderSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for SorOrderSideEnum {
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 SorOrderSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SorOrderTypeEnum {
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
#[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,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl SorOrderTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Market => "MARKET",
Self::Limit => "LIMIT",
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for SorOrderTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
"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),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid SorOrderTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SorOrderTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl SorOrderTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Ioc => "IOC",
Self::Fok => "FOK",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for SorOrderTimeInForceEnum {
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),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid SorOrderTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SorOrderNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
}
impl SorOrderNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
Self::Market => "MARKET",
Self::Limit => "LIMIT",
}
}
}
impl std::str::FromStr for SorOrderNewOrderRespTypeEnum {
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),
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
other => Err(format!("invalid SorOrderNewOrderRespTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SorOrderSelfTradePreventionModeEnum {
#[serde(rename = "NONE")]
None,
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "DECREMENT")]
Decrement,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl SorOrderSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "NONE",
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::Decrement => "DECREMENT",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for SorOrderSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NONE" => Ok(Self::None),
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"DECREMENT" => Ok(Self::Decrement),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid SorOrderSelfTradePreventionModeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SorOrderTestSideEnum {
#[serde(rename = "BUY")]
Buy,
#[serde(rename = "SELL")]
Sell,
}
impl SorOrderTestSideEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Buy => "BUY",
Self::Sell => "SELL",
}
}
}
impl std::str::FromStr for SorOrderTestSideEnum {
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 SorOrderTestSideEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SorOrderTestTypeEnum {
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
#[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,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl SorOrderTestTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Market => "MARKET",
Self::Limit => "LIMIT",
Self::StopLoss => "STOP_LOSS",
Self::StopLossLimit => "STOP_LOSS_LIMIT",
Self::TakeProfit => "TAKE_PROFIT",
Self::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
Self::LimitMaker => "LIMIT_MAKER",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for SorOrderTestTypeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
"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),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid SorOrderTestTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SorOrderTestTimeInForceEnum {
#[serde(rename = "GTC")]
Gtc,
#[serde(rename = "IOC")]
Ioc,
#[serde(rename = "FOK")]
Fok,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl SorOrderTestTimeInForceEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Gtc => "GTC",
Self::Ioc => "IOC",
Self::Fok => "FOK",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for SorOrderTestTimeInForceEnum {
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),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => Err(format!("invalid SorOrderTestTimeInForceEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SorOrderTestNewOrderRespTypeEnum {
#[serde(rename = "ACK")]
Ack,
#[serde(rename = "RESULT")]
Result,
#[serde(rename = "FULL")]
Full,
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
}
impl SorOrderTestNewOrderRespTypeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::Ack => "ACK",
Self::Result => "RESULT",
Self::Full => "FULL",
Self::Market => "MARKET",
Self::Limit => "LIMIT",
}
}
}
impl std::str::FromStr for SorOrderTestNewOrderRespTypeEnum {
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),
"MARKET" => Ok(Self::Market),
"LIMIT" => Ok(Self::Limit),
other => Err(format!("invalid SorOrderTestNewOrderRespTypeEnum: {}", other).into()),
}
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SorOrderTestSelfTradePreventionModeEnum {
#[serde(rename = "NONE")]
None,
#[serde(rename = "EXPIRE_TAKER")]
ExpireTaker,
#[serde(rename = "EXPIRE_MAKER")]
ExpireMaker,
#[serde(rename = "EXPIRE_BOTH")]
ExpireBoth,
#[serde(rename = "DECREMENT")]
Decrement,
#[serde(rename = "NON_REPRESENTABLE")]
NonRepresentable,
}
impl SorOrderTestSelfTradePreventionModeEnum {
#[must_use]
pub fn as_str(&self) -> &'static str {
match self {
Self::None => "NONE",
Self::ExpireTaker => "EXPIRE_TAKER",
Self::ExpireMaker => "EXPIRE_MAKER",
Self::ExpireBoth => "EXPIRE_BOTH",
Self::Decrement => "DECREMENT",
Self::NonRepresentable => "NON_REPRESENTABLE",
}
}
}
impl std::str::FromStr for SorOrderTestSelfTradePreventionModeEnum {
type Err = Box<dyn std::error::Error + Send + Sync>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"NONE" => Ok(Self::None),
"EXPIRE_TAKER" => Ok(Self::ExpireTaker),
"EXPIRE_MAKER" => Ok(Self::ExpireMaker),
"EXPIRE_BOTH" => Ok(Self::ExpireBoth),
"DECREMENT" => Ok(Self::Decrement),
"NON_REPRESENTABLE" => Ok(Self::NonRepresentable),
other => {
Err(format!("invalid SorOrderTestSelfTradePreventionModeEnum: {}", other).into())
}
}
}
}
/// Request parameters for the [`delete_open_orders`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`delete_open_orders`](#method.delete_open_orders).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct DeleteOpenOrdersParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl DeleteOpenOrdersParams {
/// Create a builder for [`delete_open_orders`].
///
/// Required parameters:
///
/// * `symbol` — String
///
#[must_use]
pub fn builder(symbol: String) -> DeleteOpenOrdersParamsBuilder {
DeleteOpenOrdersParamsBuilder::default().symbol(symbol)
}
}
/// Request parameters for the [`delete_order`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`delete_order`](#method.delete_order).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct DeleteOrderParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub order_id: Option<i64>,
///
/// The `orig_client_order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub orig_client_order_id: Option<String>,
/// A unique id among open orders. Automatically generated if not sent.<br/> Orders with the same `newClientOrderID` can be accepted only when the previous one is filled, otherwise the order will be rejected.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_client_order_id: Option<String>,
///
/// The `cancel_restrictions` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub cancel_restrictions: Option<DeleteOrderCancelRestrictionsEnum>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl DeleteOrderParams {
/// Create a builder for [`delete_order`].
///
/// Required parameters:
///
/// * `symbol` — String
///
#[must_use]
pub fn builder(symbol: String) -> DeleteOrderParamsBuilder {
DeleteOrderParamsBuilder::default().symbol(symbol)
}
}
/// Request parameters for the [`delete_order_list`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`delete_order_list`](#method.delete_order_list).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct DeleteOrderListParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
/// Either `orderListId` or `listClientOrderId` must be provided
///
/// This field is **optional.
#[builder(setter(into), default)]
pub order_list_id: Option<i64>,
/// A unique Id for the entire orderList
///
/// This field is **optional.
#[builder(setter(into), default)]
pub list_client_order_id: Option<String>,
/// A unique id among open orders. Automatically generated if not sent.<br/> Orders with the same `newClientOrderID` can be accepted only when the previous one is filled, otherwise the order will be rejected.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_client_order_id: Option<String>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl DeleteOrderListParams {
/// Create a builder for [`delete_order_list`].
///
/// Required parameters:
///
/// * `symbol` — String
///
#[must_use]
pub fn builder(symbol: String) -> DeleteOrderListParamsBuilder {
DeleteOrderListParamsBuilder::default().symbol(symbol)
}
}
/// Request parameters for the [`new_order`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`new_order`](#method.new_order).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct NewOrderParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub side: NewOrderSideEnum,
///
/// The `r#type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub r#type: NewOrderTypeEnum,
///
/// The `time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub time_in_force: Option<NewOrderTimeInForceEnum>,
///
/// The `quantity` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub quantity: Option<rust_decimal::Decimal>,
///
/// The `quote_order_qty` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub quote_order_qty: Option<rust_decimal::Decimal>,
///
/// The `price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub price: Option<rust_decimal::Decimal>,
/// A unique id among open orders. Automatically generated if not sent.<br/> Orders with the same `newClientOrderID` can be accepted only when the previous one is filled, otherwise the order will be rejected.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_client_order_id: Option<String>,
///
/// The `strategy_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub strategy_id: Option<i64>,
/// The value cannot be less than `1000000`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub strategy_type: Option<i32>,
/// Used with `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, and `TAKE_PROFIT_LIMIT` orders.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub stop_price: Option<rust_decimal::Decimal>,
/// See [Trailing Stop order FAQ](faqs/trailing-stop-faq.md).
///
/// This field is **optional.
#[builder(setter(into), default)]
pub trailing_delta: Option<i64>,
/// Used with `LIMIT`, `STOP_LOSS_LIMIT`, and `TAKE_PROFIT_LIMIT` to create an iceberg order.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_order_resp_type: Option<NewOrderNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub self_trade_prevention_mode: Option<NewOrderSelfTradePreventionModeEnum>,
///
/// The `peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub peg_price_type: Option<NewOrderPegPriceTypeEnum>,
/// Priceleveltopegthepriceto(max:100).<br>See[`PeggedOrdersInfo`](#pegged-orders-info)
///
/// This field is **optional.
#[builder(setter(into), default)]
pub peg_offset_value: Option<i32>,
///
/// The `peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub peg_offset_type: Option<NewOrderPegOffsetTypeEnum>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl NewOrderParams {
/// Create a builder for [`new_order`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `side` — String
/// * `r#type` — String
///
#[must_use]
pub fn builder(
symbol: String,
side: NewOrderSideEnum,
r#type: NewOrderTypeEnum,
) -> NewOrderParamsBuilder {
NewOrderParamsBuilder::default()
.symbol(symbol)
.side(side)
.r#type(r#type)
}
}
/// Request parameters for the [`order_amend_keep_priority`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`order_amend_keep_priority`](#method.order_amend_keep_priority).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct OrderAmendKeepPriorityParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
/// `newQty` must be greater than 0 and less than the order's quantity.
///
/// This field is **required.
#[builder(setter(into))]
pub new_qty: rust_decimal::Decimal,
///
/// The `order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub order_id: Option<i64>,
///
/// The `orig_client_order_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub orig_client_order_id: Option<String>,
/// A unique id among open orders. Automatically generated if not sent.<br/> Orders with the same `newClientOrderID` can be accepted only when the previous one is filled, otherwise the order will be rejected.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_client_order_id: Option<String>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl OrderAmendKeepPriorityParams {
/// Create a builder for [`order_amend_keep_priority`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `new_qty` — `newQty` must be greater than 0 and less than the order's quantity.
///
#[must_use]
pub fn builder(
symbol: String,
new_qty: rust_decimal::Decimal,
) -> OrderAmendKeepPriorityParamsBuilder {
OrderAmendKeepPriorityParamsBuilder::default()
.symbol(symbol)
.new_qty(new_qty)
}
}
/// Request parameters for the [`order_cancel_replace`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`order_cancel_replace`](#method.order_cancel_replace).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct OrderCancelReplaceParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub side: OrderCancelReplaceSideEnum,
///
/// The `r#type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub r#type: OrderCancelReplaceTypeEnum,
///
/// The `cancel_replace_mode` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub cancel_replace_mode: OrderCancelReplaceCancelReplaceModeEnum,
///
/// The `time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub time_in_force: Option<OrderCancelReplaceTimeInForceEnum>,
///
/// The `quantity` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub quantity: Option<rust_decimal::Decimal>,
///
/// The `quote_order_qty` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub quote_order_qty: Option<rust_decimal::Decimal>,
///
/// The `price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub price: Option<rust_decimal::Decimal>,
/// Used to uniquely identify this cancel. Automatically generated by default.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub cancel_new_client_order_id: Option<String>,
/// Either `cancelOrderId` or `cancelOrigClientOrderId` must be sent. <br></br> If both `cancelOrderId` and `cancelOrigClientOrderId` parameters are provided, the `cancelOrderId` is searched first, then the `cancelOrigClientOrderId` from that result is checked against that order. <br></br> If both conditions are not met the request will be rejected.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub cancel_orig_client_order_id: Option<String>,
/// Either `cancelOrderId` or `cancelOrigClientOrderId` must be sent. <br></br>If both `cancelOrderId` and `cancelOrigClientOrderId` parameters are provided, the `cancelOrderId` is searched first, then the `cancelOrigClientOrderId` from that result is checked against that order. <br></br>If both conditions are not met the request will be rejected.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub cancel_order_id: Option<i64>,
/// A unique id among open orders. Automatically generated if not sent.<br/> Orders with the same `newClientOrderID` can be accepted only when the previous one is filled, otherwise the order will be rejected.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_client_order_id: Option<String>,
///
/// The `strategy_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub strategy_id: Option<i64>,
/// The value cannot be less than `1000000`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub strategy_type: Option<i32>,
/// Used with `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, and `TAKE_PROFIT_LIMIT` orders.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub stop_price: Option<rust_decimal::Decimal>,
/// See [Trailing Stop order FAQ](faqs/trailing-stop-faq.md).
///
/// This field is **optional.
#[builder(setter(into), default)]
pub trailing_delta: Option<i64>,
/// Used with `LIMIT`, `STOP_LOSS_LIMIT`, and `TAKE_PROFIT_LIMIT` to create an iceberg order.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_order_resp_type: Option<OrderCancelReplaceNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub self_trade_prevention_mode: Option<OrderCancelReplaceSelfTradePreventionModeEnum>,
///
/// The `cancel_restrictions` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub cancel_restrictions: Option<OrderCancelReplaceCancelRestrictionsEnum>,
///
/// The `order_rate_limit_exceeded_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub order_rate_limit_exceeded_mode: Option<OrderCancelReplaceOrderRateLimitExceededModeEnum>,
///
/// The `peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub peg_price_type: Option<OrderCancelReplacePegPriceTypeEnum>,
/// Priceleveltopegthepriceto(max:100).<br>See[`PeggedOrdersInfo`](#pegged-orders-info)
///
/// This field is **optional.
#[builder(setter(into), default)]
pub peg_offset_value: Option<i32>,
///
/// The `peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub peg_offset_type: Option<OrderCancelReplacePegOffsetTypeEnum>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl OrderCancelReplaceParams {
/// Create a builder for [`order_cancel_replace`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `side` — String
/// * `r#type` — String
/// * `cancel_replace_mode` — String
///
#[must_use]
pub fn builder(
symbol: String,
side: OrderCancelReplaceSideEnum,
r#type: OrderCancelReplaceTypeEnum,
cancel_replace_mode: OrderCancelReplaceCancelReplaceModeEnum,
) -> OrderCancelReplaceParamsBuilder {
OrderCancelReplaceParamsBuilder::default()
.symbol(symbol)
.side(side)
.r#type(r#type)
.cancel_replace_mode(cancel_replace_mode)
}
}
/// Request parameters for the [`order_list_oco`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`order_list_oco`](#method.order_list_oco).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct OrderListOcoParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub side: OrderListOcoSideEnum,
///
/// The `quantity` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub quantity: rust_decimal::Decimal,
///
/// The `above_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub above_type: OrderListOcoAboveTypeEnum,
///
/// The `below_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub below_type: OrderListOcoBelowTypeEnum,
/// A unique Id for the entire orderList
///
/// This field is **optional.
#[builder(setter(into), default)]
pub list_client_order_id: Option<String>,
/// Arbitrary unique ID among open orders for the above order. Automatically generated if not sent
///
/// This field is **optional.
#[builder(setter(into), default)]
pub above_client_order_id: Option<String>,
/// Note that this can only be used if `aboveTimeInForce` is `GTC`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub above_iceberg_qty: Option<i64>,
/// Can be used if `aboveType` is `STOP_LOSS_LIMIT` , `LIMIT_MAKER`, or `TAKE_PROFIT_LIMIT` to specify the limit price.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub above_price: Option<rust_decimal::Decimal>,
/// Can be used if `aboveType` is `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, `TAKE_PROFIT_LIMIT`. <br>Either `aboveStopPrice` or `aboveTrailingDelta` or both, must be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub above_stop_price: Option<rust_decimal::Decimal>,
/// See [Trailing Stop order FAQ](faqs/trailing-stop-faq.md).
///
/// This field is **optional.
#[builder(setter(into), default)]
pub above_trailing_delta: Option<i64>,
///
/// The `above_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub above_time_in_force: Option<OrderListOcoAboveTimeInForceEnum>,
/// Arbitrary numeric value identifying the above order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub above_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the above order strategy. <br>Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub above_strategy_type: Option<i32>,
///
/// The `above_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub above_peg_price_type: Option<OrderListOcoAbovePegPriceTypeEnum>,
///
/// The `above_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub above_peg_offset_type: Option<OrderListOcoAbovePegOffsetTypeEnum>,
///
/// The `above_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub above_peg_offset_value: Option<i32>,
/// Arbitrary unique ID among open orders for the below order. Automatically generated if not sent
///
/// This field is **optional.
#[builder(setter(into), default)]
pub below_client_order_id: Option<String>,
/// Note that this can only be used if `belowTimeInForce` is `GTC`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub below_iceberg_qty: Option<i64>,
/// Can be used if `belowType` is `STOP_LOSS_LIMIT`, `LIMIT_MAKER`, or `TAKE_PROFIT_LIMIT` to specify the limit price.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub below_price: Option<rust_decimal::Decimal>,
/// Can be used if `belowType` is `STOP_LOSS`, `STOP_LOSS_LIMIT, TAKE_PROFIT` or `TAKE_PROFIT_LIMIT` <br>Either belowStopPrice or belowTrailingDelta or both, must be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub below_stop_price: Option<rust_decimal::Decimal>,
/// See [Trailing Stop order FAQ](faqs/trailing-stop-faq.md).
///
/// This field is **optional.
#[builder(setter(into), default)]
pub below_trailing_delta: Option<i64>,
///
/// The `below_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub below_time_in_force: Option<OrderListOcoBelowTimeInForceEnum>,
/// Arbitrary numeric value identifying the below order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub below_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the below order strategy. <br>Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub below_strategy_type: Option<i32>,
///
/// The `below_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub below_peg_price_type: Option<OrderListOcoBelowPegPriceTypeEnum>,
///
/// The `below_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub below_peg_offset_type: Option<OrderListOcoBelowPegOffsetTypeEnum>,
///
/// The `below_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub below_peg_offset_value: Option<i32>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_order_resp_type: Option<OrderListOcoNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub self_trade_prevention_mode: Option<OrderListOcoSelfTradePreventionModeEnum>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl OrderListOcoParams {
/// Create a builder for [`order_list_oco`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `side` — String
/// * `quantity` — `rust_decimal::Decimal`
/// * `above_type` — String
/// * `below_type` — String
///
#[must_use]
pub fn builder(
symbol: String,
side: OrderListOcoSideEnum,
quantity: rust_decimal::Decimal,
above_type: OrderListOcoAboveTypeEnum,
below_type: OrderListOcoBelowTypeEnum,
) -> OrderListOcoParamsBuilder {
OrderListOcoParamsBuilder::default()
.symbol(symbol)
.side(side)
.quantity(quantity)
.above_type(above_type)
.below_type(below_type)
}
}
/// Request parameters for the [`order_list_opo`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`order_list_opo`](#method.order_list_opo).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct OrderListOpoParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `working_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_type: OrderListOpoWorkingTypeEnum,
///
/// The `working_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_side: OrderListOpoWorkingSideEnum,
///
/// The `working_price` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_price: rust_decimal::Decimal,
/// Sets the quantity for the working order.
///
/// This field is **required.
#[builder(setter(into))]
pub working_quantity: rust_decimal::Decimal,
///
/// The `pending_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub pending_type: OrderListOpoPendingTypeEnum,
///
/// The `pending_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub pending_side: OrderListOpoPendingSideEnum,
/// A unique Id for the entire orderList
///
/// This field is **optional.
#[builder(setter(into), default)]
pub list_client_order_id: Option<String>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_order_resp_type: Option<OrderListOpoNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub self_trade_prevention_mode: Option<OrderListOpoSelfTradePreventionModeEnum>,
/// Arbitrary unique ID among open orders for the working order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_client_order_id: Option<String>,
/// This can only be used if `workingTimeInForce` is `GTC`, or if `workingType` is `LIMIT_MAKER`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `working_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_time_in_force: Option<OrderListOpoWorkingTimeInForceEnum>,
/// Arbitrary numeric value identifying the working order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the working order strategy. Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_strategy_type: Option<i32>,
///
/// The `working_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_price_type: Option<OrderListOpoWorkingPegPriceTypeEnum>,
///
/// The `working_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_offset_type: Option<OrderListOpoWorkingPegOffsetTypeEnum>,
///
/// The `working_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_offset_value: Option<i32>,
/// Arbitrary unique ID among open orders for the pending order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_client_order_id: Option<String>,
///
/// The `pending_price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_price: Option<rust_decimal::Decimal>,
///
/// The `pending_stop_price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_stop_price: Option<rust_decimal::Decimal>,
///
/// The `pending_trailing_delta` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_trailing_delta: Option<rust_decimal::Decimal>,
/// This can only be used if `pendingTimeInForce` is `GTC` or if `pendingType` is `LIMIT_MAKER`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `pending_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_time_in_force: Option<OrderListOpoPendingTimeInForceEnum>,
/// Arbitrary numeric value identifying the pending order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the pending order strategy. Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_strategy_type: Option<i32>,
///
/// The `pending_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_peg_price_type: Option<OrderListOpoPendingPegPriceTypeEnum>,
///
/// The `pending_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_peg_offset_type: Option<OrderListOpoPendingPegOffsetTypeEnum>,
///
/// The `pending_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_peg_offset_value: Option<i32>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl OrderListOpoParams {
/// Create a builder for [`order_list_opo`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `working_type` — String
/// * `working_side` — String
/// * `working_price` — `rust_decimal::Decimal`
/// * `working_quantity` — Sets the quantity for the working order.
/// * `pending_type` — String
/// * `pending_side` — String
///
#[must_use]
pub fn builder(
symbol: String,
working_type: OrderListOpoWorkingTypeEnum,
working_side: OrderListOpoWorkingSideEnum,
working_price: rust_decimal::Decimal,
working_quantity: rust_decimal::Decimal,
pending_type: OrderListOpoPendingTypeEnum,
pending_side: OrderListOpoPendingSideEnum,
) -> OrderListOpoParamsBuilder {
OrderListOpoParamsBuilder::default()
.symbol(symbol)
.working_type(working_type)
.working_side(working_side)
.working_price(working_price)
.working_quantity(working_quantity)
.pending_type(pending_type)
.pending_side(pending_side)
}
}
/// Request parameters for the [`order_list_opoco`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`order_list_opoco`](#method.order_list_opoco).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct OrderListOpocoParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `working_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_type: OrderListOpocoWorkingTypeEnum,
///
/// The `working_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_side: OrderListOpocoWorkingSideEnum,
///
/// The `working_price` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_price: rust_decimal::Decimal,
/// Sets the quantity for the working order.
///
/// This field is **required.
#[builder(setter(into))]
pub working_quantity: rust_decimal::Decimal,
///
/// The `pending_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub pending_side: OrderListOpocoPendingSideEnum,
///
/// The `pending_above_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub pending_above_type: OrderListOpocoPendingAboveTypeEnum,
/// A unique Id for the entire orderList
///
/// This field is **optional.
#[builder(setter(into), default)]
pub list_client_order_id: Option<String>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_order_resp_type: Option<OrderListOpocoNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub self_trade_prevention_mode: Option<OrderListOpocoSelfTradePreventionModeEnum>,
/// Arbitrary unique ID among open orders for the working order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_client_order_id: Option<String>,
/// This can only be used if `workingTimeInForce` is `GTC`, or if `workingType` is `LIMIT_MAKER`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `working_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_time_in_force: Option<OrderListOpocoWorkingTimeInForceEnum>,
/// Arbitrary numeric value identifying the working order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the working order strategy. Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_strategy_type: Option<i32>,
///
/// The `working_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_price_type: Option<OrderListOpocoWorkingPegPriceTypeEnum>,
///
/// The `working_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_offset_type: Option<OrderListOpocoWorkingPegOffsetTypeEnum>,
///
/// The `working_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_offset_value: Option<i32>,
/// Arbitrary unique ID among open orders for the pending above order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_client_order_id: Option<String>,
/// Can be used if `pendingAboveType` is `STOP_LOSS_LIMIT` , `LIMIT_MAKER`, or `TAKE_PROFIT_LIMIT` to specify the limit price.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_price: Option<rust_decimal::Decimal>,
/// Can be used if `pendingAboveType` is `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, `TAKE_PROFIT_LIMIT`
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_stop_price: Option<rust_decimal::Decimal>,
/// See [Trailing Stop FAQ](./faqs/trailing-stop-faq.md)
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_trailing_delta: Option<rust_decimal::Decimal>,
/// This can only be used if `pendingAboveTimeInForce` is `GTC` or if `pendingAboveType` is `LIMIT_MAKER`.
///
/// This field is **optional.
#[builder(setter(into), 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)]
pub pending_above_time_in_force: Option<OrderListOpocoPendingAboveTimeInForceEnum>,
/// Arbitrary numeric value identifying the pending above order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the pending above order strategy. Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_strategy_type: Option<i32>,
///
/// The `pending_above_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_peg_price_type: Option<OrderListOpocoPendingAbovePegPriceTypeEnum>,
///
/// The `pending_above_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_peg_offset_type: Option<OrderListOpocoPendingAbovePegOffsetTypeEnum>,
///
/// The `pending_above_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_peg_offset_value: Option<i32>,
///
/// The `pending_below_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_type: Option<OrderListOpocoPendingBelowTypeEnum>,
/// Arbitrary unique ID among open orders for the pending below order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_client_order_id: Option<String>,
/// Can be used if `pendingBelowType` is `STOP_LOSS_LIMIT` or `TAKE_PROFIT_LIMIT` to specify limit price
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_price: Option<rust_decimal::Decimal>,
/// Can be used if `pendingBelowType` is `STOP_LOSS`, `STOP_LOSS_LIMIT, TAKE_PROFIT or TAKE_PROFIT_LIMIT`. Either `pendingBelowStopPrice` or `pendingBelowTrailingDelta` or both, must be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_stop_price: Option<rust_decimal::Decimal>,
///
/// The `pending_below_trailing_delta` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_trailing_delta: Option<rust_decimal::Decimal>,
/// This can only be used if `pendingBelowTimeInForce` is `GTC`, or if `pendingBelowType` is `LIMIT_MAKER`.
///
/// This field is **optional.
#[builder(setter(into), 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)]
pub pending_below_time_in_force: Option<OrderListOpocoPendingBelowTimeInForceEnum>,
/// Arbitrary numeric value identifying the pending below order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the pending below order strategy. Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_strategy_type: Option<i32>,
///
/// The `pending_below_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_peg_price_type: Option<OrderListOpocoPendingBelowPegPriceTypeEnum>,
///
/// The `pending_below_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_peg_offset_type: Option<OrderListOpocoPendingBelowPegOffsetTypeEnum>,
///
/// The `pending_below_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_peg_offset_value: Option<i32>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl OrderListOpocoParams {
/// Create a builder for [`order_list_opoco`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `working_type` — String
/// * `working_side` — String
/// * `working_price` — `rust_decimal::Decimal`
/// * `working_quantity` — Sets the quantity for the working order.
/// * `pending_side` — String
/// * `pending_above_type` — String
///
#[must_use]
pub fn builder(
symbol: String,
working_type: OrderListOpocoWorkingTypeEnum,
working_side: OrderListOpocoWorkingSideEnum,
working_price: rust_decimal::Decimal,
working_quantity: rust_decimal::Decimal,
pending_side: OrderListOpocoPendingSideEnum,
pending_above_type: OrderListOpocoPendingAboveTypeEnum,
) -> OrderListOpocoParamsBuilder {
OrderListOpocoParamsBuilder::default()
.symbol(symbol)
.working_type(working_type)
.working_side(working_side)
.working_price(working_price)
.working_quantity(working_quantity)
.pending_side(pending_side)
.pending_above_type(pending_above_type)
}
}
/// Request parameters for the [`order_list_oto`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`order_list_oto`](#method.order_list_oto).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct OrderListOtoParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `working_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_type: OrderListOtoWorkingTypeEnum,
///
/// The `working_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_side: OrderListOtoWorkingSideEnum,
///
/// The `working_price` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_price: rust_decimal::Decimal,
/// Sets the quantity for the working order.
///
/// This field is **required.
#[builder(setter(into))]
pub working_quantity: rust_decimal::Decimal,
///
/// The `pending_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub pending_type: OrderListOtoPendingTypeEnum,
///
/// The `pending_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub pending_side: OrderListOtoPendingSideEnum,
/// Sets the quantity for the pending order.
///
/// This field is **required.
#[builder(setter(into))]
pub pending_quantity: rust_decimal::Decimal,
/// A unique Id for the entire orderList
///
/// This field is **optional.
#[builder(setter(into), default)]
pub list_client_order_id: Option<String>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_order_resp_type: Option<OrderListOtoNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub self_trade_prevention_mode: Option<OrderListOtoSelfTradePreventionModeEnum>,
/// Arbitrary unique ID among open orders for the working order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_client_order_id: Option<String>,
/// This can only be used if `workingTimeInForce` is `GTC`, or if `workingType` is `LIMIT_MAKER`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `working_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_time_in_force: Option<OrderListOtoWorkingTimeInForceEnum>,
/// Arbitrary numeric value identifying the working order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the working order strategy. Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_strategy_type: Option<i32>,
///
/// The `working_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_price_type: Option<OrderListOtoWorkingPegPriceTypeEnum>,
///
/// The `working_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_offset_type: Option<OrderListOtoWorkingPegOffsetTypeEnum>,
///
/// The `working_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_offset_value: Option<i32>,
/// Arbitrary unique ID among open orders for the pending order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_client_order_id: Option<String>,
///
/// The `pending_price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_price: Option<rust_decimal::Decimal>,
///
/// The `pending_stop_price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_stop_price: Option<rust_decimal::Decimal>,
///
/// The `pending_trailing_delta` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_trailing_delta: Option<rust_decimal::Decimal>,
/// This can only be used if `pendingTimeInForce` is `GTC` or if `pendingType` is `LIMIT_MAKER`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `pending_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_time_in_force: Option<OrderListOtoPendingTimeInForceEnum>,
/// Arbitrary numeric value identifying the pending order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the pending order strategy. Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_strategy_type: Option<i32>,
///
/// The `pending_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_peg_price_type: Option<OrderListOtoPendingPegPriceTypeEnum>,
///
/// The `pending_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_peg_offset_type: Option<OrderListOtoPendingPegOffsetTypeEnum>,
///
/// The `pending_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_peg_offset_value: Option<i32>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl OrderListOtoParams {
/// Create a builder for [`order_list_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.
/// * `pending_type` — String
/// * `pending_side` — String
/// * `pending_quantity` — Sets the quantity for the pending order.
///
#[must_use]
pub fn builder(
symbol: String,
working_type: OrderListOtoWorkingTypeEnum,
working_side: OrderListOtoWorkingSideEnum,
working_price: rust_decimal::Decimal,
working_quantity: rust_decimal::Decimal,
pending_type: OrderListOtoPendingTypeEnum,
pending_side: OrderListOtoPendingSideEnum,
pending_quantity: rust_decimal::Decimal,
) -> OrderListOtoParamsBuilder {
OrderListOtoParamsBuilder::default()
.symbol(symbol)
.working_type(working_type)
.working_side(working_side)
.working_price(working_price)
.working_quantity(working_quantity)
.pending_type(pending_type)
.pending_side(pending_side)
.pending_quantity(pending_quantity)
}
}
/// Request parameters for the [`order_list_otoco`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`order_list_otoco`](#method.order_list_otoco).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct OrderListOtocoParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `working_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_type: OrderListOtocoWorkingTypeEnum,
///
/// The `working_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_side: OrderListOtocoWorkingSideEnum,
///
/// The `working_price` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub working_price: rust_decimal::Decimal,
/// Sets the quantity for the working order.
///
/// This field is **required.
#[builder(setter(into))]
pub working_quantity: rust_decimal::Decimal,
///
/// The `pending_side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub pending_side: OrderListOtocoPendingSideEnum,
/// Sets the quantity for the pending order.
///
/// This field is **required.
#[builder(setter(into))]
pub pending_quantity: rust_decimal::Decimal,
///
/// The `pending_above_type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub pending_above_type: OrderListOtocoPendingAboveTypeEnum,
/// A unique Id for the entire orderList
///
/// This field is **optional.
#[builder(setter(into), default)]
pub list_client_order_id: Option<String>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_order_resp_type: Option<OrderListOtocoNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub self_trade_prevention_mode: Option<OrderListOtocoSelfTradePreventionModeEnum>,
/// Arbitrary unique ID among open orders for the working order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_client_order_id: Option<String>,
/// This can only be used if `workingTimeInForce` is `GTC`, or if `workingType` is `LIMIT_MAKER`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `working_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_time_in_force: Option<OrderListOtocoWorkingTimeInForceEnum>,
/// Arbitrary numeric value identifying the working order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the working order strategy. Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_strategy_type: Option<i32>,
///
/// The `working_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_price_type: Option<OrderListOtocoWorkingPegPriceTypeEnum>,
///
/// The `working_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_offset_type: Option<OrderListOtocoWorkingPegOffsetTypeEnum>,
///
/// The `working_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub working_peg_offset_value: Option<i32>,
/// Arbitrary unique ID among open orders for the pending above order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_client_order_id: Option<String>,
/// Can be used if `pendingAboveType` is `STOP_LOSS_LIMIT` , `LIMIT_MAKER`, or `TAKE_PROFIT_LIMIT` to specify the limit price.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_price: Option<rust_decimal::Decimal>,
/// Can be used if `pendingAboveType` is `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, `TAKE_PROFIT_LIMIT`
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_stop_price: Option<rust_decimal::Decimal>,
/// See [Trailing Stop FAQ](./faqs/trailing-stop-faq.md)
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_trailing_delta: Option<rust_decimal::Decimal>,
/// This can only be used if `pendingAboveTimeInForce` is `GTC` or if `pendingAboveType` is `LIMIT_MAKER`.
///
/// This field is **optional.
#[builder(setter(into), 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)]
pub pending_above_time_in_force: Option<OrderListOtocoPendingAboveTimeInForceEnum>,
/// Arbitrary numeric value identifying the pending above order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the pending above order strategy. Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_strategy_type: Option<i32>,
///
/// The `pending_above_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_peg_price_type: Option<OrderListOtocoPendingAbovePegPriceTypeEnum>,
///
/// The `pending_above_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_peg_offset_type: Option<OrderListOtocoPendingAbovePegOffsetTypeEnum>,
///
/// The `pending_above_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_above_peg_offset_value: Option<i32>,
///
/// The `pending_below_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_type: Option<OrderListOtocoPendingBelowTypeEnum>,
/// Arbitrary unique ID among open orders for the pending below order. Automatically generated if not sent.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_client_order_id: Option<String>,
/// Can be used if `pendingBelowType` is `STOP_LOSS_LIMIT` or `TAKE_PROFIT_LIMIT` to specify limit price
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_price: Option<rust_decimal::Decimal>,
/// Can be used if `pendingBelowType` is `STOP_LOSS`, `STOP_LOSS_LIMIT, TAKE_PROFIT or TAKE_PROFIT_LIMIT`. Either `pendingBelowStopPrice` or `pendingBelowTrailingDelta` or both, must be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_stop_price: Option<rust_decimal::Decimal>,
///
/// The `pending_below_trailing_delta` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_trailing_delta: Option<rust_decimal::Decimal>,
/// This can only be used if `pendingBelowTimeInForce` is `GTC`, or if `pendingBelowType` is `LIMIT_MAKER`.
///
/// This field is **optional.
#[builder(setter(into), 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)]
pub pending_below_time_in_force: Option<OrderListOtocoPendingBelowTimeInForceEnum>,
/// Arbitrary numeric value identifying the pending below order within an order strategy.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_strategy_id: Option<i64>,
/// Arbitrary numeric value identifying the pending below order strategy. Values smaller than 1000000 are reserved and cannot be used.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_strategy_type: Option<i32>,
///
/// The `pending_below_peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_peg_price_type: Option<OrderListOtocoPendingBelowPegPriceTypeEnum>,
///
/// The `pending_below_peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_peg_offset_type: Option<OrderListOtocoPendingBelowPegOffsetTypeEnum>,
///
/// The `pending_below_peg_offset_value` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub pending_below_peg_offset_value: Option<i32>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl OrderListOtocoParams {
/// Create a builder for [`order_list_otoco`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `working_type` — String
/// * `working_side` — String
/// * `working_price` — `rust_decimal::Decimal`
/// * `working_quantity` — Sets the quantity for the working order.
/// * `pending_side` — String
/// * `pending_quantity` — Sets the quantity for the pending order.
/// * `pending_above_type` — String
///
#[must_use]
pub fn builder(
symbol: String,
working_type: OrderListOtocoWorkingTypeEnum,
working_side: OrderListOtocoWorkingSideEnum,
working_price: rust_decimal::Decimal,
working_quantity: rust_decimal::Decimal,
pending_side: OrderListOtocoPendingSideEnum,
pending_quantity: rust_decimal::Decimal,
pending_above_type: OrderListOtocoPendingAboveTypeEnum,
) -> OrderListOtocoParamsBuilder {
OrderListOtocoParamsBuilder::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 [`order_oco`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`order_oco`](#method.order_oco).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct OrderOcoParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub side: OrderOcoSideEnum,
///
/// The `quantity` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub quantity: rust_decimal::Decimal,
///
/// The `price` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub price: rust_decimal::Decimal,
///
/// The `stop_price` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub stop_price: rust_decimal::Decimal,
/// A unique Id for the entire orderList
///
/// This field is **optional.
#[builder(setter(into), default)]
pub list_client_order_id: Option<String>,
/// A unique Id for the limit order
///
/// This field is **optional.
#[builder(setter(into), default)]
pub limit_client_order_id: Option<String>,
///
/// The `limit_strategy_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub limit_strategy_id: Option<i64>,
/// The value cannot be less than `1000000`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub limit_strategy_type: Option<i32>,
/// Used to make the `LIMIT_MAKER` leg an iceberg order.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub limit_iceberg_qty: Option<rust_decimal::Decimal>,
/// See [Trailing Stop order FAQ](faqs/trailing-stop-faq.md).
///
/// This field is **optional.
#[builder(setter(into), default)]
pub trailing_delta: Option<i64>,
/// A unique Id for the stop loss/stop loss limit leg
///
/// This field is **optional.
#[builder(setter(into), default)]
pub stop_client_order_id: Option<String>,
///
/// The `stop_strategy_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub stop_strategy_id: Option<i64>,
/// The value cannot be less than `1000000`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub stop_strategy_type: Option<i32>,
/// If provided, `stopLimitTimeInForce` is required.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub stop_limit_price: Option<rust_decimal::Decimal>,
/// Used with `STOP_LOSS_LIMIT` leg to make an iceberg order.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub stop_iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `stop_limit_time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub stop_limit_time_in_force: Option<OrderOcoStopLimitTimeInForceEnum>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_order_resp_type: Option<OrderOcoNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub self_trade_prevention_mode: Option<OrderOcoSelfTradePreventionModeEnum>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl OrderOcoParams {
/// Create a builder for [`order_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: OrderOcoSideEnum,
quantity: rust_decimal::Decimal,
price: rust_decimal::Decimal,
stop_price: rust_decimal::Decimal,
) -> OrderOcoParamsBuilder {
OrderOcoParamsBuilder::default()
.symbol(symbol)
.side(side)
.quantity(quantity)
.price(price)
.stop_price(stop_price)
}
}
/// Request parameters for the [`order_test`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`order_test`](#method.order_test).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct OrderTestParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub side: OrderTestSideEnum,
///
/// The `r#type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub r#type: OrderTestTypeEnum,
/// Default: `false` <br> See [Commissions FAQ](faqs/commission_faq.md#test-order-diferences) to learn more.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub compute_commission_rates: Option<bool>,
///
/// The `time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub time_in_force: Option<OrderTestTimeInForceEnum>,
///
/// The `quantity` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub quantity: Option<rust_decimal::Decimal>,
///
/// The `quote_order_qty` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub quote_order_qty: Option<rust_decimal::Decimal>,
///
/// The `price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub price: Option<rust_decimal::Decimal>,
/// A unique id among open orders. Automatically generated if not sent.<br/> Orders with the same `newClientOrderID` can be accepted only when the previous one is filled, otherwise the order will be rejected.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_client_order_id: Option<String>,
///
/// The `strategy_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub strategy_id: Option<i64>,
/// The value cannot be less than `1000000`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub strategy_type: Option<i32>,
/// Used with `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT`, and `TAKE_PROFIT_LIMIT` orders.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub stop_price: Option<rust_decimal::Decimal>,
/// See [Trailing Stop order FAQ](faqs/trailing-stop-faq.md).
///
/// This field is **optional.
#[builder(setter(into), default)]
pub trailing_delta: Option<i64>,
/// Used with `LIMIT`, `STOP_LOSS_LIMIT`, and `TAKE_PROFIT_LIMIT` to create an iceberg order.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_order_resp_type: Option<OrderTestNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub self_trade_prevention_mode: Option<OrderTestSelfTradePreventionModeEnum>,
///
/// The `peg_price_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub peg_price_type: Option<OrderTestPegPriceTypeEnum>,
/// Priceleveltopegthepriceto(max:100).<br>See[`PeggedOrdersInfo`](#pegged-orders-info)
///
/// This field is **optional.
#[builder(setter(into), default)]
pub peg_offset_value: Option<i32>,
///
/// The `peg_offset_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub peg_offset_type: Option<OrderTestPegOffsetTypeEnum>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl OrderTestParams {
/// Create a builder for [`order_test`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `side` — String
/// * `r#type` — String
///
#[must_use]
pub fn builder(
symbol: String,
side: OrderTestSideEnum,
r#type: OrderTestTypeEnum,
) -> OrderTestParamsBuilder {
OrderTestParamsBuilder::default()
.symbol(symbol)
.side(side)
.r#type(r#type)
}
}
/// Request parameters for the [`sor_order`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`sor_order`](#method.sor_order).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct SorOrderParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub side: SorOrderSideEnum,
///
/// The `r#type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub r#type: SorOrderTypeEnum,
///
/// The `quantity` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub quantity: rust_decimal::Decimal,
///
/// The `time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub time_in_force: Option<SorOrderTimeInForceEnum>,
///
/// The `price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub price: Option<rust_decimal::Decimal>,
/// A unique id among open orders. Automatically generated if not sent.<br/> Orders with the same `newClientOrderID` can be accepted only when the previous one is filled, otherwise the order will be rejected.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_client_order_id: Option<String>,
///
/// The `strategy_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub strategy_id: Option<i64>,
/// The value cannot be less than `1000000`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub strategy_type: Option<i32>,
/// Used with `LIMIT`, `STOP_LOSS_LIMIT`, and `TAKE_PROFIT_LIMIT` to create an iceberg order.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_order_resp_type: Option<SorOrderNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub self_trade_prevention_mode: Option<SorOrderSelfTradePreventionModeEnum>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl SorOrderParams {
/// Create a builder for [`sor_order`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `side` — String
/// * `r#type` — String
/// * `quantity` — `rust_decimal::Decimal`
///
#[must_use]
pub fn builder(
symbol: String,
side: SorOrderSideEnum,
r#type: SorOrderTypeEnum,
quantity: rust_decimal::Decimal,
) -> SorOrderParamsBuilder {
SorOrderParamsBuilder::default()
.symbol(symbol)
.side(side)
.r#type(r#type)
.quantity(quantity)
}
}
/// Request parameters for the [`sor_order_test`] operation.
///
/// This struct holds all of the inputs you can pass when calling
/// [`sor_order_test`](#method.sor_order_test).
#[derive(Clone, Debug, Builder)]
#[builder(pattern = "owned", build_fn(error = "ParamBuildError"))]
pub struct SorOrderTestParams {
///
/// The `symbol` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub symbol: String,
///
/// The `side` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub side: SorOrderTestSideEnum,
///
/// The `r#type` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub r#type: SorOrderTestTypeEnum,
///
/// The `quantity` parameter.
///
/// This field is **required.
#[builder(setter(into))]
pub quantity: rust_decimal::Decimal,
/// Default: `false` <br> See [Commissions FAQ](faqs/commission_faq.md#test-order-diferences) to learn more.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub compute_commission_rates: Option<bool>,
///
/// The `time_in_force` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub time_in_force: Option<SorOrderTestTimeInForceEnum>,
///
/// The `price` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub price: Option<rust_decimal::Decimal>,
/// A unique id among open orders. Automatically generated if not sent.<br/> Orders with the same `newClientOrderID` can be accepted only when the previous one is filled, otherwise the order will be rejected.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_client_order_id: Option<String>,
///
/// The `strategy_id` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub strategy_id: Option<i64>,
/// The value cannot be less than `1000000`.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub strategy_type: Option<i32>,
/// Used with `LIMIT`, `STOP_LOSS_LIMIT`, and `TAKE_PROFIT_LIMIT` to create an iceberg order.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub iceberg_qty: Option<rust_decimal::Decimal>,
///
/// The `new_order_resp_type` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub new_order_resp_type: Option<SorOrderTestNewOrderRespTypeEnum>,
///
/// The `self_trade_prevention_mode` parameter.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub self_trade_prevention_mode: Option<SorOrderTestSelfTradePreventionModeEnum>,
/// The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.
///
/// This field is **optional.
#[builder(setter(into), default)]
pub recv_window: Option<rust_decimal::Decimal>,
}
impl SorOrderTestParams {
/// Create a builder for [`sor_order_test`].
///
/// Required parameters:
///
/// * `symbol` — String
/// * `side` — String
/// * `r#type` — String
/// * `quantity` — `rust_decimal::Decimal`
///
#[must_use]
pub fn builder(
symbol: String,
side: SorOrderTestSideEnum,
r#type: SorOrderTestTypeEnum,
quantity: rust_decimal::Decimal,
) -> SorOrderTestParamsBuilder {
SorOrderTestParamsBuilder::default()
.symbol(symbol)
.side(side)
.r#type(r#type)
.quantity(quantity)
}
}
#[async_trait]
impl TradeApi for TradeApiClient {
async fn delete_open_orders(
&self,
params: DeleteOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::DeleteOpenOrdersResponseInner>>> {
let DeleteOpenOrdersParams {
symbol,
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) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<Vec<models::DeleteOpenOrdersResponseInner>>(
&self.configuration,
"/api/v3/openOrders",
reqwest::Method::DELETE,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn delete_order(
&self,
params: DeleteOrderParams,
) -> anyhow::Result<RestApiResponse<models::DeleteOrderResponse>> {
let DeleteOrderParams {
symbol,
order_id,
orig_client_order_id,
new_client_order_id,
cancel_restrictions,
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) = 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) = cancel_restrictions {
query_params.insert("cancelRestrictions".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::DeleteOrderResponse>(
&self.configuration,
"/api/v3/order",
reqwest::Method::DELETE,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn delete_order_list(
&self,
params: DeleteOrderListParams,
) -> anyhow::Result<RestApiResponse<models::DeleteOrderListResponse>> {
let DeleteOrderListParams {
symbol,
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) = 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::DeleteOrderListResponse>(
&self.configuration,
"/api/v3/orderList",
reqwest::Method::DELETE,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn new_order(
&self,
params: NewOrderParams,
) -> anyhow::Result<RestApiResponse<models::NewOrderResponse>> {
let NewOrderParams {
symbol,
side,
r#type,
time_in_force,
quantity,
quote_order_qty,
price,
new_client_order_id,
strategy_id,
strategy_type,
stop_price,
trailing_delta,
iceberg_qty,
new_order_resp_type,
self_trade_prevention_mode,
peg_price_type,
peg_offset_value,
peg_offset_type,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
query_params.insert("side".to_string(), json!(side));
query_params.insert("type".to_string(), json!(r#type));
if let Some(rw) = time_in_force {
query_params.insert("timeInForce".to_string(), json!(rw));
}
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) = new_client_order_id {
query_params.insert("newClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = strategy_id {
query_params.insert("strategyId".to_string(), json!(rw));
}
if let Some(rw) = strategy_type {
query_params.insert("strategyType".to_string(), json!(rw));
}
if let Some(rw) = stop_price {
query_params.insert("stopPrice".to_string(), json!(rw));
}
if let Some(rw) = trailing_delta {
query_params.insert("trailingDelta".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) = self_trade_prevention_mode {
query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
}
if let Some(rw) = peg_price_type {
query_params.insert("pegPriceType".to_string(), json!(rw));
}
if let Some(rw) = peg_offset_value {
query_params.insert("pegOffsetValue".to_string(), json!(rw));
}
if let Some(rw) = peg_offset_type {
query_params.insert("pegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::NewOrderResponse>(
&self.configuration,
"/api/v3/order",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn order_amend_keep_priority(
&self,
params: OrderAmendKeepPriorityParams,
) -> anyhow::Result<RestApiResponse<models::OrderAmendKeepPriorityResponse>> {
let OrderAmendKeepPriorityParams {
symbol,
new_qty,
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) = 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));
}
query_params.insert("newQty".to_string(), json!(new_qty));
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::OrderAmendKeepPriorityResponse>(
&self.configuration,
"/api/v3/order/amend/keepPriority",
reqwest::Method::PUT,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn order_cancel_replace(
&self,
params: OrderCancelReplaceParams,
) -> anyhow::Result<RestApiResponse<models::OrderCancelReplaceResponse>> {
let OrderCancelReplaceParams {
symbol,
side,
r#type,
cancel_replace_mode,
time_in_force,
quantity,
quote_order_qty,
price,
cancel_new_client_order_id,
cancel_orig_client_order_id,
cancel_order_id,
new_client_order_id,
strategy_id,
strategy_type,
stop_price,
trailing_delta,
iceberg_qty,
new_order_resp_type,
self_trade_prevention_mode,
cancel_restrictions,
order_rate_limit_exceeded_mode,
peg_price_type,
peg_offset_value,
peg_offset_type,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
query_params.insert("side".to_string(), json!(side));
query_params.insert("type".to_string(), json!(r#type));
query_params.insert("cancelReplaceMode".to_string(), json!(cancel_replace_mode));
if let Some(rw) = time_in_force {
query_params.insert("timeInForce".to_string(), json!(rw));
}
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) = cancel_new_client_order_id {
query_params.insert("cancelNewClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = cancel_orig_client_order_id {
query_params.insert("cancelOrigClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = cancel_order_id {
query_params.insert("cancelOrderId".to_string(), json!(rw));
}
if let Some(rw) = new_client_order_id {
query_params.insert("newClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = strategy_id {
query_params.insert("strategyId".to_string(), json!(rw));
}
if let Some(rw) = strategy_type {
query_params.insert("strategyType".to_string(), json!(rw));
}
if let Some(rw) = stop_price {
query_params.insert("stopPrice".to_string(), json!(rw));
}
if let Some(rw) = trailing_delta {
query_params.insert("trailingDelta".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) = self_trade_prevention_mode {
query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
}
if let Some(rw) = cancel_restrictions {
query_params.insert("cancelRestrictions".to_string(), json!(rw));
}
if let Some(rw) = order_rate_limit_exceeded_mode {
query_params.insert("orderRateLimitExceededMode".to_string(), json!(rw));
}
if let Some(rw) = peg_price_type {
query_params.insert("pegPriceType".to_string(), json!(rw));
}
if let Some(rw) = peg_offset_value {
query_params.insert("pegOffsetValue".to_string(), json!(rw));
}
if let Some(rw) = peg_offset_type {
query_params.insert("pegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::OrderCancelReplaceResponse>(
&self.configuration,
"/api/v3/order/cancelReplace",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn order_list_oco(
&self,
params: OrderListOcoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOcoResponse>> {
let OrderListOcoParams {
symbol,
side,
quantity,
above_type,
below_type,
list_client_order_id,
above_client_order_id,
above_iceberg_qty,
above_price,
above_stop_price,
above_trailing_delta,
above_time_in_force,
above_strategy_id,
above_strategy_type,
above_peg_price_type,
above_peg_offset_type,
above_peg_offset_value,
below_client_order_id,
below_iceberg_qty,
below_price,
below_stop_price,
below_trailing_delta,
below_time_in_force,
below_strategy_id,
below_strategy_type,
below_peg_price_type,
below_peg_offset_type,
below_peg_offset_value,
new_order_resp_type,
self_trade_prevention_mode,
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) = 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));
query_params.insert("aboveType".to_string(), json!(above_type));
if let Some(rw) = above_client_order_id {
query_params.insert("aboveClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = above_iceberg_qty {
query_params.insert("aboveIcebergQty".to_string(), json!(rw));
}
if let Some(rw) = above_price {
query_params.insert("abovePrice".to_string(), json!(rw));
}
if let Some(rw) = above_stop_price {
query_params.insert("aboveStopPrice".to_string(), json!(rw));
}
if let Some(rw) = above_trailing_delta {
query_params.insert("aboveTrailingDelta".to_string(), json!(rw));
}
if let Some(rw) = above_time_in_force {
query_params.insert("aboveTimeInForce".to_string(), json!(rw));
}
if let Some(rw) = above_strategy_id {
query_params.insert("aboveStrategyId".to_string(), json!(rw));
}
if let Some(rw) = above_strategy_type {
query_params.insert("aboveStrategyType".to_string(), json!(rw));
}
if let Some(rw) = above_peg_price_type {
query_params.insert("abovePegPriceType".to_string(), json!(rw));
}
if let Some(rw) = above_peg_offset_type {
query_params.insert("abovePegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = above_peg_offset_value {
query_params.insert("abovePegOffsetValue".to_string(), json!(rw));
}
query_params.insert("belowType".to_string(), json!(below_type));
if let Some(rw) = below_client_order_id {
query_params.insert("belowClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = below_iceberg_qty {
query_params.insert("belowIcebergQty".to_string(), json!(rw));
}
if let Some(rw) = below_price {
query_params.insert("belowPrice".to_string(), json!(rw));
}
if let Some(rw) = below_stop_price {
query_params.insert("belowStopPrice".to_string(), json!(rw));
}
if let Some(rw) = below_trailing_delta {
query_params.insert("belowTrailingDelta".to_string(), json!(rw));
}
if let Some(rw) = below_time_in_force {
query_params.insert("belowTimeInForce".to_string(), json!(rw));
}
if let Some(rw) = below_strategy_id {
query_params.insert("belowStrategyId".to_string(), json!(rw));
}
if let Some(rw) = below_strategy_type {
query_params.insert("belowStrategyType".to_string(), json!(rw));
}
if let Some(rw) = below_peg_price_type {
query_params.insert("belowPegPriceType".to_string(), json!(rw));
}
if let Some(rw) = below_peg_offset_type {
query_params.insert("belowPegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = below_peg_offset_value {
query_params.insert("belowPegOffsetValue".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));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::OrderListOcoResponse>(
&self.configuration,
"/api/v3/orderList/oco",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn order_list_opo(
&self,
params: OrderListOpoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOpoResponse>> {
let OrderListOpoParams {
symbol,
working_type,
working_side,
working_price,
working_quantity,
pending_type,
pending_side,
list_client_order_id,
new_order_resp_type,
self_trade_prevention_mode,
working_client_order_id,
working_iceberg_qty,
working_time_in_force,
working_strategy_id,
working_strategy_type,
working_peg_price_type,
working_peg_offset_type,
working_peg_offset_value,
pending_client_order_id,
pending_price,
pending_stop_price,
pending_trailing_delta,
pending_iceberg_qty,
pending_time_in_force,
pending_strategy_id,
pending_strategy_type,
pending_peg_price_type,
pending_peg_offset_type,
pending_peg_offset_value,
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) = 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));
}
if let Some(rw) = working_strategy_id {
query_params.insert("workingStrategyId".to_string(), json!(rw));
}
if let Some(rw) = working_strategy_type {
query_params.insert("workingStrategyType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_price_type {
query_params.insert("workingPegPriceType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_offset_type {
query_params.insert("workingPegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_offset_value {
query_params.insert("workingPegOffsetValue".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));
}
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));
}
if let Some(rw) = pending_strategy_id {
query_params.insert("pendingStrategyId".to_string(), json!(rw));
}
if let Some(rw) = pending_strategy_type {
query_params.insert("pendingStrategyType".to_string(), json!(rw));
}
if let Some(rw) = pending_peg_price_type {
query_params.insert("pendingPegPriceType".to_string(), json!(rw));
}
if let Some(rw) = pending_peg_offset_type {
query_params.insert("pendingPegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = pending_peg_offset_value {
query_params.insert("pendingPegOffsetValue".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::OrderListOpoResponse>(
&self.configuration,
"/api/v3/orderList/opo",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn order_list_opoco(
&self,
params: OrderListOpocoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOpocoResponse>> {
let OrderListOpocoParams {
symbol,
working_type,
working_side,
working_price,
working_quantity,
pending_side,
pending_above_type,
list_client_order_id,
new_order_resp_type,
self_trade_prevention_mode,
working_client_order_id,
working_iceberg_qty,
working_time_in_force,
working_strategy_id,
working_strategy_type,
working_peg_price_type,
working_peg_offset_type,
working_peg_offset_value,
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_above_strategy_id,
pending_above_strategy_type,
pending_above_peg_price_type,
pending_above_peg_offset_type,
pending_above_peg_offset_value,
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,
pending_below_strategy_id,
pending_below_strategy_type,
pending_below_peg_price_type,
pending_below_peg_offset_type,
pending_below_peg_offset_value,
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) = 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));
}
if let Some(rw) = working_strategy_id {
query_params.insert("workingStrategyId".to_string(), json!(rw));
}
if let Some(rw) = working_strategy_type {
query_params.insert("workingStrategyType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_price_type {
query_params.insert("workingPegPriceType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_offset_type {
query_params.insert("workingPegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_offset_value {
query_params.insert("workingPegOffsetValue".to_string(), json!(rw));
}
query_params.insert("pendingSide".to_string(), json!(pending_side));
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_above_strategy_id {
query_params.insert("pendingAboveStrategyId".to_string(), json!(rw));
}
if let Some(rw) = pending_above_strategy_type {
query_params.insert("pendingAboveStrategyType".to_string(), json!(rw));
}
if let Some(rw) = pending_above_peg_price_type {
query_params.insert("pendingAbovePegPriceType".to_string(), json!(rw));
}
if let Some(rw) = pending_above_peg_offset_type {
query_params.insert("pendingAbovePegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = pending_above_peg_offset_value {
query_params.insert("pendingAbovePegOffsetValue".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));
}
if let Some(rw) = pending_below_strategy_id {
query_params.insert("pendingBelowStrategyId".to_string(), json!(rw));
}
if let Some(rw) = pending_below_strategy_type {
query_params.insert("pendingBelowStrategyType".to_string(), json!(rw));
}
if let Some(rw) = pending_below_peg_price_type {
query_params.insert("pendingBelowPegPriceType".to_string(), json!(rw));
}
if let Some(rw) = pending_below_peg_offset_type {
query_params.insert("pendingBelowPegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = pending_below_peg_offset_value {
query_params.insert("pendingBelowPegOffsetValue".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::OrderListOpocoResponse>(
&self.configuration,
"/api/v3/orderList/opoco",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn order_list_oto(
&self,
params: OrderListOtoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOtoResponse>> {
let OrderListOtoParams {
symbol,
working_type,
working_side,
working_price,
working_quantity,
pending_type,
pending_side,
pending_quantity,
list_client_order_id,
new_order_resp_type,
self_trade_prevention_mode,
working_client_order_id,
working_iceberg_qty,
working_time_in_force,
working_strategy_id,
working_strategy_type,
working_peg_price_type,
working_peg_offset_type,
working_peg_offset_value,
pending_client_order_id,
pending_price,
pending_stop_price,
pending_trailing_delta,
pending_iceberg_qty,
pending_time_in_force,
pending_strategy_id,
pending_strategy_type,
pending_peg_price_type,
pending_peg_offset_type,
pending_peg_offset_value,
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) = 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));
}
if let Some(rw) = working_strategy_id {
query_params.insert("workingStrategyId".to_string(), json!(rw));
}
if let Some(rw) = working_strategy_type {
query_params.insert("workingStrategyType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_price_type {
query_params.insert("workingPegPriceType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_offset_type {
query_params.insert("workingPegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_offset_value {
query_params.insert("workingPegOffsetValue".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));
}
if let Some(rw) = pending_strategy_id {
query_params.insert("pendingStrategyId".to_string(), json!(rw));
}
if let Some(rw) = pending_strategy_type {
query_params.insert("pendingStrategyType".to_string(), json!(rw));
}
if let Some(rw) = pending_peg_price_type {
query_params.insert("pendingPegPriceType".to_string(), json!(rw));
}
if let Some(rw) = pending_peg_offset_type {
query_params.insert("pendingPegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = pending_peg_offset_value {
query_params.insert("pendingPegOffsetValue".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::OrderListOtoResponse>(
&self.configuration,
"/api/v3/orderList/oto",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn order_list_otoco(
&self,
params: OrderListOtocoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOtocoResponse>> {
let OrderListOtocoParams {
symbol,
working_type,
working_side,
working_price,
working_quantity,
pending_side,
pending_quantity,
pending_above_type,
list_client_order_id,
new_order_resp_type,
self_trade_prevention_mode,
working_client_order_id,
working_iceberg_qty,
working_time_in_force,
working_strategy_id,
working_strategy_type,
working_peg_price_type,
working_peg_offset_type,
working_peg_offset_value,
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_above_strategy_id,
pending_above_strategy_type,
pending_above_peg_price_type,
pending_above_peg_offset_type,
pending_above_peg_offset_value,
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,
pending_below_strategy_id,
pending_below_strategy_type,
pending_below_peg_price_type,
pending_below_peg_offset_type,
pending_below_peg_offset_value,
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) = 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));
}
if let Some(rw) = working_strategy_id {
query_params.insert("workingStrategyId".to_string(), json!(rw));
}
if let Some(rw) = working_strategy_type {
query_params.insert("workingStrategyType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_price_type {
query_params.insert("workingPegPriceType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_offset_type {
query_params.insert("workingPegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = working_peg_offset_value {
query_params.insert("workingPegOffsetValue".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_above_strategy_id {
query_params.insert("pendingAboveStrategyId".to_string(), json!(rw));
}
if let Some(rw) = pending_above_strategy_type {
query_params.insert("pendingAboveStrategyType".to_string(), json!(rw));
}
if let Some(rw) = pending_above_peg_price_type {
query_params.insert("pendingAbovePegPriceType".to_string(), json!(rw));
}
if let Some(rw) = pending_above_peg_offset_type {
query_params.insert("pendingAbovePegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = pending_above_peg_offset_value {
query_params.insert("pendingAbovePegOffsetValue".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));
}
if let Some(rw) = pending_below_strategy_id {
query_params.insert("pendingBelowStrategyId".to_string(), json!(rw));
}
if let Some(rw) = pending_below_strategy_type {
query_params.insert("pendingBelowStrategyType".to_string(), json!(rw));
}
if let Some(rw) = pending_below_peg_price_type {
query_params.insert("pendingBelowPegPriceType".to_string(), json!(rw));
}
if let Some(rw) = pending_below_peg_offset_type {
query_params.insert("pendingBelowPegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = pending_below_peg_offset_value {
query_params.insert("pendingBelowPegOffsetValue".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::OrderListOtocoResponse>(
&self.configuration,
"/api/v3/orderList/otoco",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn order_oco(
&self,
params: OrderOcoParams,
) -> anyhow::Result<RestApiResponse<models::OrderOcoResponse>> {
let OrderOcoParams {
symbol,
side,
quantity,
price,
stop_price,
list_client_order_id,
limit_client_order_id,
limit_strategy_id,
limit_strategy_type,
limit_iceberg_qty,
trailing_delta,
stop_client_order_id,
stop_strategy_id,
stop_strategy_type,
stop_limit_price,
stop_iceberg_qty,
stop_limit_time_in_force,
new_order_resp_type,
self_trade_prevention_mode,
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) = 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_strategy_id {
query_params.insert("limitStrategyId".to_string(), json!(rw));
}
if let Some(rw) = limit_strategy_type {
query_params.insert("limitStrategyType".to_string(), json!(rw));
}
if let Some(rw) = limit_iceberg_qty {
query_params.insert("limitIcebergQty".to_string(), json!(rw));
}
if let Some(rw) = trailing_delta {
query_params.insert("trailingDelta".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_strategy_id {
query_params.insert("stopStrategyId".to_string(), json!(rw));
}
if let Some(rw) = stop_strategy_type {
query_params.insert("stopStrategyType".to_string(), json!(rw));
}
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) = self_trade_prevention_mode {
query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::OrderOcoResponse>(
&self.configuration,
"/api/v3/order/oco",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn order_test(
&self,
params: OrderTestParams,
) -> anyhow::Result<RestApiResponse<models::OrderTestResponse>> {
let OrderTestParams {
symbol,
side,
r#type,
compute_commission_rates,
time_in_force,
quantity,
quote_order_qty,
price,
new_client_order_id,
strategy_id,
strategy_type,
stop_price,
trailing_delta,
iceberg_qty,
new_order_resp_type,
self_trade_prevention_mode,
peg_price_type,
peg_offset_value,
peg_offset_type,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = compute_commission_rates {
query_params.insert("computeCommissionRates".to_string(), json!(rw));
}
query_params.insert("symbol".to_string(), json!(symbol));
query_params.insert("side".to_string(), json!(side));
query_params.insert("type".to_string(), json!(r#type));
if let Some(rw) = time_in_force {
query_params.insert("timeInForce".to_string(), json!(rw));
}
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) = new_client_order_id {
query_params.insert("newClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = strategy_id {
query_params.insert("strategyId".to_string(), json!(rw));
}
if let Some(rw) = strategy_type {
query_params.insert("strategyType".to_string(), json!(rw));
}
if let Some(rw) = stop_price {
query_params.insert("stopPrice".to_string(), json!(rw));
}
if let Some(rw) = trailing_delta {
query_params.insert("trailingDelta".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) = self_trade_prevention_mode {
query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
}
if let Some(rw) = peg_price_type {
query_params.insert("pegPriceType".to_string(), json!(rw));
}
if let Some(rw) = peg_offset_value {
query_params.insert("pegOffsetValue".to_string(), json!(rw));
}
if let Some(rw) = peg_offset_type {
query_params.insert("pegOffsetType".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::OrderTestResponse>(
&self.configuration,
"/api/v3/order/test",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn sor_order(
&self,
params: SorOrderParams,
) -> anyhow::Result<RestApiResponse<models::SorOrderResponse>> {
let SorOrderParams {
symbol,
side,
r#type,
quantity,
time_in_force,
price,
new_client_order_id,
strategy_id,
strategy_type,
iceberg_qty,
new_order_resp_type,
self_trade_prevention_mode,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
query_params.insert("symbol".to_string(), json!(symbol));
query_params.insert("side".to_string(), json!(side));
query_params.insert("type".to_string(), json!(r#type));
if let Some(rw) = time_in_force {
query_params.insert("timeInForce".to_string(), json!(rw));
}
query_params.insert("quantity".to_string(), json!(quantity));
if let Some(rw) = price {
query_params.insert("price".to_string(), json!(rw));
}
if let Some(rw) = new_client_order_id {
query_params.insert("newClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = strategy_id {
query_params.insert("strategyId".to_string(), json!(rw));
}
if let Some(rw) = strategy_type {
query_params.insert("strategyType".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) = self_trade_prevention_mode {
query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::SorOrderResponse>(
&self.configuration,
"/api/v3/sor/order",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
async fn sor_order_test(
&self,
params: SorOrderTestParams,
) -> anyhow::Result<RestApiResponse<models::SorOrderTestResponse>> {
let SorOrderTestParams {
symbol,
side,
r#type,
quantity,
compute_commission_rates,
time_in_force,
price,
new_client_order_id,
strategy_id,
strategy_type,
iceberg_qty,
new_order_resp_type,
self_trade_prevention_mode,
recv_window,
} = params;
let mut query_params = BTreeMap::new();
let body_params = BTreeMap::new();
if let Some(rw) = compute_commission_rates {
query_params.insert("computeCommissionRates".to_string(), json!(rw));
}
query_params.insert("symbol".to_string(), json!(symbol));
query_params.insert("side".to_string(), json!(side));
query_params.insert("type".to_string(), json!(r#type));
if let Some(rw) = time_in_force {
query_params.insert("timeInForce".to_string(), json!(rw));
}
query_params.insert("quantity".to_string(), json!(quantity));
if let Some(rw) = price {
query_params.insert("price".to_string(), json!(rw));
}
if let Some(rw) = new_client_order_id {
query_params.insert("newClientOrderId".to_string(), json!(rw));
}
if let Some(rw) = strategy_id {
query_params.insert("strategyId".to_string(), json!(rw));
}
if let Some(rw) = strategy_type {
query_params.insert("strategyType".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) = self_trade_prevention_mode {
query_params.insert("selfTradePreventionMode".to_string(), json!(rw));
}
if let Some(rw) = recv_window {
query_params.insert("recvWindow".to_string(), json!(rw));
}
send_request::<models::SorOrderTestResponse>(
&self.configuration,
"/api/v3/sor/order/test",
reqwest::Method::POST,
query_params,
body_params,
if HAS_TIME_UNIT {
self.configuration.time_unit
} else {
None
},
true,
)
.await
}
}
#[cfg(all(test, feature = "spot"))]
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 delete_open_orders(
&self,
_params: DeleteOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::DeleteOpenOrdersResponseInner>>> {
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","origClientOrderId":"E6APeyTJvkMvLMYMqu1KQ4","orderId":11,"orderListId":-1,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1684804350068,"price":"0.089853","origQty":"0.178622","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","origClientOrderId":"A3EF2HCwxgZPFMrfwbgrhv","orderId":13,"orderListId":-1,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1684804350069,"price":"0.090430","origQty":"0.178622","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE"},{"orderListId":1929,"contingencyType":"OCO","listStatusType":"ALL_DONE","listOrderStatus":"ALL_DONE","listClientOrderId":"2inzWQdDvZLHbbAmAozX2N","transactionTime":1585230948299,"symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":20,"clientOrderId":"CwOOIPHSmYywx6jZX77TdL"},{"symbol":"BTCUSDT","orderId":21,"clientOrderId":"461cPg51vQjV3zIMOXNz39"}],"orderReports":[{"symbol":"BTCUSDT","origClientOrderId":"CwOOIPHSmYywx6jZX77TdL","orderId":20,"orderListId":1929,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1688005070874,"price":"0.668611","origQty":"0.690354","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"BUY","stopPrice":"0.378131","icebergQty":"0.017083","selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","origClientOrderId":"461cPg51vQjV3zIMOXNz39","orderId":21,"orderListId":1929,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1688005070874,"price":"0.008791","origQty":"0.690354","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT_MAKER","side":"BUY","icebergQty":"0.639962","selfTradePreventionMode":"NONE"}]}]"#).unwrap();
let dummy_response: Vec<models::DeleteOpenOrdersResponseInner> =
serde_json::from_value(resp_json.clone())
.expect("should parse into Vec<models::DeleteOpenOrdersResponseInner>");
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_order(
&self,
_params: DeleteOrderParams,
) -> anyhow::Result<RestApiResponse<models::DeleteOrderResponse>> {
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","origClientOrderId":"myOrder1","orderId":4,"orderListId":-1,"clientOrderId":"cancelMyOrder1","transactTime":1684804350068,"price":"2.00000000","origQty":"1.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE"}"#).unwrap();
let dummy_response: models::DeleteOrderResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::DeleteOrderResponse");
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_order_list(
&self,
_params: DeleteOrderListParams,
) -> anyhow::Result<RestApiResponse<models::DeleteOrderListResponse>> {
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","orders":[{"symbol":"LTCBTC","orderId":3,"clientOrderId":"TXOvglzXuaubXAaENpaRCB"},{"symbol":"LTCBTC","orderId":2,"clientOrderId":"pO9ufTiFGg3nw2fOdgeOXa"}],"orderReports":[{"symbol":"LTCBTC","origClientOrderId":"TXOvglzXuaubXAaENpaRCB","orderId":3,"orderListId":0,"clientOrderId":"unfWT8ig8i0uj6lPuYLez6","transactTime":1688005070874,"price":"3.00000000","origQty":"10.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT_MAKER","side":"SELL","selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","origClientOrderId":"pO9ufTiFGg3nw2fOdgeOXa","orderId":2,"orderListId":0,"clientOrderId":"unfWT8ig8i0uj6lPuYLez6","transactTime":1688005070874,"price":"1.00000000","origQty":"10.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"1.00000000","selfTradePreventionMode":"NONE"}]}"#).unwrap();
let dummy_response: models::DeleteOrderListResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::DeleteOrderListResponse");
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 new_order(
&self,
_params: NewOrderParams,
) -> anyhow::Result<RestApiResponse<models::NewOrderResponse>> {
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":28,"orderListId":-1,"clientOrderId":"6gCrw2kRUAF9CvJDGP16IP","transactTime":1507725176595,"price":"0.00000000","origQty":"10.00000000","executedQty":"10.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"10.00000000","status":"FILLED","timeInForce":"GTC","type":"MARKET","side":"SELL","workingTime":1507725176595,"selfTradePreventionMode":"NONE","fills":[{"price":"3995.00000000","qty":"1.00000000","commission":"3.99500000","commissionAsset":"USDT","tradeId":60},{"price":"3997.00000000","qty":"1.00000000","commission":"3.99700000","commissionAsset":"USDT","tradeId":59},{"price":"3998.00000000","qty":"2.00000000","commission":"7.99600000","commissionAsset":"USDT","tradeId":58},{"price":"3999.00000000","qty":"5.00000000","commission":"19.99500000","commissionAsset":"USDT","tradeId":57},{"price":"4000.00000000","qty":"1.00000000","commission":"4.00000000","commissionAsset":"USDT","tradeId":56},{"price":"3995.00000000","qty":"1.00000000","commission":"3.99500000","commissionAsset":"USDT","tradeId":60},{"price":"3997.00000000","qty":"1.00000000","commission":"3.99700000","commissionAsset":"USDT","tradeId":59},{"price":"3998.00000000","qty":"2.00000000","commission":"7.99600000","commissionAsset":"USDT","tradeId":58},{"price":"3999.00000000","qty":"5.00000000","commission":"19.99500000","commissionAsset":"USDT","tradeId":57},{"price":"4000.00000000","qty":"1.00000000","commission":"4.00000000","commissionAsset":"USDT","tradeId":56}]}"#).unwrap();
let dummy_response: models::NewOrderResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::NewOrderResponse");
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 order_amend_keep_priority(
&self,
_params: OrderAmendKeepPriorityParams,
) -> anyhow::Result<RestApiResponse<models::OrderAmendKeepPriorityResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
let resp_json: Value = serde_json::from_str(r#"{"transactTime":1741669661670,"executionId":22,"amendedOrder":{"symbol":"BTCUSDT","orderId":9,"orderListId":1,"origClientOrderId":"W0fJ9fiLKHOJutovPK3oJp","clientOrderId":"UQ1Np3bmQ71jJzsSDW9Vpi","price":"0.00000000","qty":"4.00000000","executedQty":"0.00000000","preventedQty":"0.00000000","quoteOrderQty":"0.00000000","cumulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"MARKET","side":"BUY","workingTime":1741926410242,"selfTradePreventionMode":"NONE"},"listStatus":{"orderListId":1,"contingencyType":"OTO","listOrderStatus":"EXECUTING","listClientOrderId":"AT7FTxZXylVSwRoZs52mt3","symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":9,"clientOrderId":"UQ1Np3bmQ71jJzsSDW9Vpi"},{"symbol":"BTCUSDT","orderId":8,"clientOrderId":"GkwwHZUUbFtZOoH1YsZk9Q"},{"symbol":"BTCUSDT","orderId":9,"clientOrderId":"UQ1Np3bmQ71jJzsSDW9Vpi"},{"symbol":"BTCUSDT","orderId":8,"clientOrderId":"GkwwHZUUbFtZOoH1YsZk9Q"}]}}"#).unwrap();
let dummy_response: models::OrderAmendKeepPriorityResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::OrderAmendKeepPriorityResponse");
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 order_cancel_replace(
&self,
_params: OrderCancelReplaceParams,
) -> anyhow::Result<RestApiResponse<models::OrderCancelReplaceResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
let resp_json: Value = serde_json::from_str(r#"{"cancelResult":"SUCCESS","newOrderResult":"SUCCESS","cancelResponse":{"symbol":"BTCUSDT","origClientOrderId":"DnLo3vTAQcjha43lAZhZ0y","orderId":9,"orderListId":-1,"clientOrderId":"osxN3JXAtJvKvCqGeMWMVR","transactTime":1684804350068,"price":"0.01000000","origQty":"0.000100","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"SELL","selfTradePreventionMode":"NONE"},"newOrderResponse":{"symbol":"BTCUSDT","orderId":10,"orderListId":-1,"clientOrderId":"wOceeeOzNORyLiQfw7jd8S","transactTime":1652928801803,"price":"0.02000000","origQty":"0.040000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1669277163808,"fills":[],"selfTradePreventionMode":"NONE"},"code":-2021,"msg":"Order cancel-replace partially failed.","data":{"cancelResult":"SUCCESS","newOrderResult":"FAILURE","cancelResponse":{"code":-2011,"msg":"Unknown order sent.","symbol":"LTCBNB","origClientOrderId":"GKt5zzfOxRDSQLveDYCTkc","orderId":64,"orderListId":-1,"clientOrderId":"loehOJF3FjoreUBDmv739R","transactTime":1715779007228,"price":"1.00","origQty":"10.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"SELL","selfTradePreventionMode":"NONE"},"newOrderResponse":{"code":-1015,"msg":"Too many new orders; current limit is 1 orders per 10 SECOND.","symbol":"BTCUSDT","orderId":11,"orderListId":-1,"clientOrderId":"pfojJMg6IMNDKuJqDxvoxN","transactTime":1648540168818}}}"#).unwrap();
let dummy_response: models::OrderCancelReplaceResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::OrderCancelReplaceResponse");
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 order_list_oco(
&self,
_params: OrderListOcoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOcoResponse>> {
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":1,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"lH1YDkuQKWiXVXHPSKYEIp","transactionTime":1710485608839,"symbol":"LTCBTC","orders":[{"symbol":"LTCBTC","orderId":11,"clientOrderId":"NuMp0nVYnciDiFmVqfpBqK"},{"symbol":"LTCBTC","orderId":10,"clientOrderId":"44nZvqpemY7sVYgPYbvPih"}],"orderReports":[{"symbol":"LTCBTC","orderId":11,"orderListId":1,"clientOrderId":"NuMp0nVYnciDiFmVqfpBqK","transactTime":1710485608839,"price":"3.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"SELL","workingTime":1710485608839,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":10,"orderListId":1,"clientOrderId":"44nZvqpemY7sVYgPYbvPih","transactTime":1710485608839,"price":"1.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"1.00000000","workingTime":-1,"icebergQty":"1.00000000","selfTradePreventionMode":"NONE"}]}"#).unwrap();
let dummy_response: models::OrderListOcoResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::OrderListOcoResponse");
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 order_list_opo(
&self,
_params: OrderListOpoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOpoResponse>> {
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":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"H94qCqO27P74OEiO4X8HOG","transactionTime":1762998011671,"symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":3,"clientOrderId":"2ZJCY0IjOhuYIMLGN8kU8S"},{"symbol":"BTCUSDT","orderId":2,"clientOrderId":"JX6xfdjo0wysiGumfHNmPu"}],"orderReports":[{"symbol":"BTCUSDT","orderId":3,"orderListId":0,"clientOrderId":"2ZJCY0IjOhuYIMLGN8kU8S","transactTime":1762998011671,"price":"0.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"MARKET","side":"SELL","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","orderId":2,"orderListId":0,"clientOrderId":"JX6xfdjo0wysiGumfHNmPu","transactTime":1762998011671,"price":"102264.00000000","origQty":"0.00060000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1762998011671,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let dummy_response: models::OrderListOpoResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::OrderListOpoResponse");
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 order_list_opoco(
&self,
_params: OrderListOpocoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOpocoResponse>> {
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":2,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"bcedxMpQG6nFrZUPQyshoL","transactionTime":1763000506354,"symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":11,"clientOrderId":"yINkaXSJeoi3bU5vWMY8Z8"},{"symbol":"BTCUSDT","orderId":10,"clientOrderId":"mfif39yPTHsB3C0FIXznR2"},{"symbol":"BTCUSDT","orderId":9,"clientOrderId":"OLSBhMWaIlLSzZ9Zm7fnKB"}],"orderReports":[{"symbol":"BTCUSDT","orderId":11,"orderListId":2,"clientOrderId":"yINkaXSJeoi3bU5vWMY8Z8","transactTime":1763000506354,"price":"104261.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"SELL","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","orderId":10,"orderListId":2,"clientOrderId":"mfif39yPTHsB3C0FIXznR2","transactTime":1763000506354,"price":"101613.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"10100.00000000","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","orderId":9,"orderListId":2,"clientOrderId":"OLSBhMWaIlLSzZ9Zm7fnKB","transactTime":1763000506354,"price":"102496.00000000","origQty":"0.00170000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1763000506354,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let dummy_response: models::OrderListOpocoResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::OrderListOpocoResponse");
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 order_list_oto(
&self,
_params: OrderListOtoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOtoResponse>> {
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":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"yl2ERtcar1o25zcWtqVBTC","transactionTime":1712289389158,"symbol":"LTCBTC","orders":[{"symbol":"LTCBTC","orderId":5,"clientOrderId":"arLFo0zGJVDE69cvGBaU0d"},{"symbol":"LTCBTC","orderId":4,"clientOrderId":"Bq17mn9fP6vyCn75Jw1xya"}],"orderReports":[{"symbol":"LTCBTC","orderId":5,"orderListId":0,"clientOrderId":"arLFo0zGJVDE69cvGBaU0d","transactTime":1712289389158,"price":"0.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"MARKET","side":"BUY","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":4,"orderListId":0,"clientOrderId":"Bq17mn9fP6vyCn75Jw1xya","transactTime":1712289389158,"price":"1.00000000","origQty":"1.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","workingTime":1712289389158,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let dummy_response: models::OrderListOtoResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::OrderListOtoResponse");
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 order_list_otoco(
&self,
_params: OrderListOtocoParams,
) -> anyhow::Result<RestApiResponse<models::OrderListOtocoResponse>> {
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":1,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"RumwQpBaDctlUu5jyG5rs0","transactionTime":1712291372842,"symbol":"LTCBTC","orders":[{"symbol":"LTCBTC","orderId":8,"clientOrderId":"r4JMv9cwAYYUwwBZfbussx"},{"symbol":"LTCBTC","orderId":7,"clientOrderId":"6pcQbFIzTXGZQ1e2MkGDq4"},{"symbol":"LTCBTC","orderId":6,"clientOrderId":"fM9Y4m23IFJVCQmIrlUmMK"}],"orderReports":[{"symbol":"LTCBTC","orderId":8,"orderListId":1,"clientOrderId":"r4JMv9cwAYYUwwBZfbussx","transactTime":1712291372842,"price":"3.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"BUY","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":7,"orderListId":1,"clientOrderId":"6pcQbFIzTXGZQ1e2MkGDq4","transactTime":1712291372842,"price":"1.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"IOC","type":"STOP_LOSS_LIMIT","side":"BUY","stopPrice":"6.00000000","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":6,"orderListId":1,"clientOrderId":"fM9Y4m23IFJVCQmIrlUmMK","transactTime":1712291372842,"price":"1.00000000","origQty":"1.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","workingTime":1712291372842,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let dummy_response: models::OrderListOtocoResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::OrderListOtocoResponse");
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 order_oco(
&self,
_params: OrderOcoParams,
) -> anyhow::Result<RestApiResponse<models::OrderOcoResponse>> {
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","orders":[{"symbol":"LTCBTC","orderId":3,"clientOrderId":"xTXKaGYd4bluPVp78IVRvl"},{"symbol":"LTCBTC","orderId":2,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos"}],"orderReports":[{"symbol":"LTCBTC","orderId":3,"orderListId":0,"clientOrderId":"xTXKaGYd4bluPVp78IVRvl","transactTime":1563417480525,"price":"0.036435","origQty":"0.624363","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"BUY","workingTime":1563417480525,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":2,"orderListId":0,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos","transactTime":1563417480525,"price":"0.000000","origQty":"0.624363","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"NEW","timeInForce":"GTC","type":"STOP_LOSS","side":"BUY","stopPrice":"0.960664","workingTime":-1,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let dummy_response: models::OrderOcoResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::OrderOcoResponse");
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 order_test(
&self,
_params: OrderTestParams,
) -> anyhow::Result<RestApiResponse<models::OrderTestResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
let resp_json: Value = serde_json::from_str(r#"{"standardCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"specialCommissionForOrder":{"maker":"0.05000000","taker":"0.06000000"},"taxCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"discount":{"enabledForAccount":true,"enabledForSymbol":true,"discountAsset":"BNB","discount":"0.25000000"}}"#).unwrap();
let dummy_response: models::OrderTestResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::OrderTestResponse");
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 sor_order(
&self,
_params: SorOrderParams,
) -> anyhow::Result<RestApiResponse<models::SorOrderResponse>> {
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":2,"orderListId":-1,"clientOrderId":"sBI1KM6nNtOfj5tccZSKly","transactTime":1689149087774,"price":"31000.00000000","origQty":"0.50000000","executedQty":"0.50000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"14000.00000000","status":"FILLED","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1689149087774,"fills":[{"matchType":"ONE_PARTY_TRADE_REPORT","price":"28000.00000000","qty":"0.50000000","commission":"0.00000000","commissionAsset":"BTC","tradeId":-1,"allocId":0}],"workingFloor":"SOR","selfTradePreventionMode":"NONE","usedSor":true}"#).unwrap();
let dummy_response: models::SorOrderResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::SorOrderResponse");
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 sor_order_test(
&self,
_params: SorOrderTestParams,
) -> anyhow::Result<RestApiResponse<models::SorOrderTestResponse>> {
if self.force_error {
return Err(ConnectorError::ConnectorClientError {
msg: "ResponseError".to_string(),
code: None,
}
.into());
}
let resp_json: Value = serde_json::from_str(r#"{"standardCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"taxCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"discount":{"enabledForAccount":true,"enabledForSymbol":true,"discountAsset":"BNB","discount":"0.25000000"}}"#).unwrap();
let dummy_response: models::SorOrderTestResponse =
serde_json::from_value(resp_json.clone())
.expect("should parse into models::SorOrderTestResponse");
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 delete_open_orders_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = DeleteOpenOrdersParams::builder("BNBUSDT".to_string(),).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"[{"symbol":"BTCUSDT","origClientOrderId":"E6APeyTJvkMvLMYMqu1KQ4","orderId":11,"orderListId":-1,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1684804350068,"price":"0.089853","origQty":"0.178622","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","origClientOrderId":"A3EF2HCwxgZPFMrfwbgrhv","orderId":13,"orderListId":-1,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1684804350069,"price":"0.090430","origQty":"0.178622","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE"},{"orderListId":1929,"contingencyType":"OCO","listStatusType":"ALL_DONE","listOrderStatus":"ALL_DONE","listClientOrderId":"2inzWQdDvZLHbbAmAozX2N","transactionTime":1585230948299,"symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":20,"clientOrderId":"CwOOIPHSmYywx6jZX77TdL"},{"symbol":"BTCUSDT","orderId":21,"clientOrderId":"461cPg51vQjV3zIMOXNz39"}],"orderReports":[{"symbol":"BTCUSDT","origClientOrderId":"CwOOIPHSmYywx6jZX77TdL","orderId":20,"orderListId":1929,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1688005070874,"price":"0.668611","origQty":"0.690354","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"BUY","stopPrice":"0.378131","icebergQty":"0.017083","selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","origClientOrderId":"461cPg51vQjV3zIMOXNz39","orderId":21,"orderListId":1929,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1688005070874,"price":"0.008791","origQty":"0.690354","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT_MAKER","side":"BUY","icebergQty":"0.639962","selfTradePreventionMode":"NONE"}]}]"#).unwrap();
let expected_response : Vec<models::DeleteOpenOrdersResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::DeleteOpenOrdersResponseInner>");
let resp = client.delete_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 delete_open_orders_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = DeleteOpenOrdersParams::builder("BNBUSDT".to_string(),).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"[{"symbol":"BTCUSDT","origClientOrderId":"E6APeyTJvkMvLMYMqu1KQ4","orderId":11,"orderListId":-1,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1684804350068,"price":"0.089853","origQty":"0.178622","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","origClientOrderId":"A3EF2HCwxgZPFMrfwbgrhv","orderId":13,"orderListId":-1,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1684804350069,"price":"0.090430","origQty":"0.178622","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE"},{"orderListId":1929,"contingencyType":"OCO","listStatusType":"ALL_DONE","listOrderStatus":"ALL_DONE","listClientOrderId":"2inzWQdDvZLHbbAmAozX2N","transactionTime":1585230948299,"symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":20,"clientOrderId":"CwOOIPHSmYywx6jZX77TdL"},{"symbol":"BTCUSDT","orderId":21,"clientOrderId":"461cPg51vQjV3zIMOXNz39"}],"orderReports":[{"symbol":"BTCUSDT","origClientOrderId":"CwOOIPHSmYywx6jZX77TdL","orderId":20,"orderListId":1929,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1688005070874,"price":"0.668611","origQty":"0.690354","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"BUY","stopPrice":"0.378131","icebergQty":"0.017083","selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","origClientOrderId":"461cPg51vQjV3zIMOXNz39","orderId":21,"orderListId":1929,"clientOrderId":"pXLV6Hz6mprAcVYpVMTGgx","transactTime":1688005070874,"price":"0.008791","origQty":"0.690354","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT_MAKER","side":"BUY","icebergQty":"0.639962","selfTradePreventionMode":"NONE"}]}]"#).unwrap();
let expected_response : Vec<models::DeleteOpenOrdersResponseInner> = serde_json::from_value(resp_json.clone()).expect("should parse into Vec<models::DeleteOpenOrdersResponseInner>");
let resp = client.delete_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 delete_open_orders_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = DeleteOpenOrdersParams::builder("BNBUSDT".to_string())
.build()
.unwrap();
match client.delete_open_orders(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn delete_order_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = DeleteOrderParams::builder("BNBUSDT".to_string(),).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"symbol":"LTCBTC","origClientOrderId":"myOrder1","orderId":4,"orderListId":-1,"clientOrderId":"cancelMyOrder1","transactTime":1684804350068,"price":"2.00000000","origQty":"1.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE"}"#).unwrap();
let expected_response : models::DeleteOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::DeleteOrderResponse");
let resp = client.delete_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 delete_order_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = DeleteOrderParams::builder("BNBUSDT".to_string(),).order_id(1).orig_client_order_id("orig_client_order_id_example".to_string()).new_client_order_id("new_client_order_id_example".to_string()).cancel_restrictions(DeleteOrderCancelRestrictionsEnum::OnlyNew).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"symbol":"LTCBTC","origClientOrderId":"myOrder1","orderId":4,"orderListId":-1,"clientOrderId":"cancelMyOrder1","transactTime":1684804350068,"price":"2.00000000","origQty":"1.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"BUY","selfTradePreventionMode":"NONE"}"#).unwrap();
let expected_response : models::DeleteOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::DeleteOrderResponse");
let resp = client.delete_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 delete_order_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = DeleteOrderParams::builder("BNBUSDT".to_string())
.build()
.unwrap();
match client.delete_order(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn delete_order_list_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = DeleteOrderListParams::builder("BNBUSDT".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","orders":[{"symbol":"LTCBTC","orderId":3,"clientOrderId":"TXOvglzXuaubXAaENpaRCB"},{"symbol":"LTCBTC","orderId":2,"clientOrderId":"pO9ufTiFGg3nw2fOdgeOXa"}],"orderReports":[{"symbol":"LTCBTC","origClientOrderId":"TXOvglzXuaubXAaENpaRCB","orderId":3,"orderListId":0,"clientOrderId":"unfWT8ig8i0uj6lPuYLez6","transactTime":1688005070874,"price":"3.00000000","origQty":"10.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT_MAKER","side":"SELL","selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","origClientOrderId":"pO9ufTiFGg3nw2fOdgeOXa","orderId":2,"orderListId":0,"clientOrderId":"unfWT8ig8i0uj6lPuYLez6","transactTime":1688005070874,"price":"1.00000000","origQty":"10.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"1.00000000","selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::DeleteOrderListResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::DeleteOrderListResponse");
let resp = client.delete_order_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 delete_order_list_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = DeleteOrderListParams::builder("BNBUSDT".to_string(),).order_list_id(1).list_client_order_id("list_client_order_id_example".to_string()).new_client_order_id("new_client_order_id_example".to_string()).recv_window(dec!(5000.0)).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","orders":[{"symbol":"LTCBTC","orderId":3,"clientOrderId":"TXOvglzXuaubXAaENpaRCB"},{"symbol":"LTCBTC","orderId":2,"clientOrderId":"pO9ufTiFGg3nw2fOdgeOXa"}],"orderReports":[{"symbol":"LTCBTC","origClientOrderId":"TXOvglzXuaubXAaENpaRCB","orderId":3,"orderListId":0,"clientOrderId":"unfWT8ig8i0uj6lPuYLez6","transactTime":1688005070874,"price":"3.00000000","origQty":"10.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT_MAKER","side":"SELL","selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","origClientOrderId":"pO9ufTiFGg3nw2fOdgeOXa","orderId":2,"orderListId":0,"clientOrderId":"unfWT8ig8i0uj6lPuYLez6","transactTime":1688005070874,"price":"1.00000000","origQty":"10.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"1.00000000","selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::DeleteOrderListResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::DeleteOrderListResponse");
let resp = client.delete_order_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 delete_order_list_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = DeleteOrderListParams::builder("BNBUSDT".to_string())
.build()
.unwrap();
match client.delete_order_list(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn new_order_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = NewOrderParams::builder("BNBUSDT".to_string(),NewOrderSideEnum::Buy,NewOrderTypeEnum::Market,).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"symbol":"BTCUSDT","orderId":28,"orderListId":-1,"clientOrderId":"6gCrw2kRUAF9CvJDGP16IP","transactTime":1507725176595,"price":"0.00000000","origQty":"10.00000000","executedQty":"10.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"10.00000000","status":"FILLED","timeInForce":"GTC","type":"MARKET","side":"SELL","workingTime":1507725176595,"selfTradePreventionMode":"NONE","fills":[{"price":"3995.00000000","qty":"1.00000000","commission":"3.99500000","commissionAsset":"USDT","tradeId":60},{"price":"3997.00000000","qty":"1.00000000","commission":"3.99700000","commissionAsset":"USDT","tradeId":59},{"price":"3998.00000000","qty":"2.00000000","commission":"7.99600000","commissionAsset":"USDT","tradeId":58},{"price":"3999.00000000","qty":"5.00000000","commission":"19.99500000","commissionAsset":"USDT","tradeId":57},{"price":"4000.00000000","qty":"1.00000000","commission":"4.00000000","commissionAsset":"USDT","tradeId":56},{"price":"3995.00000000","qty":"1.00000000","commission":"3.99500000","commissionAsset":"USDT","tradeId":60},{"price":"3997.00000000","qty":"1.00000000","commission":"3.99700000","commissionAsset":"USDT","tradeId":59},{"price":"3998.00000000","qty":"2.00000000","commission":"7.99600000","commissionAsset":"USDT","tradeId":58},{"price":"3999.00000000","qty":"5.00000000","commission":"19.99500000","commissionAsset":"USDT","tradeId":57},{"price":"4000.00000000","qty":"1.00000000","commission":"4.00000000","commissionAsset":"USDT","tradeId":56}]}"#).unwrap();
let expected_response : models::NewOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::NewOrderResponse");
let resp = client.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 new_order_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = NewOrderParams::builder("BNBUSDT".to_string(),NewOrderSideEnum::Buy,NewOrderTypeEnum::Market,).time_in_force(NewOrderTimeInForceEnum::Gtc).quantity(dec!(1.0)).quote_order_qty(dec!(1.0)).price(dec!(400.0)).new_client_order_id("new_client_order_id_example".to_string()).strategy_id(1).strategy_type(1).stop_price(dec!(1.0)).trailing_delta(1).iceberg_qty(dec!(1.0)).new_order_resp_type(NewOrderNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(NewOrderSelfTradePreventionModeEnum::None).peg_price_type(NewOrderPegPriceTypeEnum::PrimaryPeg).peg_offset_value(1).peg_offset_type(NewOrderPegOffsetTypeEnum::PriceLevel).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"symbol":"BTCUSDT","orderId":28,"orderListId":-1,"clientOrderId":"6gCrw2kRUAF9CvJDGP16IP","transactTime":1507725176595,"price":"0.00000000","origQty":"10.00000000","executedQty":"10.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"10.00000000","status":"FILLED","timeInForce":"GTC","type":"MARKET","side":"SELL","workingTime":1507725176595,"selfTradePreventionMode":"NONE","fills":[{"price":"3995.00000000","qty":"1.00000000","commission":"3.99500000","commissionAsset":"USDT","tradeId":60},{"price":"3997.00000000","qty":"1.00000000","commission":"3.99700000","commissionAsset":"USDT","tradeId":59},{"price":"3998.00000000","qty":"2.00000000","commission":"7.99600000","commissionAsset":"USDT","tradeId":58},{"price":"3999.00000000","qty":"5.00000000","commission":"19.99500000","commissionAsset":"USDT","tradeId":57},{"price":"4000.00000000","qty":"1.00000000","commission":"4.00000000","commissionAsset":"USDT","tradeId":56},{"price":"3995.00000000","qty":"1.00000000","commission":"3.99500000","commissionAsset":"USDT","tradeId":60},{"price":"3997.00000000","qty":"1.00000000","commission":"3.99700000","commissionAsset":"USDT","tradeId":59},{"price":"3998.00000000","qty":"2.00000000","commission":"7.99600000","commissionAsset":"USDT","tradeId":58},{"price":"3999.00000000","qty":"5.00000000","commission":"19.99500000","commissionAsset":"USDT","tradeId":57},{"price":"4000.00000000","qty":"1.00000000","commission":"4.00000000","commissionAsset":"USDT","tradeId":56}]}"#).unwrap();
let expected_response : models::NewOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::NewOrderResponse");
let resp = client.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 new_order_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = NewOrderParams::builder(
"BNBUSDT".to_string(),
NewOrderSideEnum::Buy,
NewOrderTypeEnum::Market,
)
.build()
.unwrap();
match client.new_order(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn order_amend_keep_priority_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderAmendKeepPriorityParams::builder("BNBUSDT".to_string(),dec!(1.0),).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"transactTime":1741669661670,"executionId":22,"amendedOrder":{"symbol":"BTCUSDT","orderId":9,"orderListId":1,"origClientOrderId":"W0fJ9fiLKHOJutovPK3oJp","clientOrderId":"UQ1Np3bmQ71jJzsSDW9Vpi","price":"0.00000000","qty":"4.00000000","executedQty":"0.00000000","preventedQty":"0.00000000","quoteOrderQty":"0.00000000","cumulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"MARKET","side":"BUY","workingTime":1741926410242,"selfTradePreventionMode":"NONE"},"listStatus":{"orderListId":1,"contingencyType":"OTO","listOrderStatus":"EXECUTING","listClientOrderId":"AT7FTxZXylVSwRoZs52mt3","symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":9,"clientOrderId":"UQ1Np3bmQ71jJzsSDW9Vpi"},{"symbol":"BTCUSDT","orderId":8,"clientOrderId":"GkwwHZUUbFtZOoH1YsZk9Q"},{"symbol":"BTCUSDT","orderId":9,"clientOrderId":"UQ1Np3bmQ71jJzsSDW9Vpi"},{"symbol":"BTCUSDT","orderId":8,"clientOrderId":"GkwwHZUUbFtZOoH1YsZk9Q"}]}}"#).unwrap();
let expected_response : models::OrderAmendKeepPriorityResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderAmendKeepPriorityResponse");
let resp = client.order_amend_keep_priority(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 order_amend_keep_priority_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderAmendKeepPriorityParams::builder("BNBUSDT".to_string(),dec!(1.0),).order_id(1).orig_client_order_id("orig_client_order_id_example".to_string()).new_client_order_id("new_client_order_id_example".to_string()).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"transactTime":1741669661670,"executionId":22,"amendedOrder":{"symbol":"BTCUSDT","orderId":9,"orderListId":1,"origClientOrderId":"W0fJ9fiLKHOJutovPK3oJp","clientOrderId":"UQ1Np3bmQ71jJzsSDW9Vpi","price":"0.00000000","qty":"4.00000000","executedQty":"0.00000000","preventedQty":"0.00000000","quoteOrderQty":"0.00000000","cumulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"MARKET","side":"BUY","workingTime":1741926410242,"selfTradePreventionMode":"NONE"},"listStatus":{"orderListId":1,"contingencyType":"OTO","listOrderStatus":"EXECUTING","listClientOrderId":"AT7FTxZXylVSwRoZs52mt3","symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":9,"clientOrderId":"UQ1Np3bmQ71jJzsSDW9Vpi"},{"symbol":"BTCUSDT","orderId":8,"clientOrderId":"GkwwHZUUbFtZOoH1YsZk9Q"},{"symbol":"BTCUSDT","orderId":9,"clientOrderId":"UQ1Np3bmQ71jJzsSDW9Vpi"},{"symbol":"BTCUSDT","orderId":8,"clientOrderId":"GkwwHZUUbFtZOoH1YsZk9Q"}]}}"#).unwrap();
let expected_response : models::OrderAmendKeepPriorityResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderAmendKeepPriorityResponse");
let resp = client.order_amend_keep_priority(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 order_amend_keep_priority_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = OrderAmendKeepPriorityParams::builder("BNBUSDT".to_string(), dec!(1.0))
.build()
.unwrap();
match client.order_amend_keep_priority(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn order_cancel_replace_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderCancelReplaceParams::builder("BNBUSDT".to_string(),OrderCancelReplaceSideEnum::Buy,OrderCancelReplaceTypeEnum::Market,OrderCancelReplaceCancelReplaceModeEnum::StopOnFailure,).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"cancelResult":"SUCCESS","newOrderResult":"SUCCESS","cancelResponse":{"symbol":"BTCUSDT","origClientOrderId":"DnLo3vTAQcjha43lAZhZ0y","orderId":9,"orderListId":-1,"clientOrderId":"osxN3JXAtJvKvCqGeMWMVR","transactTime":1684804350068,"price":"0.01000000","origQty":"0.000100","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"SELL","selfTradePreventionMode":"NONE"},"newOrderResponse":{"symbol":"BTCUSDT","orderId":10,"orderListId":-1,"clientOrderId":"wOceeeOzNORyLiQfw7jd8S","transactTime":1652928801803,"price":"0.02000000","origQty":"0.040000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1669277163808,"fills":[],"selfTradePreventionMode":"NONE"},"code":-2021,"msg":"Order cancel-replace partially failed.","data":{"cancelResult":"SUCCESS","newOrderResult":"FAILURE","cancelResponse":{"code":-2011,"msg":"Unknown order sent.","symbol":"LTCBNB","origClientOrderId":"GKt5zzfOxRDSQLveDYCTkc","orderId":64,"orderListId":-1,"clientOrderId":"loehOJF3FjoreUBDmv739R","transactTime":1715779007228,"price":"1.00","origQty":"10.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"SELL","selfTradePreventionMode":"NONE"},"newOrderResponse":{"code":-1015,"msg":"Too many new orders; current limit is 1 orders per 10 SECOND.","symbol":"BTCUSDT","orderId":11,"orderListId":-1,"clientOrderId":"pfojJMg6IMNDKuJqDxvoxN","transactTime":1648540168818}}}"#).unwrap();
let expected_response : models::OrderCancelReplaceResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderCancelReplaceResponse");
let resp = client.order_cancel_replace(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 order_cancel_replace_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderCancelReplaceParams::builder("BNBUSDT".to_string(),OrderCancelReplaceSideEnum::Buy,OrderCancelReplaceTypeEnum::Market,OrderCancelReplaceCancelReplaceModeEnum::StopOnFailure,).time_in_force(OrderCancelReplaceTimeInForceEnum::Gtc).quantity(dec!(1.0)).quote_order_qty(dec!(1.0)).price(dec!(400.0)).cancel_new_client_order_id("cancel_new_client_order_id_example".to_string()).cancel_orig_client_order_id("cancel_orig_client_order_id_example".to_string()).cancel_order_id(1).new_client_order_id("new_client_order_id_example".to_string()).strategy_id(1).strategy_type(1).stop_price(dec!(1.0)).trailing_delta(1).iceberg_qty(dec!(1.0)).new_order_resp_type(OrderCancelReplaceNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(OrderCancelReplaceSelfTradePreventionModeEnum::None).cancel_restrictions(OrderCancelReplaceCancelRestrictionsEnum::OnlyNew).order_rate_limit_exceeded_mode(OrderCancelReplaceOrderRateLimitExceededModeEnum::DoNothing).peg_price_type(OrderCancelReplacePegPriceTypeEnum::PrimaryPeg).peg_offset_value(1).peg_offset_type(OrderCancelReplacePegOffsetTypeEnum::PriceLevel).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"cancelResult":"SUCCESS","newOrderResult":"SUCCESS","cancelResponse":{"symbol":"BTCUSDT","origClientOrderId":"DnLo3vTAQcjha43lAZhZ0y","orderId":9,"orderListId":-1,"clientOrderId":"osxN3JXAtJvKvCqGeMWMVR","transactTime":1684804350068,"price":"0.01000000","origQty":"0.000100","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"SELL","selfTradePreventionMode":"NONE"},"newOrderResponse":{"symbol":"BTCUSDT","orderId":10,"orderListId":-1,"clientOrderId":"wOceeeOzNORyLiQfw7jd8S","transactTime":1652928801803,"price":"0.02000000","origQty":"0.040000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1669277163808,"fills":[],"selfTradePreventionMode":"NONE"},"code":-2021,"msg":"Order cancel-replace partially failed.","data":{"cancelResult":"SUCCESS","newOrderResult":"FAILURE","cancelResponse":{"code":-2011,"msg":"Unknown order sent.","symbol":"LTCBNB","origClientOrderId":"GKt5zzfOxRDSQLveDYCTkc","orderId":64,"orderListId":-1,"clientOrderId":"loehOJF3FjoreUBDmv739R","transactTime":1715779007228,"price":"1.00","origQty":"10.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00","status":"CANCELED","timeInForce":"GTC","type":"LIMIT","side":"SELL","selfTradePreventionMode":"NONE"},"newOrderResponse":{"code":-1015,"msg":"Too many new orders; current limit is 1 orders per 10 SECOND.","symbol":"BTCUSDT","orderId":11,"orderListId":-1,"clientOrderId":"pfojJMg6IMNDKuJqDxvoxN","transactTime":1648540168818}}}"#).unwrap();
let expected_response : models::OrderCancelReplaceResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderCancelReplaceResponse");
let resp = client.order_cancel_replace(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 order_cancel_replace_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = OrderCancelReplaceParams::builder(
"BNBUSDT".to_string(),
OrderCancelReplaceSideEnum::Buy,
OrderCancelReplaceTypeEnum::Market,
OrderCancelReplaceCancelReplaceModeEnum::StopOnFailure,
)
.build()
.unwrap();
match client.order_cancel_replace(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn order_list_oco_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderListOcoParams::builder("BNBUSDT".to_string(),OrderListOcoSideEnum::Buy,dec!(1.0),OrderListOcoAboveTypeEnum::StopLossLimit,OrderListOcoBelowTypeEnum::StopLoss,).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"orderListId":1,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"lH1YDkuQKWiXVXHPSKYEIp","transactionTime":1710485608839,"symbol":"LTCBTC","orders":[{"symbol":"LTCBTC","orderId":11,"clientOrderId":"NuMp0nVYnciDiFmVqfpBqK"},{"symbol":"LTCBTC","orderId":10,"clientOrderId":"44nZvqpemY7sVYgPYbvPih"}],"orderReports":[{"symbol":"LTCBTC","orderId":11,"orderListId":1,"clientOrderId":"NuMp0nVYnciDiFmVqfpBqK","transactTime":1710485608839,"price":"3.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"SELL","workingTime":1710485608839,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":10,"orderListId":1,"clientOrderId":"44nZvqpemY7sVYgPYbvPih","transactTime":1710485608839,"price":"1.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"1.00000000","workingTime":-1,"icebergQty":"1.00000000","selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderListOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderListOcoResponse");
let resp = client.order_list_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 order_list_oco_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderListOcoParams::builder("BNBUSDT".to_string(),OrderListOcoSideEnum::Buy,dec!(1.0),OrderListOcoAboveTypeEnum::StopLossLimit,OrderListOcoBelowTypeEnum::StopLoss,).list_client_order_id("list_client_order_id_example".to_string()).above_client_order_id("above_client_order_id_example".to_string()).above_iceberg_qty(1).above_price(dec!(1.0)).above_stop_price(dec!(1.0)).above_trailing_delta(1).above_time_in_force(OrderListOcoAboveTimeInForceEnum::Gtc).above_strategy_id(1).above_strategy_type(1).above_peg_price_type(OrderListOcoAbovePegPriceTypeEnum::PrimaryPeg).above_peg_offset_type(OrderListOcoAbovePegOffsetTypeEnum::PriceLevel).above_peg_offset_value(1).below_client_order_id("below_client_order_id_example".to_string()).below_iceberg_qty(1).below_price(dec!(1.0)).below_stop_price(dec!(1.0)).below_trailing_delta(1).below_time_in_force(OrderListOcoBelowTimeInForceEnum::Gtc).below_strategy_id(1).below_strategy_type(1).below_peg_price_type(OrderListOcoBelowPegPriceTypeEnum::PrimaryPeg).below_peg_offset_type(OrderListOcoBelowPegOffsetTypeEnum::PriceLevel).below_peg_offset_value(1).new_order_resp_type(OrderListOcoNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(OrderListOcoSelfTradePreventionModeEnum::None).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"orderListId":1,"contingencyType":"OCO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"lH1YDkuQKWiXVXHPSKYEIp","transactionTime":1710485608839,"symbol":"LTCBTC","orders":[{"symbol":"LTCBTC","orderId":11,"clientOrderId":"NuMp0nVYnciDiFmVqfpBqK"},{"symbol":"LTCBTC","orderId":10,"clientOrderId":"44nZvqpemY7sVYgPYbvPih"}],"orderReports":[{"symbol":"LTCBTC","orderId":11,"orderListId":1,"clientOrderId":"NuMp0nVYnciDiFmVqfpBqK","transactTime":1710485608839,"price":"3.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"SELL","workingTime":1710485608839,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":10,"orderListId":1,"clientOrderId":"44nZvqpemY7sVYgPYbvPih","transactTime":1710485608839,"price":"1.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"1.00000000","workingTime":-1,"icebergQty":"1.00000000","selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderListOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderListOcoResponse");
let resp = client.order_list_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 order_list_oco_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = OrderListOcoParams::builder(
"BNBUSDT".to_string(),
OrderListOcoSideEnum::Buy,
dec!(1.0),
OrderListOcoAboveTypeEnum::StopLossLimit,
OrderListOcoBelowTypeEnum::StopLoss,
)
.build()
.unwrap();
match client.order_list_oco(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn order_list_opo_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderListOpoParams::builder("BNBUSDT".to_string(),OrderListOpoWorkingTypeEnum::Limit,OrderListOpoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),OrderListOpoPendingTypeEnum::Limit,OrderListOpoPendingSideEnum::Buy,).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"orderListId":0,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"H94qCqO27P74OEiO4X8HOG","transactionTime":1762998011671,"symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":3,"clientOrderId":"2ZJCY0IjOhuYIMLGN8kU8S"},{"symbol":"BTCUSDT","orderId":2,"clientOrderId":"JX6xfdjo0wysiGumfHNmPu"}],"orderReports":[{"symbol":"BTCUSDT","orderId":3,"orderListId":0,"clientOrderId":"2ZJCY0IjOhuYIMLGN8kU8S","transactTime":1762998011671,"price":"0.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"MARKET","side":"SELL","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","orderId":2,"orderListId":0,"clientOrderId":"JX6xfdjo0wysiGumfHNmPu","transactTime":1762998011671,"price":"102264.00000000","origQty":"0.00060000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1762998011671,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderListOpoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderListOpoResponse");
let resp = client.order_list_opo(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 order_list_opo_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderListOpoParams::builder("BNBUSDT".to_string(),OrderListOpoWorkingTypeEnum::Limit,OrderListOpoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),OrderListOpoPendingTypeEnum::Limit,OrderListOpoPendingSideEnum::Buy,).list_client_order_id("list_client_order_id_example".to_string()).new_order_resp_type(OrderListOpoNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(OrderListOpoSelfTradePreventionModeEnum::None).working_client_order_id("working_client_order_id_example".to_string()).working_iceberg_qty(dec!(1.0)).working_time_in_force(OrderListOpoWorkingTimeInForceEnum::Gtc).working_strategy_id(1).working_strategy_type(1).working_peg_price_type(OrderListOpoWorkingPegPriceTypeEnum::PrimaryPeg).working_peg_offset_type(OrderListOpoWorkingPegOffsetTypeEnum::PriceLevel).working_peg_offset_value(1).pending_client_order_id("pending_client_order_id_example".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(OrderListOpoPendingTimeInForceEnum::Gtc).pending_strategy_id(1).pending_strategy_type(1).pending_peg_price_type(OrderListOpoPendingPegPriceTypeEnum::PrimaryPeg).pending_peg_offset_type(OrderListOpoPendingPegOffsetTypeEnum::PriceLevel).pending_peg_offset_value(1).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"orderListId":0,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"H94qCqO27P74OEiO4X8HOG","transactionTime":1762998011671,"symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":3,"clientOrderId":"2ZJCY0IjOhuYIMLGN8kU8S"},{"symbol":"BTCUSDT","orderId":2,"clientOrderId":"JX6xfdjo0wysiGumfHNmPu"}],"orderReports":[{"symbol":"BTCUSDT","orderId":3,"orderListId":0,"clientOrderId":"2ZJCY0IjOhuYIMLGN8kU8S","transactTime":1762998011671,"price":"0.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"MARKET","side":"SELL","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","orderId":2,"orderListId":0,"clientOrderId":"JX6xfdjo0wysiGumfHNmPu","transactTime":1762998011671,"price":"102264.00000000","origQty":"0.00060000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1762998011671,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderListOpoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderListOpoResponse");
let resp = client.order_list_opo(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 order_list_opo_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = OrderListOpoParams::builder(
"BNBUSDT".to_string(),
OrderListOpoWorkingTypeEnum::Limit,
OrderListOpoWorkingSideEnum::Buy,
dec!(1.0),
dec!(1.0),
OrderListOpoPendingTypeEnum::Limit,
OrderListOpoPendingSideEnum::Buy,
)
.build()
.unwrap();
match client.order_list_opo(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn order_list_opoco_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderListOpocoParams::builder("BNBUSDT".to_string(),OrderListOpocoWorkingTypeEnum::Limit,OrderListOpocoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),OrderListOpocoPendingSideEnum::Buy,OrderListOpocoPendingAboveTypeEnum::StopLossLimit,).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"orderListId":2,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"bcedxMpQG6nFrZUPQyshoL","transactionTime":1763000506354,"symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":11,"clientOrderId":"yINkaXSJeoi3bU5vWMY8Z8"},{"symbol":"BTCUSDT","orderId":10,"clientOrderId":"mfif39yPTHsB3C0FIXznR2"},{"symbol":"BTCUSDT","orderId":9,"clientOrderId":"OLSBhMWaIlLSzZ9Zm7fnKB"}],"orderReports":[{"symbol":"BTCUSDT","orderId":11,"orderListId":2,"clientOrderId":"yINkaXSJeoi3bU5vWMY8Z8","transactTime":1763000506354,"price":"104261.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"SELL","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","orderId":10,"orderListId":2,"clientOrderId":"mfif39yPTHsB3C0FIXznR2","transactTime":1763000506354,"price":"101613.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"10100.00000000","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","orderId":9,"orderListId":2,"clientOrderId":"OLSBhMWaIlLSzZ9Zm7fnKB","transactTime":1763000506354,"price":"102496.00000000","origQty":"0.00170000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1763000506354,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderListOpocoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderListOpocoResponse");
let resp = client.order_list_opoco(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 order_list_opoco_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderListOpocoParams::builder("BNBUSDT".to_string(),OrderListOpocoWorkingTypeEnum::Limit,OrderListOpocoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),OrderListOpocoPendingSideEnum::Buy,OrderListOpocoPendingAboveTypeEnum::StopLossLimit,).list_client_order_id("list_client_order_id_example".to_string()).new_order_resp_type(OrderListOpocoNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(OrderListOpocoSelfTradePreventionModeEnum::None).working_client_order_id("working_client_order_id_example".to_string()).working_iceberg_qty(dec!(1.0)).working_time_in_force(OrderListOpocoWorkingTimeInForceEnum::Gtc).working_strategy_id(1).working_strategy_type(1).working_peg_price_type(OrderListOpocoWorkingPegPriceTypeEnum::PrimaryPeg).working_peg_offset_type(OrderListOpocoWorkingPegOffsetTypeEnum::PriceLevel).working_peg_offset_value(1).pending_above_client_order_id("pending_above_client_order_id_example".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(OrderListOpocoPendingAboveTimeInForceEnum::Gtc).pending_above_strategy_id(1).pending_above_strategy_type(1).pending_above_peg_price_type(OrderListOpocoPendingAbovePegPriceTypeEnum::PrimaryPeg).pending_above_peg_offset_type(OrderListOpocoPendingAbovePegOffsetTypeEnum::PriceLevel).pending_above_peg_offset_value(1).pending_below_type(OrderListOpocoPendingBelowTypeEnum::StopLoss).pending_below_client_order_id("pending_below_client_order_id_example".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(OrderListOpocoPendingBelowTimeInForceEnum::Gtc).pending_below_strategy_id(1).pending_below_strategy_type(1).pending_below_peg_price_type(OrderListOpocoPendingBelowPegPriceTypeEnum::PrimaryPeg).pending_below_peg_offset_type(OrderListOpocoPendingBelowPegOffsetTypeEnum::PriceLevel).pending_below_peg_offset_value(1).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"orderListId":2,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"bcedxMpQG6nFrZUPQyshoL","transactionTime":1763000506354,"symbol":"BTCUSDT","orders":[{"symbol":"BTCUSDT","orderId":11,"clientOrderId":"yINkaXSJeoi3bU5vWMY8Z8"},{"symbol":"BTCUSDT","orderId":10,"clientOrderId":"mfif39yPTHsB3C0FIXznR2"},{"symbol":"BTCUSDT","orderId":9,"clientOrderId":"OLSBhMWaIlLSzZ9Zm7fnKB"}],"orderReports":[{"symbol":"BTCUSDT","orderId":11,"orderListId":2,"clientOrderId":"yINkaXSJeoi3bU5vWMY8Z8","transactTime":1763000506354,"price":"104261.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"SELL","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","orderId":10,"orderListId":2,"clientOrderId":"mfif39yPTHsB3C0FIXznR2","transactTime":1763000506354,"price":"101613.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"STOP_LOSS_LIMIT","side":"SELL","stopPrice":"10100.00000000","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"BTCUSDT","orderId":9,"orderListId":2,"clientOrderId":"OLSBhMWaIlLSzZ9Zm7fnKB","transactTime":1763000506354,"price":"102496.00000000","origQty":"0.00170000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1763000506354,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderListOpocoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderListOpocoResponse");
let resp = client.order_list_opoco(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 order_list_opoco_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = OrderListOpocoParams::builder(
"BNBUSDT".to_string(),
OrderListOpocoWorkingTypeEnum::Limit,
OrderListOpocoWorkingSideEnum::Buy,
dec!(1.0),
dec!(1.0),
OrderListOpocoPendingSideEnum::Buy,
OrderListOpocoPendingAboveTypeEnum::StopLossLimit,
)
.build()
.unwrap();
match client.order_list_opoco(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn order_list_oto_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderListOtoParams::builder("BNBUSDT".to_string(),OrderListOtoWorkingTypeEnum::Limit,OrderListOtoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),OrderListOtoPendingTypeEnum::Limit,OrderListOtoPendingSideEnum::Buy,dec!(1.0),).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"orderListId":0,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"yl2ERtcar1o25zcWtqVBTC","transactionTime":1712289389158,"symbol":"LTCBTC","orders":[{"symbol":"LTCBTC","orderId":5,"clientOrderId":"arLFo0zGJVDE69cvGBaU0d"},{"symbol":"LTCBTC","orderId":4,"clientOrderId":"Bq17mn9fP6vyCn75Jw1xya"}],"orderReports":[{"symbol":"LTCBTC","orderId":5,"orderListId":0,"clientOrderId":"arLFo0zGJVDE69cvGBaU0d","transactTime":1712289389158,"price":"0.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"MARKET","side":"BUY","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":4,"orderListId":0,"clientOrderId":"Bq17mn9fP6vyCn75Jw1xya","transactTime":1712289389158,"price":"1.00000000","origQty":"1.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","workingTime":1712289389158,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderListOtoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderListOtoResponse");
let resp = client.order_list_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 order_list_oto_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderListOtoParams::builder("BNBUSDT".to_string(),OrderListOtoWorkingTypeEnum::Limit,OrderListOtoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),OrderListOtoPendingTypeEnum::Limit,OrderListOtoPendingSideEnum::Buy,dec!(1.0),).list_client_order_id("list_client_order_id_example".to_string()).new_order_resp_type(OrderListOtoNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(OrderListOtoSelfTradePreventionModeEnum::None).working_client_order_id("working_client_order_id_example".to_string()).working_iceberg_qty(dec!(1.0)).working_time_in_force(OrderListOtoWorkingTimeInForceEnum::Gtc).working_strategy_id(1).working_strategy_type(1).working_peg_price_type(OrderListOtoWorkingPegPriceTypeEnum::PrimaryPeg).working_peg_offset_type(OrderListOtoWorkingPegOffsetTypeEnum::PriceLevel).working_peg_offset_value(1).pending_client_order_id("pending_client_order_id_example".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(OrderListOtoPendingTimeInForceEnum::Gtc).pending_strategy_id(1).pending_strategy_type(1).pending_peg_price_type(OrderListOtoPendingPegPriceTypeEnum::PrimaryPeg).pending_peg_offset_type(OrderListOtoPendingPegOffsetTypeEnum::PriceLevel).pending_peg_offset_value(1).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"orderListId":0,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"yl2ERtcar1o25zcWtqVBTC","transactionTime":1712289389158,"symbol":"LTCBTC","orders":[{"symbol":"LTCBTC","orderId":5,"clientOrderId":"arLFo0zGJVDE69cvGBaU0d"},{"symbol":"LTCBTC","orderId":4,"clientOrderId":"Bq17mn9fP6vyCn75Jw1xya"}],"orderReports":[{"symbol":"LTCBTC","orderId":5,"orderListId":0,"clientOrderId":"arLFo0zGJVDE69cvGBaU0d","transactTime":1712289389158,"price":"0.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"MARKET","side":"BUY","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":4,"orderListId":0,"clientOrderId":"Bq17mn9fP6vyCn75Jw1xya","transactTime":1712289389158,"price":"1.00000000","origQty":"1.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","workingTime":1712289389158,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderListOtoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderListOtoResponse");
let resp = client.order_list_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 order_list_oto_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = OrderListOtoParams::builder(
"BNBUSDT".to_string(),
OrderListOtoWorkingTypeEnum::Limit,
OrderListOtoWorkingSideEnum::Buy,
dec!(1.0),
dec!(1.0),
OrderListOtoPendingTypeEnum::Limit,
OrderListOtoPendingSideEnum::Buy,
dec!(1.0),
)
.build()
.unwrap();
match client.order_list_oto(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn order_list_otoco_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderListOtocoParams::builder("BNBUSDT".to_string(),OrderListOtocoWorkingTypeEnum::Limit,OrderListOtocoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),OrderListOtocoPendingSideEnum::Buy,dec!(1.0),OrderListOtocoPendingAboveTypeEnum::StopLossLimit,).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"orderListId":1,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"RumwQpBaDctlUu5jyG5rs0","transactionTime":1712291372842,"symbol":"LTCBTC","orders":[{"symbol":"LTCBTC","orderId":8,"clientOrderId":"r4JMv9cwAYYUwwBZfbussx"},{"symbol":"LTCBTC","orderId":7,"clientOrderId":"6pcQbFIzTXGZQ1e2MkGDq4"},{"symbol":"LTCBTC","orderId":6,"clientOrderId":"fM9Y4m23IFJVCQmIrlUmMK"}],"orderReports":[{"symbol":"LTCBTC","orderId":8,"orderListId":1,"clientOrderId":"r4JMv9cwAYYUwwBZfbussx","transactTime":1712291372842,"price":"3.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"BUY","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":7,"orderListId":1,"clientOrderId":"6pcQbFIzTXGZQ1e2MkGDq4","transactTime":1712291372842,"price":"1.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"IOC","type":"STOP_LOSS_LIMIT","side":"BUY","stopPrice":"6.00000000","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":6,"orderListId":1,"clientOrderId":"fM9Y4m23IFJVCQmIrlUmMK","transactTime":1712291372842,"price":"1.00000000","origQty":"1.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","workingTime":1712291372842,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderListOtocoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderListOtocoResponse");
let resp = client.order_list_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 order_list_otoco_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderListOtocoParams::builder("BNBUSDT".to_string(),OrderListOtocoWorkingTypeEnum::Limit,OrderListOtocoWorkingSideEnum::Buy,dec!(1.0),dec!(1.0),OrderListOtocoPendingSideEnum::Buy,dec!(1.0),OrderListOtocoPendingAboveTypeEnum::StopLossLimit,).list_client_order_id("list_client_order_id_example".to_string()).new_order_resp_type(OrderListOtocoNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(OrderListOtocoSelfTradePreventionModeEnum::None).working_client_order_id("working_client_order_id_example".to_string()).working_iceberg_qty(dec!(1.0)).working_time_in_force(OrderListOtocoWorkingTimeInForceEnum::Gtc).working_strategy_id(1).working_strategy_type(1).working_peg_price_type(OrderListOtocoWorkingPegPriceTypeEnum::PrimaryPeg).working_peg_offset_type(OrderListOtocoWorkingPegOffsetTypeEnum::PriceLevel).working_peg_offset_value(1).pending_above_client_order_id("pending_above_client_order_id_example".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(OrderListOtocoPendingAboveTimeInForceEnum::Gtc).pending_above_strategy_id(1).pending_above_strategy_type(1).pending_above_peg_price_type(OrderListOtocoPendingAbovePegPriceTypeEnum::PrimaryPeg).pending_above_peg_offset_type(OrderListOtocoPendingAbovePegOffsetTypeEnum::PriceLevel).pending_above_peg_offset_value(1).pending_below_type(OrderListOtocoPendingBelowTypeEnum::StopLoss).pending_below_client_order_id("pending_below_client_order_id_example".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(OrderListOtocoPendingBelowTimeInForceEnum::Gtc).pending_below_strategy_id(1).pending_below_strategy_type(1).pending_below_peg_price_type(OrderListOtocoPendingBelowPegPriceTypeEnum::PrimaryPeg).pending_below_peg_offset_type(OrderListOtocoPendingBelowPegOffsetTypeEnum::PriceLevel).pending_below_peg_offset_value(1).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"orderListId":1,"contingencyType":"OTO","listStatusType":"EXEC_STARTED","listOrderStatus":"EXECUTING","listClientOrderId":"RumwQpBaDctlUu5jyG5rs0","transactionTime":1712291372842,"symbol":"LTCBTC","orders":[{"symbol":"LTCBTC","orderId":8,"clientOrderId":"r4JMv9cwAYYUwwBZfbussx"},{"symbol":"LTCBTC","orderId":7,"clientOrderId":"6pcQbFIzTXGZQ1e2MkGDq4"},{"symbol":"LTCBTC","orderId":6,"clientOrderId":"fM9Y4m23IFJVCQmIrlUmMK"}],"orderReports":[{"symbol":"LTCBTC","orderId":8,"orderListId":1,"clientOrderId":"r4JMv9cwAYYUwwBZfbussx","transactTime":1712291372842,"price":"3.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"BUY","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":7,"orderListId":1,"clientOrderId":"6pcQbFIzTXGZQ1e2MkGDq4","transactTime":1712291372842,"price":"1.00000000","origQty":"5.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"PENDING_NEW","timeInForce":"IOC","type":"STOP_LOSS_LIMIT","side":"BUY","stopPrice":"6.00000000","workingTime":-1,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":6,"orderListId":1,"clientOrderId":"fM9Y4m23IFJVCQmIrlUmMK","transactTime":1712291372842,"price":"1.00000000","origQty":"1.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","workingTime":1712291372842,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderListOtocoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderListOtocoResponse");
let resp = client.order_list_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 order_list_otoco_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = OrderListOtocoParams::builder(
"BNBUSDT".to_string(),
OrderListOtocoWorkingTypeEnum::Limit,
OrderListOtocoWorkingSideEnum::Buy,
dec!(1.0),
dec!(1.0),
OrderListOtocoPendingSideEnum::Buy,
dec!(1.0),
OrderListOtocoPendingAboveTypeEnum::StopLossLimit,
)
.build()
.unwrap();
match client.order_list_otoco(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn order_oco_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderOcoParams::builder("BNBUSDT".to_string(),OrderOcoSideEnum::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","orders":[{"symbol":"LTCBTC","orderId":3,"clientOrderId":"xTXKaGYd4bluPVp78IVRvl"},{"symbol":"LTCBTC","orderId":2,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos"}],"orderReports":[{"symbol":"LTCBTC","orderId":3,"orderListId":0,"clientOrderId":"xTXKaGYd4bluPVp78IVRvl","transactTime":1563417480525,"price":"0.036435","origQty":"0.624363","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"BUY","workingTime":1563417480525,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":2,"orderListId":0,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos","transactTime":1563417480525,"price":"0.000000","origQty":"0.624363","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"NEW","timeInForce":"GTC","type":"STOP_LOSS","side":"BUY","stopPrice":"0.960664","workingTime":-1,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderOcoResponse");
let resp = client.order_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 order_oco_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderOcoParams::builder("BNBUSDT".to_string(),OrderOcoSideEnum::Buy,dec!(1.0),dec!(1.0),dec!(1.0),).list_client_order_id("list_client_order_id_example".to_string()).limit_client_order_id("limit_client_order_id_example".to_string()).limit_strategy_id(1).limit_strategy_type(1).limit_iceberg_qty(dec!(1.0)).trailing_delta(1).stop_client_order_id("stop_client_order_id_example".to_string()).stop_strategy_id(1).stop_strategy_type(1).stop_limit_price(dec!(1.0)).stop_iceberg_qty(dec!(1.0)).stop_limit_time_in_force(OrderOcoStopLimitTimeInForceEnum::Gtc).new_order_resp_type(OrderOcoNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(OrderOcoSelfTradePreventionModeEnum::None).recv_window(dec!(5000.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","orders":[{"symbol":"LTCBTC","orderId":3,"clientOrderId":"xTXKaGYd4bluPVp78IVRvl"},{"symbol":"LTCBTC","orderId":2,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos"}],"orderReports":[{"symbol":"LTCBTC","orderId":3,"orderListId":0,"clientOrderId":"xTXKaGYd4bluPVp78IVRvl","transactTime":1563417480525,"price":"0.036435","origQty":"0.624363","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"NEW","timeInForce":"GTC","type":"LIMIT_MAKER","side":"BUY","workingTime":1563417480525,"selfTradePreventionMode":"NONE"},{"symbol":"LTCBTC","orderId":2,"orderListId":0,"clientOrderId":"Kk7sqHb9J6mJWTMDVW7Vos","transactTime":1563417480525,"price":"0.000000","origQty":"0.624363","executedQty":"0.000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"0.000000","status":"NEW","timeInForce":"GTC","type":"STOP_LOSS","side":"BUY","stopPrice":"0.960664","workingTime":-1,"selfTradePreventionMode":"NONE"}]}"#).unwrap();
let expected_response : models::OrderOcoResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderOcoResponse");
let resp = client.order_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 order_oco_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = OrderOcoParams::builder(
"BNBUSDT".to_string(),
OrderOcoSideEnum::Buy,
dec!(1.0),
dec!(1.0),
dec!(1.0),
)
.build()
.unwrap();
match client.order_oco(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn order_test_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderTestParams::builder("BNBUSDT".to_string(),OrderTestSideEnum::Buy,OrderTestTypeEnum::Market,).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"standardCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"specialCommissionForOrder":{"maker":"0.05000000","taker":"0.06000000"},"taxCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"discount":{"enabledForAccount":true,"enabledForSymbol":true,"discountAsset":"BNB","discount":"0.25000000"}}"#).unwrap();
let expected_response : models::OrderTestResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderTestResponse");
let resp = client.order_test(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 order_test_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = OrderTestParams::builder("BNBUSDT".to_string(),OrderTestSideEnum::Buy,OrderTestTypeEnum::Market,).compute_commission_rates(false).time_in_force(OrderTestTimeInForceEnum::Gtc).quantity(dec!(1.0)).quote_order_qty(dec!(1.0)).price(dec!(400.0)).new_client_order_id("new_client_order_id_example".to_string()).strategy_id(1).strategy_type(1).stop_price(dec!(1.0)).trailing_delta(1).iceberg_qty(dec!(1.0)).new_order_resp_type(OrderTestNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(OrderTestSelfTradePreventionModeEnum::None).peg_price_type(OrderTestPegPriceTypeEnum::PrimaryPeg).peg_offset_value(1).peg_offset_type(OrderTestPegOffsetTypeEnum::PriceLevel).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"standardCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"specialCommissionForOrder":{"maker":"0.05000000","taker":"0.06000000"},"taxCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"discount":{"enabledForAccount":true,"enabledForSymbol":true,"discountAsset":"BNB","discount":"0.25000000"}}"#).unwrap();
let expected_response : models::OrderTestResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::OrderTestResponse");
let resp = client.order_test(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 order_test_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = OrderTestParams::builder(
"BNBUSDT".to_string(),
OrderTestSideEnum::Buy,
OrderTestTypeEnum::Market,
)
.build()
.unwrap();
match client.order_test(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn sor_order_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = SorOrderParams::builder("BNBUSDT".to_string(),SorOrderSideEnum::Buy,SorOrderTypeEnum::Market,dec!(1.0),).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"symbol":"BTCUSDT","orderId":2,"orderListId":-1,"clientOrderId":"sBI1KM6nNtOfj5tccZSKly","transactTime":1689149087774,"price":"31000.00000000","origQty":"0.50000000","executedQty":"0.50000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"14000.00000000","status":"FILLED","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1689149087774,"fills":[{"matchType":"ONE_PARTY_TRADE_REPORT","price":"28000.00000000","qty":"0.50000000","commission":"0.00000000","commissionAsset":"BTC","tradeId":-1,"allocId":0}],"workingFloor":"SOR","selfTradePreventionMode":"NONE","usedSor":true}"#).unwrap();
let expected_response : models::SorOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::SorOrderResponse");
let resp = client.sor_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 sor_order_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = SorOrderParams::builder("BNBUSDT".to_string(),SorOrderSideEnum::Buy,SorOrderTypeEnum::Market,dec!(1.0),).time_in_force(SorOrderTimeInForceEnum::Gtc).price(dec!(400.0)).new_client_order_id("new_client_order_id_example".to_string()).strategy_id(1).strategy_type(1).iceberg_qty(dec!(1.0)).new_order_resp_type(SorOrderNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(SorOrderSelfTradePreventionModeEnum::None).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"symbol":"BTCUSDT","orderId":2,"orderListId":-1,"clientOrderId":"sBI1KM6nNtOfj5tccZSKly","transactTime":1689149087774,"price":"31000.00000000","origQty":"0.50000000","executedQty":"0.50000000","origQuoteOrderQty":"0.000000","cummulativeQuoteQty":"14000.00000000","status":"FILLED","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1689149087774,"fills":[{"matchType":"ONE_PARTY_TRADE_REPORT","price":"28000.00000000","qty":"0.50000000","commission":"0.00000000","commissionAsset":"BTC","tradeId":-1,"allocId":0}],"workingFloor":"SOR","selfTradePreventionMode":"NONE","usedSor":true}"#).unwrap();
let expected_response : models::SorOrderResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::SorOrderResponse");
let resp = client.sor_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 sor_order_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = SorOrderParams::builder(
"BNBUSDT".to_string(),
SorOrderSideEnum::Buy,
SorOrderTypeEnum::Market,
dec!(1.0),
)
.build()
.unwrap();
match client.sor_order(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
#[test]
fn sor_order_test_required_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = SorOrderTestParams::builder("BNBUSDT".to_string(),SorOrderTestSideEnum::Buy,SorOrderTestTypeEnum::Market,dec!(1.0),).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"standardCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"taxCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"discount":{"enabledForAccount":true,"enabledForSymbol":true,"discountAsset":"BNB","discount":"0.25000000"}}"#).unwrap();
let expected_response : models::SorOrderTestResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::SorOrderTestResponse");
let resp = client.sor_order_test(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 sor_order_test_optional_params_success() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: false };
let params = SorOrderTestParams::builder("BNBUSDT".to_string(),SorOrderTestSideEnum::Buy,SorOrderTestTypeEnum::Market,dec!(1.0),).compute_commission_rates(false).time_in_force(SorOrderTestTimeInForceEnum::Gtc).price(dec!(400.0)).new_client_order_id("new_client_order_id_example".to_string()).strategy_id(1).strategy_type(1).iceberg_qty(dec!(1.0)).new_order_resp_type(SorOrderTestNewOrderRespTypeEnum::Ack).self_trade_prevention_mode(SorOrderTestSelfTradePreventionModeEnum::None).recv_window(dec!(5000.0)).build().unwrap();
let resp_json: Value = serde_json::from_str(r#"{"standardCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"taxCommissionForOrder":{"maker":"0.00000112","taker":"0.00000114"},"discount":{"enabledForAccount":true,"enabledForSymbol":true,"discountAsset":"BNB","discount":"0.25000000"}}"#).unwrap();
let expected_response : models::SorOrderTestResponse = serde_json::from_value(resp_json.clone()).expect("should parse into models::SorOrderTestResponse");
let resp = client.sor_order_test(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 sor_order_test_response_error() {
TOKIO_SHARED_RT.block_on(async {
let client = MockTradeApiClient { force_error: true };
let params = SorOrderTestParams::builder(
"BNBUSDT".to_string(),
SorOrderTestSideEnum::Buy,
SorOrderTestTypeEnum::Market,
dec!(1.0),
)
.build()
.unwrap();
match client.sor_order_test(params).await {
Ok(_) => panic!("Expected an error"),
Err(err) => {
assert_eq!(err.to_string(), "Connector client error: ResponseError");
}
}
});
}
}