|
@@ -55,7 +55,7 @@ pub struct Predictor {
|
|
|
pub fair_price_ema_short: Decimal, // 公平价格_ema
|
|
pub fair_price_ema_short: Decimal, // 公平价格_ema
|
|
|
pub fair_price_ema_long: Decimal, // 公平价格_ema
|
|
pub fair_price_ema_long: Decimal, // 公平价格_ema
|
|
|
pub fair_rate_focus_open: Decimal, // 变化幅度焦点
|
|
pub fair_rate_focus_open: Decimal, // 变化幅度焦点
|
|
|
- pub fair_price_focus_open: Decimal, // 观测焦点时的价格
|
|
|
|
|
|
|
+ pub mid_price_focus_open: Decimal, // 观测焦点时的价格
|
|
|
pub fair_rate_focus_close: Decimal, // 变化幅度焦点
|
|
pub fair_rate_focus_close: Decimal, // 变化幅度焦点
|
|
|
pub fair_price_focus_close: Decimal, // 观测焦点时的价格
|
|
pub fair_price_focus_close: Decimal, // 观测焦点时的价格
|
|
|
pub fair_price_when_ordering: Decimal, // 下单时的公平价格
|
|
pub fair_price_when_ordering: Decimal, // 下单时的公平价格
|
|
@@ -171,7 +171,7 @@ impl Predictor {
|
|
|
fair_price_ema_short: Default::default(),
|
|
fair_price_ema_short: Default::default(),
|
|
|
fair_price_ema_long: Default::default(),
|
|
fair_price_ema_long: Default::default(),
|
|
|
fair_rate_focus_open: Default::default(),
|
|
fair_rate_focus_open: Default::default(),
|
|
|
- fair_price_focus_open: Default::default(),
|
|
|
|
|
|
|
+ mid_price_focus_open: Default::default(),
|
|
|
fair_rate_focus_close: Default::default(),
|
|
fair_rate_focus_close: Default::default(),
|
|
|
fair_price_focus_close: Default::default(),
|
|
fair_price_focus_close: Default::default(),
|
|
|
fair_price_when_ordering: Default::default(),
|
|
fair_price_when_ordering: Default::default(),
|
|
@@ -383,8 +383,8 @@ impl Predictor {
|
|
|
self.fair_rate_focus_open = Decimal::ZERO;
|
|
self.fair_rate_focus_open = Decimal::ZERO;
|
|
|
}
|
|
}
|
|
|
// 重置开仓焦点,条件3
|
|
// 重置开仓焦点,条件3
|
|
|
- if !self.fair_price_focus_open.is_zero() {
|
|
|
|
|
- let focus_rate = (self.fair_price - self.fair_price_focus_open) / self.fair_price_focus_open;
|
|
|
|
|
|
|
+ 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 / Decimal::TWO {
|
|
|
self.fair_rate_focus_open = Decimal::ZERO;
|
|
self.fair_rate_focus_open = Decimal::ZERO;
|
|
@@ -401,13 +401,13 @@ impl Predictor {
|
|
|
// 向上涨,并且fair下穿mid,视为观测阶段开始
|
|
// 向上涨,并且fair下穿mid,视为观测阶段开始
|
|
|
if rate > Decimal::ZERO {
|
|
if rate > Decimal::ZERO {
|
|
|
self.fair_rate_focus_open = rate;
|
|
self.fair_rate_focus_open = rate;
|
|
|
- self.fair_price_focus_open = self.fair_price;
|
|
|
|
|
|
|
+ self.mid_price_focus_open = self.mid_price;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 向下跌,并且fair上穿mid,视为观测阶段开始
|
|
// 向下跌,并且fair上穿mid,视为观测阶段开始
|
|
|
if rate < Decimal::ZERO {
|
|
if rate < Decimal::ZERO {
|
|
|
self.fair_rate_focus_open = rate;
|
|
self.fair_rate_focus_open = rate;
|
|
|
- self.fair_price_focus_open = self.fair_price;
|
|
|
|
|
|
|
+ self.mid_price_focus_open = self.mid_price;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|