Browse Source

添加指令下单撤单报错处理

gepangpang 2 years ago
parent
commit
5a95ac4001
2 changed files with 19 additions and 3 deletions
  1. 10 2
      standard/src/gate_swap.rs
  2. 9 1
      standard/src/kucoin_swap.rs

+ 10 - 2
standard/src/gate_swap.rs

@@ -9,7 +9,7 @@ use rust_decimal_macros::dec;
 use serde_json::{json};
 use futures::stream::FuturesUnordered;
 use futures::{TryStreamExt};
-use tracing::{error, debug};
+use tracing::{error, debug, trace};
 use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand, PositionModeEnum};
 use exchanges::gate_swap_rest::GateSwapRest;
 
@@ -362,6 +362,14 @@ impl Platform for GateSwap {
                         result_sd.send(result).await.unwrap();
                     }
                     Err(error) => {
+                        if error.to_string() == "ORDER_NOT_FOUND" {
+                            let mut err_order = Order::new();
+                            err_order.id = order_id;
+                            err_order.custom_id = custom_id;
+                            err_order.status = "REMOVE".to_string();
+
+                            result_sd.send(err_order).await.unwrap();
+                        }
                         err_sd.send(error).await.unwrap();
                     }
                 }
@@ -393,7 +401,7 @@ impl Platform for GateSwap {
                     }
                     Err(error) => {
                         let mut err_order = Order::new();
-                        err_order.custom_id = (*cid).clone();
+                        err_order.custom_id = cid.clone();
                         err_order.status = "REMOVE".to_string();
 
                         result_sd.send(err_order).await.unwrap();

+ 9 - 1
standard/src/kucoin_swap.rs

@@ -333,6 +333,14 @@ impl Platform for KucoinSwap {
                         result_sd.send(result).await.unwrap();
                     }
                     Err(error) => {
+                        if error.to_string() == "The order cannot be canceled." {
+                            let mut err_order = Order::new();
+                            err_order.id = order_id;
+                            err_order.custom_id = custom_id;
+                            err_order.status = "REMOVE".to_string();
+
+                            result_sd.send(err_order).await.unwrap();
+                        }
                         err_sd.send(error).await.unwrap();
                     }
                 }
@@ -364,7 +372,7 @@ impl Platform for KucoinSwap {
                     }
                     Err(error) => {
                         let mut err_order = Order::new();
-                        err_order.custom_id = (*cid).clone();
+                        err_order.custom_id = cid.clone();
                         err_order.status = "REMOVE".to_string();
 
                         result_sd.send(err_order).await.unwrap();