|
|
@@ -892,7 +892,7 @@ impl Strategy {
|
|
|
// }
|
|
|
// // debug!(?command);
|
|
|
|
|
|
- if predictor.inventory > Decimal::ZERO && predictor.ask_delta != Decimal::NEGATIVE_ONE {
|
|
|
+ if predictor.inventory > Decimal::ZERO && predictor.ask_delta != dec!(-2) {
|
|
|
if pd_order_num == 0 {
|
|
|
let mut price = (short_lower + short_upper) * dec!(0.5);
|
|
|
// 不限制大小
|
|
|
@@ -912,7 +912,7 @@ impl Strategy {
|
|
|
// debug!(?command);
|
|
|
}
|
|
|
}
|
|
|
- if predictor.inventory < Decimal::ZERO && predictor.bid_delta != Decimal::NEGATIVE_ONE {
|
|
|
+ if predictor.inventory < Decimal::ZERO && predictor.bid_delta != dec!(-2) {
|
|
|
if pk_order_num == 0 {
|
|
|
let mut price = (long_upper + long_lower) * dec!(0.5);
|
|
|
// 不限制大小
|
|
|
@@ -936,7 +936,7 @@ impl Strategy {
|
|
|
|
|
|
// 生成取消订单的指令
|
|
|
// #[instrument(skip(self, command), level="TRACE")]
|
|
|
- pub fn _cancel_open(&self, command: &mut OrderCommand, local_orders: &HashMap<String, OrderInfo>, predictor: &mut Predictor) {
|
|
|
+ pub fn _cancel_open(&self, command: &mut OrderCommand, local_orders: &HashMap<String, OrderInfo>, _predictor: &mut Predictor) {
|
|
|
// debug!(?command);
|
|
|
// 挂单范围
|
|
|
// let long_upper = self.open_dist[0];
|
|
|
@@ -953,9 +953,9 @@ impl Strategy {
|
|
|
if order.side == "kd".to_string() {
|
|
|
// 在价格范围内时不处理
|
|
|
// if order.price <= long_upper && order.price >= long_lower {
|
|
|
- // if self.local_time - order.local_time <= 500 {
|
|
|
+ if self.local_time - order.local_time <= 500 {
|
|
|
// if (self.local_time - order.local_time <= 500) && (order.price <= long_upper && order.price >= long_lower) {
|
|
|
- if predictor.bid_price == order.price {
|
|
|
+ // if predictor.bid_price == order.price {
|
|
|
continue
|
|
|
}
|
|
|
command.cancel.insert(key, value);
|
|
|
@@ -964,8 +964,8 @@ impl Strategy {
|
|
|
// 在价格范围内时不处理
|
|
|
// if (self.local_time - order.local_time <= 500) && (order.price >= short_lower && order.price <= short_upper) {
|
|
|
// if order.price >= short_lower && order.price <= short_upper {
|
|
|
- // if self.local_time - order.local_time <= 500 {
|
|
|
- if predictor.ask_price == order.price {
|
|
|
+ if self.local_time - order.local_time <= 500 {
|
|
|
+ // if predictor.ask_price == order.price {
|
|
|
continue
|
|
|
}
|
|
|
// debug!(?key, ?order.price, ?short_lower, ?short_upper);
|
|
|
@@ -1068,7 +1068,7 @@ impl Strategy {
|
|
|
// let one_hand_long_value = dec!(0.99) * (self.max_long_value / self.grid);
|
|
|
// let one_hand_short_value = dec!(0.99) * (self.max_short_value / self.grid);
|
|
|
// 挂多单
|
|
|
- if self.post_side >= 0 && buy_value == Decimal::ZERO && predictor.inventory.is_zero() && predictor.bid_delta != Decimal::NEGATIVE_ONE {
|
|
|
+ if self.post_side >= 0 && buy_value == Decimal::ZERO && predictor.inventory.is_zero() && predictor.bid_delta != dec!(-2) {
|
|
|
let mut target_buy_price = predictor.optimal_bid_price;
|
|
|
// target_buy_price = utils::clip(target_buy_price, self.bp * dec!(0.97), self.ap * dec!(1.0005));
|
|
|
target_buy_price = utils::fix_price(target_buy_price, self.tick_size);
|
|
|
@@ -1111,7 +1111,7 @@ impl Strategy {
|
|
|
}
|
|
|
}
|
|
|
// 挂空单
|
|
|
- if self.post_side <= 0 && sell_value == Decimal::ZERO && predictor.inventory.is_zero() && predictor.ask_delta != Decimal::NEGATIVE_ONE {
|
|
|
+ if self.post_side <= 0 && sell_value == Decimal::ZERO && predictor.inventory.is_zero() && predictor.ask_delta != dec!(-2) {
|
|
|
let mut target_sell_price = predictor.optimal_ask_price;
|
|
|
// target_sell_price = utils::clip(target_sell_price, self.bp * dec!(0.9995), self.ap * dec!(1.03));
|
|
|
// 取消大小限制
|
|
|
@@ -1232,7 +1232,7 @@ impl Strategy {
|
|
|
// 修复相关价格
|
|
|
self.fix_price(predictor);
|
|
|
|
|
|
- self._cancel_open(&mut command, local_orders, predictor); // 撤单命令处理
|
|
|
+ self._cancel_open(&mut command, local_orders, predictor); // 撤单命令处理
|
|
|
self._post_close(&mut command, local_orders, predictor); // 平仓单命令处理
|
|
|
self._post_open(&mut command, local_orders, predictor); // 限价单命令处理
|
|
|
self._check_local_orders(&mut command, local_orders); // 固定时间检查超时订单
|