From 1386e631b872a32a8c33485e6bc6de9c6db9e017 Mon Sep 17 00:00:00 2001 From: zengbin93 Date: Thu, 13 Jul 2023 19:54:42 +0800 Subject: [PATCH] 0.9.24 update --- czsc/sensors/event.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/czsc/sensors/event.py b/czsc/sensors/event.py index 176add3af..eca1d7ad9 100644 --- a/czsc/sensors/event.py +++ b/czsc/sensors/event.py @@ -66,8 +66,13 @@ def __init__(self, events: List[Union[Dict[str, Any], Event]], symbols: List[str self.kwargs = kwargs logger.info(f"事件匹配传感器初始化完成,共有{len(self.events)}个事件,{len(self.symbols)}个标的") - self.data = self._multi_symbols(self.symbols, max_workers=self.kwargs.pop("max_workers", 1)) - self.data.to_feather(os.path.join(self.results_path, "data.feather")) + file_data = os.path.join(self.results_path, "data.feather") + if os.path.exists(file_data): + self.data = pd.read_feather(file_data) + logger.info(f"读取事件匹配数据:{file_data}") + else: + self.data = self._multi_symbols(self.symbols, max_workers=self.kwargs.pop("max_workers", 1)) + self.data.to_feather(os.path.join(self.results_path, "data.feather")) _res = [] for event_name in self.events_name: @@ -75,8 +80,8 @@ def __init__(self, events: List[Union[Dict[str, Any], Event]], symbols: List[str df = df.set_index("dt") _res.append(df) df = pd.concat(_res, axis=1, ignore_index=False).reset_index() - file_csc = os.path.join(self.results_path, f"cross_section_counts.xlsx") - df.to_excel(file_csc, index=False) + file_csc = os.path.join(self.results_path, f"cross_section_counts.csv") + df.to_csv(file_csc, index=False) logger.info(f"截面匹配次数计算完成,结果保存至:{file_csc}") # csc = cross section count,表示截面匹配次数