DDPM-based financial return simulation framework for volatility forecasting, Value-at-Risk (VaR) estimation, and Monte Carlo comparison using GARCH(1,1).
This repository accompanies the research paper:
DDPM as a Data-Driven Return Simulator: Benchmarking Financial Risk Analysis Against GARCH and Monte Carlo Baselines
- DDPM implementation for financial return generation
- 1D U-Net architecture for time-series diffusion
- Pretrained models for multiple window lengths
- Forward and reverse diffusion process visualization
- GARCH(1,1) volatility modeling
- Monte Carlo simulation baseline
- Value-at-Risk (VaR) estimation
- Volatility forecasting evaluation
- FastAPI web application
- Simple HTML showcase interface
The repository contains three pretrained models:
| Model | Window Length |
|---|---|
model_128.pth |
128 returns |
model_256.pth |
256 returns |
model_512.pth |
512 returns |
Each model generates fixed-length synthetic return windows using the reverse diffusion process.
.
├── app/
│ ├── main.py
│ └── ...
│
├── static/
│ ├── index.html
│ └── ...
│
├── models/
│ ├── model_128.pth
│ ├── model_256.pth
│ └── model_512.pth
│
├── diffusion/
│ ├── forward_process.py
│ ├── reverse_process.py
│ └── ...
│
├── garch/
│ └── ...
│
├── data/
│ └── ...
│
└── README.md
Clone the repository:
git clone https://github.com/HenryGunadi/diffusion-garch.git
cd diffusion-garchCreate a virtual environment:
python -m venv .venvActivate the environment:
.venv\Scripts\activatesource .venv/bin/activateInstall dependencies:
pip install -r requirements.txtFrom the project root:
uvicorn app.main:app --reloadOpen:
http://127.0.0.1:8000
The web interface is served through the FastAPI backend and provides a simple demonstration of synthetic return generation.
The forward process gradually adds Gaussian noise to return windows until they become nearly pure noise.
Historical Returns
│
▼
Forward Diffusion
│
▼
Gaussian Noise
The reverse process starts from Gaussian noise and iteratively reconstructs synthetic return windows.
Gaussian Noise
│
▼
Reverse Diffusion
│
▼
Synthetic Returns
The repository also includes a traditional Monte Carlo benchmark.
Workflow:
Historical Returns
│
▼
Fit GARCH(1,1)
│
▼
Monte Carlo Simulation
│
▼
Synthetic Returns
This baseline is used for comparison against DDPM-generated scenarios.
- Load a pretrained model.
model_512.pth-
Generate synthetic return windows using reverse diffusion.
-
Fit a GARCH(1,1) model.
-
Perform:
- Volatility forecasting
- VaR estimation
- Risk analysis
- Monte Carlo comparison
| Model | Recommended Use |
|---|---|
model_128.pth |
Short horizon experiments |
model_256.pth |
Medium horizon experiments |
model_512.pth |
Long horizon experiments |
The repository includes:
main.py— FastAPI backendindex.html— lightweight web showcase
The showcase demonstrates:
- Loading pretrained models
- Running reverse diffusion sampling
- Generating synthetic return windows
- Comparing DDPM outputs against GARCH-based simulations
The full paper is available in this repository.
Topics covered include:
- Stylized facts retention
- GARCH diagnostics
- Volatility persistence
- Volatility forecasting
- QLIKE evaluation
- Value-at-Risk estimation
- Monte Carlo benchmarking
This project is intended for research and educational purposes only.
It should not be used as financial advice or investment recommendations.