microsoft / microsoft/qlib

Multiple Issues in Yahoo Data Collector Causing Failures

Open
#1,981 1 comment 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

🐛 Bug Description

The Yahoo data collector (scripts/data_collector/yahoo/collector.py) has multiple critical issues that prevent successful data collection and normalization. These include date parsing errors, deprecated
pandas method warnings, type conversion failures, timezone handling problems, and performance issues.

To Reproduce

Steps to reproduce the behavior:

  1. Run the Yahoo data collector command:
  python scripts/data_collector/yahoo/collector.py -m 64 \
    update_data_to_bin \
    --qlib_data_1d_dir ~/.qlib/qlib_data/cn_data \
    --trading_date 2000-08-07 \
    --end_date 2025-08-13
  1. Observe multiple errors occurring during execution:
    • Date parsing ValueError at position 1183
    • FutureWarning about deprecated fillna method
    • TypeError for string/float division
    • AttributeError for tz_localize on Index objects
  2. Process fails or runs extremely slowly (2-4 files/second for 5000+ files)

Expected Behavior

The data collector should:

  • Successfully parse all date formats without errors

  • Run without pandas deprecation warnings

  • Handle data type conversions properly

  • Process files efficiently

  • Complete the full data collection and normalization pipeline

    Screenshot

    ValueError: unconverted data remains when parsing with format "%Y-%m-%d": " 00:00:00", at position 1183. You might want to try:

    • passing format if your strings have a consistent format;
    • passing format='ISO8601' if your strings are all ISO8601 but not necessarily in exactly the same format;
    • passing format='mixed', and the format will be inferred for each element individually.

    FutureWarning: Series.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead.

    TypeError: unsupported operand type(s) for /: 'str' and 'float'

    AttributeError: 'Index' object has no attribute 'tz_localize'

    Environment

  • Qlib version: main branch

  • Python version: 3.10

  • OS: macOS (Darwin 24.3.0)

  • Commit number: 1b426503

    Additional Notes

    Issues Identified:

  1. Date Parsing Error (base.py:308, collector.py:395)
    • pd.to_datetime() fails on mixed date formats ("YYYY-MM-DD" vs "YYYY-MM-DD HH:MM:SS")
    • Fix: Add format='mixed' parameter
  2. FutureWarning (collector.py:374, collector.py:462)
    • fillna(method="ffill") is deprecated
    • Fix: Replace with .ffill()
  3. Type Conversion Error (collector.py:506)
    • String data in numeric columns causes division errors
    • Fix: Add pd.to_numeric(df[_col], errors='coerce') before calculations
  4. Timezone Handling (collector.py:396)
    • Mixed timezone warning and AttributeError on Index objects
    • Fix: Add utc=True and proper DatetimeIndex conversion
  5. Performance Issues
    • ProcessPoolExecutor inefficient for I/O-bound tasks
    • Redundant CSV reads for column detection
    • Fix: Use ThreadPoolExecutor and optimize CSV reading
  6. Missing Recovery Option
    • No way to skip download after interruption
    • Fix: Add --skip_download parameter

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

Start by running the documented Yahoo collector command, then inspect scripts/data_collector/yahoo/base.py around line 308 and collector.py around lines 374, 395, 396, 462, and 506. Reproduce the listed parsing, warning, conversion, timezone, and performance failures before changing the collector. Done means the full update and normalization pipeline completes without those errors or warnings and supports the requested recovery option.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.