mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-11 23:06:58 +08:00
more clearly structure
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import qlib
|
||||
from qlib.model.trainer import task_train
|
||||
from qlib.workflow.task.update import ModelUpdater
|
||||
from qlib.workflow.task.online import RollingOnlineManager
|
||||
from qlib.config import REG_CN
|
||||
import fire
|
||||
from qlib.workflow import R
|
||||
|
||||
data_handler_config = {
|
||||
"start_time": "2008-01-01",
|
||||
@@ -50,33 +51,33 @@ task = {
|
||||
},
|
||||
}
|
||||
|
||||
provider_uri = "~/.qlib/qlib_data/cn_data" # target_dir
|
||||
|
||||
|
||||
def first_train(experiment_name="online_svr"):
|
||||
|
||||
qlib.init(provider_uri=provider_uri, region=REG_CN)
|
||||
model_updater = ModelUpdater(experiment_name)
|
||||
rom = RollingOnlineManager(experiment_name)
|
||||
|
||||
rid = task_train(task_config=task, experiment_name=experiment_name)
|
||||
model_updater.reset_online_model(rid)
|
||||
|
||||
rom.reset_online_model(rid)
|
||||
|
||||
|
||||
def update_online_pred(experiment_name="online_svr"):
|
||||
|
||||
qlib.init(provider_uri=provider_uri, region=REG_CN)
|
||||
model_updater = ModelUpdater(experiment_name)
|
||||
rom = RollingOnlineManager(experiment_name)
|
||||
|
||||
print("Here are the online models waiting for update:")
|
||||
for rid, rec in model_updater.list_online_model().items():
|
||||
for rid, rec in rom.list_online_model().items():
|
||||
print(rid)
|
||||
|
||||
model_updater.update_online_pred()
|
||||
rom.update_online_pred()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
fire.Fire()
|
||||
# to train a model and set it to online model, use the command below
|
||||
## to train a model and set it to online model, use the command below
|
||||
# python update_online_pred.py first_train
|
||||
# to update online predictions once a day, use the command below
|
||||
## to update online predictions once a day, use the command below
|
||||
# python update_online_pred.py update_online_pred
|
||||
|
||||
provider_uri = "~/.qlib/qlib_data/cn_data" # target_dir
|
||||
qlib.init(provider_uri=provider_uri, region=REG_CN)
|
||||
fire.Fire()
|
||||
|
||||
Reference in New Issue
Block a user