فهرست منبع

v4.2.4:
1. 刚开机时开仓难度从5降低到3。
2. 显示持仓均价。
3. 卡仓位自动退出。

skyffire 7 ماه پیش
والد
کامیت
2c4c3d26d1
1فایلهای تغییر یافته به همراه11 افزوده شده و 2 حذف شده
  1. 11 2
      strategy/src/predictor.rs

+ 11 - 2
strategy/src/predictor.rs

@@ -503,6 +503,11 @@ impl Predictor {
                 self.trade_side_map.remove(&pop_time);
                 self.trade_amount_map.remove(&pop_time);
                 self.trade_price_map.remove(&pop_time);
+            } else {
+                // 卡仓位临时处理方案,后面再改
+                if self.inventory.is_zero() && !self.pos_amount.is_zero() {
+                    panic!("仓位卡起了:inventory={}, pos_amount={}", self.inventory, self.pos_amount);
+                }
             }
         }
 
@@ -625,7 +630,7 @@ impl Predictor {
 
         // 刚开机要把条件限制的厉害一些。
         let data_rate = Decimal::from(self.deviation_vec.len()) / Decimal::from(600);
-        let times = dec!(1) + dec!(5) * (dec!(1) - data_rate);
+        let times = dec!(1) + dec!(2) * (dec!(1) - data_rate);
         let amplitude_limit = dec!(1.5) * times;
         let as_position_increase_distance = dec!(-0.0005) * times;
         let is_open_long = self.inventory < self.params.grid
@@ -785,7 +790,11 @@ impl Predictor {
         let optimal_ask_price = self.optimal_ask_price;
         let optimal_bid_price = self.optimal_bid_price;
         let last_price = Self::DONT_VIEW;
-        let fair_price = self.fair_price;
+        let fair_price = if self.pos_avg_price.is_zero() {
+            Self::DONT_VIEW
+        } else {
+            self.pos_avg_price
+        };
 
         let spread = Self::DONT_VIEW;
         let spread_max = self.deviation;