You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
與 #231 問題差不多,使用 30m 的數據會出現 calendar not exists for freq day 的錯誤
To Reproduce
Steps to reproduce the behavior:
載入資料
import time
import numpy as np
import pandas as pd
import qlib
from qlib.config import REG_US
from qlib.contrib.model.gbdt import LGBModel
from qlib.contrib.data.handler import Alpha158
from qlib.contrib.strategy.strategy import TopkDropoutStrategy
from qlib.contrib.evaluate import (
backtest as normal_backtest,
risk_analysis
)
from qlib.utils import exists_qlib_data, init_instance_by_config
from qlib.workflow import R
from qlib.workflow.record_temp import SignalRecord, PortAnaRecord
from qlib.utils import flatten_dict
from qlib.data import D
qlib.init(provider_uri='~/.qlib/qlib_data/my_data/')
instruments = D.instruments(market='all')
[18021:MainThread](2021-01-31 23:42:01,889) INFO - qlib.Initialization - [config.py:277] - default_conf: client.
[18021:MainThread](2021-01-31 23:42:01,896) WARNING - qlib.Initialization - [config.py:292] - redis connection failed(host=127.0.0.1 port=6379), cache will not be used!
[18021:MainThread](2021-01-31 23:42:01,900) INFO - qlib.Initialization - [__init__.py:46] - qlib successfully initialized based on client settings.
[18021:MainThread](2021-01-31 23:42:01,901) INFO - qlib.Initialization - [__init__.py:47] - data_path=/home/kenneth/.qlib/qlib_data/my_data
定義訓練參數
data_handler_config = {
'start_time': '2017-07-15',
'end_time': '2021-01-15',
'fit_start_time': '2017-07-15',
'fit_end_time': '2020-06-30',
'instruments': instruments,
'freq': '30m'
}
task = {
'model': {
'class': 'LGBModel',
'module_path': 'qlib.contrib.model.gbdt',
'kwargs':{
'loss': 'mse',
'colsample_bytree': 0.8879,
'learning_rate': 0.0421,
'subsample': 0.8789,
'lambda_l1': 205.6999,
'lambda_l2': 580.9768,
'max_depth': 8,
'num_leaves': 210,
'num_threads': 20
}
},
'dataset':{
'class': 'DatasetH',
'module_path': 'qlib.data.dataset',
'kwargs':{
'handler':{
'class': 'Alpha158',
'module_path': 'qlib.contrib.data.handler',
'kwargs': data_handler_config
},
'segments':{
'train': ('2017-07-15', '2020-01-01'),
'valid': ('2020-01-02', '2020-06-30'),
'test': ('2020-07-07', '2021-01-15'),
}
}
}
}
model = init_instance_by_config(task['model'])
dataset = init_instance_by_config(task['dataset'])
[18021:MainThread](2021-02-01 00:16:14,111) INFO - qlib.timer - [log.py:81] - Time cost: 46.901s | Loading data Done
[18021:MainThread](2021-02-01 00:16:15,333) INFO - qlib.timer - [log.py:81] - Time cost: 1.017s | DropnaLabel Done
[18021:MainThread](2021-02-01 00:21:03,812) INFO - qlib.timer - [log.py:81] - Time cost: 288.477s | CSZScoreNorm Done
[18021:MainThread](2021-02-01 00:21:03,815) INFO - qlib.timer - [log.py:81] - Time cost: 289.700s | fit & process data Done
[18021:MainThread](2021-02-01 00:21:03,816) INFO - qlib.timer - [log.py:81] - Time cost: 336.607s | Init data Done
訓練模型
t_start = time.time()
with R.start(experiment_name='train_model'):
R.log_params(**flatten_dict(task))
model.fit(dataset)
R.save_objects(trained_model=model)
rid = R.get_recorder().id
t_end = time.time()
print('train model - Time count: %.3fs'%(t_end - t_start))
[18021:MainThread](2021-02-01 00:24:55,000) INFO - qlib.workflow - [expm.py:245] - No tracking URI is provided. Use the default tracking URI.
[18021:MainThread](2021-02-01 00:24:55,014) INFO - qlib.workflow - [expm.py:168] - No valid experiment found. Create a new experiment with name train_model.
[18021:MainThread](2021-02-01 00:24:55,022) INFO - qlib.workflow - [exp.py:181] - Experiment 1 starts running ...
[18021:MainThread](2021-02-01 00:24:55,213) INFO - qlib.workflow - [recorder.py:233] - Recorder 03e37d24ab8b4c809b619bdfecad8c78 starts running under Experiment 1 ...
Training until validation scores don't improve for 50 rounds
[20] train's l2: 0.891066 valid's l2: 0.94816
[40] train's l2: 0.889417 valid's l2: 0.948044
[60] train's l2: 0.888093 valid's l2: 0.948017
[80] train's l2: 0.886899 valid's l2: 0.948024
[100] train's l2: 0.885763 valid's l2: 0.948017
[120] train's l2: 0.884643 valid's l2: 0.948036
Early stopping, best iteration is:
[87] train's l2: 0.886497 valid's l2: 0.947999
train model - Time count: 34.624s
🐛 Bug Description
與 #231 問題差不多,使用 30m 的數據會出現
calendar not exists for freq day
的錯誤To Reproduce
Steps to reproduce the behavior:
Error message:
Environment
Note: User could run
cd scripts && python collect_info.py all
under project directory to get system informationand paste them here directly.
Windows
,Linux
,MacOS
): LinuxThe text was updated successfully, but these errors were encountered: