1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-05 20:11:08 +08:00

datahandler support explicit selector & PortAnaRecord support strategy instance

This commit is contained in:
Dong Zhou
2020-11-27 09:00:43 +08:00
parent 6b4156ab9f
commit ad21092375
2 changed files with 5 additions and 1 deletions

View File

@@ -51,6 +51,9 @@ def fetch_df_by_index(
-------
Data of the given index.
"""
# level = None -> use selector directly
if level == None:
return df.loc(axis=0)[selector]
# Try to get the right index
idx_slc = (selector, slice(None, None))
if get_level_index(df, level) == 1:

View File

@@ -15,6 +15,7 @@ from ..utils import init_instance_by_config, get_module_by_module_path
from ..log import get_module_logger
from ..utils import flatten_dict
from ..contrib.eva.alpha import calc_ic, calc_long_short_return
from ..contrib.strategy.strategy import BaseStrategy
logger = get_module_logger("workflow", "INFO")
@@ -220,7 +221,7 @@ class PortAnaRecord(SignalRecord):
self.strategy_config = config["strategy"]
self.backtest_config = config["backtest"]
self.strategy = init_instance_by_config(self.strategy_config)
self.strategy = init_instance_by_config(self.strategy_config, accept_types=BaseStrategy)
def generate(self, **kwargs):
# check previously stored prediction results