mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-17 09:24:34 +08:00
fix: handler_mod func don't work when dealing None end date (#2068)
* [fix] handler_mod func don't work when dealing None end date * refactor: avoid deep access by extracting handler_kwargs and using get(end_time) --------- Co-authored-by: Linlang <Lv.Linlang@hotmail.com>
This commit is contained in:
@@ -106,15 +106,13 @@ def handler_mod(task: dict, rolling_gen):
|
|||||||
rg (RollingGen): an instance of RollingGen
|
rg (RollingGen): an instance of RollingGen
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
interval = rolling_gen.ta.cal_interval(
|
handler_kwargs = task["dataset"]["kwargs"]["handler"]["kwargs"]
|
||||||
task["dataset"]["kwargs"]["handler"]["kwargs"]["end_time"],
|
handler_end_time = handler_kwargs.get("end_time")
|
||||||
task["dataset"]["kwargs"]["segments"][rolling_gen.test_key][1],
|
test_seg_end_time = task["dataset"]["kwargs"]["segments"][rolling_gen.test_key][1]
|
||||||
)
|
# if the end of test_segments is None (open-ended segment, i.e., "until now") or end_time < the end of test_segments,
|
||||||
# if end_time < the end of test_segments, then change end_time to allow load more data
|
# then change end_time to allow load more data
|
||||||
if interval < 0:
|
if test_seg_end_time is None or rolling_gen.ta.cal_interval(handler_end_time, test_seg_end_time) < 0:
|
||||||
task["dataset"]["kwargs"]["handler"]["kwargs"]["end_time"] = copy.deepcopy(
|
handler_kwargs["end_time"] = copy.deepcopy(test_seg_end_time)
|
||||||
task["dataset"]["kwargs"]["segments"][rolling_gen.test_key][1]
|
|
||||||
)
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# Maybe dataset do not have handler, then do nothing.
|
# Maybe dataset do not have handler, then do nothing.
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user