← 开源
Albert-Z-Guo

Deep-Reinforcement-Stock-Trading

A light-weight deep reinforcement learning framework for portfolio management. This project explores the possibility of applying deep reinforcement learning algorithms to stock trading in a highly modular and scalable framework.

ApplicationsSpecialistsJupyter Notebook
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
690
Star
157
Fork
+-1
本周
3
贡献者
创建于 2019-05-19 · 更新于 2026-10-12 · 今日第 14955 名
主要开发者
Albert-Z-Guofengints

Albert-Z-Guo/Deep-Reinforcement-Stock-Trading 排名第 14,955,有 690 个星标。

同类别比较

Albert-Z-Guo/Deep-Reinforcement-Stock-Trading 排名第 14,955,此处有 8 个同类条目;space-nuko/ComfyBox 排名第 14,952。

同类别比较
名称排名指标
SipherAGI/sd-webui-agent-scheduler14,944
语言:
Python
星标数:
691
分叉数:
92
简介:
An open source Scheduling Agent for Generative AI
mic1on/chatGPT-web14,948
语言:
Vue
星标数:
691
分叉数:
242
简介:
chatGPT私有化部署
natanielruiz/android-yolo14,949
语言:
C++
星标数:
691
分叉数:
211
简介:
Real-time object detection on Android using the YOLO network with TensorFlow
space-nuko/ComfyBox14,952
语言:
TypeScript
星标数:
691
分叉数:
51
简介:
Customizable Stable Diffusion frontend for ComfyUI
AlexanderDzhoganov/ComfyTextures14,961
语言:
C++
星标数:
689
分叉数:
86
简介:
Unreal Engine ⚔️ ComfyUI - Automatic texturing using generative diffusion models
AnsahMohammad/shots-studio14,962
语言:
Dart
星标数:
689
分叉数:
48
简介:
An AI Powered Screenshot manager for Android
datvodinh/rag-chatbot14,967
语言:
Python
星标数:
689
分叉数:
110
简介:
Chat with multiple PDFs locally
sharonzhou/long_stable_diffusion14,976
语言:
Python
星标数:
689
分叉数:
52
简介:
Long-form text-to-images generation, using a pipeline of deep generative models (GPT-3 and Stable Diffusion)
关键参数与规格
关键参数与规格
参数值
语言Jupyter Notebook
类别Applications
子类别Specialists
关键词Finance, RL, Trading
星标数690
分叉数157
贡献者3
创建日期2019-05-19
更新日期2026-10-12
1 天星标数0
7 天星标数-1
排名14,955
上次排名14,784
排名变化-171
7 天星标排名17,708
上次 7 天星标排名17,665
7 天星标排名变化-43
总星标排名15,044
上次总星标排名15,017
总星标排名变化-27
国家China
README 摘录

Deep-Reinforcement-Stock-Trading This project intends to leverage deep reinforcement learning in portfolio management. The framework structure is inspired by Q-Trader. The reward for agents is the net unrealized (meaning the stocks are still in portfolio and not cashed out yet) profit evaluated at each action step. For inaction at each step, a negtive penalty is added to the portfolio as the missed opportunity to invest in "risk-free" Treasury bonds. A lot of new features and improvements

are made in the training and evaluation pipelines. All evaluation metrics and visualizations are built from scratch. Key assumptions and limitations of the current framework: trading has no impact on the market only single stock type is supported only 3 basic actions: buy, hold, sell (no short selling or other complex actions) the agent performs only 1 action for portfolio reallocation at the end of each trade day all reallocations can be finished at the closing prices no missing data

in price history no transaction cost Key challenges of the current framework: implementing algorithms from scratch with a thorough understanding of their pros and cons building a reliable reward mechanism (learning tends to be stationary/stuck in local optima quite often) ensuring the framework is scalable and extensible Currently, the state is defined as the normalized adjacent daily stock price differences for days plus . In the future, we plan to add other state-of-the-art deep reinforcement learning algorithms

, such as Proximal Policy Optimization (PPO), to the framework and increase the complexity to the state in each algorithm by constructing more complex price tensors etc. with a wider range of deep learning approaches, such as convolutional neural networks or attention mechanism. In addition, we plan to integrate better pipelines for high quality data source, e. from vendors like Quandl; and backtesting, e. Getting Started To install all libraries/dependencies used in this project, run To train a DDPG agent

or a DQN agent, e. over S&P 500 from 2010 to 2015, run is the model to use: either or ; default is is the stock used to train the model; default is , which is S&P 500 from 1/1/2010 to 12/31/2015 is the span (days) of observation; default is is the number of episodes used for training; default is is the initial balance of the portfolio; default is To evaluate a DDPG or DQN agent

