增加CTA模块中,策略对于当前运行环境的识别函数
This commit is contained in:
parent
377beb9d82
commit
b9e89657d9
@ -42,6 +42,9 @@ class BacktestingEngine(object):
|
||||
self.stopOrderDict = {} # 停止单撤销后不会从本字典中删除
|
||||
self.workingStopOrderDict = {} # 停止单撤销后会从本字典中删除
|
||||
|
||||
# 引擎类型为回测
|
||||
self.engineType = ENGINETYPE_BACKTESTING
|
||||
|
||||
# 回测相关
|
||||
self.strategy = None # 回测策略
|
||||
self.mode = self.BAR_MODE # 回测模式,默认为K线
|
||||
|
@ -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
|
||||
|
@ -70,6 +70,9 @@ class CtaEngine(object):
|
||||
# key为vtSymbol,value为PositionBuffer对象
|
||||
self.posBufferDict = {}
|
||||
|
||||
# 引擎类型为实盘
|
||||
self.engineType = ENGINETYPE_TRADING
|
||||
|
||||
# 注册事件监听
|
||||
self.registerEvent()
|
||||
|
||||
|
@ -165,4 +165,9 @@ class CtaTemplate(object):
|
||||
def putEvent(self):
|
||||
"""发出策略状态变化事件"""
|
||||
self.ctaEngine.putStrategyEvent(self.name)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def getEngineType(self):
|
||||
"""查询当前运行的环境"""
|
||||
return self.ctaEngine.engineType
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user