From 876fa9643fcbdb41a056219780f7a4fbc23b228b Mon Sep 17 00:00:00 2001 From: jichao <jichao614@foxmail.com> Date: Sat, 7 Jan 2023 03:08:21 +0800 Subject: [PATCH] 6258 --- robo_executor.py | 58 ++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/robo_executor.py b/robo_executor.py index 1893d0f..a53a90c 100644 --- a/robo_executor.py +++ b/robo_executor.py @@ -90,35 +90,35 @@ class BacktestExecutor(RoboExecutor): self._rule.clear_signal() def start_exec(self): - # if self.is_sync_data: - # for sync in self._syncs: - # sync.do_sync() - # if self.is_clean_up: - # self.clear_datas() - # if self.start_step.within(BacktestStep.EWMA_VALUE) and self.end_step.without(BacktestStep.EWMA_VALUE): - # logger.info("start to build fund ewma value.".center(50, '-')) - # now = dt.now() - # wait([self.async_build_risk_date(x['id']) for x in self._datum.get_datums(type=DatumType.FUND, risk=(3, 4, 5))]) - # logger.info(f"build fund ewma value success, use[{(dt.now() - now).seconds}s]") - # if self.start_step.within(BacktestStep.ASSET_POOL) and self.end_step.without(BacktestStep.ASSET_POOL): - # logger.info("start to build asset pool".center(50, '-')) - # now = dt.now() - # workdays = workday_range(self.start_date, self.end_date) - # for date in workdays: - # self._risk.get_risk_pool(date) - # for date in workdays: - # self._pool.get_pool(date) - # logger.info(f"build asset pool success, use[{(dt.now() - now).seconds}s]") - # if self.start_step.within(BacktestStep.NORMAL_PORTFOLIO) and self.end_step.without(BacktestStep.NORMAL_PORTFOLIO): - # logger.info("start to build normal portfolios".center(50, '-')) - # now = dt.now() - # wait([self.async_build_portfolios(day, risk) for risk in PortfoliosRisk for day in workday_range(self.start_date, self.end_date)]) - # logger.info(f"build normal portfolios success, use[{(dt.now() - now).seconds}s]") - # if self.start_step.within(BacktestStep.HOLD_PORTFOLIO) and self.end_step.without(BacktestStep.HOLD_PORTFOLIO): - # logger.info("start to build hold portfolios".center(50, '-')) - # now = dt.now() - # wait([self.async_build_hold(x) for x in PortfoliosRisk]) - # logger.info(f"build hold portfolios success, use[{(dt.now() - now).seconds}s]") + if self.is_sync_data: + for sync in self._syncs: + sync.do_sync() + if self.is_clean_up: + self.clear_datas() + if self.start_step.within(BacktestStep.EWMA_VALUE) and self.end_step.without(BacktestStep.EWMA_VALUE): + logger.info("start to build fund ewma value.".center(50, '-')) + now = dt.now() + wait([self.async_build_risk_date(x['id']) for x in self._datum.get_datums(type=DatumType.FUND, risk=(3, 4, 5))]) + logger.info(f"build fund ewma value success, use[{(dt.now() - now).seconds}s]") + if self.start_step.within(BacktestStep.ASSET_POOL) and self.end_step.without(BacktestStep.ASSET_POOL): + logger.info("start to build asset pool".center(50, '-')) + now = dt.now() + workdays = workday_range(self.start_date, self.end_date) + for date in workdays: + self._risk.get_risk_pool(date) + for date in workdays: + self._pool.get_pool(date) + logger.info(f"build asset pool success, use[{(dt.now() - now).seconds}s]") + if self.start_step.within(BacktestStep.NORMAL_PORTFOLIO) and self.end_step.without(BacktestStep.NORMAL_PORTFOLIO): + logger.info("start to build normal portfolios".center(50, '-')) + now = dt.now() + wait([self.async_build_portfolios(day, risk) for risk in PortfoliosRisk for day in workday_range(self.start_date, self.end_date)]) + logger.info(f"build normal portfolios success, use[{(dt.now() - now).seconds}s]") + if self.start_step.within(BacktestStep.HOLD_PORTFOLIO) and self.end_step.without(BacktestStep.HOLD_PORTFOLIO): + logger.info("start to build hold portfolios".center(50, '-')) + now = dt.now() + wait([self.async_build_hold(x) for x in PortfoliosRisk]) + logger.info(f"build hold portfolios success, use[{(dt.now() - now).seconds}s]") logger.info("start to export report".center(50, '-')) now = dt.now() file = self._export.export(max_date=self.end_date) -- 2.18.1