From 30d7b67a1ebf6f6cab2dcf2f30031d007510f064 Mon Sep 17 00:00:00 2001 From: Whning0513 Date: Thu, 4 Jun 2026 22:06:36 +0800 Subject: [PATCH] fix: change assert tp_idx > 0 to tp_idx >= 0 in TimeAdjuster.truncate() Fixes #1610 When start_time in the workflow config exactly matches the first trading day in the calendar, tp_idx is 0, causing the assertion to fail. The >= check handles this edge case without affecting existing behavior. --- qlib/workflow/task/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qlib/workflow/task/utils.py b/qlib/workflow/task/utils.py index 4b4a7c06b8e..15a9c083a82 100644 --- a/qlib/workflow/task/utils.py +++ b/qlib/workflow/task/utils.py @@ -226,7 +226,7 @@ def truncate(self, segment: tuple, test_start, days: int) -> tuple: new_seg = [] for time_point in segment: tp_idx = min(self.align_idx(time_point), test_idx - days) - assert tp_idx > 0 + assert tp_idx >= 0 new_seg.append(self.get(tp_idx)) return tuple(new_seg) else: