Skip to content

Bug: ValueError in processor_yahoofinance.df_to_array due to mismatched array lengths #1389

@guillaumePoidatz

Description

@guillaumePoidatz

Describe the bug
When running the FinRL training pipeline, a ValueError is raised during data preprocessing with Yahoo Finance.
The error occurs in processor_yahoofinance.py when concatenating arrays using numpy.hstack.
It seems that the generated arrays do not share the same time dimension, which causes the concatenation to fail.

To Reproduce
Steps to reproduce the behavior:
just run this: python finrl/main.py --mode=train

Expected behavior
All arrays (price_array, technical indicators, turbulence/VIX if enabled) should have consistent lengths before concatenation.

Traceback (most recent call last): File "/Users/guillaumepoidatz/Documents/GitHub/FinRL/finrl/main.py", line 154, in <module> raise SystemExit(main()) File "/Users/guillaumepoidatz/Documents/GitHub/FinRL/finrl/main.py", line 73, in main train( File "/Users/guillaumepoidatz/Documents/GitHub/FinRL/finrl/train.py", line 36, in train price_array, tech_array, turbulence_array = dp.df_to_array(data, if_vix) File "/Users/guillaumepoidatz/Documents/GitHub/FinRL/finrl/meta/data_processor.py", line 80, in df_to_array price_array, tech_array, turbulence_array = self.processor.df_to_array( File "/Users/guillaumepoidatz/Documents/GitHub/FinRL/finrl/meta/data_processors/processor_yahoofinance.py", line 513, in df_to_array price_array = np.hstack( File "/Users/guillaumepoidatz/Documents/GitHub/FinRL/.venv/lib/python3.10/site-packages/numpy/_core/shape_base.py", line 367, in hstack return _nx.concatenate(arrs, 1, dtype=dtype, casting=casting) ValueError: all the input array dimensions except for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 3310 and the array at index 1 has size 2001

Desktop (please complete the following information):

  • OS: MacOS sequoia 15.1
  • Browser safari

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions