=>Py3.5
This commit is contained in:
parent
5f034ccf3f
commit
50ed55ac32
@ -14,7 +14,7 @@ STRATEGY_CLASS = {}
|
||||
# 获取目录路径
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
print 'init {0}'.format(path)
|
||||
print ('init {0}'.format(path))
|
||||
|
||||
# 遍历strategy目录下的文件
|
||||
for root, subdirs, files in os.walk(path):
|
||||
@ -23,19 +23,19 @@ for root, subdirs, files in os.walk(path):
|
||||
if 'strategy' in name and '.pyc' not in name:
|
||||
# 模块名称需要上前缀
|
||||
moduleName = 'vnpy.trader.app.ctaStrategy.strategy.' + name.replace('.py', '')
|
||||
print 'loading {0}'.format(moduleName)
|
||||
print ('loading {0}'.format(moduleName))
|
||||
try:
|
||||
# 使用importlib动态载入模块
|
||||
module = importlib.import_module(moduleName)
|
||||
except Exception as ex:
|
||||
print 'load fail,excepion:{0}'.format(ex)
|
||||
print ('load fail,excepion:{0}'.format(ex))
|
||||
continue
|
||||
|
||||
# 遍历模块下的对象,只有名称中包含'Strategy'的才是策略类
|
||||
for k in dir(module):
|
||||
if 'Strategy' in k:
|
||||
print 'adding {0} into STRATEGY_CLASS'.format(k)
|
||||
print ('adding {0} into STRATEGY_CLASS'.format(k))
|
||||
v = module.__getattribute__(k)
|
||||
STRATEGY_CLASS[k] = v
|
||||
|
||||
print 'finished load modules'
|
||||
print( 'finished load strategy modules')
|
Loading…
Reference in New Issue
Block a user