diff --git a/vnpy/trader/app/ctaStrategy/ctaBacktesting.py b/vnpy/trader/app/ctaStrategy/ctaBacktesting.py index 83daf4d7..3b4e3557 100644 --- a/vnpy/trader/app/ctaStrategy/ctaBacktesting.py +++ b/vnpy/trader/app/ctaStrategy/ctaBacktesting.py @@ -1130,8 +1130,6 @@ class DailyResult(object): self.totalPnl = self.tradingPnl + self.positionPnl self.netPnl = self.totalPnl - self.commission - self.slippage - - ######################################################################## class OptimizationSetting(object): diff --git a/vnpy/trader/app/ctaStrategy/strategy/strategyDoubleMa.py b/vnpy/trader/app/ctaStrategy/strategy/strategyDoubleMa.py index 2692ddf6..776b1ef7 100644 --- a/vnpy/trader/app/ctaStrategy/strategy/strategyDoubleMa.py +++ b/vnpy/trader/app/ctaStrategy/strategy/strategyDoubleMa.py @@ -154,115 +154,3 @@ class DoubleMaStrategy(CtaTemplate): def onStopOrder(self, so): """停止单推送""" pass - - -######################################################################################## -class OrderManagementDemoStrategy(CtaTemplate): - """基于tick级别细粒度撤单追单测试demo""" - - className = 'OrderManagementDemoStrategy' - author = u'用Python的交易员' - - # 策略参数 - initDays = 10 # 初始化数据所用的天数 - - # 策略变量 - bar = None - barMinute = EMPTY_STRING - - - # 参数列表,保存了参数的名称 - paramList = ['name', - 'className', - 'author', - 'vtSymbol'] - - # 变量列表,保存了变量的名称 - varList = ['inited', - 'trading', - 'pos'] - - #---------------------------------------------------------------------- - def __init__(self, ctaEngine, setting): - """Constructor""" - super(OrderManagementDemoStrategy, self).__init__(ctaEngine, setting) - - self.lastOrder = None - self.orderType = '' - - #---------------------------------------------------------------------- - def onInit(self): - """初始化策略(必须由用户继承实现)""" - self.writeCtaLog(u'双EMA演示策略初始化') - - initData = self.loadBar(self.initDays) - for bar in initData: - self.onBar(bar) - - self.putEvent() - - #---------------------------------------------------------------------- - def onStart(self): - """启动策略(必须由用户继承实现)""" - self.writeCtaLog(u'双EMA演示策略启动') - self.putEvent() - - #---------------------------------------------------------------------- - def onStop(self): - """停止策略(必须由用户继承实现)""" - self.writeCtaLog(u'双EMA演示策略停止') - self.putEvent() - - #---------------------------------------------------------------------- - def onTick(self, tick): - """收到行情TICK推送(必须由用户继承实现)""" - - # 建立不成交买单测试单 - if self.lastOrder == None: - self.buy(tick.lastprice - 10.0, 1) - - # CTA委托类型映射 - if self.lastOrder != None and self.lastOrder.direction == u'多' and self.lastOrder.offset == u'开仓': - self.orderType = u'买开' - - elif self.lastOrder != None and self.lastOrder.direction == u'多' and self.lastOrder.offset == u'平仓': - self.orderType = u'买平' - - elif self.lastOrder != None and self.lastOrder.direction == u'空' and self.lastOrder.offset == u'开仓': - self.orderType = u'卖开' - - elif self.lastOrder != None and self.lastOrder.direction == u'空' and self.lastOrder.offset == u'平仓': - self.orderType = u'卖平' - - # 不成交,即撤单,并追单 - if self.lastOrder != None and self.lastOrder.status == u'未成交': - - self.cancelOrder(self.lastOrder.vtOrderID) - self.lastOrder = None - elif self.lastOrder != None and self.lastOrder.status == u'已撤销': - # 追单并设置为不能成交 - - self.sendOrder(self.orderType, self.tick.lastprice - 10, 1) - self.lastOrder = None - - #---------------------------------------------------------------------- - def onBar(self, bar): - """收到Bar推送(必须由用户继承实现)""" - pass - - #---------------------------------------------------------------------- - def onOrder(self, order): - """收到委托变化推送(必须由用户继承实现)""" - # 对于无需做细粒度委托控制的策略,可以忽略onOrder - self.lastOrder = order - - #---------------------------------------------------------------------- - def onTrade(self, trade): - """收到成交推送(必须由用户继承实现)""" - # 对于无需做细粒度委托控制的策略,可以忽略onOrder - pass - - #---------------------------------------------------------------------- - def onStopOrder(self, so): - """停止单推送""" - pass