Skip to content

A production-grade pricing engine for Multi-Asset Phoenix Autocallables. Features Numba-accelerated Monte Carlo, Local Volatility, Finite Difference Greeks, and a Streamlit Dashboard.

Notifications You must be signed in to change notification settings

fogatogl/ProjetMARC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

High-Performance MARC Pricing Engine (Multi-Asset Autocallable Reverse Convertible)

1. Executive Summary

This repository contains a production-grade pricing engine for Multi-Asset Autocallable Reverse Convertibles (MARC).

In the modern equity derivatives landscape, structurers face significant risks when pricing barrier-contingent payoffs. Legacy systems (often C++ wrapped in Excel) struggle to price the "Worst-Of" correlation exposure and American Barriers with sufficient speed and accuracy.

This engine leverages the Python numerical stack (specifically Numba) to achieve nanosecond latency comparable to C++, while maintaining the flexibility of a scripting language. It explicitly handles:

  • Path Dependency: American barriers and Autocall triggers.
  • Skew Risk: Local Volatility (Dupire) modeling.
  • Negative Gamma: Advanced risk visualizations for "Pin Risk" and "Gap Risk."

2. Mathematical Fundamentals

The engine moves beyond standard Black-Scholes assumptions to model the true behavior of multi-asset baskets.

2.1 The "Worst-Of" Performance Metric

The product performance is linked to the asset with the lowest return in the basket. The pricing kernel treats the correlation matrix as a first-order pricing parameter.

$$P(t) = \min_{i=1,...,N} \left( \frac{S_i(t)}{S_i(0)} \right)$$

2.2 Numerical Methods & Volatility

To ensure market-consistent pricing, we employ:

  • Local Volatility (Dupire): We construct a smooth Implied Volatility Surface using Bicubic Splines and pre-compute a Local Volatility grid. This allows the simulation to "ride" the skew, returning higher volatilities as the spot drops toward the barrier (Knock-In). $$\sigma_{loc}^2(K,T) = \frac{\frac{\partial C}{\partial T} + (r-q)K\frac{\partial C}{\partial K} + qC}{\frac{1}{2}K^2\frac{\partial^2 C}{\partial K^2}}$$
  • Cholesky Decomposition: Used to simulate correlated Brownian motions. The engine includes spectral decomposition (Higham's Algorithm) to project non-PSD correlation matrices onto the nearest valid PSD matrix.

2.3 Variance Reduction

To achieve convergence (Standard Error < 0.1%) without computational bloat, we utilize:

  1. Antithetic Variates: Simulating path pairs $(Z, -Z)$ to reduce variance at zero cost.
  2. Control Variates: We use a Geometric Basket Option (which has an analytical closed-form solution) as a control to correct the Monte Carlo error for the "Worst-Of" simulation.

3. Technology Architecture

This project strictly follows a Model-View-Controller (MVC) pattern to separate mathematical kernels from UI logic.

Core Stack

  • Language: Python 3.9+
  • JIT Compilation: Numba (Used for the Monte Carlo loop to avoid Python's branching overhead).
  • Visualization: Streamlit (Dashboard) & Plotly (Interactive Greeks).

Performance Logic (Numba vs. Numpy)

We utilize Numba over standard Numpy vectorization. While Numpy is efficient for arrays, Numba allows for optimized "Early Exit" branching—essential for Autocall structures where paths terminate early, saving significant computational resources.


4. Project Structure


📂 Project Structure

MARC_Pricing_Engine/
├── data/
│   ├── config.yaml               # Simulation parameters (N paths, time steps)
│   ├── market_data.parquet       # Historical price data (Yahoo Finance)
│   └── market_vols.parquet       # Generated local volatility surfaces
├── src/
│   ├── __init__.py
│   ├── simulation.py             # Main simulation wrapper (Pricing & Plotting modes)
│   ├── math_core/
│   │   ├── __init__.py
│   │   ├── cholesky.py           # Correlation matrix PSD fixes & decomposition
│   │   ├── gbm_numba.py          # The compiled JIT Monte Carlo kernel
│   │   └── spline_vol.py         # Cubic spline volatility surface interpolation
│   ├── instruments/
│   │   ├── __init__.py
│   │   ├── marc.py               # Product definition class (Barriers, Coupons, Maturity)
│   │   ├── market.py             # Market Environment data class
│   │   └── payoff.py             # Payoff logic (Autocall, Knock-In, Memory Coupons)
│   ├── analytics/
│   │   ├── greeks.py             # Finite Difference Greeks (Delta, Vega)
│   │   └── variance_reduction.py # Control Variate (Martingale) regression logic
│   └── app/
│       ├── dashboard.py          # Streamlit Web UI entry point
│       ├── plots.py              # Matplotlib/Plotly visualization wrappers
│       └── reporting.py          # PDF Term Sheet generator (FPDF)
├── tests/
│   ├── test_analytical.py        # Unit tests: MC vs Black-Scholes benchmark
│   └── test_barriers.py          # Unit tests: Barrier hit logic verification
├── fetch_data.py                 # Script to download prices & generate volatility surfaces
├── main.py                       # CLI entry point for running the engine locally
├── requirements.txt              # Project dependencies
└── README.md                     # Project documentation

About

A production-grade pricing engine for Multi-Asset Phoenix Autocallables. Features Numba-accelerated Monte Carlo, Local Volatility, Finite Difference Greeks, and a Streamlit Dashboard.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages