This repository demonstrates the power of Minimax/GAN-based robust optimization for financial derivatives hedging.
Traditional hedging relies on the Black-Scholes formula, which assumes a log-normal distribution with constant volatility. While optimal in a perfect mathematical world, it fails catastrophically during market crashes.
This project implements Adversarial Deep Hedging. We train a Neural Network "Hedger" to minimize financial risk. Instead of training it on standard geometric brownian motion, we train it against an "Adversarial Market Generator" — a second Neural Network whose entire goal is to generate market paths that maximize the Hedger's loss.
In a standard Image GAN:
- Generator makes fake images.
- Discriminator classifies real vs. fake.
In Adversarial Hedging:
- Generator: Generates future stock price paths (drifts and volatilities). It wins by maximizing the Hedger's financial loss.
- Hedger (Replaces Discriminator): Decides how many shares to buy/sell to eliminate risk. It wins by minimizing financial loss (via the Entropic Risk Measure).
We conduct a 4-way comparison across standard and stressed market regimes:
- Black-Scholes: The classical mathematical baseline.
- Standard Deep Hedger: A feedforward neural network trained on normal market data.
- GAN (GRU): The adversarial framework utilizing a standard GRU for the Generator.
- GAN (LSTM): An improved adversarial framework where the Generator uses an LSTM to better capture long-term temporal dependencies in market stress.
Dependencies: torch, numpy, scipy, matplotlib, pandas, jupyter
The benchmark has been structured into professional folders for clarity:
src/: Contains the core Python implementation (Neural Networks, Simulation logic, Training loops).notebooks/: Contains interactive execution notebooks.results/: Contains generated risk metric logs and visual plots.
To run the models and see the visualizations, open the interactive Jupyter Notebooks located in the notebooks/ folder:
notebooks/1_Standard_Hedging_and_Baselines.ipynb: Demonstrates the classical Black-Scholes baseline and trains a standard feedforward Deep Hedger.notebooks/2_Adversarial_GAN_Hedging.ipynb: Trains the adversarial GRU and LSTM generators against the Hedger, and compares all models in a simulated Regime-Switching Crash market.
Open the notebooks to execute the cells. The notebooks will output detailed risk metrics including:
- Mean P&L: Average profit/loss across all simulated paths.
- Std Dev: Standard deviation of returns.
- VaR (95%): Value at Risk; the threshold loss at the worst 5% tail.
- CVaR (95%): Conditional Value at Risk; the average expected loss in the worst 5% of scenarios.
- Worst Case: The absolute maximum drawdown observed.