From c9903ee430974ace077dd592577392cfca370a1f Mon Sep 17 00:00:00 2001 From: Shalev David Date: Sat, 29 Nov 2025 16:10:49 +0200 Subject: [PATCH 1/8] added the debug and clone derives to PositionSide and OrderSide enums --- src/account.rs | 1 + src/futures/account.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/account.rs b/src/account.rs index 5c5bd6d2..a56c263d 100644 --- a/src/account.rs +++ b/src/account.rs @@ -65,6 +65,7 @@ impl Display for OrderType { } } +#[derive(Debug, Clone)] pub enum OrderSide { Buy, Sell, diff --git a/src/futures/account.rs b/src/futures/account.rs index 208af8c7..ef6657bf 100644 --- a/src/futures/account.rs +++ b/src/futures/account.rs @@ -40,6 +40,7 @@ impl From for String { } } +#[derive(Debug, Clone)] pub enum PositionSide { Both, Long, From 652b2b09ac3144bcfb59323bef6c3ba8beda64d9 Mon Sep 17 00:00:00 2001 From: Shalev David Date: Sat, 29 Nov 2025 16:32:11 +0200 Subject: [PATCH 2/8] added Debug, Clone, PartialEq and Hash derive to OrderType --- src/futures/account.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/futures/account.rs b/src/futures/account.rs index ef6657bf..935eff4b 100644 --- a/src/futures/account.rs +++ b/src/futures/account.rs @@ -57,6 +57,7 @@ impl Display for PositionSide { } } +#[derive(Debug, Clone, PartialEq, Hash)] pub enum OrderType { Limit, Market, From c6173173c032665146ab86bfa11f47867381f1ec Mon Sep 17 00:00:00 2001 From: Shalev David Date: Sat, 29 Nov 2025 16:37:14 +0200 Subject: [PATCH 3/8] also added the Eq derive to OrderType --- src/futures/account.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/futures/account.rs b/src/futures/account.rs index 935eff4b..b2d8adf7 100644 --- a/src/futures/account.rs +++ b/src/futures/account.rs @@ -57,7 +57,7 @@ impl Display for PositionSide { } } -#[derive(Debug, Clone, PartialEq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum OrderType { Limit, Market, From 6666ab4c20525ffcf84d25f84f8fc759a481d957 Mon Sep 17 00:00:00 2001 From: Shalev David Date: Mon, 1 Dec 2025 00:30:01 +0200 Subject: [PATCH 4/8] added gtd to futures orders --- src/futures/account.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/futures/account.rs b/src/futures/account.rs index b2d8adf7..f8413304 100644 --- a/src/futures/account.rs +++ b/src/futures/account.rs @@ -102,6 +102,7 @@ pub enum TimeInForce { IOC, FOK, GTX, + GTD, } impl Display for TimeInForce { @@ -111,6 +112,7 @@ impl Display for TimeInForce { Self::IOC => write!(f, "IOC"), Self::FOK => write!(f, "FOK"), Self::GTX => write!(f, "GTX"), + Self::GTD => write!(f, "GTD"), } } } @@ -131,6 +133,7 @@ struct OrderRequest { pub working_type: Option, pub price_protect: Option, pub new_client_order_id: Option, + pub good_till_date: Option, } pub struct CustomOrderRequest { @@ -149,6 +152,7 @@ pub struct CustomOrderRequest { pub working_type: Option, pub price_protect: Option, pub new_client_order_id: Option, + pub good_till_date: Option, } pub struct IncomeRequest { @@ -229,6 +233,7 @@ impl FuturesAccount { working_type: None, price_protect: None, new_client_order_id: None, + good_till_date: None, }; let order = self.build_order(buy, None); let request = build_signed_request(order, self.recv_window)?; @@ -256,6 +261,7 @@ impl FuturesAccount { working_type: None, price_protect: None, new_client_order_id: None, + good_till_date: None, }; let order = self.build_order(sell, None); let request = build_signed_request(order, self.recv_window)?; @@ -285,6 +291,7 @@ impl FuturesAccount { working_type: None, price_protect: None, new_client_order_id: None, + good_till_date: None, }; let order = self.build_order(buy, None); let request = build_signed_request(order, self.recv_window)?; @@ -314,6 +321,7 @@ impl FuturesAccount { working_type: None, price_protect: None, new_client_order_id: None, + good_till_date: None, }; let order = self.build_order(sell, None); let request = build_signed_request(order, self.recv_window)?; @@ -371,6 +379,7 @@ impl FuturesAccount { working_type: None, price_protect: None, new_client_order_id: None, + good_till_date: None, }; let order = self.build_order(sell, None); let request = build_signed_request(order, self.recv_window)?; @@ -400,6 +409,7 @@ impl FuturesAccount { working_type: None, price_protect: None, new_client_order_id: None, + good_till_date: None, }; let order = self.build_order(sell, None); let request = build_signed_request(order, self.recv_window)?; @@ -432,6 +442,7 @@ impl FuturesAccount { working_type: order_request.working_type, price_protect: order_request.price_protect, new_client_order_id: order_request.new_client_order_id, + good_till_date: order_request.good_till_date, }; let order = self.build_order(order, Some(request_params)); let request = build_signed_request(order, self.recv_window)?; @@ -462,6 +473,7 @@ impl FuturesAccount { working_type: order_request.working_type, price_protect: order_request.price_protect, new_client_order_id: order_request.new_client_order_id, + good_till_date: order_request.good_till_date, }; let _order = self.build_order(order, Some(request_params.clone())); // TODO : make a request string for batch orders api @@ -587,6 +599,10 @@ impl FuturesAccount { parameters.insert("newClientOrderId".into(), uuid); } + if let Some(good_till_date) = order.good_till_date { + parameters.insert("goodTillDate".into(), good_till_date.to_string()); + } + if let Some(params) = request_params { for (key, value) in params { parameters.insert(key, value.to_string()); From c5c57c984080b63e86cb1e2b486da5dd33e02e07 Mon Sep 17 00:00:00 2001 From: Shalev David Date: Mon, 1 Dec 2025 12:19:52 +0200 Subject: [PATCH 5/8] deleted the has and partial eq derive --- src/futures/account.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/futures/account.rs b/src/futures/account.rs index f8413304..08001a73 100644 --- a/src/futures/account.rs +++ b/src/futures/account.rs @@ -57,7 +57,7 @@ impl Display for PositionSide { } } -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone)] pub enum OrderType { Limit, Market, From b353929c02c619ab914cb9048384dd0b4185154d Mon Sep 17 00:00:00 2001 From: Shalev David Date: Mon, 1 Dec 2025 12:43:48 +0200 Subject: [PATCH 6/8] added some documentations --- src/futures/account.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/futures/account.rs b/src/futures/account.rs index 08001a73..8a0a2972 100644 --- a/src/futures/account.rs +++ b/src/futures/account.rs @@ -98,10 +98,15 @@ impl Display for WorkingType { #[allow(clippy::all)] pub enum TimeInForce { + /// Good Till Cancel GTC, + /// Immediate or Cancel IOC, + /// Fill or Kill FOK, + /// Good Till Crossing GTX, + /// Good Till Date GTD, } @@ -139,19 +144,33 @@ struct OrderRequest { pub struct CustomOrderRequest { pub symbol: String, pub side: OrderSide, + /// Default `BOTH` for One-way Mode ; `LONG` or `SHORT` for Hedge Mode. \ + /// It must be sent in Hedge Mode. pub position_side: Option, pub order_type: OrderType, pub time_in_force: Option, + /// Cannot be sent with `closePosition`=true(Close-All) pub qty: Option, pub reduce_only: Option, pub price: Option, + /// Used with `STOP`/`STOP_MARKET` or `TAKE_PROFIT`/`TAKE_PROFIT_MARKET` orders. pub stop_price: Option, + /// Close-All,used with `STOP_MARKET` or `TAKE_PROFIT_MARKET`. pub close_position: Option, + /// Used with `TRAILING_STOP_MARKET` orders, default as the latest price(supporting different `workingType`) pub activation_price: Option, + /// Used with `TRAILING_STOP_MARKET` orders, min `0.1`, max `10` where `1` for `1%` pub callback_rate: Option, + /// `stopPrice` triggered by: `MARK_PRICE`, `CONTRACT_PRICE`. Default `CONTRACT_PRICE` pub working_type: Option, pub price_protect: Option, + /// A unique id among open orders. \ + /// Automatically generated if not sent. \ + /// Can only be string following the rule: `^[\.A-Z\:/a-z0-9_-]{1,32}$` pub new_client_order_id: Option, + /// order cancel time for timeInForce **GTD**, mandatory when [TimeInForce] set to **GTD** \ + /// order the timestamp only retains second-level precision, **ms part will be ignored** \ + /// The goodTillDate timestamp must be greater than the current time **plus 600 seconds** and smaller than **253402300799000**. pub good_till_date: Option, } From a9354aafce10ee3e7b57aa96276f4bfaf3e6494e Mon Sep 17 00:00:00 2001 From: Shalev David Date: Mon, 1 Dec 2025 12:45:22 +0200 Subject: [PATCH 7/8] added one more documentation note --- src/futures/account.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/futures/account.rs b/src/futures/account.rs index 8a0a2972..08462e12 100644 --- a/src/futures/account.rs +++ b/src/futures/account.rs @@ -171,6 +171,7 @@ pub struct CustomOrderRequest { /// order cancel time for timeInForce **GTD**, mandatory when [TimeInForce] set to **GTD** \ /// order the timestamp only retains second-level precision, **ms part will be ignored** \ /// The goodTillDate timestamp must be greater than the current time **plus 600 seconds** and smaller than **253402300799000**. + /// the timestamp should be in `UTC` timezone pub good_till_date: Option, } From 3e709e5f97d885242468e04795a7be295cb16001 Mon Sep 17 00:00:00 2001 From: Shalev David Date: Mon, 1 Dec 2025 12:54:06 +0200 Subject: [PATCH 8/8] fixed the test file to include the gtd field --- tests/futures_account_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/futures_account_tests.rs b/tests/futures_account_tests.rs index 0ab30a24..4dc6ed0d 100644 --- a/tests/futures_account_tests.rs +++ b/tests/futures_account_tests.rs @@ -246,6 +246,7 @@ mod tests { working_type: None, price_protect: None, new_client_order_id: Some("myId".into()), + good_till_date: None, }; let transaction: Transaction = account.custom_order(custom_order).unwrap();