CoolFace
Apppublic

MrSamak/gbm-mcwf-cvar-optimizer

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
App README

GBM–MCWF CVaR Optimizer

A Quantum-Inspired Jump–Diffusion Framework for Portfolio Optimization

![Hugging Face Spaces](https://huggingface.co/spaces/<your-username>/gbm-mcwf-cvar-optimizer) ![Python]() ![License: MIT](LICENSE)


🧭 Overview

This repository implements the complete workflow presented in the Quantum-Inspired Portfolio Optimization (GBM–MCWF) study. It extends the traditional Geometric Brownian Motion (GBM) with Monte-Carlo Wave-Function (MCWF) style jump dynamics — calibrated adaptively using neural networks — and integrates Conditional Value-at-Risk (CVaR) optimization for risk-aware asset allocation.

The model simulates correlated asset prices with stochastic jumps and constructs the Efficient Frontier under both Variance and CVaR objectives.


🧩 Key Features

CategoryDescription
Model CoreGeometric Brownian Motion with Quantum-Inspired Jumps (MCWF analogue)
CalibrationNeural network estimation of jump probability p_jump and jump amplitude Δ via MLPRegressor
OptimizationPortfolio allocation under both Variance-based and CVaR-based objectives
SimulationCholesky-correlated multivariate Monte Carlo paths with adjustable horizon, α-level, and target return
InterfaceFully interactive Streamlit app for exploration and visualization
OutputsEfficient frontier, CVaR frontier, portfolio weights, and loss probability distribution

⚙️ Installation & Execution

🧱 Prerequisites

  • —Python ≥ 3.9
  • —pip, virtualenv (recommended)

💻 Local Setup

bash
# 1. Clone the repository
git clone https://github.com/<your-username>/gbm-mcwf-cvar-optimizer.git
cd gbm-mcwf-cvar-optimizer

# 2. Install dependencies
pip install -r requirements.txt

# 3. Launch Streamlit app
streamlit run app.py

Then open your browser at http://localhost:8501.


☁️ Deploy on Hugging Face Spaces

This repository is pre-configured for Hugging Face deployment.

  1. 1.Go to 👉 https://huggingface.co/new-space
  2. 2.Set:
  3. 3.Space name: gbm-mcwf-cvar-optimizer
  4. 4.SDK: streamlit
  5. 5.Repository: link to this GitHub repo
  6. 6.Wait for the build to complete. Your app will be live at:
   https://huggingface.co/spaces/<your-username>/gbm-mcwf-cvar-optimizer

📊 Example Usage

Sample Data

This repo includes a demo file: stock_prices.csv

Expected format:

csv
Date,AAPL,ADBE,ADI,BA,BIDU,CSCO,DELL,EBAY,FB,GE
2020-01-02,74.36,329.81,118.45,329.88,135.84,47.51,51.08,36.26,209.78,11.87
...

In the App:

  • —Upload your own CSV or use the included sample.
  • —Adjust simulation parameters (paths, α, horizon, target return).
  • —Observe:
  • —Efficient frontier (Variance vs CVaR)
  • —Portfolio weights under both objectives
  • —Return distribution and risk metrics

📐 Theoretical Framework

1️⃣ Jump–Diffusion Dynamics

Each asset follows: \[ dSt = \mu St dt + \sigma St dWt + St dJt \] where \(dJt\) represents quantum-inspired jumps (MCWF-like collapses) governed by an adaptive probability \(p\text{jump}\).

2️⃣ CVaR Optimization

The CVaR objective minimizes the tail loss: \[ \minw \; \text{CVaR}\alpha(w) = \mathbb{E}[ -r(w) \mid r(w) \leq \text{VaR}\alpha(w) ] \] subject to expected return \(E[r(w)] = R^*\) and \(\sumi w_i = 1\).

3️⃣ Neural Calibration

Both \(p_\text{jump}\) and jump amplitude \(\Delta\) are calibrated by an MLP using rolling volatility, lagged returns, and absolute movements.


🧠 Research Context

This model forms part of the Quantum Inspire Portfolio OPT project — an interdisciplinary exploration bridging quantum dynamics, stochastic processes, and financial optimization. It provides a geometric and probabilistic perspective on risk propagation, extending the classical mean-variance paradigm to include non-Gaussian market shocks and tail risk asymmetry.


🧮 Folder Structure

gbm-mcwf-cvar-optimizer/
├─ app.py                # Streamlit application (main entry)
├─ requirements.txt      # Python dependencies
├─ stock_prices.csv      # Example dataset
├─ README.md             # (This file) — Hugging Face + GitHub unified documentation
└─ LICENSE               # MIT license

📚 References

  • —Rockafellar, R.T., & Uryasev, S. (2000). Optimization of Conditional Value-at-Risk. Journal of Risk.
  • —Bouchard, J.P., & Potters, M. (2009). Theory of Financial Risk and Derivative Pricing.
  • —Gardiner, C.W. (1985). Handbook of Stochastic Methods. Springer.
  • —Schack, R., & Brun, T.A. (1997). Monte-Carlo Wave-Function Method in Open Quantum Systems.
  • —Samak Boonpan et al. (2025). Quantum-Inspired Portfolio Optimization via GBM–MCWF and CVaR Framework. KKU Quantum Inspire Project.

🏷 Citation

If you use this framework in your research, please cite:

bibtex
@software{Boonpan2025_GBM_MCWF_CVaR,
  author = {Boonpan, Samak},
  title = {GBM–MCWF CVaR Optimizer: A Quantum-Inspired Jump–Diffusion Framework for Portfolio Optimization},
  year = {2025},
  url = {https://github.com/<your-username>/gbm-mcwf-cvar-optimizer},
  note = {Version 1.0, Streamlit + Hugging Face Space}
}

⚖️ License

This project is licensed under the MIT License. © 2025 Samak Boonpan, Khon Kaen University — Quantum Inspire Portfolio OPT Project.