|
|
@@ -961,24 +961,24 @@ impl Core {
|
|
|
self.stop().await;
|
|
|
}
|
|
|
// 回撤风控3,加浮亏的回撤风控
|
|
|
- let floating_profit = if !self.local_position.long_pos.is_zero() && !self.local_position.long_avg.is_zero() && !self.strategy.mp.is_zero() {
|
|
|
- let profit_price = self.strategy.mp - self.local_position.long_avg;
|
|
|
-
|
|
|
- profit_price * self.local_position.long_pos
|
|
|
- } else if !self.local_position.short_pos.is_zero() && !self.local_position.short_pos.is_zero() && !self.strategy.mp.is_zero() {
|
|
|
- let profit_price = self.local_position.short_avg - self.strategy.mp;
|
|
|
-
|
|
|
- profit_price * self.local_position.short_pos
|
|
|
- } else {
|
|
|
- Decimal::ZERO
|
|
|
- };
|
|
|
- let floating_draw_back = floating_profit / self.strategy.start_equity;
|
|
|
- if floating_draw_back < -self.stop_loss {
|
|
|
- let exit_msg = format!("{} 浮动亏损太大{},当前价格:{}, 准备停机。", self.params.account_name, floating_profit, self.strategy.mp);
|
|
|
- warn!(exit_msg);
|
|
|
- self.exit_msg = exit_msg;
|
|
|
- self.stop().await;
|
|
|
- }
|
|
|
+ // let floating_profit = if !self.local_position.long_pos.is_zero() && !self.local_position.long_avg.is_zero() && !self.strategy.mp.is_zero() {
|
|
|
+ // let profit_price = self.strategy.mp - self.local_position.long_avg;
|
|
|
+ //
|
|
|
+ // profit_price * self.local_position.long_pos
|
|
|
+ // } else if !self.local_position.short_pos.is_zero() && !self.local_position.short_pos.is_zero() && !self.strategy.mp.is_zero() {
|
|
|
+ // let profit_price = self.local_position.short_avg - self.strategy.mp;
|
|
|
+ //
|
|
|
+ // profit_price * self.local_position.short_pos
|
|
|
+ // } else {
|
|
|
+ // Decimal::ZERO
|
|
|
+ // };
|
|
|
+ // let floating_draw_back = floating_profit / self.strategy.start_equity;
|
|
|
+ // if floating_draw_back < -self.stop_loss {
|
|
|
+ // let exit_msg = format!("{} 浮动亏损太大{},当前价格:{}, 准备停机。", self.params.account_name, floating_profit, self.strategy.mp);
|
|
|
+ // warn!(exit_msg);
|
|
|
+ // self.exit_msg = exit_msg;
|
|
|
+ // self.stop().await;
|
|
|
+ // }
|
|
|
|
|
|
// 报单延迟风控,平均延迟允许上限5000ms
|
|
|
if self.ready == 1 && self.platform_rest.get_request_avg_delay() > dec!(5000) {
|