|
|
@@ -67,7 +67,7 @@ pub struct Core {
|
|
|
pub local_buy_value: Decimal,
|
|
|
pub local_sell_value: Decimal,
|
|
|
pub local_cancel_log: HashMap<String, i64>,
|
|
|
- pub local_cancel_time: HashMap<String, i64>,
|
|
|
+ pub local_cancel_cache: HashMap<String, OrderInfo>,
|
|
|
pub interval: u64,
|
|
|
pub exchange: String,
|
|
|
pub exit_msg: String,
|
|
|
@@ -162,7 +162,7 @@ impl Core {
|
|
|
local_buy_value: Default::default(),
|
|
|
local_sell_value: Default::default(),
|
|
|
local_cancel_log: Default::default(),
|
|
|
- local_cancel_time: Default::default(),
|
|
|
+ local_cancel_cache: Default::default(),
|
|
|
interval: params.interval,
|
|
|
exchange: params.exchange.clone(),
|
|
|
exit_msg: "正常退出".to_string(),
|
|
|
@@ -495,10 +495,11 @@ impl Core {
|
|
|
info!("更新推算仓位 {:?}", self.local_position_by_orders);
|
|
|
let place_time = self.local_order_infos.get(&data.client_id).unwrap()[4].parse::<i64>().unwrap();
|
|
|
info!("当前时间-订单委托时间={}ms", Utc::now().timestamp_millis() - place_time);
|
|
|
- if let Some(cancel_time) = self.local_cancel_time.get(&data.client_id) {
|
|
|
- info!("当前时间-订单首次取消时间={}ms", Utc::now().timestamp_millis() - cancel_time)
|
|
|
+ if let Some(oi) = self.local_cancel_cache.get(&data.client_id) {
|
|
|
+ info!("取消报文:{}", oi.symbol);
|
|
|
+ info!("当前时间-订单首次取消时间={}ms", Utc::now().timestamp_millis() - oi.local_time)
|
|
|
} else {
|
|
|
- info!("没有提交过取消订单")
|
|
|
+ info!("没有提交过/没有提交成功过取消订单")
|
|
|
}
|
|
|
info!("委托时fp={}, mp={}, op={}",
|
|
|
self.local_order_infos.get(&data.client_id).unwrap()[5],
|
|
|
@@ -512,6 +513,13 @@ impl Core {
|
|
|
self.strategy._print_summary();
|
|
|
info!("------------------------------------------------------------------------------------");
|
|
|
}
|
|
|
+ // 这里主要是为了抓提交过的取消订单又成交的情况
|
|
|
+ else if filled.is_zero() {
|
|
|
+ // 提交取消订单成功
|
|
|
+ if !self.local_cancel_cache.contains_key(&data.client_id) {
|
|
|
+ self.local_cancel_cache.insert(data.client_id.clone(), data.clone());
|
|
|
+ }
|
|
|
+ }
|
|
|
// 每次有订单变动就触发一次策略
|
|
|
if self.mode_signal == 0 && self.ready == 1 {
|
|
|
// 更新交易数据
|
|
|
@@ -846,11 +854,6 @@ impl Core {
|
|
|
for cancel_key in orders.cancel.keys() {
|
|
|
let cid = orders.cancel.get(cancel_key).unwrap()[0].clone();
|
|
|
|
|
|
- // 提交取消订单的时间
|
|
|
- if !self.local_cancel_time.contains_key(&cid) {
|
|
|
- self.local_cancel_time.insert(cid.clone(), Utc::now().timestamp_millis());
|
|
|
- }
|
|
|
-
|
|
|
if self.local_cancel_log.contains_key(&cid) {
|
|
|
let num = self.local_cancel_log.get(&cid).unwrap() + 1;
|
|
|
self.local_cancel_log.insert(cid, num);
|