From b5e9bdb559479402b1f653536b17820806e0963e Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Tue, 6 Aug 2019 22:40:11 +0800 Subject: [PATCH] [Mod] change strategy import function of pyd files --- vnpy/app/cta_backtester/engine.py | 6 +++++- vnpy/app/cta_strategy/engine.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/vnpy/app/cta_backtester/engine.py b/vnpy/app/cta_backtester/engine.py index ea9a368b..b64045a2 100644 --- a/vnpy/app/cta_backtester/engine.py +++ b/vnpy/app/cta_backtester/engine.py @@ -94,7 +94,11 @@ class BacktesterEngine(BaseEngine): if filename.endswith(".py"): strategy_module_name = ".".join( [module_name, filename.replace(".py", "")]) - self.load_strategy_class_from_module(strategy_module_name) + 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): """ diff --git a/vnpy/app/cta_strategy/engine.py b/vnpy/app/cta_strategy/engine.py index 76eda3d8..cd02823a 100644 --- a/vnpy/app/cta_strategy/engine.py +++ b/vnpy/app/cta_strategy/engine.py @@ -755,9 +755,9 @@ class CtaEngine(BaseEngine): if filename.endswith(".py"): strategy_module_name = ".".join( [module_name, filename.replace(".py", "")]) - elif filename.endswith(".cp37-win_amd64.pyd"): + elif filename.endswith(".pyd"): strategy_module_name = ".".join( - [module_name, filename.replace(".cp37-win_amd64.pyd", "")]) + [module_name, filename.split(".")[0]]) self.load_strategy_class_from_module(strategy_module_name)