[Fix] strategy_module_name may be not defined

This commit is contained in:
vn.py 2019-09-21 11:33:52 +08:00
parent 846ea95093
commit 5bb4a7135f

View File

@ -91,13 +91,15 @@ class BacktesterEngine(BaseEngine):
"""
for dirpath, dirnames, filenames in os.walk(path):
for filename in filenames:
# Load python source code file
if filename.endswith(".py"):
strategy_module_name = ".".join(
[module_name, filename.replace(".py", "")])
self.load_strategy_class_from_module(strategy_module_name)
# Load compiled pyd binary file
elif filename.endswith(".pyd"):
strategy_module_name = ".".join(
[module_name, filename.split(".")[0]])
self.load_strategy_class_from_module(strategy_module_name)
def load_strategy_class_from_module(self, module_name: str):