加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
run_DRL.py 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
Bruce Yang 提交于 2020-09-01 20:07 . Update run_DRL.py
# common library
import pandas as pd
import numpy as np
import time
from stable_baselines.common.vec_env import DummyVecEnv
# preprocessor
from preprocessing.preprocessors import *
# config
from config.config import *
# model
from model.models import *
def run_model() -> None:
"""Train the model."""
# read and preprocess data
data = preprocess_data()
data = add_turbulence(data)
# 2015/10/01 is the date that validation starts
# 2016/01/01 is the date that real trading starts
# unique_trade_date needs to start from 2015/10/01 for validation purpose
unique_trade_date = data[(data.datadate > 20151001)&(data.datadate <= 20200707)].datadate.unique()
# rebalance_window is the number of months to retrain the model
# validation_window is the numebr of months to validation the model and select for trading
rebalance_window = 63
validation_window = 63
## Ensemble Strategy
run_ensemble_strategy(df=data,
unique_trade_date= unique_trade_date,
rebalance_window = rebalance_window,
validation_window=validation_window)
#_logger.info(f"saving model version: {_version}")
if __name__ == "__main__":
run_model()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化