Skip to content
An example and description to Reinforcement Learning DQN model and dataformats for trading
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
agent
data
info
models
LICENSE
MLWriteRLTrainData.PNG
PVQEvaluate.py
PVQTrain.py
PlotModel.py
README.md
RLDataExample.ipynb
RLDataExample.md
Train.ipynb
constant.py
functions.py

README.md

RLDQTrading

Check RLDataExample now, just format and features of the written datafiles with MLWriteRLTrainData https://pvoodoo.blogspot.com/2019/03/writetraindata-tool-for-reinforcement.html

If you wonder the special Bar type, MBT, it is actually a special adaptive bar type, which can switch to next bar at next minute line if range or volume has been high.. (blog has some info of the adaptive bar)

Supervised models available too, check the blog.

Files:

Additional files coming step by step:

PVQTrain.py = main train program, DayTrading model inside if D ..

Usage: python PVQTrain.py [stockfile] [episodes] [timesteps]

Example: python PVQTrain.py RLDataForCL60D 4000 4

OR #import PVQTrain

PVQTrain.main(stock_name, episodes, timesteps)

Output:

PVQEvaluate.py to show and predict trades, out of data too

Usage: python PVQEvaluate.py [stockfile] [model]

Example: python PVQEvaluate.py RLDataForCL60D RLDataForCL60D_4000

Output:

Zoomed Output:

PVAgent.py keras model and reinforcement learning setup, some setup moved to constant.py

functions.py Actually have an important function, getNextPositionState as it defines how the predicted actions are handled

constant.py Defines some important values like Comissions, need to be changed based to instrument

PlotModel.py Draw the keras neural network model to a picture

Further info of files & directories at blog Design Consepts Test Results Neural Network Model

Other:

Probably some notebook formats added to use the whole system in colab.research.google.com (keras, GPU) FYI, No reason to run this with GPU as epoch = 1, faster with CPU model (data transfer do not delay)

Resources:

Financial Trading as a Game: A Deep Reinforcement Learning Approach

You can’t perform that action at this time.