Browse Source

删除订单逻辑修改为与python一致。

skyfffire 1 year ago
parent
commit
3019296503
1 changed files with 14 additions and 13 deletions
  1. 14 13
      strategy/src/quant.rs

+ 14 - 13
strategy/src/quant.rs

@@ -327,18 +327,6 @@ impl Quant {
             if self.local_cancel_log.contains_key(&data.client_id) {
                 self.local_cancel_log.remove(&data.client_id);
             }
-            if self.local_orders.contains_key(&data.client_id) {
-                // 成交数量不为空,则打印耗时追踪
-                if data.filled > Decimal::ZERO {
-                    let local_order = self.local_orders.get(&data.client_id).unwrap();
-                    info!("订单耗时追踪:{:?}", local_order.trace_stack.to_string());
-                }
-
-                debug!("删除本地订单, client_id:{:?}", data);
-                self.local_orders.remove(&data.client_id);
-            } else {
-                debug!("该订单不在本地挂单表中, order:{:?}", data);
-            }
             // 在cid缓存队列中 说明是本策略的订单
             if self.local_orders_backup.contains_key(&data.client_id) {
                 // 不在已处理cid缓存队列中 说明还没参与过仓位计算 则执行订单计算
@@ -511,6 +499,19 @@ impl Quant {
             } else {
                 debug!("订单不属于本策略 拒绝进行仓位计算: {}", data.client_id);
             }
+
+            if self.local_orders.contains_key(&data.client_id) {
+                // 成交数量不为空,则打印耗时追踪
+                if data.filled > Decimal::ZERO {
+                    let local_order = self.local_orders.get(&data.client_id).unwrap();
+                    info!("订单耗时追踪:{:?}", local_order.trace_stack.to_string());
+                }
+
+                debug!("删除本地订单, client_id:{:?}", data);
+                self.local_orders.remove(&data.client_id);
+            } else {
+                debug!("该订单不在本地挂单表中, order:{:?}", data);
+            }
         } else {
             error!("未知的订单事件类型:{:?}", data);
         }
@@ -579,7 +580,7 @@ impl Quant {
     }
 
     pub fn _update_depth(&mut self, depth: Vec<Decimal>, name: String, mut trace_stack: TraceStack) {
-        info!(?depth, ?name);
+        // info!(?depth, ?name);
         trace_stack.on_depth();
 
         // 要从回调传入的深度信息中获取data.name