[bug fix]

This commit is contained in:
msincenselee 2021-05-25 21:48:32 +08:00
parent 2ed5301b6a
commit b1e0b74d98
2 changed files with 11 additions and 4 deletions

View File

@ -1248,9 +1248,14 @@ class CtaEngine(BaseEngine):
""" """
strategy = self.strategies[strategy_name] strategy = self.strategies[strategy_name]
if strategy.trading: if strategy.trading:
err_msg = f"策略{strategy.strategy_name}移除失败,请先停止" # err_msg = f"策略{strategy.strategy_name}正在运行,先停止"
self.write_error(err_msg) # self.write_error(err_msg)
return False, 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 # Remove setting
self.remove_strategy_setting(strategy_name) self.remove_strategy_setting(strategy_name)

View File

@ -101,6 +101,7 @@ class PortfolioTestingEngine(BackTestingEngine):
# 加载csv文件 =》 dateframe # 加载csv文件 =》 dateframe
symbol_df = pd.read_csv(bar_file, dtype=data_types) symbol_df = pd.read_csv(bar_file, dtype=data_types)
if len(symbol_df)==0: if len(symbol_df)==0:
print(f'回测时加载{vt_symbol} csv文件{bar_file}失败。', file=sys.stderr)
self.write_error(f'回测时加载{vt_symbol} csv文件{bar_file}失败。') self.write_error(f'回测时加载{vt_symbol} csv文件{bar_file}失败。')
return False return False
@ -133,7 +134,8 @@ class PortfolioTestingEngine(BackTestingEngine):
""" """
self.output('comine_df') self.output('comine_df')
if len(self.bar_df_dict) == 0: 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 = pd.concat(self.bar_df_dict, axis=0).swaplevel(0, 1).sort_index()
self.bar_df_dict.clear() self.bar_df_dict.clear()