From 5bb4a7135fb895026f93979971d6f9f3e14f840c Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 21 Sep 2019 11:33:52 +0800 Subject: [PATCH] [Fix] strategy_module_name may be not defined --- vnpy/app/cta_backtester/engine.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vnpy/app/cta_backtester/engine.py b/vnpy/app/cta_backtester/engine.py index c501f350..5b677c9a 100644 --- a/vnpy/app/cta_backtester/engine.py +++ b/vnpy/app/cta_backtester/engine.py @@ -91,14 +91,16 @@ 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) + self.load_strategy_class_from_module(strategy_module_name) def load_strategy_class_from_module(self, module_name: str): """