This commit is contained in:
msincenselee 2017-06-08 17:32:54 +08:00
parent c261056c75
commit 8b89464ca7

View File

@ -23,14 +23,12 @@ for root, subdirs, files in os.walk(path):
if 'strategy' in name and '.pyc' not in name: if 'strategy' in name and '.pyc' not in name:
# 模块名称需要上前缀 # 模块名称需要上前缀
moduleName = 'ctaStrategy.strategy.' + name.replace('.py', '') moduleName = 'ctaStrategy.strategy.' + name.replace('.py', '')
print 'loading {0}'.format(moduleName)
print 'loading {0}'.format(moduleName) try:
try: # 使用importlib动态载入模块
# 使用importlib动态载入模块 module = importlib.import_module(moduleName)
module = importlib.import_module(moduleName) except Exception as ex:
print 'load fail,excepion:{0}'.format(ex)
except:
print 'load fail'
continue continue
# 遍历模块下的对象,只有名称中包含'Strategy'的才是策略类 # 遍历模块下的对象,只有名称中包含'Strategy'的才是策略类