Przeglądaj źródła

1. 修复ref为0时被div的问题
2. 使用ref平仓。

skyffire 1 rok temu
rodzic
commit
e637eac698
2 zmienionych plików z 11 dodań i 7 usunięć
  1. 4 0
      strategy/src/avellaneda_stoikov.rs
  2. 7 7
      strategy/src/strategy.rs

+ 4 - 0
strategy/src/avellaneda_stoikov.rs

@@ -320,6 +320,10 @@ impl AvellanedaStoikov {
            return;
         }
 
+        if self.ref_price == Decimal::ZERO {
+            return;
+        }
+
         if self.ask_price == Decimal::ZERO {
             return;
         }

+ 7 - 7
strategy/src/strategy.rs

@@ -1094,6 +1094,13 @@ impl Strategy {
             self.max_equity = self.equity;
         }
 
+        let mut command = OrderCommand::new();
+
+        // 检查是否准备充分
+        if !predictor.is_ready {
+            return command;
+        }
+
         self.ref_ap = predictor.optimal_ask_price;
         self.ref_bp = predictor.optimal_bid_price;
         self.ref_price = predictor.ref_price;
@@ -1102,13 +1109,6 @@ impl Strategy {
         // 修复相关价格
         self.fix_price(predictor);
 
-        let mut command = OrderCommand::new();
-
-        // 检查是否准备充分
-        if !predictor.is_ready {
-            return command;
-        }
-
         self._cancel_open(&mut command, local_orders);              // 撤单命令处理
         self._post_open(&mut command, local_orders, predictor);     // 限价单命令处理
         self._check_local_orders(&mut command, local_orders);       // 固定时间检查超时订单