Skip to content

chasemetoyer/Volatility_World_Model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Visual Latent World Models for Financial Risk Planning

Author: Chase Metoyer Status: Research Prototype (Completed) License: MIT

Abstract

This project introduces a Latent World Model for quantitative finance, shifting the paradigm from price prediction to visual surface reasoning. By treating the Implied Volatility (IV) Surface as a dynamic visual scene, we train a Variational Autoencoder (VAE) to compress market states into a continuous latent manifold and a Recurrent Neural Network (LSTM) to learn the "physics" of volatility dynamics.

Unlike traditional stochastic volatility models (e.g., Heston, SABR), this system possesses hallucinatory capabilities—it can generate counterfactual market scenarios (e.g., "What if a crash happens today?") and allows an autonomous agent to perform visual reasoning over these hallucinations to optimize hedging strategies in real-time.


Architecture

The pipeline consists of four distinct stages, mirroring the biological loop of Sensation, Perception, Cognition, and Action.

Stage Component Description
1. Sensation Dataset Builder Ingests raw OPRA option chains (via Databento), performs Black-Scholes inversion, and fits SVI (Stochastic Volatility Inspired) curves to rasterize dense volatility surfaces.
2. Perception Variational Autoencoder (VAE) A Convolutional Neural Network that compresses the high-dimensional surface () into a compact latent vector (), learning a continuous representation of market structure (Skew, Smile, Term).
3. Cognition Dynamics Model (LSTM) A temporal model trained on the sequence of latent vectors to predict . It captures the "physics" of fear, including mean reversion and shock decay.
4. Action Visual Reasoning Agent A heuristic agent that monitors the Total Energy (magnitude) of the latent state. It autonomously triggers hedging decisions (buying Puts) when it perceives structural anomalies in the hallucinated future.

Key Results

The model was evaluated on high-frequency SPY option data (Jan–Feb 2024).

Table 1: Performance Metrics

Metric Baseline World Model (Ours) Interpretation
Reconstruction (SSIM) 0.8642 (PCA) 0.7688 (VAE) Linear PCA captures static pixels better, but fails to model dynamics.
Prediction Error (MSE) 0.1084 (Naive) 0.0501 (LSTM) 54% improvement in forecasting surface dynamics vs. Random Walk.
Risk-Adjusted Return 0.00 (Buy & Hold) 87.99 (AI Agent) Agent successfully identified a tail-risk event and hedged profitably.*

Evaluation Metrics Chart

> Note: Sharpe Ratio is simulated on a specific crash scenario ( shock) and represents theoretical performance during a tail event, not long-term backtesting.

Research Insight: The PCA vs. VAE Trade-off

While Principal Component Analysis (PCA) achieved higher structural similarity (SSIM), it produces a disjointed latent space that is difficult to forecast. The VAE sacrifices minor reconstruction fidelity (blurriness) to create a smooth, continuous manifold. This trade-off enabled the LSTM to predict future states with 2x greater accuracy than the baseline, validating the superiority of generative models for dynamics forecasting.


Visualizing the "Dream"

1. Crash Hallucination (Stress Test)

The model was subjected to a Directed Latent Shock (multiplying the latent vector of the worst historical day by ).

  • Scenario A (Left): Baseline calm market.
  • Scenario B (Right): The AI hallucinates a "Flash Crash" (Bright Yellow). Crucially, it predicts the subsequent Mean Reversion, fading the fear back to normal levels over 50 steps.

Stress test animation

(Generated via stress_test_v2.py)

2. Hedging Performance

The Green Line represents the AI-Hedged Portfolio, which separates from the Naive Portfolio (Grey Line) exactly when the crash begins. The Red Zone indicates the agent's active decision to buy protection based on "Visual Risk."

image

(Generated via hedge_simulation_pnl_v2.py)


Installation & Usage

Prerequisites

  • Python 3.8+
  • Databento API Key (for data ingestion)
git clone https://github.com/chasemetoyer/volatility-world-model.git
cd volatility-world-model
pip install -r requirements.txt

1. Data Generation

Rasterize raw option data into tensor surfaces.

python surface_builder.py
python batch_processor.py

2. Train the Brain

Train the VAE (Compression) and LSTM (Dynamics).

python world_model_vae.py
python train_dynamics.py

3. Run Simulations

Generate counterfactuals and test the hedging agent.

python stress_test_v2.py
python hedge_simulation_pnl_v2.py

4. Reproduce Metrics

Generate the final evaluation table.

python evaluation_metrics.py

Methodology References

  1. World Models: Ha, D., & Schmidhuber, J. (2018). World Models. (Applied VAE+RNN to game environments; adapted here for financial surfaces).
  2. SVI Parameterization: Gatheral, J., & Jacquier, A. (2014). Arbitrage-Free SVI Volatility Surfaces. (Used for arbitrage-free interpolation).
  3. Visual Finance: Simulating the implied volatility surface as a visual texture to capture non-local dependencies (skew/term structure correlations) often missed by parametric models.

About

World model for volatility surfaces using VAE + LSTM to simulate market dynamics and drive autonomous hedging decisions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages