[bug fix]

This commit is contained in:
msincenselee 2020-03-29 13:53:04 +08:00
parent b31faa6b03
commit 5ff49f70b2
3 changed files with 6 additions and 4 deletions

View File

@ -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)

View File

@ -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 \

View File

@ -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
# 处理状态为‘撤销’的委托单