skyffire 1 年之前
父節點
當前提交
f6b8e59fd3
共有 1 個文件被更改,包括 5 次插入7 次删除
  1. 5 7
      strategy/src/avellaneda_stoikov.rs

+ 5 - 7
strategy/src/avellaneda_stoikov.rs

@@ -148,12 +148,16 @@ impl AvellanedaStoikov {
 
     pub async fn on_depth(&mut self, depth: &Depth, index: usize) {
         self.depth_vec[index] = depth.clone();
+        self.update_fair_price(depth, index).await;
 
         self.ask_price = depth.asks[0].price;
         self.bid_price = depth.bids[0].price;
         self.mid_price = (self.ask_price + self.bid_price) / Decimal::TWO;
 
-        self.update_fair_price(depth, index).await;
+        if !self.fair_price_vec[0].is_zero() && !self.fair_price_vec[1].is_zero() {
+            self.ref_price = (self.fair_price_vec[0] + self.fair_price_vec[1]) / Decimal::TWO;
+        }
+
         self.processor().await;
     }
 
@@ -183,8 +187,6 @@ impl AvellanedaStoikov {
 
         let fair_price = mid + (a1.price - b1.price) * i_upper / Decimal::TWO;
 
-        info!(?mid, ?fair_price, ?index);
-
         self.fair_price_vec[index] = fair_price;
     }
 
@@ -332,10 +334,6 @@ impl AvellanedaStoikov {
             return;
         }
 
-        if self.depth_vec.len() < 100 {
-            return;
-        }
-
         if self.trade_long_vec.len() < 100 {
             return;
         }