qlib icon indicating copy to clipboard operation
qlib copied to clipboard

滚动预测时可能的bug

Open quant2008 opened this issue 2 years ago • 0 comments

我执行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:就正常了。不知这样改正确否。

quant2008 avatar Sep 30 '23 02:09 quant2008