qlib icon indicating copy to clipboard operation
qlib copied to clipboard

ValueError: freq format is not supported when using D.calendar with freq='day'

Open Bat-Reality opened this issue 2 months ago • 1 comments

❓ Questions and Help

Hi, I am encountering an error when trying to build a stock pool using the released CN data (investment_data releases).

from pathlib import Path
from qlib.config import REG_CN
import qlib
from qlib.data import D

ROOT_DIR = Path(__file__).resolve().parents[1]
PROVIDER_URI = str(ROOT_DIR / "qlib_bin")
print(f"Using qlib data dir: {PROVIDER_URI}")

qlib.init(
    provider_uri=PROVIDER_URI,
    region=REG_CN,
)
start_date = "2012-01-01"
end_date = "2024-12-31"

trade_calendar = D.calendar(start_time=start_date, end_time=end_date, freq="day")

stock_instruments = D.instruments("all")
stock_list = D.list_instruments(
    instruments=stock_instruments, start_time=start_date, end_time=end_date
)

Error Message

ValueError: freq format is not supported, the freq should be like (n)month/mon, (n)week/w, (n)day/d, (n)minute/min

Bat-Reality avatar Oct 04 '25 04:10 Bat-Reality

Hi, @Bat-Reality Thanks for your attention to qlib, I tried to reproduce the problem using the latest main branch and the latest investment data, and the code you provided, but it didn't reproduce your problem, and I don't think the ValueError should occur if freq = "day". Reference code: https://github.com/microsoft/qlib/blob/main/qlib/utils/time.py#L167

SunsetWolf avatar Oct 09 '25 05:10 SunsetWolf