增加CTA模块中,策略对于当前运行环境的识别函数

This commit is contained in:
chenxy123 2016-08-03 21:54:40 +08:00
parent 377beb9d82
commit b9e89657d9
4 changed files with 14 additions and 0 deletions

View File

@ -42,6 +42,9 @@ class BacktestingEngine(object):
self.stopOrderDict = {} # 停止单撤销后不会从本字典中删除 self.stopOrderDict = {} # 停止单撤销后不会从本字典中删除
self.workingStopOrderDict = {} # 停止单撤销后会从本字典中删除 self.workingStopOrderDict = {} # 停止单撤销后会从本字典中删除
# 引擎类型为回测
self.engineType = ENGINETYPE_BACKTESTING
# 回测相关 # 回测相关
self.strategy = None # 回测策略 self.strategy = None # 回测策略
self.mode = self.BAR_MODE # 回测模式默认为K线 self.mode = self.BAR_MODE # 回测模式默认为K线

View File

@ -33,6 +33,9 @@ TICK_DB_NAME = 'VnTrader_Tick_Db'
DAILY_DB_NAME = 'VnTrader_Daily_Db' DAILY_DB_NAME = 'VnTrader_Daily_Db'
MINUTE_DB_NAME = 'VnTrader_1Min_Db' MINUTE_DB_NAME = 'VnTrader_1Min_Db'
# 引擎类型,用于区分当前策略的运行环境
ENGINETYPE_BACKTESTING = 'backtesting' # 回测
ENGINETYPE_TRADING = 'trading' # 实盘
# CTA引擎中涉及的数据类定义 # CTA引擎中涉及的数据类定义
from vtConstant import EMPTY_UNICODE, EMPTY_STRING, EMPTY_FLOAT, EMPTY_INT from vtConstant import EMPTY_UNICODE, EMPTY_STRING, EMPTY_FLOAT, EMPTY_INT

View File

@ -70,6 +70,9 @@ class CtaEngine(object):
# key为vtSymbolvalue为PositionBuffer对象 # key为vtSymbolvalue为PositionBuffer对象
self.posBufferDict = {} self.posBufferDict = {}
# 引擎类型为实盘
self.engineType = ENGINETYPE_TRADING
# 注册事件监听 # 注册事件监听
self.registerEvent() self.registerEvent()

View File

@ -165,4 +165,9 @@ class CtaTemplate(object):
def putEvent(self): def putEvent(self):
"""发出策略状态变化事件""" """发出策略状态变化事件"""
self.ctaEngine.putStrategyEvent(self.name) self.ctaEngine.putStrategyEvent(self.name)
#----------------------------------------------------------------------
def getEngineType(self):
"""查询当前运行的环境"""
return self.ctaEngine.engineType