|
@@ -436,14 +436,14 @@ impl Predictor {
|
|
|
// mid_trend_rate防止追高
|
|
// mid_trend_rate防止追高
|
|
|
if mid_rate.abs() > self.params.open_activate {
|
|
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_rate_signal_open = dec!(0.01);
|
|
|
self.mid_price_focus_cancel = mid_max_price;
|
|
self.mid_price_focus_cancel = mid_max_price;
|
|
|
self.mid_price_focus_stop_loss = mid_min_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_rate_signal_open = dec!(-0.01);
|
|
|
self.mid_price_focus_cancel = mid_min_price;
|
|
self.mid_price_focus_cancel = mid_min_price;
|
|
|
self.mid_price_focus_stop_loss = mid_max_price;
|
|
self.mid_price_focus_stop_loss = mid_max_price;
|
|
@@ -475,7 +475,7 @@ impl Predictor {
|
|
|
let close_activate = self.params.open_activate;
|
|
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.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 {
|
|
if self.profit_point > Decimal::ZERO {
|
|
|
self.mid_rate_signal_close = mid_rate;
|
|
self.mid_rate_signal_close = mid_rate;
|
|
|
} else if self.t_diff.is_zero() {
|
|
} 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 {
|
|
if self.profit_point > Decimal::ZERO {
|
|
|
self.mid_rate_signal_close = mid_rate;
|
|
self.mid_rate_signal_close = mid_rate;
|
|
|
} else if self.t_diff.is_zero() {
|
|
} 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!("硬止损, 在价格{}处,成本价{},价值={}, p={}。", self.fair_price_focus_close, self.pos_avg_price, self.pos_avg_price*self.pos_amount, self.profit_point);
|
|
|
// info!("----------------------------------------");
|
|
// info!("----------------------------------------");
|
|
|
// }
|
|
// }
|
|
|
- // ============================ 平仓特殊逻辑处理2 =======================
|
|
|
|
|
|
|
+ // // ============================ 平仓特殊逻辑处理2 =======================
|
|
|
if self.mid_rate_signal_close.is_zero() && !self.inventory.is_zero() && self.profit_point_vec.len() > 1 {
|
|
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 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];
|
|
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) {
|
|
pub fn update_optimal_ask_and_bid(&mut self) {
|
|
|
self.optimal_ask_price = if self.ask_delta == dec!(-1) {
|
|
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) {
|
|
} else if self.ask_delta == dec!(-2) {
|
|
|
Self::DONT_VIEW
|
|
Self::DONT_VIEW
|
|
|
} else {
|
|
} else {
|
|
@@ -656,7 +656,7 @@ impl Predictor {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
self.optimal_bid_price = if self.bid_delta == dec!(-1) {
|
|
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) {
|
|
} else if self.bid_delta == dec!(-2) {
|
|
|
Self::DONT_VIEW
|
|
Self::DONT_VIEW
|
|
|
} else {
|
|
} else {
|