mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-17 17:34:35 +08:00
support check_transform_proc module_path
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
from qlib.data.dataset.handler import DataHandler, DataHandlerLP
|
from qlib.data.dataset.handler import DataHandler, DataHandlerLP
|
||||||
from qlib.data.dataset.processor import Processor
|
from qlib.contrib.data.handler import check_transform_proc
|
||||||
from qlib.utils import get_cls_kwargs
|
|
||||||
from qlib.log import TimeInspector
|
|
||||||
|
|
||||||
|
|
||||||
class HighFreqHandler(DataHandlerLP):
|
class HighFreqHandler(DataHandlerLP):
|
||||||
@@ -16,20 +15,9 @@ class HighFreqHandler(DataHandlerLP):
|
|||||||
fit_end_time=None,
|
fit_end_time=None,
|
||||||
drop_raw=True,
|
drop_raw=True,
|
||||||
):
|
):
|
||||||
def check_transform_proc(proc_l):
|
|
||||||
new_l = []
|
|
||||||
for p in proc_l:
|
|
||||||
p["kwargs"].update(
|
|
||||||
{
|
|
||||||
"fit_start_time": fit_start_time,
|
|
||||||
"fit_end_time": fit_end_time,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
new_l.append(p)
|
|
||||||
return new_l
|
|
||||||
|
|
||||||
infer_processors = check_transform_proc(infer_processors)
|
infer_processors = check_transform_proc(infer_processors, fit_start_time, fit_end_time)
|
||||||
learn_processors = check_transform_proc(learn_processors)
|
learn_processors = check_transform_proc(learn_processors, fit_start_time, fit_end_time)
|
||||||
|
|
||||||
data_loader = {
|
data_loader = {
|
||||||
"class": "QlibDataLoader",
|
"class": "QlibDataLoader",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def get_calendar_day(freq="day", future=False):
|
|||||||
if flag in H["c"]:
|
if flag in H["c"]:
|
||||||
_calendar = H["c"][flag]
|
_calendar = H["c"][flag]
|
||||||
else:
|
else:
|
||||||
_calendar = np.array(list(map(lambda x: x.date(), Cal.load_calendar(freq, future))))
|
_calendar = np.array(list(map(lambda x: pd.Timestamp(x.date()), Cal.load_calendar(freq, future))))
|
||||||
H["c"][flag] = _calendar
|
H["c"][flag] = _calendar
|
||||||
return _calendar
|
return _calendar
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class HighfreqWorkflow:
|
|||||||
"fit_start_time": start_time,
|
"fit_start_time": start_time,
|
||||||
"fit_end_time": train_end_time,
|
"fit_end_time": train_end_time,
|
||||||
"instruments": MARKET,
|
"instruments": MARKET,
|
||||||
"infer_processors": [{"class": "HighFreqNorm", "module_path": "highfreq_processor", "kwargs": {}}],
|
"infer_processors": [{"class": "HighFreqNorm", "module_path": "highfreq_processor"}],
|
||||||
}
|
}
|
||||||
DATA_HANDLER_CONFIG1 = {
|
DATA_HANDLER_CONFIG1 = {
|
||||||
"start_time": start_time,
|
"start_time": start_time,
|
||||||
|
|||||||
@@ -26,8 +26,10 @@ def check_transform_proc(proc_l, fit_start_time, fit_end_time):
|
|||||||
"fit_end_time": fit_end_time,
|
"fit_end_time": fit_end_time,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
# FIXME: the `module_path` parameter is missed.
|
proc_config = {"class": klass.__name__, "kwargs": pkwargs}
|
||||||
new_l.append({"class": klass.__name__, "kwargs": pkwargs})
|
if isinstance(p, dict) and "module_path" in p:
|
||||||
|
proc_config["module_path"] = p["module_path"]
|
||||||
|
new_l.append(proc_config)
|
||||||
else:
|
else:
|
||||||
new_l.append(p)
|
new_l.append(p)
|
||||||
return new_l
|
return new_l
|
||||||
|
|||||||
Reference in New Issue
Block a user