Explorar o código

尝试解决持仓数量问题。

skyfffire hai 1 ano
pai
achega
4d47d2cbed
Modificáronse 2 ficheiros con 3 adicións e 3 borrados
  1. 1 1
      strategy/src/avellaneda_stoikov.rs
  2. 2 2
      strategy/src/strategy.rs

+ 1 - 1
strategy/src/avellaneda_stoikov.rs

@@ -278,7 +278,7 @@ impl AvellanedaStoikov {
     pub async fn update_inventory(&mut self, pos_amount: &Decimal, min_amount_value: &Decimal) {
         let prev_inventory = self.inventory;
         self.pos_amount = pos_amount.clone();
-        self.inventory = (pos_amount / (min_amount_value / self.mid_price)).round();
+        self.inventory = (pos_amount / (min_amount_value / self.mid_price)).floor();
         if prev_inventory != self.inventory {
             self.prev_trade_time = Utc::now().timestamp_micros();
         }

+ 2 - 2
strategy/src/strategy.rs

@@ -983,7 +983,7 @@ impl Strategy {
                 // debug!(?order);
                 command.limits_open.insert(client_id, order);
             } else {
-                info!("下单价值太小,要求:{},但是价格:{}, 数量:{}", self.min_amount_value, target_buy_price, amount);
+                info!("下单价值太小,要求:{},但是价格:{}, 数量:{}", self.min_amount_value, target_buy_price, amount);
             }
         }
         // 挂空单
@@ -1025,7 +1025,7 @@ impl Strategy {
                 // debug!(?order);
                 command.limits_open.insert(client_id, order);
             } else {
-                info!("下单价值太小,要求:{},但是价格:{}, 数量:{}", self.min_amount_value, target_sell_price, amount);
+                info!("下单价值太小,要求:{},但是价格:{}, 数量:{}, inv={}", self.min_amount_value, target_sell_price, amount, predictor.inventory.abs());
             }
         }
     }