RL-MLDM / alphagen

Generating sets of formulaic alpha (predictive) stock factors via reinforcement learning.
478 stars 159 forks source link

运行报错求助:real_end_time = cal[end_index + self.max_future_days] IndexError: index 8246 is out of bounds for axis 0 with size 8222 #53

Open forhonourlx opened 4 weeks ago

forhonourlx commented 4 weeks ago

各位大佬, 运行报错求助,感激!

train_maskable_ppo.py中时间参数修改:

    data_train = StockData(instrument=instruments,
                           start_time='2016-01-01',
                           end_time='2024-03-31')
    data_valid = StockData(instrument=instruments,
                           start_time='2024-04-01',
                           end_time='2024-06-30')
    data_test = StockData(instrument=instruments,
                          start_time='2024-07-01',
                          end_time='2024-08-15')

运行run: python train_maskable_ppo.py --seed=25 --pool=10 --code=all --step=100000 报错error:

[26556:MainThread](2024-08-19 00:54:40,218) INFO - qlib.Initialization - [config.py:416] - default_conf: client.
[26556:MainThread](2024-08-19 00:54:40,768) INFO - qlib.Initialization - [__init__.py:74] - qlib successfully initialized based on client settings.
[26556:MainThread](2024-08-19 00:54:40,768) INFO - qlib.Initialization - [__init__.py:76] - data_path={'__DEFAULT_FREQ': WindowsPath('C:/Users/Administrator/.qlib/qlib_data/cn_data_rolling')}
[26556:MainThread](2024-08-19 00:56:16,074) ERROR - qlib.workflow - [utils.py:41] - An exception has been raised[IndexError: index 8246 is out of bounds for axis 0 with size 8222].
  File "train_maskable_ppo.py", line 189, in <module>
    fire.Fire(fire_helper)
  File "C:\Users\Administrator\.conda\envs\qlib\lib\site-packages\fire\core.py", line 143, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "C:\Users\Administrator\.conda\envs\qlib\lib\site-packages\fire\core.py", line 477, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "C:\Users\Administrator\.conda\envs\qlib\lib\site-packages\fire\core.py", line 693, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "train_maskable_ppo.py", line 181, in fire_helper
    main(_seed,
  File "train_maskable_ppo.py", line 111, in main
    data_test = StockData(instrument=instruments,
  File "C:\Users\Administrator\Desktop\DeepLearning\alphagen-0.1.0\alphagen_qlib\stock_data.py", line 37, in __init__
    self.data, self._dates, self._stock_ids = self._get_data()
  File "C:\Users\Administrator\Desktop\DeepLearning\alphagen-0.1.0\alphagen_qlib\stock_data.py", line 67, in _get_data
    df = self._load_exprs(features)
  File "C:\Users\Administrator\Desktop\DeepLearning\alphagen-0.1.0\alphagen_qlib\stock_data.py", line 61, in _load_exprs
    real_end_time = cal[end_index + self.max_future_days]
IndexError: index 8250 is out of bounds for axis 0 with size 8222
forhonourlx commented 4 weeks ago

max_future_days 是不是要在测试集中扣除啊?