Deep Reinforcement Learning Backtesting and Analysis Framework
A comprehensive Python framework for developing, testing, and deploying Deep Reinforcement Learning agents for quantitative finance applications.
- Backtesting Framework — Walk-forward validation, rolling windows, transaction costs, slippage modeling with realistic portfolio simulation
- Regime Analysis — Detect bull/bear/sideways markets using K-Means, GMM, or rule-based methods; compute regime-conditioned metrics
- Error Handling & Logging — Comprehensive exception hierarchy, centralized logging with rotation, checkpointing for resume capability
- Data Validation — Statistical tests (stationarity via ADF test), data quality checks (outliers, missing data), type validation
- Hyperparameter Tuning — Systematic grid search + random search with early stopping
- Comparative Strategy Analysis — Side-by-side comparison, sensitivity analysis, performance attribution
- Ensemble Models — Framework for combining multiple forecasters/DRL agents
- Enhanced Visualizations — Equity curves with regime backgrounds, rolling metrics, interactive dashboards
- Professional Reporting — PDF/HTML/CSV export with automated formatting
# Clone the repository
git clone https://github.com/hypercoreiai/DRLWorkbench.git
cd DRLWorkbench
# Create a virtual environment (optional but recommended)
python -m venv .venv
# Activate the virtual environment
# Windows:
.venv\Scripts\activate
# Linux/Mac:
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txtThe main entry point for the pipeline is run_pipeline.py.
# Run the pipeline with default configuration
python run_pipeline.py
# Run with a specific config file
python run_pipeline.py --config configs/my_config.yaml
# Resume from a checkpoint
python run_pipeline.py --resume outputs/checkpoint.pklComprehensive documentation is available in the project:
- PROJECT_OUTLINE_V3.md - Detailed project architecture and implementation plan
- PROJECT_OUTLINE_V4.md - Enhanced features including MLOps, API service, risk management
- PROJECT_QUESTIONS_V3.md - 170+ technical questions covering all aspects
- PROJECT_ANSWERS_V3.md - Detailed implementation decisions and rationale
# Run all tests
pytest tests/ -v
# Run with coverage report
pytest tests/ --cov=drlworkbench --cov-report=html
# Run specific test module
pytest tests/test_validation/ -vCurrent Version: 0.1.0 (Alpha)
Test Coverage: 76% (22 tests, all passing)
Security: No vulnerabilities detected (CodeQL verified)
setup_logger()- Centralized logging configurationCheckpoint- Save/load state for long-running operationsException Classes- Hierarchy for better error handling
BacktestEngine- Core backtesting with transaction costsPortfolio- Position and cash management- Performance metrics: Sharpe, Sortino, Calmar, max drawdown
RegimeDetector- Market state identification- Methods: K-Means, Gaussian Mixture Model, Rule-based
- Automatic regime labeling (Bear/Sideways/Bull)
DataValidator- Comprehensive data quality checks- Statistical tests: ADF (stationarity), outlier detection
- Data type validation and missing data analysis
This project follows professional Python development practices:
- Type hints throughout the codebase
- Comprehensive docstrings (NumPy style)
- Unit tests with pytest
- Code formatting with black
- Linting with flake8
MIT License - see LICENSE file for details
DRLWorkbench Team
Built on industry-standard libraries:
- NumPy, Pandas, SciPy for numerical computing
- scikit-learn for machine learning algorithms
- statsmodels for statistical tests
- matplotlib, seaborn, plotly for visualization