|
|
@@ -8,7 +8,7 @@ use futures::TryStreamExt;
|
|
|
use rust_decimal::Decimal;
|
|
|
use rust_decimal::prelude::{FromPrimitive, ToPrimitive};
|
|
|
use rust_decimal_macros::dec;
|
|
|
-use serde_json::{json};
|
|
|
+use serde_json::{json, Value};
|
|
|
use tracing::{error};
|
|
|
use exchanges::kucoin_swap_rest::KucoinSwapRest;
|
|
|
use crate::exchange::ExchangeEnum;
|
|
|
@@ -363,8 +363,9 @@ impl Platform for KucoinSwap {
|
|
|
Ok(order) => {
|
|
|
result_sd.send(order).await.unwrap();
|
|
|
}
|
|
|
- Err(_) => {
|
|
|
- panic!("撤单失败,而且查单也失败了,kucoin_swap,oid={}, cid={}。", order_id.clone(), custom_id.clone());
|
|
|
+ Err(query_err) => {
|
|
|
+ error!(?query_err);
|
|
|
+ error!("撤单失败,而且查单也失败了,kucoin_swap,oid={}, cid={}。", order_id.clone(), custom_id.clone());
|
|
|
}
|
|
|
}
|
|
|
err_sd.send(error).await.unwrap();
|
|
|
@@ -438,7 +439,7 @@ impl Platform for KucoinSwap {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Order {
|
|
|
+pub fn format_order_item(order: Value, amount_size: Decimal) -> Order {
|
|
|
let price = Decimal::from_str(order["price"].as_str().unwrap()).unwrap();
|
|
|
let size = Decimal::from_str(&order["size"].to_string()).unwrap();
|
|
|
let status = order["status"].as_str().unwrap_or("");
|
|
|
@@ -448,7 +449,15 @@ pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Orde
|
|
|
let amount = size * amount_size;
|
|
|
let deal_amount = filled_size * amount_size;
|
|
|
let avg_price = if deal_amount.is_zero() { dec!(0) } else { filled_value / deal_amount };
|
|
|
- let custom_status = if ["done", "match"].contains(&status) { "REMOVE".to_string() } else if status == "open" { "NEW".to_string() } else { panic!("Kucoin:格式化订单状态错误!\nformat_order_item:status={:?}", status); };
|
|
|
+ let custom_status;
|
|
|
+ if ["cancelled", "closed", "finished"].contains(&status) {
|
|
|
+ custom_status = "REMOVE".to_string();
|
|
|
+ } else if status == "open" {
|
|
|
+ custom_status = "NEW".to_string();
|
|
|
+ } else {
|
|
|
+ custom_status = "NULL".to_string();
|
|
|
+ };
|
|
|
+
|
|
|
Order {
|
|
|
id: order["id"].as_str().unwrap().to_string(),
|
|
|
custom_id: order["clientOid"].as_str().unwrap().to_string(),
|