Stochastic Control Portfolio is a high-performance computational engine designed to solve optimal decision-making problems in finance. By transforming a modular reaction-diffusion PDE framework into a Hamilton-Jacobi-Bellman (HJB) solver, this project provides a robust numerical approach to the Merton Portfolio Problem, determining the optimal allocation of wealth between risky and risk-free assets over a continuous-time horizon.
This repository implements a high-performance Merton Portfolio Problem solver developed for quantitative finance. Built from a modular PDE engine, this repo optimizes investment strategies under uncertainty by solving the Hamilton-Jacobi-Bellman (HJB) equation. Features include GPU-accelerated time-stepping and Neumann boundary support.
-
Optimal Control Solver: Solves the non-linear HJB equation to determine the optimal portfolio weight (
$\pi^*$ ) at every point on a wealth-time grid. - Modular PDE Architecture: Decouples the financial "physics" (Merton dynamics) from the numerical integration engine (Implicit-Explicit time-stepping).
- High-Performance Computing: Utilizes vectorized operations and optional GPU acceleration (via Numba/CuPy) to handle dense spatial grids efficiently.
- Advanced Boundary Management: Implements Neumann (Reflective) boundary conditions to ensure utility conservation across the wealth domain.
- Automated Risk Monitoring: Built-in health checks to detect and prevent numerical instabilities during non-linear optimization steps.
The core of the repository is the Merton Portfolio Problem, which seeks to maximize the expected power utility of terminal wealth:
The solver iterates backward in time from the terminal utility state, solving the HJB equation:
At each step, the engine performs a local optimization to find the optimal control
- Python ≥ 3.11
- NumPy, SciPy, Matplotlib
- Numba (CPU acceleration)
- CuPy (optional — GPU acceleration)
git clone https://github.com/Diegotistical/stochastic-control-portfolio.git
cd stochastic-control-portfolio
pip install -r requirements.txt