Metadata-Version: 2.4
Name: garch-lnmm
Version: 0.1.0
Summary: Log-normal moment-matching simulation for GARCH diffusion option pricing
Author: MATH5030 Group 11
License: MIT
Project-URL: Homepage, https://github.com/JM357/MATH5030Group11
Keywords: finance,monte-carlo,garch,option-pricing
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.10
Requires-Dist: pandas>=1.5
Requires-Dist: matplotlib>=3.7
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# garch-lnmm

Log-normal and Shifted-lognormal moment-matching simulation for European call option pricing under the GARCH diffusion model

## Problem

The continuous-time GARCH diffusion model is useful for stochastic volatility option pricing, but standard Euler discretization can generate negative variance values. In practice, truncation is often applied, which may introduce discretization bias under coarse time steps.

This package implements and compares positivity-preserving moment-matching schemes, including Log-Normal Moment-Matching (LN-MM) and Shifted Log-Normal Moment-Matching (SLN-MM), against Euler conditional Monte Carlo and the Taylor closed-form analytical approximation from Barone-Adesi et al. (2003).

The conditional mean, variance, and skewness used in these schemes are computed from the **exact** conditional moments of the next-step GARCH diffusion variance transition.

## Installation

```bash
pip install garch-lnmm
```
## Quick Start
```python
from garch_lnmm import GarchDiffusionMC

model = GarchDiffusionMC(
    S0=100,
    V0=0.16,
    r=0.05,
    kappa=0.75,
    theta=0.04,
    sigma=0.85,
    rho=0,
    T=5,
)

lnmm_price = model.simulate_moment_matching_cond_mc(
    N_paths=50000,
    N_steps=32,
    K=130,
    seed=42,
)

slnmm_price = model.simulate_shifted_lognormal_cond_mc(
    N_paths=50000,
    N_steps=32,
    K=130,
    seed=42,
)

print("LN-MM price:", lnmm_price)
print("SLN-MM price:", slnmm_price)
```

## API Reference

### `GarchDiffusionMC(S0, V0, r, kappa, theta, sigma, rho, T)`

Main simulator class for the continuous-time GARCH diffusion model.

| Parameter | Type | Description |
|---|---|---|
| `S0` | float | Initial stock price |
| `V0` | float | Initial variance |
| `r` | float | Risk-free interest rate |
| `kappa` | float | Mean-reversion speed of variance |
| `theta` | float | Long-run variance level |
| `sigma` | float | Volatility of variance |
| `rho` | float | Correlation parameter |
| `T` | float | Maturity |

---

### `simulate_euler_cond_mc(N_paths, N_steps, K, seed=None, return_stats=False)`

Prices a European call using truncated Euler conditional Monte Carlo.

| Parameter | Type | Description |
|---|---|---|
| `N_paths` | int | Number of Monte Carlo paths |
| `N_steps` | int | Number of time steps |
| `K` | float | Strike price |
| `seed` | int or None | Random seed |
| `return_stats` | bool | If True, return price and error statistics |

Returns:

| Field | Type | Description |
|---|---|---|
| `price` | float | Estimated option price |
| `std_dev` | float | Sample standard deviation |
| `std_error` | float | Monte Carlo standard error |

---

### `simulate_moment_matching_cond_mc(N_paths, N_steps, K, seed=None, return_stats=False)`

Prices a European call using the Log-Normal Moment-Matching scheme.

| Parameter | Type | Description |
|---|---|---|
| `N_paths` | int | Number of Monte Carlo paths |
| `N_steps` | int | Number of time steps |
| `K` | float | Strike price |
| `seed` | int or None | Random seed |
| `return_stats` | bool | If True, return price and error statistics |

Returns:

| Field | Type | Description |
|---|---|---|
| `price` | float | Estimated option price |
| `std_dev` | float | Sample standard deviation |
| `std_error` | float | Monte Carlo standard error |

---

### `simulate_shifted_lognormal_cond_mc(N_paths, N_steps, K, seed=None, return_stats=False)`

Prices a European call using the Shifted Log-Normal Moment-Matching scheme.

This method computes the first three exact conditional raw moments of the next-step variance transition \(V(t+h)\), converts them into conditional mean, variance, and skewness, and then samples from a shifted-lognormal approximation matching these moments.

| Parameter | Type | Description |
|---|---|---|
| `N_paths` | int | Number of Monte Carlo paths |
| `N_steps` | int | Number of time steps |
| `K` | float | Strike price |
| `seed` | int or None | Random seed |
| `return_stats` | bool | If True, return price and error statistics |

Returns:

| Field | Type | Description |
|---|---|---|
| `price` | float | Estimated option price |
| `std_dev` | float | Sample standard deviation |
| `std_error` | float | Monte Carlo standard error |

---


## License
MIT

## Demo Notebook

[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/JM357/MATH5030Group11/blob/main/notebooks/demo.ipynb)

## References
> Choi, J., Hu, L., & Kwok, Y. K. (2024).  
> *Efficient and Accurate Simulation of the Stochastic-Alpha-Beta-Rho Model*.

Motivates the shifted-lognormal moment-matching framework used in the SLN-MM extension.

> Barone-Adesi, G., Rasmussen, H., & Ravanelli, C. (2003).  
> *An Option Pricing Formula for the GARCH Diffusion Model*.

Provides the conditional moments and Taylor approximation used as analytical benchmarks in this project.

> Andersen, L. (2008).  
> *Simple and Efficient Simulation of the Heston Stochastic Volatility Model*.  

Motivates the moment-matching methodology adopted for the variance simulation scheme.
