Commit 2b9e7ee0 authored by jichao's avatar jichao

6258

parent c7eac260
...@@ -90,36 +90,36 @@ class BacktestExecutor(RoboExecutor): ...@@ -90,36 +90,36 @@ class BacktestExecutor(RoboExecutor):
self._rule.clear_signal() self._rule.clear_signal()
def start_exec(self): def start_exec(self):
if self.is_sync_data: # if self.is_sync_data:
for sync in self._syncs: # for sync in self._syncs:
sync.do_sync() # sync.do_sync()
if self.is_clean_up: # if self.is_clean_up:
self.clear_datas() # self.clear_datas()
if self.start_step.within(BacktestStep.EWMA_VALUE) and self.end_step.without(BacktestStep.EWMA_VALUE): # 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, '-')) # logger.info("start to build fund ewma value.".center(50, '-'))
now = dt.now() # 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))]) # 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]") # 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): # 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, '-')) # logger.info("start to build asset pool".center(50, '-'))
now = dt.now() # now = dt.now()
workdays = workday_range(self.start_date, self.end_date) # workdays = workday_range(self.start_date, self.end_date)
for date in workdays: # for date in workdays:
self._risk.get_risk_pool(date) # self._risk.get_risk_pool(date)
for date in workdays: # for date in workdays:
self._pool.get_pool(date) # self._pool.get_pool(date)
logger.info(f"build asset pool success, use[{(dt.now() - now).seconds}s]") # 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): # 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, '-')) # logger.info("start to build normal portfolios".center(50, '-'))
now = dt.now() # 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)]) # 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]") # 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): # 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, '-')) # logger.info("start to build hold portfolios".center(50, '-'))
now = dt.now() # now = dt.now()
wait([self.async_build_hold(x) for x in PortfoliosRisk]) # 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(f"build hold portfolios success, use[{(dt.now() - now).seconds}s]")
logger.info("start to export report".center(50, '-')) # logger.info("start to export report".center(50, '-'))
now = dt.now() now = dt.now()
file = self._export.export(max_date=self.end_date) file = self._export.export(max_date=self.end_date)
logger.info(f"report file[{os.path.basename(file)}] exported successfully. use[{(dt.now() - now).seconds}s].") logger.info(f"report file[{os.path.basename(file)}] exported successfully. use[{(dt.now() - now).seconds}s].")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment