skyffire 9 months ago
parent
commit
9b3fa8c5c9
1 changed files with 7 additions and 7 deletions
  1. 7 7
      strategy/src/predictor.rs

+ 7 - 7
strategy/src/predictor.rs

@@ -436,14 +436,14 @@ impl Predictor {
                 // mid_trend_rate防止追高
                 if mid_rate.abs() > self.params.open_activate {
                     // 向上涨,带量的,视为观测阶段开始
-                    if mid_rate > Decimal::ZERO && mid_long_rate > Decimal::ZERO && mid_trend_rate < Decimal::ZERO {
+                    if mid_rate > Decimal::ZERO && mid_long_rate > Decimal::ZERO {
                         self.mid_rate_signal_open = dec!(0.01);
                         self.mid_price_focus_cancel = mid_max_price;
                         self.mid_price_focus_stop_loss = mid_min_price;
                     }
 
                     // 向下跌,带量的,视为观测阶段开始
-                    if mid_rate < Decimal::ZERO && mid_long_rate < Decimal::ZERO && mid_trend_rate > Decimal::ZERO {
+                    if mid_rate < Decimal::ZERO && mid_long_rate < Decimal::ZERO {
                         self.mid_rate_signal_open = dec!(-0.01);
                         self.mid_price_focus_cancel = mid_min_price;
                         self.mid_price_focus_stop_loss = mid_max_price;
@@ -475,7 +475,7 @@ impl Predictor {
             let close_activate = self.params.open_activate;
             if self.mid_rate_signal_close.is_zero() && !self.inventory.is_zero() && mid_rate.abs() > close_activate {
                 // 多单平仓逻辑
-                if self.inventory > Decimal::ZERO && mid_rate > Decimal::ZERO {
+                if self.inventory > Decimal::ZERO && mid_rate < Decimal::ZERO {
                     if self.profit_point > Decimal::ZERO {
                         self.mid_rate_signal_close = mid_rate;
                     } else if self.t_diff.is_zero() {
@@ -484,7 +484,7 @@ impl Predictor {
                 }
 
                 // 空单平仓逻辑
-                if self.inventory < Decimal::ZERO && mid_rate < Decimal::ZERO {
+                if self.inventory < Decimal::ZERO && mid_rate > Decimal::ZERO {
                     if self.profit_point > Decimal::ZERO {
                         self.mid_rate_signal_close = mid_rate;
                     } else if self.t_diff.is_zero() {
@@ -518,7 +518,7 @@ impl Predictor {
             //     info!("硬止损, 在价格{}处,成本价{},价值={}, p={}。", self.fair_price_focus_close, self.pos_avg_price, self.pos_avg_price*self.pos_amount, self.profit_point);
             //     info!("----------------------------------------");
             // }
-            // ============================ 平仓特殊逻辑处理2 =======================
+            // // ============================ 平仓特殊逻辑处理2 =======================
             if self.mid_rate_signal_close.is_zero() && !self.inventory.is_zero() && self.profit_point_vec.len() > 1 {
                 let prev_profit_point = self.profit_point_vec[self.profit_point_vec.len() - 2];
                 let profit_point = self.profit_point_vec[self.profit_point_vec.len() - 1];
@@ -648,7 +648,7 @@ impl Predictor {
 
     pub fn update_optimal_ask_and_bid(&mut self) {
         self.optimal_ask_price = if self.ask_delta == dec!(-1) {
-            self.bid_price
+            self.bid_price * dec!(0.9995)
         } else if self.ask_delta == dec!(-2) {
             Self::DONT_VIEW
         } else {
@@ -656,7 +656,7 @@ impl Predictor {
         };
 
         self.optimal_bid_price = if self.bid_delta == dec!(-1) {
-            self.ask_price
+            self.ask_price * dec!(1.0005)
         } else if self.bid_delta == dec!(-2) {
             Self::DONT_VIEW
         } else {