Sfoglia il codice sorgente

风控编译错误解决

JiahengHe 2 anni fa
parent
commit
ebb08d33c2
1 ha cambiato i file con 18 aggiunte e 18 eliminazioni
  1. 18 18
      strategy/src/quant.rs

+ 18 - 18
strategy/src/quant.rs

@@ -802,13 +802,13 @@ impl Quant {
         // 参数检查的风控
         if self.strategy.start_cash == Decimal::ZERO {
             warn!("请检查交易账户余额");
-            warn!(?_self.strategy.start_cash);
+            warn!(?self.strategy.start_cash);
             return;
         }
 
         if self.strategy.mp == Decimal::ZERO {
             warn!("请检查最新价格");
-            warn!(?_self.strategy.mp);
+            warn!(?self.strategy.mp);
             return;
         }
 
@@ -851,14 +851,14 @@ impl Quant {
             let diff_pos = max(long_diff, short_diff);
             let diff_pos_value = diff_pos * self.strategy.mp;
             if diff_pos_value > self.strategy._min_amount_value {
-                warn!("{}发现仓位异常", _self.params.account_name);
-                warn!(?_self.local_position_by_orders, ?_self.local_position);
+                warn!("{}发现仓位异常", self.params.account_name);
+                warn!(?self.local_position_by_orders, ?self.local_position);
                 self.position_check_series.push(1);
             } else {
                 self.position_check_series.push(0);
             }
 
-            // _self.position_check_series长度限制
+            // self.position_check_series长度限制
             if self.position_check_series.len() > 30 {
                 self.position_check_series.remove(0);
             }
@@ -869,7 +869,7 @@ impl Quant {
                 warn!(exit_msg);
                 self.exit_msg = exit_msg;
                 // TODO quant.stop()不存在
-                // _self.stop()
+                // self.stop()
             }
         }
 
@@ -879,7 +879,7 @@ impl Quant {
             warn!(exit_msg);
             self.exit_msg = exit_msg;
             // TODO quant.stop()不存在
-            // _self.stop()
+            // self.stop()
         }
 
         // 行情更新异常风控
@@ -898,19 +898,19 @@ impl Quant {
                 warn!(exit_msg);
                 self.exit_msg = exit_msg;
                 // TODO quant.stop()不存在
-                // _self.stop()
+                // self.stop()
             }
         }
-
+        let local_orders = self.local_orders.clone();
         // 订单异常风控
-        for (client_id, order) in self.local_orders {
+        for (client_id, order) in local_orders{
             // 订单长时间停留 怀疑漏单 但未必一定漏 5min
             if Utc::now().timestamp_millis() - order.local_time > 5 * 60 * 1000 {
                 let exit_msg = format!("{}订单停留过长,怀疑异常,退出,cid:{}。", self.params.account_name, client_id);
                 warn!(exit_msg);
                 self.exit_msg = exit_msg;
                 // TODO quant.stop()不存在
-                // _self.stop()
+                // self.stop()
             }
         }
 
@@ -922,7 +922,7 @@ impl Quant {
                     warn!(exit_msg);
                     self.exit_msg = exit_msg;
                     // TODO quant.stop()不存在
-                    // _self.stop()
+                    // self.stop()
                 }
             }
         }
@@ -933,20 +933,20 @@ impl Quant {
                     warn!(exit_msg);
                     self.exit_msg = exit_msg;
                     // TODO quant.stop()不存在
-                    // _self.stop()
+                    // self.stop()
                 }
             }
         }
 
         // 订单撤单异常风控
-        for (client_id, cancel_delay) in self.local_cancel_log {
+        for (client_id, cancel_delay) in self.local_cancel_log.clone() {
             if cancel_delay > 300 {
                 let exit_msg = format!("{} 长时间无法撤销,client_id: {},退出。", self.params.account_name, client_id);
                 warn!(exit_msg);
-                warn!(?_self.strategy.ref_price, ?_self.strategy.mp);
+                warn!(?self.strategy.ref_price, ?self.strategy.mp);
                 self.exit_msg = exit_msg;
                 // TODO quant.stop()不存在
-                // _self.stop()
+                // self.stop()
             }
         }
 
@@ -954,10 +954,10 @@ impl Quant {
         if (self.strategy.ref_price - self.strategy.mp).abs() / self.strategy.mp > dec!(0.03) {
             let exit_msg = format!("{} 定价偏离过大,怀疑定价异常,退出。", self.params.account_name);
             warn!(exit_msg);
-            warn!(?_self.strategy.ref_price, ?_self.strategy.mp);
+            warn!(?self.strategy.ref_price, ?self.strategy.mp);
             self.exit_msg = exit_msg;
             // TODO quant.stop()不存在
-            // _self.stop()
+            // self.stop()
         }
     }