microsoft / microsoft/qlib

滚动预测时可能的bug

Open
#1,660 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

我执行rolling_benchmark.py时,发生如下错误。

[11664:MainThread](2023-09-30 09:46:50,926) WARNING - qlib.data - [data.py:666] - load calendar error: freq=day, future=True; return current calendar!
[11664:MainThread](2023-09-30 09:46:50,927) WARNING - qlib.data - [data.py:669] - You can get future calendar by referring to the following document: https://github.com/microsoft/qlib/blob/main/scripts/data_collector/contrib/README.md
[11664:MainThread](2023-09-30 09:46:50,941) ERROR - qlib.workflow - [utils.py:41] - An exception has been raised[TypeError: '>' not supported between instances of 'NoneType' and 'Timestamp'].
File "g:/qlibtutor/advance/benchmarks_dynamic/baseline/my_rolling_benchmark.py", line 61, in
rb._train_rolling_tasks()
File "E:\anaconda3\envs\qlib230908\lib\site-packages\qlib\contrib\rolling\base.py", line 187, in _train_rolling_tasks
task_l = self.get_task_list()
File "E:\anaconda3\envs\qlib230908\lib\site-packages\qlib\contrib\rolling\base.py", line 177, in get_task_list
task_l = task_generator(
File "E:\anaconda3\envs\qlib230908\lib\site-packages\qlib\workflow\task\gen.py", line 46, in task_generator
new_task_list.extend(gen.generate(task))
File "E:\anaconda3\envs\qlib230908\lib\site-packages\qlib\workflow\task\gen.py", line 301, in generate
res.extend(self.gen_following_tasks(t, test_end))
File "E:\anaconda3\envs\qlib230908\lib\site-packages\qlib\workflow\task\gen.py", line 217, in gen_following_tasks
if segments[self.test_key][0] > test_end:
TypeError: '>' not supported between instances of 'NoneType' and 'Timestamp'

我把gen_following_tasks方法中的
if segments[self.test_key][0] > test_end:改为 if segments[self.test_key][0] is None or segments[self.test_key][0] > test_end:就正常了。不知这样改正确否。

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

Reproduce the failure with rolling_benchmark.py, then inspect gen_following_tasks in qlib/workflow/task/gen.py around the comparison at line 217. Trace how segments[self.test_key][0] and test_end are produced, and verify the intended handling of a None start value. Done means rolling task generation completes without the TypeError and preserves the expected date boundaries.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.