Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DDPM-GARCH

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


Features

  • 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

Pretrained Models

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.


Project Structure

.
├── 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

Installation

Clone the repository:

git clone https://github.com/HenryGunadi/diffusion-garch.git
cd diffusion-garch

Create a virtual environment:

python -m venv .venv

Activate the environment:

Windows

.venv\Scripts\activate

Linux / macOS

source .venv/bin/activate

Install dependencies:

pip install -r requirements.txt

Running the Web Application

From the project root:

uvicorn app.main:app --reload

Open:

http://127.0.0.1:8000

The web interface is served through the FastAPI backend and provides a simple demonstration of synthetic return generation.


Diffusion Workflow

Forward Process

The forward process gradually adds Gaussian noise to return windows until they become nearly pure noise.

Historical Returns
        │
        ▼
Forward Diffusion
        │
        ▼
Gaussian Noise

Reverse Process

The reverse process starts from Gaussian noise and iteratively reconstructs synthetic return windows.

Gaussian Noise
        │
        ▼
Reverse Diffusion
        │
        ▼
Synthetic Returns

Monte Carlo Baseline

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.


Example Workflow

Generate Synthetic Returns

  1. Load a pretrained model.
model_512.pth
  1. Generate synthetic return windows using reverse diffusion.

  2. Fit a GARCH(1,1) model.

  3. Perform:

  • Volatility forecasting
  • VaR estimation
  • Risk analysis
  • Monte Carlo comparison

Models

Model Recommended Use
model_128.pth Short horizon experiments
model_256.pth Medium horizon experiments
model_512.pth Long horizon experiments

Showcase

The repository includes:

  • main.py — FastAPI backend
  • index.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

Research

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

Disclaimer

This project is intended for research and educational purposes only.

It should not be used as financial advice or investment recommendations.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages