Skip to content

fix(backtest): handle IndexError at right calendar boundary - #2330

Open
Akshay Kumar Hudedmani (akshaykumarhudedmani) wants to merge 1 commit into
microsoft:mainfrom
akshaykumarhudedmani:fix-calendar-index-bug
Open

fix(backtest): handle IndexError at right calendar boundary#2330
Akshay Kumar Hudedmani (akshaykumarhudedmani) wants to merge 1 commit into
microsoft:mainfrom
akshaykumarhudedmani:fix-calendar-index-bug

Conversation

@akshaykumarhudedmani

Description

Fixes #2278. This adds a bounds check in get_step_time when calculating the right endpoint of the step interval to prevent an IndexError on the final trading day of the calendar. If the boundary is reached, it uses the previous time delta to safely advance.

Motivation and Context

Fixes #2278. When backtesting on a dataset without a future=True calendar extension, the right interval endpoint on the very last day throws an IndexError. This properly handles the boundary condition.

How Has This Been Tested?

  • Pass the test by running: pytest qlib/tests/test_all_pipeline.py under upper directory of qlib.
  • If you are adding a new feature, test on your own test scripts.

Screenshots of Test Results (if appropriate):

Pipeline test passed successfully (3 tests passed).

Types of changes

  • Fix bugs
  • Add new feature
  • Update documentation

@akshaykumarhudedmani

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backtest IndexError at the right calendar boundary (get_step_time peeks calendar[index+1])

1 participant