microsoft / microsoft/qlib

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

Open Beginner friendly
#2,165 2 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.