diff --git a/src/futures/account.rs b/src/futures/account.rs index a91c488e..2f63abbd 100644 --- a/src/futures/account.rs +++ b/src/futures/account.rs @@ -1,7 +1,6 @@ use std::collections::BTreeMap; use std::fmt::Display; - use crate::util::{build_signed_request, uuid_futures}; use crate::errors::Result; use crate::client::Client; @@ -248,6 +247,7 @@ impl FuturesAccount { pub fn limit_buy( &self, symbol: impl Into, qty: impl Into, price: f64, time_in_force: TimeInForce, + reduce_only: Option, ) -> Result { let buy = OrderRequest { symbol: symbol.into(), @@ -256,7 +256,7 @@ impl FuturesAccount { order_type: OrderType::Limit, time_in_force: Some(time_in_force), qty: Some(qty.into()), - reduce_only: None, + reduce_only: reduce_only, price: Some(price), stop_price: None, close_position: None, @@ -278,6 +278,7 @@ impl FuturesAccount { pub fn limit_sell( &self, symbol: impl Into, qty: impl Into, price: f64, time_in_force: TimeInForce, + reduce_only : Option ) -> Result { let sell = OrderRequest { symbol: symbol.into(), @@ -286,7 +287,7 @@ impl FuturesAccount { order_type: OrderType::Limit, time_in_force: Some(time_in_force), qty: Some(qty.into()), - reduce_only: None, + reduce_only: reduce_only, price: Some(price), stop_price: None, close_position: None, @@ -613,7 +614,7 @@ impl FuturesAccount { if let Some(API::Futures(Futures::AlgoOrder)) = api_type { parameters.insert("algoType".into(), "Conditional".into()); parameters.insert("clientAlgoId".into(), "Conditional".into()); - + if let Some(client_algo_id) = order.client_algo_id { parameters.insert("clientAlgoId".into(), client_algo_id.to_string()); } diff --git a/src/futures/model.rs b/src/futures/model.rs index e6debac4..514f44d4 100644 --- a/src/futures/model.rs +++ b/src/futures/model.rs @@ -212,16 +212,16 @@ pub struct Order { pub client_order_id: String, #[serde(with = "string_or_float", default = "default_stop_price")] pub cum_qty: f64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub cum_quote: f64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub executed_qty: f64, pub order_id: u64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub avg_price: f64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub orig_qty: f64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub price: f64, pub side: String, pub reduce_only: bool, @@ -248,22 +248,22 @@ pub struct Order { #[serde(rename_all = "camelCase")] pub struct Transaction { pub client_order_id: String, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub cum_qty: f64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub cum_quote: f64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub executed_qty: f64, pub order_id: u64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub avg_price: f64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub orig_qty: f64, pub reduce_only: bool, pub side: String, pub position_side: String, pub status: String, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub stop_price: f64, pub close_position: bool, pub symbol: String, @@ -286,23 +286,23 @@ pub struct Transaction { #[serde(rename_all = "camelCase")] pub struct CanceledOrder { pub client_order_id: String, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub cum_qty: f64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub cum_quote: f64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub executed_qty: f64, pub order_id: u64, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub orig_qty: f64, pub orig_type: String, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub price: f64, pub reduce_only: bool, pub side: String, pub position_side: String, pub status: String, - #[serde(with = "string_or_float")] + #[serde(with = "string_or_float", default = "default_stop_price")] pub stop_price: f64, pub close_position: bool, pub symbol: String,