-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
questionFurther information is requestedFurther information is requested
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}")
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested