microsoft / microsoft/qlib

Frequency format error in US data

Open
#2,081 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi! I am loading the data collected from:

python scripts/get_data.py qlib_data --target_dir /Volumes/KediPrivate/Project KQuant/data/DAILY/us_data --region us --interval 1d

and when i am checking the stock data, an error occured: freq format is not supported, the freq should be like (n)month/mon, (n)week/w, (n)day/d, (n)minute/min

import qlib
from qlib.data import D
from qlib.config import REG_US

provider_uri = "/Volumes/KediPrivate/Project KQuant/data/DAILY/us_data"
qlib.init(provider_uri=provider_uri, region=REG_US)

try:
    
    calendar = D.calendar(start_time='2010-01-01', end_time='2019-12-31', freq='day')
    print(f"日历读取成功!共计 {len(calendar)} 个交易日。")

    instruments = D.list_instruments(D.instruments('all'))
    print(f"股票池读取成功!识别到 {len(instruments)} 只股票。")
    sample_stocks = ['aapl', 'nvda']
    print(f"样例股票: {sample_stocks}")


    if sample_stocks:

        target_stock = sample_stocks[0]
        df = D.features([target_stock], ['$close', '$volume'],
                        start_time='2019-01-01',
                        freq='day')

        if df.empty:
            print(f"警告:读取了 {target_stock},但返回结果为空。请检查数据时间范围。")
        else:
            print(f"数据解析成功![{target_stock}] 最近 5 行数据:")
            print(df.tail())
    else:
        print("错误:股票池中没有找到任何股票。")
except Exception as e:
    print(f"验证失败!错误信息:\n{e}")

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 issue with scripts/get_data.py using the shown qlib_data command, then run the provided qlib.init, D.calendar, D.list_instruments, and D.features calls to isolate which frequency value fails. Done means identifying the source of the format error and confirming that the documented frequency values work or documenting the required correction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.