|
|
@@ -221,7 +221,7 @@ impl Predictor {
|
|
|
(self.pos_avg_price - self.mid_price) / self.pos_avg_price
|
|
|
};
|
|
|
|
|
|
- profit_now -= dec!(0.001);
|
|
|
+ profit_now -= dec!(0.0006);
|
|
|
profit_now.rescale(8);
|
|
|
|
|
|
self.profit_point_vec.push(profit_now);
|
|
|
@@ -385,9 +385,7 @@ impl Predictor {
|
|
|
}
|
|
|
|
|
|
let mut rate = Self::get_real_rate(&self.fair_price_time_vec);
|
|
|
- let mut long_rate = Self::get_real_rate(&self.fair_price_long_time_vec);
|
|
|
rate.rescale(8);
|
|
|
- long_rate.rescale(8);
|
|
|
|
|
|
// 重置开仓焦点,条件1
|
|
|
if !self.fair_rate_focus_open.is_zero() {
|
|
|
@@ -407,11 +405,11 @@ impl Predictor {
|
|
|
if !self.mid_price_focus_open.is_zero() {
|
|
|
let focus_rate = (self.mid_price - self.mid_price_focus_open) / self.mid_price_focus_open;
|
|
|
|
|
|
- if self.fair_rate_focus_open > Decimal::ZERO && focus_rate < Decimal::NEGATIVE_ONE * self.params.open_activate / Decimal::TWO {
|
|
|
+ if self.fair_rate_focus_open > Decimal::ZERO && focus_rate < Decimal::NEGATIVE_ONE * self.params.open_activate / dec!(3) {
|
|
|
self.fair_rate_focus_open = Decimal::ZERO;
|
|
|
}
|
|
|
|
|
|
- if self.fair_rate_focus_open < Decimal::ZERO && focus_rate > self.params.open_activate / Decimal::TWO {
|
|
|
+ if self.fair_rate_focus_open < Decimal::ZERO && focus_rate > self.params.open_activate / dec!(3) {
|
|
|
self.fair_rate_focus_open = Decimal::ZERO;
|
|
|
}
|
|
|
}
|
|
|
@@ -426,7 +424,7 @@ impl Predictor {
|
|
|
}
|
|
|
|
|
|
// 向下跌,并且fair上穿mid,视为观测阶段开始
|
|
|
- if rate < Decimal::ZERO && self.spread < Decimal::ZERO {
|
|
|
+ if rate < Decimal::ZERO && self.spread > Decimal::ZERO {
|
|
|
self.fair_rate_focus_open = rate;
|
|
|
self.mid_price_focus_open = self.mid_price;
|
|
|
}
|
|
|
@@ -696,7 +694,11 @@ impl Predictor {
|
|
|
|
|
|
let inventory = self.inventory;
|
|
|
|
|
|
- let sigma_square = Self::get_real_rate(&self.fair_price_long_time_vec);
|
|
|
+ let sigma_square = if self.fair_price_time_vec.len() > 1 {
|
|
|
+ Self::get_real_rate(&self.fair_price_time_vec)
|
|
|
+ } else {
|
|
|
+ Decimal::ZERO
|
|
|
+ };
|
|
|
// let sigma_square = self.error_rate;
|
|
|
|
|
|
let gamma = self.fair_rate_focus_open;
|