Automated Stock Trading Using Approximate Q-Learning
RME 3211 · Intelligent Systems and Robotics Lab, University of Dhaka · Aug – Nov 2022
Supervised by Dr. Sejuti Rahman
In short
Instead of hand-written trading rules, a reinforcement learning agent learns when to buy, sell or hold three Bangladeshi stocks from price history alone.
- 13.29%return on investment, test period including COVID-19
- 3stocks: Grameenphone, Square Pharma, ACI Formulations
- 3actions: buy, sell or hold

Approach
Trading is framed as a sequential decision problem. At each step the agent observes features of recent prices and chooses to buy, sell or hold. Because the state space is continuous, a tabular Q-table is replaced by approximate Q-learning, where Q-values are a linear function of the state features and the weights are updated from the temporal-difference error.
Stocks
Results
Return on investment on the test period
| Test period | ROI |
|---|---|
| Including the COVID-19 timeline | 13.29% |
| Excluding the COVID-19 timeline | −37.46% |


The code builds on this open-source implementation.
Tools: Python, Jupyter