From 036e5931f98481867b1dd294fd99fe76e992a463 Mon Sep 17 00:00:00 2001 From: Huoran Li Date: Thu, 21 Jul 2022 16:31:19 +0800 Subject: [PATCH] Rename receive_execute_result() --- qlib/backtest/executor.py | 2 +- qlib/rl/order_execution/simulator_qlib.py | 2 +- qlib/strategy/base.py | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/qlib/backtest/executor.py b/qlib/backtest/executor.py index d46fc96c5..13af7aea7 100644 --- a/qlib/backtest/executor.py +++ b/qlib/backtest/executor.py @@ -464,7 +464,6 @@ class NestedExecutor(BaseExecutor): ) assert isinstance(_inner_execute_result, list) self.post_inner_exe_step(_inner_execute_result) - self.inner_strategy.receive_execute_result(_inner_execute_result) execute_result.extend(_inner_execute_result) inner_order_indicators.append( @@ -485,6 +484,7 @@ class NestedExecutor(BaseExecutor): inner_exe_res : the execution result of inner task """ + self.inner_strategy.post_exe_step(inner_exe_res) def get_all_executors(self) -> List[BaseExecutor]: """get all executors, including self and inner_executor.get_all_executors()""" diff --git a/qlib/rl/order_execution/simulator_qlib.py b/qlib/rl/order_execution/simulator_qlib.py index 6b6498d92..c48aa4c18 100644 --- a/qlib/rl/order_execution/simulator_qlib.py +++ b/qlib/rl/order_execution/simulator_qlib.py @@ -48,7 +48,7 @@ class DecomposedStrategy(BaseStrategy): def alter_outer_trade_decision(self, outer_trade_decision: BaseTradeDecision) -> BaseTradeDecision: return outer_trade_decision - def receive_execute_result(self, execute_result: list) -> None: + def post_exe_step(self, execute_result: list) -> None: self.execute_result = execute_result def reset(self, outer_trade_decision: TradeDecisionWO = None, **kwargs) -> None: diff --git a/qlib/strategy/base.py b/qlib/strategy/base.py index 14b3d30bf..5e61221a8 100644 --- a/qlib/strategy/base.py +++ b/qlib/strategy/base.py @@ -207,8 +207,15 @@ class BaseStrategy: range_limit = self.outer_trade_decision.get_data_cal_range_limit(rtype=rtype) return max(cal_range[0], range_limit[0]), min(cal_range[1], range_limit[1]) - def receive_execute_result(self, execute_result: list) -> None: - pass + def post_exe_step(self, execute_result: list) -> None: + """ + A hook for doing sth after the corresponding executor finished its execution. + + Parameters + ---------- + execute_result : + the execution result + """ class RLStrategy(BaseStrategy, metaclass=ABCMeta):