gepangpang пре 2 година
родитељ
комит
1b7bc651cd

+ 2 - 2
standard/src/binance_swap.rs

@@ -298,7 +298,7 @@ impl Platform for BinanceSwap {
                 avg_price: Decimal::from_str(res_data_json["avgPrice"].as_str().unwrap()).unwrap(),
                 status: custom_status,
                 order_type: res_data_json["type"].as_str().unwrap().parse().unwrap(),
-                trace_stack: TraceStack::default().on_special("300 binance_swap".to_string()),
+                trace_stack: TraceStack::default().on_special("301 binance_swap".to_string()),
             };
             Ok(result)
         } else {
@@ -328,7 +328,7 @@ impl Platform for BinanceSwap {
                     avg_price: Decimal::from_str(item["avgPrice"].as_str().unwrap()).unwrap(),
                     status: custom_status,
                     order_type: item["type"].as_str().unwrap().parse().unwrap(),
-                    trace_stack: TraceStack::default().on_special("330 binance_swap".to_string()),
+                    trace_stack: TraceStack::default().on_special("331 binance_swap".to_string()),
                 }
             }).collect();
             Ok(result)

+ 33 - 27
standard/src/bitget_spot.rs

@@ -305,7 +305,7 @@ impl Platform for BitgetSpot {
                 avg_price: Decimal::ZERO,
                 status: "NEW".to_string(),
                 order_type: "".to_string(),
-                trace_stack: TraceStack::default().on_special("310 bitget_spot".to_string()),
+                trace_stack: TraceStack::default().on_special("308 bitget_spot".to_string()),
             };
             Ok(result)
         } else {
@@ -357,7 +357,7 @@ impl Platform for BitgetSpot {
                 avg_price: Decimal::ZERO,
                 status: "NEW".to_string(),
                 order_type: "".to_string(),
-                trace_stack: TraceStack::default().on_special("357 bitget_spot".to_string()),
+                trace_stack: TraceStack::default().on_special("360 bitget_spot".to_string()),
             };
             Ok(result)
         } else {
@@ -380,7 +380,7 @@ impl Platform for BitgetSpot {
                 avg_price: Decimal::ZERO,
                 status: "REMOVE".to_string(),
                 order_type: "".to_string(),
-                trace_stack: TraceStack::default().on_special("380 bitget_spot".to_string()),
+                trace_stack: TraceStack::default().on_special("383 bitget_spot".to_string()),
             };
             Ok(result)
         } else {
@@ -390,31 +390,37 @@ impl Platform for BitgetSpot {
 
     async fn cancel_orders(&mut self) -> Result<Vec<Order>, Error> {
         let symbol_format = utils::format_symbol(self.symbol.clone(), "");
-        let res_data = self.request.spot_cancel_symbol_orders(symbol_format.to_string()).await;
-        if res_data.code == "200" {
-            // 1. 获取当前委托列表
-            // 2. 取消委托列表,不然就不会传详情回来
-
-            // let res_data_str = &res_data.data;
-            // let res_data_json: serde_json::Value = serde_json::from_str(res_data_str).unwrap();
-            // info!(?res_data);
-            // let order_info_list: Vec<serde_json::Value> = res_data_json["successList"].as_array().unwrap().clone();
-            // let result = order_info_list.iter().map(|item|
-            //     Order {
-            //         id: item["orderId"].as_str().unwrap().to_string(),
-            //         custom_id: item["clientOid"].as_str().unwrap().to_string(),
-            //         price: Decimal::ZERO,
-            //         amount: Decimal::ZERO,
-            //         deal_amount: Decimal::ZERO,
-            //         avg_price: Decimal::ZERO,
-            //         status: "REMOVE".to_string(),
-            //         order_type: "".to_string(),
-            //         trace_stack: TraceStack::default().on_special("405 bitget_spot".to_string()),
-            //     }
-            // ).collect();
-            Ok(vec![])
+        let orders_res_data = self.request.get_unfilled_orders(symbol_format.to_string(), "".to_string(), "".to_string(), "".to_string(), "100".to_string(), "".to_string()).await;
+        if orders_res_data.code == "200" {
+            let mut result = vec![];
+            let orders_res_data_str = &orders_res_data.data;
+            let orders_res_data_json: Vec<serde_json::Value> = serde_json::from_str(orders_res_data_str).unwrap();
+            for order in orders_res_data_json {
+                let cancel_symbol = order["symbol"].as_str().unwrap().to_uppercase();
+                let cancel_res_data = self.request.spot_cancel_symbol_orders(cancel_symbol).await;
+                if cancel_res_data.code == "200" {
+                    let cancel_res_data_str = &cancel_res_data.data;
+                    let cancel_res_data_json: Vec<serde_json::Value> = serde_json::from_str(cancel_res_data_str).unwrap();
+                    for cancel in cancel_res_data_json {
+                        result.push(Order {
+                            id: cancel["orderId"].as_str().unwrap().to_string(),
+                            custom_id: cancel["clientOid"].as_str().unwrap().to_string(),
+                            price: Decimal::ZERO,
+                            amount: Decimal::ZERO,
+                            deal_amount: Decimal::ZERO,
+                            avg_price: Decimal::ZERO,
+                            status: "REMOVE".to_string(),
+                            order_type: "".to_string(),
+                            trace_stack: TraceStack::default().on_special("414 bitget_spot".to_string()),
+                        });
+                    };
+                } else {
+                    return Err(Error::new(ErrorKind::Other, cancel_res_data.to_string()));
+                }
+            }
+            Ok(result)
         } else {
-            Err(Error::new(ErrorKind::Other, res_data.to_string()))
+            Err(Error::new(ErrorKind::Other, orders_res_data.to_string()))
         }
     }
 

+ 1 - 1
standard/src/gate_swap.rs

@@ -685,7 +685,7 @@ pub fn format_order_item(order: serde_json::Value, ct_val: Decimal) -> Order {
         avg_price: Decimal::from_str(&order["fill_price"].as_str().unwrap()).unwrap(),
         status: custom_status,
         order_type: "limit".to_string(),
-        trace_stack: TraceStack::default().on_special("690 trace_stack".to_string()),
+        trace_stack: TraceStack::default().on_special("688 trace_stack".to_string()),
     };
     debug!(?rst_order);
     debug!("format-order-end, gate_swap");

+ 1 - 1
standard/src/kucoin_handle.rs

@@ -133,7 +133,7 @@ pub fn format_order_item(order: serde_json::Value, ct_val: Decimal) -> Order {
         avg_price,
         status: custom_status,
         order_type: order["type"].as_str().unwrap().to_string(),
-        trace_stack: TraceStack::default().on_special("135 kucoin_handle".to_string()),
+        trace_stack: TraceStack::default().on_special("136 kucoin_handle".to_string()),
     }
 }
 

+ 1 - 1
standard/src/kucoin_swap.rs

@@ -356,7 +356,7 @@ impl Platform for KucoinSwap {
                 avg_price: Decimal::ZERO,
                 status: "NEW".to_string(),
                 order_type: "".to_string(),
-                trace_stack: TraceStack::default().on_special("358 kucoin_swap".to_string()),
+                trace_stack: TraceStack::default().on_special("359 kucoin_swap".to_string()),
             };
             Ok(result)
         } else {

+ 1 - 1
standard/src/okx_handle.rs

@@ -74,7 +74,7 @@ pub fn format_order_item(order: serde_json::Value, ct_val: Decimal) -> Order {
         avg_price,
         status: custom_status,
         order_type: order["ordType"].as_str().unwrap().to_string(),
-        trace_stack: TraceStack::default().on_special("76 okx_handle".to_string()),
+        trace_stack: TraceStack::default().on_special("77 okx_handle".to_string()),
     }
 }
 

+ 1 - 1
standard/src/okx_swap.rs

@@ -425,7 +425,7 @@ impl Platform for OkxSwap {
                 avg_price: Decimal::ZERO,
                 status: "REMOVE".to_string(),
                 order_type: "".to_string(),
-                trace_stack: TraceStack::default().on_special("393 okx_handle".to_string()),
+                trace_stack: TraceStack::default().on_special("428 okx_handle".to_string()),
             };
             Ok(result)
         } else {