加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.py 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
XianfengJiao 提交于 2021-12-02 12:31 . 添加对模型训练框架的描述
from backtester.trade_back_tester import BackTester
from data.read_data import get_data_by_pickle, get_data_for_model
from data.time_data import TimeData
from strategy.greedy_strategy import GreedyStrategy
from strategy.gru_strategy import GRUStrategy
from strategy.concare_strategy import ConCareStrategy
from utils.date_util import diagnostics
import numpy as np
from view import Draw
if __name__ == '__main__':
back_tester = BackTester(start_date="2010-01-05", end_date="2010-02-06",
trade_strategy=GreedyStrategy(3, 2, 3, 1000))
# back_tester = BackTester(start_date="2010-01-30", end_date="2010-03-07",
# trade_strategy=GRUStrategy(3, 2, 3, 1000, './model/checkpoints/GRU/GRU_best_model.pt'))
# back_tester = BackTester(start_date="2010-01-30", end_date="2010-03-07",
# trade_strategy=ConCareStrategy(3, 2, 3, 1000, './model/checkpoints/ConCare/ConCare_best_model.pt'))
back_tester.execute_trade()
cash = back_tester.get_cash_array()
capital = back_tester.get_capital_array()
stock = back_tester.get_stock_array()
profits = back_tester.get_profit_array()
Draw().draw_plot(cash, 'cash')
Draw().draw_plot(capital, 'capital')
Draw().draw_plot(profits, 'profits')
print('-'*100)
print(stock)
print('-'*100)
print(back_tester.get_profit_array())
print('-'*100)
print(diagnostics(np.array(list(profits.values())))/1000)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化