Giter Site home page Giter Site logo

reinforcementlearning_for_stock's Introduction

强化学习炒股,走向人生巅峰(或倾家荡产)

免责声明

  • 本网站所载的资料并不构成投资的意见或建议,据此操作风险自担。股市有风险,投资需谨慎!

Quickstart

单股票

1. 数据获取

以下任选一种:

cd data
nohup python -u get_stock_data_baostock_train.py > get_train.log 2>&1 &
nohup python -u get_stock_data_baostock_test.py > get_test.log 2>&1 &
cd data
nohup python -u get_stock_data_tushare.py > get_data.log 2>&1 &

2. 设置配置文件config.yaml(也可使用默认配置参数)

3. 训练模型

python train.py

4. 测试模型

python test.py

多股票

python multi_stock_ensemble_strategy.py

环境

  • 单只股票
  • 多只股票

RL算法

  • PPO
  • A2C
  • DDPG
  • TD3

实验结果

  • 初始本金 100000
  • 单只股票
  • 股票代码:sh.600006
  • 训练集:1990-01-01至2019-12-31
  • 测试集:2020-01-01至2020-12-31
  • 模拟操作 242

盈利情况:

PPO: 盈利77801

drawing

A2C: 盈利23054

drawing

参考资料, 本项目参考了以下资料,感谢原作者

  1. Create custom gym environments from scratch — A stock market example
  2. RL-Stock
  3. Deep-Reinforcement-Learning-Hands-On, chapter 10
  4. Personae
  5. FinRL

主要改动:

  1. 调整代码结构,增加配置文件
  2. RL算法模型使用最新版本的stable-baselines3,之前的stable-baselines已处于维护状态,且容易遇到tensorflow版本不兼容的问题
  3. 丰富RL模型
  4. 增加交易手续费
  5. 股票价格后复权
  6. 特征优化
  7. 测试集长度设置为1年

优先todo:

todo:

  • 将特征接口抽出来
  • 将模型接口抽出来
  • 将reward的定义抽出来
  • 特征优化: 历史统计信息
  • 特征优化: 模型预测结果
  • 特征优化: 外部数据,如天气
  • 策略优化: 组合策略
  • 选股说明
  • 可视化优化

reinforcementlearning_for_stock's People

Contributors

enjoysport2022 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.