瀏覽代碼

修复平仓*2的bug。

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

+ 3 - 1
strategy/src/avellaneda_stoikov.rs

@@ -269,6 +269,8 @@ impl AvellanedaStoikov {
 
             Decimal::ONE_HUNDRED - Decimal::ONE_HUNDRED / (Decimal::ONE + money_flow_ratio)
         };
+
+        self.update_flow_ratio();
     }
 
     pub async fn update_inventory(&mut self, inventory: &Decimal, min_amount_value: &Decimal) {
@@ -462,7 +464,7 @@ impl AvellanedaStoikov {
             inventory: self.inventory,
             sigma_square: self.sigma_square,
             gamma: self.money_flow_index,
-            kappa: self.kappa,
+            kappa: self.flow_ratio,
 
             flow_ratio: Decimal::ZERO,
             ref_price: self.fair_price_vec[0],

+ 1 - 1
strategy/src/strategy.rs

@@ -992,7 +992,7 @@ impl Strategy {
             // target_sell_price = utils::clip(target_sell_price, self.bp * dec!(0.9995), self.ap * dec!(1.03));
             // 取消大小限制
             target_sell_price = utils::fix_price(target_sell_price, self.tick_size);
-            let amount = if predictor.inventory > Decimal::TWO && predictor.flow_ratio > Decimal::ZERO {
+            let amount = if predictor.inventory.abs() > Decimal::TWO && predictor.flow_ratio > Decimal::ZERO {
                 utils::get_amount_by_min_amount_value(self.min_amount_value * Decimal::TWO, target_sell_price, self.step_size)
             } else {
                 utils::get_amount_by_min_amount_value(self.min_amount_value, target_sell_price, self.step_size)