A stock trader powered with deep q-network.
Python 3. To install all the libraries, run pip3 install -r requirements.txt
agent.py
: a Deep Q learning agentenvs.py
: a simple x-stock trading environmentmodel.py
: a multi-layer perceptron as the function approximatorutils.py
: some utility functionsrun.py
: train/test logicrequirement.txt
: all dependenciesdata/
: stock price data
To train a Deep Q agent, run python3 run.py --mode train
. There are other parameters and I encourage you look at the run.py
script. After training, a trained model as well as the portfolio value history at episode end would be saved to disk.
To test the model performance on validation set, run python3 run.py --mode validate --weights <trained_model>
, where <trained_model>
points to the local model weights file. Validation data portfolio value history at episode end would be saved to disk.
To test the model performance on test set, run python3 run.py --mode test --weights <trained_model>
, where <trained_model>
points to the local model weights file. Test data portfolio value history at episode end would be saved to disk.
To visualize performance run python3 visualize.py --file <pickle_file>
, where <pickle_file>
points to the local portfolio value history file for a specific train/validate/test file.
Credits for starter code go to ShuaiW.