|
|
@@ -42,7 +42,7 @@ pub struct Core {
|
|
|
//
|
|
|
pub strategy: Strategy,
|
|
|
// 本地挂单时间表
|
|
|
- pub local_order_times: HashMap<String, Decimal>,
|
|
|
+ pub local_order_times: HashMap<String, i64>,
|
|
|
// 本地挂单表
|
|
|
pub local_orders: HashMap<String, OrderInfo>,
|
|
|
// 本地订单缓存队列
|
|
|
@@ -67,6 +67,7 @@ pub struct Core {
|
|
|
pub local_buy_value: Decimal,
|
|
|
pub local_sell_value: Decimal,
|
|
|
pub local_cancel_log: HashMap<String, i64>,
|
|
|
+ pub local_cancel_time: HashMap<String, i64>,
|
|
|
pub interval: u64,
|
|
|
pub exchange: String,
|
|
|
pub exit_msg: String,
|
|
|
@@ -161,6 +162,7 @@ impl Core {
|
|
|
local_buy_value: Default::default(),
|
|
|
local_sell_value: Default::default(),
|
|
|
local_cancel_log: Default::default(),
|
|
|
+ local_cancel_time: Default::default(),
|
|
|
interval: params.interval,
|
|
|
exchange: params.exchange.clone(),
|
|
|
exit_msg: "正常退出".to_string(),
|
|
|
@@ -491,7 +493,12 @@ impl Core {
|
|
|
}
|
|
|
// info!("成交单耗时数据:{}", time_record.to_string());
|
|
|
info!("更新推算仓位 {:?}", self.local_position_by_orders);
|
|
|
- info!("当前时间-订单委托时间={}", Decimal::from(Utc::now().timestamp_millis()) - self.local_order_times.get(&data.client_id).unwrap());
|
|
|
+ info!("当前时间-订单委托时间={}ms", Utc::now().timestamp_millis() - self.local_order_times.get(&data.client_id).unwrap());
|
|
|
+ if let Some(cancel_time) = self.local_cancel_time.get(&data.client_id) {
|
|
|
+ info!("当前时间-订单首次取消时间={}ms", Utc::now().timestamp_millis() - cancel_time)
|
|
|
+ } else {
|
|
|
+ info!("没有提交过取消订单")
|
|
|
+ }
|
|
|
// 本地计算利润
|
|
|
self._print_local_trades_summary().await;
|
|
|
// 打印各类信息
|
|
|
@@ -820,7 +827,7 @@ impl Core {
|
|
|
fee: Default::default(),
|
|
|
trace_stack: TraceStack::new(0, Instant::now()),
|
|
|
};
|
|
|
- self.local_order_times.insert(orders.limits_open.get(j).unwrap()[3].clone(), Decimal::from(Utc::now().timestamp_millis()));
|
|
|
+ self.local_order_times.insert(orders.limits_open.get(j).unwrap()[3].clone(), Utc::now().timestamp_millis());
|
|
|
// 本地挂单表
|
|
|
self.local_orders.insert(orders.limits_open.get(j).unwrap()[3].clone(), order_info.clone());
|
|
|
// 本地缓存表
|
|
|
@@ -832,6 +839,12 @@ impl Core {
|
|
|
if !orders.cancel.is_empty() {
|
|
|
for cancel_key in orders.cancel.keys() {
|
|
|
let cid = orders.cancel.get(cancel_key).unwrap()[0].clone();
|
|
|
+
|
|
|
+ // 提交取消订单的时间
|
|
|
+ if !self.local_cancel_time.contains_key(&cid) {
|
|
|
+ self.local_cancel_time.insert(cid.clone(), Utc::now().timestamp_millis());
|
|
|
+ }
|
|
|
+
|
|
|
if self.local_cancel_log.contains_key(&cid) {
|
|
|
let num = self.local_cancel_log.get(&cid).unwrap() + 1;
|
|
|
self.local_cancel_log.insert(cid, num);
|