An enterprise-grade quantitative finance platform for derivative pricing, risk analytics, portfolio management, and reinforcement learning–based hedging strategies.
The platform combines modern quantitative research infrastructure with scalable backend systems, real-time analytics, ML training pipelines, and production-ready deployment architecture.
This project is designed to simulate and optimize derivative hedging strategies using Reinforcement Learning (RL) and advanced quantitative finance models.
The system integrates:
- Reinforcement Learning training environments
- Option pricing engines
- Portfolio risk analytics
- Backtesting infrastructure
- Real-time websocket streaming
- Production-grade backend APIs
- Interactive frontend dashboards
- Containerized deployment infrastructure
The objective is to create a scalable research and deployment platform for algorithmic hedging and quantitative trading workflows.
- Black-Scholes pricing
- Monte Carlo simulation
- Heston stochastic volatility model
- Jump diffusion models
- Greeks computation
- Portfolio risk metrics
- PnL analytics
- Drawdown analysis
- RL training environments
- Stable-Baselines3 integration
- Continuous-action hedging agents
- Market simulation engine
- Reward optimization pipelines
- Strategy experimentation workflows
- Portfolio exposure tracking
- Risk analytics dashboard
- Strategy monitoring
- Performance metrics
- Scenario analysis
- Backtesting engine
- Interactive analytics dashboard
- Real-time websocket updates
- Multi-page Next.js frontend
- Strategy visualization panels
- Research monitoring interface
- Training metrics visualization
- FastAPI backend services
- REST API architecture
- Websocket communication layer
- Authentication system
- Redis integration
- PostgreSQL integration
- MLflow experiment tracking
- Docker Compose orchestration
- Kubernetes deployment manifests
- NGINX reverse proxy
- Prometheus monitoring
- Grafana dashboards
- Healthcheck systems
- Runtime validation pipelines
- Python 3.11+ (Docker image); local tests support Python 3.9+ with
eval_type_backport - FastAPI
- SQLAlchemy
- PostgreSQL
- Redis
- Celery
- PyTorch
- Stable-Baselines3
- NumPy
- Pandas
- SciPy
- Next.js
- React
- TypeScript
- Zustand
- React Query
- Docker
- Kubernetes
- NGINX
- Prometheus
- Grafana
- MLflow
Frontend (Next.js)
│
▼
NGINX Reverse Proxy
│
▼
FastAPI Backend Services
│
┌──────┼─────────┐
▼ ▼ ▼
Redis PostgreSQL MLflow
│
▼
Celery Workers
│
▼
RL Training + Quant Engine
Reinforcement-Learning-Derivative-Hedging/
│
├── backend/
│ ├── app/
│ │ ├── api/
│ │ ├── quant/
│ │ ├── services/
│ │ ├── websocket/
│ │ ├── middleware/
│ │ └── db/
│ │
│ ├── scripts/
│ └── tests/
│
├── frontend/
│ ├── src/
│ │ ├── app/
│ │ ├── components/
│ │ ├── hooks/
│ │ ├── store/
│ │ └── lib/
│ │
│ └── public/
│
├── infra/
│ ├── kubernetes/
│ ├── nginx/
│ ├── prometheus/
│ └── grafana/
│
├── docker-compose.yml
├── README.md
└── .env.example
git clone https://github.com/your-username/Reinforcement-Learning-Derivative-Hedging.gitcd Reinforcement-Learning-Derivative-Hedgingdocker compose up --build| Service | Port (host) |
|---|---|
| NGINX (unified entry) | 8080 |
| Frontend | 3000 |
| Backend API | 8000 |
| MLflow | 5001 |
| Grafana | 3001 |
| Prometheus | 9090 |
| PostgreSQL | 55432 |
| Redis | 6380 |
POST /api/v1/training/start— launch a training run withTrainingRequestconfig.GET /api/v1/training/— list training runs for the authenticated user.GET /api/v1/training/{run_id}— fetch a single training run.POST /api/v1/training/stop/{run_id}— stop a training run.
POST /api/v1/benchmarks/run— run pricing, risk, and backtest benchmarks.
WS /ws/{client_id}?token=<JWT>— live stream with heartbeat (ping/pong).WS /ws/telemetry?token=<JWT>&channels=training,risk,portfolio&replay=50— telemetry stream with replay.
- Gateway:
TelemetryGatewaypublishes typed events to Redis pub/sub and persists short replay buffers. - Channels: training, training.metrics, portfolio, risk, and api.latency are streamed over websocket fanout.
- Recovery: websocket clients support heartbeat ping/pong, reconnect backoff, replay windows, and bounded queues.
- Middleware: request latency is captured by
TelemetryMiddlewareand emitted automatically as telemetry events.
- Backend services emit typed telemetry events.
- Redis pub/sub fans events out to websocket subscribers.
- The frontend telemetry bootstrap subscribes to live channels on app load.
- The dashboard pages render the live event stream, latency stats, and RL observability panels.
- Training monitoring: start a run through
POST /api/v1/training/start, then watchtrainingandtraining.metricschannels. - Portfolio/risk monitoring: open the dashboard or call
GET /api/v1/metrics/latestandGET /api/v1/portfolios/overview. - Replay recovery: connect to
WS /ws/telemetry?...&replay=50to recover missed events after a disconnect. - Compression: pass
compress=1on the websocket URL if you want compressed event payloads.
- API health:
GET /health. - Prometheus:
GET /metricsexposes application and websocket counters. - Container logs:
docker-compose logs -f apianddocker-compose logs -f worker. - Websocket verification: confirm the client receives
ping/pongand replay events before live updates. - Redis checks: verify the
telemetry:*keys to inspect buffered event history.
- Use
docker-compose build --pull=false apiwhen offline or on constrained networks. - The backend image avoids system-package installs to keep builds lightweight and memory-safe.
- The training pipeline lazily imports MLflow/W&B so the API can start cleanly even when experiment tooling is unavailable.
- Quant pricing engine
- Reinforcement learning training environment
- FastAPI backend architecture
- Multi-page frontend dashboard
- Real-time websocket infrastructure
- Portfolio analytics system
- Backtesting engine
- Dockerized deployment stack
- Kubernetes deployment manifests
- Prometheus monitoring integration
- Grafana dashboard provisioning
- MLflow experiment tracking
- Runtime validation pipelines
- NGINX reverse proxy integration
- Redis and PostgreSQL integration
- Healthcheck and readiness systems
- Runtime stabilization improvements
- Security hardening foundation
- Deployment orchestration system
- Enterprise-ready backend architecture
- Real-time analytics infrastructure
- Reinforcement learning research workflows
- Quantitative risk management pipelines
- Distributed service orchestration
- Monitoring and observability stack
- Containerized deployment support
- Kubernetes-native infrastructure
- Scalable websocket communication
- Experiment tracking and analytics
- Prometheus metrics
- Grafana dashboards
- Runtime healthchecks
- Service readiness probes
- API monitoring
- Training telemetry
- Infrastructure observability
- Multi-agent RL hedging
- Live market data integration
- Institutional-grade risk systems
- High-frequency simulation support
- Distributed RL training
- Cloud-native scaling
- Advanced strategy optimization
- Automated model evaluation
This project is licensed under the MIT License.
Developed as a full-stack quantitative finance and reinforcement learning research platform focused on scalable derivative hedging infrastructure and production-grade quantitative systems.