|
@@ -8,8 +8,9 @@ use rust_decimal::prelude::{FromPrimitive, ToPrimitive};
|
|
|
use rust_decimal_macros::dec;
|
|
use rust_decimal_macros::dec;
|
|
|
use serde_json::{json};
|
|
use serde_json::{json};
|
|
|
use futures::stream::FuturesUnordered;
|
|
use futures::stream::FuturesUnordered;
|
|
|
-use futures::{TryStreamExt};
|
|
|
|
|
-use tracing::error;
|
|
|
|
|
|
|
+use futures::{TryFutureExt, TryStreamExt};
|
|
|
|
|
+use futures::future::err;
|
|
|
|
|
+use tracing::{error, info};
|
|
|
use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand, PositionModeEnum};
|
|
use crate::{Platform, ExchangeEnum, Account, Position, Ticker, Market, Order, OrderCommand, PositionModeEnum};
|
|
|
use exchanges::gate_swap_rest::GateSwapRest;
|
|
use exchanges::gate_swap_rest::GateSwapRest;
|
|
|
|
|
|
|
@@ -392,6 +393,11 @@ impl Platform for GateSwap {
|
|
|
result_sd.send(result).await.unwrap();
|
|
result_sd.send(result).await.unwrap();
|
|
|
}
|
|
}
|
|
|
Err(error) => {
|
|
Err(error) => {
|
|
|
|
|
+ let mut err_order = Order::new();
|
|
|
|
|
+ err_order.custom_id = (*cid).clone();
|
|
|
|
|
+ err_order.status = "REMOVE".to_string();
|
|
|
|
|
+
|
|
|
|
|
+ result_sd.send(err_order).await.unwrap();
|
|
|
err_sd.send(error).await.unwrap();
|
|
err_sd.send(error).await.unwrap();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -449,6 +455,8 @@ pub fn format_position_item(position: &serde_json::Value, amount_size: Decimal)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Order {
|
|
pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Order {
|
|
|
|
|
+ info!("format-order-start, gate_swap");
|
|
|
|
|
+ info!(?order);
|
|
|
let status = order["status"].as_str().unwrap_or("");
|
|
let status = order["status"].as_str().unwrap_or("");
|
|
|
let text = order["text"].as_str().unwrap_or("");
|
|
let text = order["text"].as_str().unwrap_or("");
|
|
|
let size = Decimal::from_str(&order["size"].to_string()).unwrap();
|
|
let size = Decimal::from_str(&order["size"].to_string()).unwrap();
|
|
@@ -457,7 +465,7 @@ pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Orde
|
|
|
let amount = size * amount_size;
|
|
let amount = size * amount_size;
|
|
|
let deal_amount = (size - left) * amount_size;
|
|
let deal_amount = (size - left) * amount_size;
|
|
|
let custom_status = if status == "finished" { "REMOVE".to_string() } else if status == "open" { "NEW".to_string() } else { panic!("Gate:格式化订单状态错误!\nformat_order_item:status={}", status) };
|
|
let custom_status = if status == "finished" { "REMOVE".to_string() } else if status == "open" { "NEW".to_string() } else { panic!("Gate:格式化订单状态错误!\nformat_order_item:status={}", status) };
|
|
|
- Order {
|
|
|
|
|
|
|
+ let rst_order = Order {
|
|
|
id: order["id"].to_string(),
|
|
id: order["id"].to_string(),
|
|
|
custom_id: text.replace("t-my-custom-id_", ""),
|
|
custom_id: text.replace("t-my-custom-id_", ""),
|
|
|
price: Decimal::from_str(order["price"].as_str().unwrap()).unwrap(),
|
|
price: Decimal::from_str(order["price"].as_str().unwrap()).unwrap(),
|
|
@@ -466,5 +474,8 @@ pub fn format_order_item(order: serde_json::Value, amount_size: Decimal) -> Orde
|
|
|
avg_price: Decimal::from_str(&order["fill_price"].as_str().unwrap()).unwrap(),
|
|
avg_price: Decimal::from_str(&order["fill_price"].as_str().unwrap()).unwrap(),
|
|
|
status: custom_status,
|
|
status: custom_status,
|
|
|
order_type: "limit".to_string(),
|
|
order_type: "limit".to_string(),
|
|
|
- }
|
|
|
|
|
|
|
+ };
|
|
|
|
|
+ info!(?rst_order);
|
|
|
|
|
+ info!("format-order-end, gate_swap");
|
|
|
|
|
+ return rst_order;
|
|
|
}
|
|
}
|