Q-Trader
An implementation of Q-learning applied to (short-term) stock trading. The model uses n-day windows of closing prices to determine if the best action to take at a given time is to buy, sell or sit.
As a result of the short-term state representation, the model is not very good at making decisions over long-term trends, but is quite good at predicting peaks and troughs.
Results
Some examples of results on test sets:




Running the Code
To train the model, download a training and test csv files from Yahoo! Finance into data/
mkdir model
python train ^GSPC 10 1000
Then when training finishes (minimum 200 episodes for results):
python evaluate.py ^GSPC_2011 model_ep1000
References
Deep Q-Learning with Keras and Gym - Q-learning overview and Agent skeleton code