Skip to content

Bug: sort_index() result discarded in filter.py — timestamp series may be unsorted #2165

@warren618

Description

@warren618

Description

In qlib/data/filter.py line 163, timestamp_series.sort_index() is called but its return value is discarded:

timestamp_series.sort_index() # returns new Series, original unchanged

pandas.Series.sort_index() returns a new sorted Series and does not modify in place (unlike sort_index(inplace=True)). The unsorted series is then iterated to build timestamp ranges, which can produce incorrect filter boundaries.

Fix

- timestamp_series.sort_index() + timestamp_series = timestamp_series.sort_index()

I will submit a fix shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions