From b1e0b74d98645ccb2ffd8df210983b1952de9e69 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Tue, 25 May 2021 21:48:32 +0800 Subject: [PATCH] [bug fix] --- vnpy/app/cta_strategy_pro/engine.py | 11 ++++++++--- vnpy/app/cta_strategy_pro/portfolio_testing.py | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/vnpy/app/cta_strategy_pro/engine.py b/vnpy/app/cta_strategy_pro/engine.py index 9ec13aba..35bce4c1 100644 --- a/vnpy/app/cta_strategy_pro/engine.py +++ b/vnpy/app/cta_strategy_pro/engine.py @@ -1248,9 +1248,14 @@ class CtaEngine(BaseEngine): """ strategy = self.strategies[strategy_name] if strategy.trading: - err_msg = f"策略{strategy.strategy_name}移除失败,请先停止" - self.write_error(err_msg) - return False, err_msg + # err_msg = f"策略{strategy.strategy_name}正在运行,先停止" + # self.write_error(err_msg) + # return False, err_msg + ret, msg = self.stop_strategy(strategy_name) + if not ret: + return False, msg + else: + self.write_log(msg) # Remove setting self.remove_strategy_setting(strategy_name) diff --git a/vnpy/app/cta_strategy_pro/portfolio_testing.py b/vnpy/app/cta_strategy_pro/portfolio_testing.py index 96aebac8..636da884 100644 --- a/vnpy/app/cta_strategy_pro/portfolio_testing.py +++ b/vnpy/app/cta_strategy_pro/portfolio_testing.py @@ -101,6 +101,7 @@ class PortfolioTestingEngine(BackTestingEngine): # 加载csv文件 =》 dateframe symbol_df = pd.read_csv(bar_file, dtype=data_types) if len(symbol_df)==0: + print(f'回测时加载{vt_symbol} csv文件{bar_file}失败。', file=sys.stderr) self.write_error(f'回测时加载{vt_symbol} csv文件{bar_file}失败。') return False @@ -133,7 +134,8 @@ class PortfolioTestingEngine(BackTestingEngine): """ self.output('comine_df') if len(self.bar_df_dict) == 0: - self.output(f'无加载任何数据,请检查bar文件路径配置') + print(f'{self.test_name}:无加载任何数据,请检查bar文件路径配置',file=sys.stderr) + self.output(f'{self.test_name}:无加载任何数据,请检查bar文件路径配置') self.bar_df = pd.concat(self.bar_df_dict, axis=0).swaplevel(0, 1).sort_index() self.bar_df_dict.clear()