diff --git a/vn.trader/ctaAlgo/ctaTemplate.py b/vn.trader/ctaAlgo/ctaTemplate.py index 7cd3150b..e98a6f83 100644 --- a/vn.trader/ctaAlgo/ctaTemplate.py +++ b/vn.trader/ctaAlgo/ctaTemplate.py @@ -120,11 +120,16 @@ class CtaTemplate(object): vtOrderID = self.ctaEngine.sendOrder(self.vtSymbol, orderType, price, volume, self) return vtOrderID else: - return None + # 交易停止时发单返回空字符串 + return '' #---------------------------------------------------------------------- def cancelOrder(self, vtOrderID): """撤单""" + # 如果发单号为空字符串,则不进行后续操作 + if not vtOrderID: + return + if STOPORDERPREFIX in vtOrderID: self.ctaEngine.cancelStopOrder(vtOrderID) else: diff --git a/vn.trader/vtGateway.py b/vn.trader/vtGateway.py index 88216377..3967c1a6 100644 --- a/vn.trader/vtGateway.py +++ b/vn.trader/vtGateway.py @@ -355,7 +355,7 @@ class VtContractData(VtBaseData): #---------------------------------------------------------------------- def __init__(self): """Constructor""" - super(VtBaseData, self).__init__() + super(VtContractData, self).__init__() self.symbol = EMPTY_STRING # 代码 self.exchange = EMPTY_STRING # 交易所代码