diff --git a/vn.trader/ctaAlgo/ctaBacktesting.py b/vn.trader/ctaAlgo/ctaBacktesting.py index 61295317..d82b6636 100644 --- a/vn.trader/ctaAlgo/ctaBacktesting.py +++ b/vn.trader/ctaAlgo/ctaBacktesting.py @@ -42,6 +42,9 @@ class BacktestingEngine(object): self.stopOrderDict = {} # 停止单撤销后不会从本字典中删除 self.workingStopOrderDict = {} # 停止单撤销后会从本字典中删除 + # 引擎类型为回测 + self.engineType = ENGINETYPE_BACKTESTING + # 回测相关 self.strategy = None # 回测策略 self.mode = self.BAR_MODE # 回测模式,默认为K线 diff --git a/vn.trader/ctaAlgo/ctaBase.py b/vn.trader/ctaAlgo/ctaBase.py index f0fffbca..8060b6a3 100644 --- a/vn.trader/ctaAlgo/ctaBase.py +++ b/vn.trader/ctaAlgo/ctaBase.py @@ -33,6 +33,9 @@ TICK_DB_NAME = 'VnTrader_Tick_Db' DAILY_DB_NAME = 'VnTrader_Daily_Db' MINUTE_DB_NAME = 'VnTrader_1Min_Db' +# 引擎类型,用于区分当前策略的运行环境 +ENGINETYPE_BACKTESTING = 'backtesting' # 回测 +ENGINETYPE_TRADING = 'trading' # 实盘 # CTA引擎中涉及的数据类定义 from vtConstant import EMPTY_UNICODE, EMPTY_STRING, EMPTY_FLOAT, EMPTY_INT diff --git a/vn.trader/ctaAlgo/ctaEngine.py b/vn.trader/ctaAlgo/ctaEngine.py index e4649580..17f2c020 100644 --- a/vn.trader/ctaAlgo/ctaEngine.py +++ b/vn.trader/ctaAlgo/ctaEngine.py @@ -70,6 +70,9 @@ class CtaEngine(object): # key为vtSymbol,value为PositionBuffer对象 self.posBufferDict = {} + # 引擎类型为实盘 + self.engineType = ENGINETYPE_TRADING + # 注册事件监听 self.registerEvent() diff --git a/vn.trader/ctaAlgo/ctaTemplate.py b/vn.trader/ctaAlgo/ctaTemplate.py index e98a6f83..2e4f57d4 100644 --- a/vn.trader/ctaAlgo/ctaTemplate.py +++ b/vn.trader/ctaAlgo/ctaTemplate.py @@ -165,4 +165,9 @@ class CtaTemplate(object): def putEvent(self): """发出策略状态变化事件""" self.ctaEngine.putStrategyEvent(self.name) + + #---------------------------------------------------------------------- + def getEngineType(self): + """查询当前运行的环境""" + return self.ctaEngine.engineType