Bug: sort_index() result discarded in filter.py — timestamp series may be unsorted
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 48.7k
- Forks
- 7.7k
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open qlib/data/filter.py at line 163 and inspect how timestamp_series is used to build timestamp ranges. Verify the sorted result is the series being iterated, then confirm that filter boundaries are ordered correctly for unsorted input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100