From 4c39d4003e3bc60c19bab2c4157f5fb2f5024ac5 Mon Sep 17 00:00:00 2001 From: nanoric Date: Wed, 31 Oct 2018 00:01:38 -0400 Subject: [PATCH] =?UTF-8?q?[Fix]=20=E9=9D=9E=E5=BD=93=E5=89=8D=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=8B=E7=9A=84strategyXxx.py=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E8=A2=AB=E8=BD=BD=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/ctaStrategy/strategy/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vnpy/trader/app/ctaStrategy/strategy/__init__.py b/vnpy/trader/app/ctaStrategy/strategy/__init__.py index 5b10bc02..2aea54b3 100644 --- a/vnpy/trader/app/ctaStrategy/strategy/__init__.py +++ b/vnpy/trader/app/ctaStrategy/strategy/__init__.py @@ -12,6 +12,7 @@ import traceback # 用来保存策略类的字典 STRATEGY_CLASS = {} + #---------------------------------------------------------------------- def loadStrategyModule(moduleName): """使用importlib动态载入模块""" @@ -34,7 +35,7 @@ path = os.path.abspath(os.path.dirname(__file__)) for root, subdirs, files in os.walk(path): for name in files: # 只有文件名中包含strategy且以.py结尾的文件,才是策略文件 - if 'strategy' in name and name[-3:] == '.py': + if 'strategy' in name and name[-3:] == '.py' and '/' not in name and '\\' not in name: # 模块名称需要模块路径前缀 moduleName = 'vnpy.trader.app.ctaStrategy.strategy.' + name.replace('.py', '') loadStrategyModule(moduleName) @@ -45,7 +46,7 @@ workingPath = os.getcwd() for root, subdirs, files in os.walk(workingPath): for name in files: # 只有文件名中包含strategy且以.py结尾的文件,才是策略文件 - if 'strategy' in name and name[-3:] == '.py': + if 'strategy' in name and name[-3:] == '.py' and '/' not in name and '\\' not in name: # 模块名称无需前缀 moduleName = name.replace('.py', '') loadStrategyModule(moduleName)