, run is the model to load; default is ; alternative is etc. is the stock used to evaluate the model; default is , which is S&P 500 from 1/1/2018 to 12/31/2018 is the initial balance of the portfolio; default is is the span (days) of observation; default is where can be referred in directory and can be referred in directory. To visualize training loss and portfolio value fluctuations history, run: where can be found in directory. Example

Results Note that the following results were obtained with 10 epochs of training only. Frequently Asked Questions (FAQ) How is

常见问题

记录了多少星标和分叉?

Albert-Z-Guo/Deep-Reinforcement-Stock-Trading 有 690 个星标和 157 个分叉。

仓库排名是多少?

Albert-Z-Guo/Deep-Reinforcement-Stock-Trading 排名第 14,955。

记录的语言和类别是什么?

Albert-Z-Guo/Deep-Reinforcement-Stock-Trading 有 690 个星标,语言为 Jupyter Notebook,类别为 Applications。

哪个仓库排名最接近?

Albert-Z-Guo/Deep-Reinforcement-Stock-Trading 与 space-nuko/ComfyBox 比较,后者排名第 14,952,有 691 个星标。

README

Deep-Reinforcement-Stock-Trading

This project intends to leverage deep reinforcement learning in portfolio management. The framework structure is inspired by Q-Trader. The reward for agents is the net unrealized (meaning the stocks are still in portfolio and not cashed out yet) profit evaluated at each action step. For inaction at each step, a negtive penalty is added to the portfolio as the missed opportunity to invest in "risk-free" Treasury bonds. A lot of new features and improvements are made in the training and evaluation pipelines. All evaluation metrics and visualizations are built from scratch.

Key assumptions and limitations of the current framework:

  • trading has no impact on the market
  • only single stock type is supported
  • only 3 basic actions: buy, hold, sell (no short selling or other complex actions)
  • the agent performs only 1 action for portfolio reallocation at the end of each trade day
  • all reallocations can be finished at the closing prices
  • no missing data in price history
  • no transaction cost

Key challenges of the current framework:

  • implementing algorithms from scratch with a thorough understanding of their pros and cons
  • building a reliable reward mechanism (learning tends to be stationary/stuck in local optima quite often)
  • ensuring the framework is scalable and extensible

Currently, the state is defined as the normalized adjacent daily stock price differences for n days plus [stock_price, balance, num_holding].

In the future, we plan to add other state-of-the-art deep reinforcement learning algorithms, such as Proximal Policy Optimization (PPO), to the framework and increase the complexity to the state in each algorithm by constructing more complex price tensors etc. with a wider range of deep learning approaches, such as convolutional neural networks or attention mechanism. In addition, we plan to integrate better pipelines for high quality data source, e.g. from vendors like Quandl; and backtesting, e.g. zipline.

Getting Started

To install all libraries/dependencies used in this project, run

pip3 install -r requirements.txt

To train a DDPG agent or a DQN agent, e.g. over S&P 500 from 2010 to 2015, run

python3 train.py --model_name=model_name --stock_name=stock_name
  • model_name is the model to use: either DQN or DDPG; default is DQN
  • stock_name is the stock used to train the model; default is ^GSPC_2010-2015, which is S&P 500 from 1/1/2010 to 12/31/2015
  • window_size is the span (days) of observation; default is 10
  • num_episode is the number of episodes used for training; default is 10
  • initial_balance is the initial balance of the portfolio; default is 50000

To evaluate a DDPG or DQN agent, run

python3 evaluate.py --model_to_load=model_to_load --stock_name=stock_name
  • model_to_load is the model to load; default is DQN_ep10; alternative is DDPG_ep10 etc.
  • stock_name is the stock used to evaluate the model; default is ^GSPC_2018, which is S&P 500 from 1/1/2018 to 12/31/2018
  • initial_balance is the initial balance of the portfolio; default is 50000
  • window_size is the span (days) of observation; default is 10

where stock_name can be referred in data directory and model_to_laod can be referred in saved_models directory.

To visualize training loss and portfolio value fluctuations history, run:

tensorboard --logdir=logs/model_events

where model_events can be found in logs directory.

Example Results

Note that the following results were obtained with 10 epochs of training only.

Frequently Asked Questions (FAQ)

  • How is this project different from other price prediction approaches, such as logistic regression or LSTM?
    • Price prediction approaches like logistic regression have numerical outputs, which have to be mapped (through some interpretation of the predicted price) to action space (e.g. buy, sell, hold) separately. On the other hand, reinforcement learning approaches directly output the agent's action.

References:

排名相邻
同类项目