From 5ff49f70b21aafcc1b25f2dd38f8a5b5fa2b5f7f Mon Sep 17 00:00:00 2001 From: msincenselee Date: Sun, 29 Mar 2020 13:53:04 +0800 Subject: [PATCH] [bug fix] --- vnpy/app/cta_strategy_pro/back_testing.py | 4 ++-- vnpy/app/cta_strategy_pro/engine.py | 2 +- vnpy/app/cta_strategy_pro/template.py | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/vnpy/app/cta_strategy_pro/back_testing.py b/vnpy/app/cta_strategy_pro/back_testing.py index 04be4627..6d910a5a 100644 --- a/vnpy/app/cta_strategy_pro/back_testing.py +++ b/vnpy/app/cta_strategy_pro/back_testing.py @@ -377,7 +377,7 @@ class BackTestingEngine(object): def get_position_holding(self, vt_symbol: str, gateway_name: str = ''): """ 查询合约在账号的持仓(包含多空)""" - if gateway_name: + if len(gateway_name) == 0: gateway_name = self.gateway_name k = f'{gateway_name}.{vt_symbol}' holding = self.holdings.get(k, None) @@ -952,7 +952,7 @@ class BackTestingEngine(object): strategy_cond = strategy.strategy_name == order_strategy.strategy_name if offset_cond and symbol_cond and strategy_cond: - self.write_log(u'撤销订单:{},{} {}@{}' + self.write_log(u'撤销限价订单:{},{} {}@{}' .format(vt_orderid, order.direction, order.price, order.volume)) order.status = Status.CANCELLED order.cancel_time = str(self.last_dt) diff --git a/vnpy/app/cta_strategy_pro/engine.py b/vnpy/app/cta_strategy_pro/engine.py index 2f19372e..a7eb2055 100644 --- a/vnpy/app/cta_strategy_pro/engine.py +++ b/vnpy/app/cta_strategy_pro/engine.py @@ -1533,7 +1533,7 @@ class CtaEngine(BaseEngine): 'account_id': self.engine_config.get('account_id', '-'), 'vt_symbol': vt_symbol, 'direction': Direction.SHORT.value, - 'strategy_list': symbol_pos.get('多单策略', [])} + 'strategy_list': symbol_pos.get('空单策略', [])} # 多空都一致 if round(symbol_pos['账号空单'], 7) == round(symbol_pos['策略空单'], 7) and \ diff --git a/vnpy/app/cta_strategy_pro/template.py b/vnpy/app/cta_strategy_pro/template.py index d5c9fe27..a5981116 100644 --- a/vnpy/app/cta_strategy_pro/template.py +++ b/vnpy/app/cta_strategy_pro/template.py @@ -1580,7 +1580,9 @@ class CtaProFutureTemplate(CtaProTemplate): self.write_log(u'撤单失败,更新状态为撤单成功') order_info.update({'status': Status.CANCELLED}) self.active_orders.update({vt_orderid: order_info}) - + if order_grid: + if vt_orderid in order_grid.order_ids: + order_grid.order_ids.remove(vt_orderid) continue # 处理状态为‘撤销’的委托单