|
|
@@ -397,37 +397,35 @@ impl Predictor {
|
|
|
// 多单平仓逻辑
|
|
|
if self.inventory > Decimal::ZERO && self.spread_ema_1000 < Decimal::ZERO {
|
|
|
// 是否强干扰平仓
|
|
|
- let target_price = if self.params.is_strong_interfere {
|
|
|
- self.pos_avg_price + self.params.open_activate * self.mid_price * self.t_diff * dec!(0.5)
|
|
|
+ if self.params.is_strong_interfere {
|
|
|
+ if self.mid_price > self.pos_avg_price {
|
|
|
+ self.fair_rate_focus_close = self.spread_ema_1000;
|
|
|
+ self.fair_price_focus_close = self.fair_price;
|
|
|
+ } else if self.t_diff.is_zero() {
|
|
|
+ self.fair_rate_focus_close = self.spread_ema_1000;
|
|
|
+ self.fair_price_focus_close = self.fair_price;
|
|
|
+ }
|
|
|
} else {
|
|
|
- self.pos_avg_price
|
|
|
- };
|
|
|
-
|
|
|
- if self.mid_price > target_price {
|
|
|
- self.fair_rate_focus_close = self.spread_ema_1000;
|
|
|
- self.fair_price_focus_close = self.fair_price;
|
|
|
- } else if self.t_diff.is_zero() {
|
|
|
self.fair_rate_focus_close = self.spread_ema_1000;
|
|
|
self.fair_price_focus_close = self.fair_price;
|
|
|
- }
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
// 空单平仓逻辑
|
|
|
if self.inventory < Decimal::ZERO && self.spread_ema_1000 > Decimal::ZERO {
|
|
|
// 是否强干扰平仓
|
|
|
- let target_price = if self.params.is_strong_interfere {
|
|
|
- self.pos_avg_price - self.params.open_activate * self.mid_price * self.t_diff * dec!(0.5)
|
|
|
+ if self.params.is_strong_interfere {
|
|
|
+ if self.mid_price < self.pos_avg_price {
|
|
|
+ self.fair_rate_focus_close = self.spread_ema_1000;
|
|
|
+ self.fair_price_focus_close = self.fair_price;
|
|
|
+ } else if self.t_diff.is_zero() {
|
|
|
+ self.fair_rate_focus_close = self.spread_ema_1000;
|
|
|
+ self.fair_price_focus_close = self.fair_price;
|
|
|
+ }
|
|
|
} else {
|
|
|
- self.pos_avg_price
|
|
|
- };
|
|
|
-
|
|
|
- if self.mid_price < target_price {
|
|
|
- self.fair_rate_focus_close = self.spread_ema_1000;
|
|
|
- self.fair_price_focus_close = self.fair_price;
|
|
|
- } else if self.t_diff.is_zero() {
|
|
|
self.fair_rate_focus_close = self.spread_ema_1000;
|
|
|
self.fair_price_focus_close = self.fair_price;
|
|
|
- }
|
|
|
+ };
|
|
|
}
|
|
|
}
|
|
|
}
|