From 548a610610916f80038eb6c466328fb3a941d771 Mon Sep 17 00:00:00 2001 From: whning Date: Fri, 5 Jun 2026 01:59:05 +0800 Subject: [PATCH] Fix no-op sort_index() in SeriesDFilter._toTimestamp `timestamp_series.sort_index()` was called without reassignment or inplace=True, making it a silent no-op. The _toTimestamp state machine iterates over `timestamp_series.items()` and depends on the index being sorted to correctly detect transitions between contiguous True/False ranges. Without the sort, adjacent timestamps in arbitrary insertion order can produce spurious split intervals or merged ones, causing ExpressionDFilter and NameDFilter to yield incorrect instrument coverage intervals. This went unnoticed because ExpressionDFilter typically operates on calendar-ordered data from DatasetD, meaning the series often arrives pre-sorted by coincidence. Explicitly reassigning the sorted result guarantees correctness regardless of input order. --- qlib/data/filter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qlib/data/filter.py b/qlib/data/filter.py index 246d6baf765..9850680394b 100644 --- a/qlib/data/filter.py +++ b/qlib/data/filter.py @@ -160,7 +160,7 @@ def _toTimestamp(self, timestamp_series): the list of tuple (timestamp, timestamp). """ # sort the timestamp_series according to the timestamps - timestamp_series.sort_index() + timestamp_series = timestamp_series.sort_index() timestamp = [] _lbool = None _ltime = None