📈 quant-drl-core
quant-drl-core is a research-focused framework for applying Deep Reinforcement Learning (DRL) to portfolio management and financial decision-making.
It is designed to be modular, extensible, and easy to integrate into experimentation pipelines or production systems.
🎓 This project was developed as part of my Bachelor's Thesis (TFG) for the Double Degree in Mathematics and Computer Engineering at the University of Seville.
🧠 Key Features
- ✅ Modular training pipeline for multiple DRL algorithms:
PPO,SAC,DDPG,TD3 - ✅ Custom
Gymnasium-compatible environments for realistic financial simulations - ✅ Support for
CNN,LSTM,Transformerand hybrid feature extractors - ✅ Integrated technical indicators and raw market data handling
- ✅ Easy portfolio configuration (by sector and number of companies)
- ✅ Clean logging with
loguru - ✅ Compatible with interactive dashboards for visualization (e.g., Streamlit webapp)
🛠️ Getting Started
🔧 Installation
git clone https://github.com/your-username/quant-drl-core.git
cd quant-drl-core
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -e .
🧪 Training models
Use the train_models.py script to train models.
Basic command (default config)
python train_models.py
If you want to update the hierarchy.json automatically. Add the --update_hierarchy flag:
python train_models.py --update_hierarchy
Custom training with options:
python train_models.py \
--algorithms PPO SAC \
--features LSTM CNNLSTM \
--learning_rates 0.0003 0.0001 \
--n_companies 10 18 \
--length_train_data 8 \
--length_eval_data 2 \
--end_date_year 2021 \
--total_timesteps 1_000_000 \
--checkpoint_freq 100_000 \
--update_hierarchy
Models and logs will be saved in:
- 📁
models/– trained model files - 📁
logs/– experiment logs - 📄
models/metadata/hierarchy.json– metadata for evaluation
Optional (Open Tensorboard)
tensorboard --logdir=logs/
Tensorboard framework will be available at http://localhost:16006
📊 Evaluating models
Use the evaluate_models.py script to evaluate trained models.
- Option 1: Evaluate final models
python evaluate_models.py \
--use_final_model
- Option 2: Evaluate by specific checkpoint steps
python evaluate_models.py \
--steps_override PPO=500000 SAC=300000
- Option 3: Full customized evaluation
python evaluate_models.py \
--hierarchy_path models/metadata/hierarchy.json \
--results_path results/eval_sac_vs_ppo.csv \
--models_dir models \
--out_dir models/metadata/out \
--steps_override PPO=500000 SAC=300000 \
--no_move
📚 Notebooks
Inside notebooks/ you’ll find:
- 📈 Data exploration
- 📊 Testing models
- 📝 Exporting results to LaTeX
🔮 Planned Features
- Risk-adjusted rewards (Sharpe, Sortino, etc.)
- Hyperparameter optimization with Optuna
- Integration with MLFlow
- Multi-agent extensions
- Integration with a live dashboard (Streamlit) (quant-drl-web)
📝 License
This project is licensed under the MIT License.
See the LICENSE file for details.
🙋♂️ Author
Made with ❤️ by Pablo Diego Acosta
- 💼 LinkedIn: linkedin.com/in/pablodiegoacosta
🤝 Contributing
Whether you're a researcher, developer, or enthusiast — feel free to contribute!
You're welcome to suggest improvements, propose new architectures, experiment with custom reward functions, or integrate new DRL algorithms.
✨ Open a pull request, start a discussion, or simply share your ideas.
Together, we can make this framework even more powerful for the DRL + Finance community 🚀
📚 References
This project is based on a wide range of research articles, theses, technical reports, and open-source implementations in the field of reinforcement learning and portfolio management.
Some of the most relevant references include:
- Filos, A. (2019). Reinforcement Learning for Portfolio Management. arXiv:1909.09571
- Jiang, Z. et al. (2017). A Deep Reinforcement Learning Framework for the Financial Portfolio Management Problem. arXiv:1706.10059
- Sutton, R. S., & Barto, A. G. (2018). Reinforcement Learning: An Introduction. MIT Press.
- Haarnoja, T. et al. (2018). Soft Actor-Critic: Off-Policy Maximum Entropy Deep Reinforcement Learning. arXiv:1801.01290
- Raffin, A. et al. (2021). Stable-Baselines3: Reliable RL Implementations. JMLR
- Markowitz, H. (1959). Portfolio Selection: Efficient Diversification of Investments. Yale University Press.
- Open-source: Zenlii – Deep RL Portfolio Management
A complete list of all references (BibTeX format) used in this project is available here.
Metadata
Release files for quant-drl-core 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quant_drl_core-0.1.6.tar.gz | 32.1 kB | With provenance | Details for quant_drl_core-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quant_drl_core-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for quant_drl_core-0.1.6-py3-none-any.whl |
Total release size: 65.6 kB
Release files / quant_drl_core-0.1.6.tar.gz
| Download URL | quant_drl_core-0.1.6.tar.gz |
|---|---|
| Size | 32.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f850bfdb485195b89557a42d55604180602ab0642a90218402e0b10af19f15f
|
|
BLAKE2b-256 checksum How to use checksums |
ed7236abba2c7d0ad431648b7a565dce63cef806e157c906cca2d978cff96f60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2025.
Transparency logRelease files / quant_drl_core-0.1.6-py3-none-any.whl
| Download URL | quant_drl_core-0.1.6-py3-none-any.whl |
|---|---|
| Size | 33.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
df9aa4a99231a3c45be2058a8e04e916a205fd1604ab3b1fb94edf819232920e
|
|
BLAKE2b-256 checksum How to use checksums |
39b78246b273f2c00fafdd25cde9bf7f9751f28d048cf45d191b253586e5106a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2025.
Transparency logSecurity for quant-drl-core 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for quant_drl_core-0.1.6.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.