Monte Carlo pricing of variance derivatives under the Heston model
Project description
heston_mc
Monte Carlo pricing of variance swaps and variance options under the Heston stochastic volatility model, with control variates for improved efficiency.
Course project on efficient Monte Carlo pricing of variance derivatives under the Heston model.
For a more detailed project description, see docs/PROJECT_SCOPE.md.
What are variance derivatives?
Variance derivatives are contracts whose payoff depends on how much an asset fluctuates over time, rather than only on its final price. In this project, we focus on two examples:
- Variance swaps, whose payoff depends linearly on realized variance relative to a strike
- Variance options, whose payoff depends on the positive part of realized variance above a strike
This package is being built to simulate stock-price and variance paths under the Heston model, compute realized variance from simple returns, and use Monte Carlo methods to price these products. It also includes a control variate component to improve efficiency by reducing Monte Carlo noise.
Model
Under the risk-neutral measure, the Heston model is
$$ dS_t = (r-q)S_t dt + \sqrt{v_t} S_t dW_t^{(1)} $$
$$ dv_t = \kappa(\theta - v_t) dt + \sigma \sqrt{v_t} dW_t^{(2)} $$
$$ d\langle W^{(1)}, W^{(2)} \rangle_t = \rho dt $$
where:
- $S_t$ is the stock price
- $v_t$ is the instantaneous variance
- $r$ is the risk-free rate
- $q$ is the dividend yield
- $\kappa$ is the mean-reversion speed
- $\theta$ is the long-run variance level
- $\sigma$ is the volatility of variance
- $\rho$ is the correlation between the stock and variance shocks
Installation
pip install heston-mc-variance-project
Quick start
from heston_mc.params import HestonParams, MonteCarloConfig, default_heston_params, default_mc_config
from heston_mc.interfaces import SimulationResult, PricingResult
params = default_heston_params()
config = default_mc_config()
print(params)
print(config)
This package is currently under active development. The main pricing workflow is being assembled across the following modules:
heston_mc.simulationheston_mc.realized_varianceheston_mc.variance_swapheston_mc.variance_optionheston_mc.control_variate
Demo notebook
An interactive demo will be available at notebooks/demo.ipynb:
API reference
HestonParams
Shared parameter class for the Heston stochastic volatility model.
| Parameter | Type | Description |
|---|---|---|
s0 |
float |
Initial stock price |
v0 |
float |
Initial variance |
r |
float |
Risk-free interest rate |
q |
float |
Dividend yield |
kappa |
float |
Mean-reversion speed of variance |
theta |
float |
Long-run variance level |
sigma |
float |
Volatility of variance |
rho |
float |
Correlation between stock and variance shocks |
MonteCarloConfig
Shared Monte Carlo configuration.
| Parameter | Type | Description |
|---|---|---|
maturity |
float |
Time to maturity |
n_steps |
int |
Number of time steps |
n_paths |
int |
Number of simulated paths |
seed |
int |
Random seed |
periods_per_year |
int |
Scaling used in realized variance |
SimulationResult
Container for simulation output.
| Field | Type | Description |
|---|---|---|
stock_paths |
np.ndarray |
Simulated stock-price paths |
variance_paths |
np.ndarray |
Simulated variance paths |
dt |
float |
Time step size |
PricingResult
Container for pricing output.
| Field | Type | Description |
|---|---|---|
price |
float |
Estimated derivative price |
std_error |
float |
Monte Carlo standard error |
n_paths |
int |
Number of simulation paths |
n_steps |
int |
Number of time steps |
runtime_seconds |
float |
Runtime in seconds |
method_name |
str |
Name of pricing method |
Module overview
heston_mc.simulation— Heston path simulationheston_mc.realized_variance— realized variance from simple returnsheston_mc.variance_swap— variance swap pricingheston_mc.variance_option— variance option pricingheston_mc.control_variate— control variate estimatorsheston_mc.interfaces— shared result containersheston_mc.params— shared parameter and Monte Carlo configuration objects
References
Broadie, M., & Jain, A. (2008). Pricing and Hedging Volatility Derivatives. The Journal of Derivatives, 15(3), 7–24. https://doi.org/10.3905/jod.2008.702503
Fouque, J.-P., & Han, C.-H. (2004). Variance reduction for Monte Carlo methods to evaluate option prices under multi-factor stochastic volatility models. Quantitative Finance, 4(5), 597–606. https://doi.org/10.1080/14697680400020317
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file heston_mc_variance_project-0.1.0.tar.gz.
File metadata
- Download URL: heston_mc_variance_project-0.1.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3633297d003bd0bc8985893ad84b6568b0109649fe8e5dd616abbfa5a708c525
|
|
| MD5 |
601920738697d90e6706049379ec886e
|
|
| BLAKE2b-256 |
e51740b74b96a3bba97c83aeba74477f244b11c76a55faed5b5fedec6fd0e173
|
Provenance
The following attestation bundles were made for heston_mc_variance_project-0.1.0.tar.gz:
Publisher:
publish.yml on htp2105/MATH5030GR-project
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
heston_mc_variance_project-0.1.0.tar.gz -
Subject digest:
3633297d003bd0bc8985893ad84b6568b0109649fe8e5dd616abbfa5a708c525 - Sigstore transparency entry: 1489621458
- Sigstore integration time:
-
Permalink:
htp2105/MATH5030GR-project@d8d319040de6e38be83cc8cfaf79c307ce91e590 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/htp2105
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d8d319040de6e38be83cc8cfaf79c307ce91e590 -
Trigger Event:
release
-
Statement type:
File details
Details for the file heston_mc_variance_project-0.1.0-py3-none-any.whl.
File metadata
- Download URL: heston_mc_variance_project-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ca76d5aa51728d62a0eabdb0bf0bed498104966bffadeaaf95642c367dbed99
|
|
| MD5 |
a6469f87ac09078a7f78a546164caedb
|
|
| BLAKE2b-256 |
340a9d4ec043931888ac2235d348987cb7394f078722d0f92f5b06303d9392e0
|
Provenance
The following attestation bundles were made for heston_mc_variance_project-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on htp2105/MATH5030GR-project
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
heston_mc_variance_project-0.1.0-py3-none-any.whl -
Subject digest:
7ca76d5aa51728d62a0eabdb0bf0bed498104966bffadeaaf95642c367dbed99 - Sigstore transparency entry: 1489621738
- Sigstore integration time:
-
Permalink:
htp2105/MATH5030GR-project@d8d319040de6e38be83cc8cfaf79c307ce91e590 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/htp2105
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d8d319040de6e38be83cc8cfaf79c307ce91e590 -
Trigger Event:
release
-
Statement type: