microsoft / microsoft/qlib

TradeCalendarManager: IndexError: index 4132 is out of bounds for axis 0 with size 4132

Open
#1,063 1 comment 0 reactions 1 assignee View on GitHub

@SunsetWolf is already working on this.

Since May 6, 2022.

bug
Dominant language
Python
Stars
48.7k
Forks
7.7k
PR merge metrics
No merged PRs in 30d

Description

🐛 Bug Description

TradeCalendarManager: IndexError: index 4132 is out of bounds for axis 0 with size 4132

To Reproduce

Steps to reproduce the behavior:

  1. The following code will raise the exception
start_time = "2021-01-01"

end_time = "2021-12-31"

calendar_manager = TradeCalendarManager("day", start_time, end_time)

for i in range(calendar_manager.get_trade_len()):

    trade_start_time, trade_end_time = calendar_manager.get_step_time(i)

    print(trade_start_time, trade_end_time, i, calendar_manager.start_index + i)
  1. however, if you change the start_time and end_time to other values, it's fine. So I assume there must be a bug here.
    for examples:
start_time = "2017-01-01"
end_time = "2020-08-01"

Bug Exception

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Input In [57], in <cell line: 13>()
     10 calendar_manager = TradeCalendarManager("day", start_time, end_time)
     13 for i in range(calendar_manager.get_trade_len()):
---> 14     trade_start_time, trade_end_time = calendar_manager.get_step_time(i)
     15     print(trade_start_time, trade_end_time, i, calendar_manager.start_index + i)

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/qlib/backtest/utils.py:117, in TradeCalendarManager.get_step_time(self, trade_step, shift)
    115 trade_step = trade_step - shift
    116 calendar_index = self.start_index + trade_step
--> 117 return self._calendar[calendar_index], epsilon_change(self._calendar[calendar_index + 1])

IndexError: index 4132 is out of bounds for axis 0 with size 4132

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.