Skip to main content

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.simulation
  • heston_mc.realized_variance
  • heston_mc.variance_swap
  • heston_mc.variance_option
  • heston_mc.control_variate

Demo notebook

An interactive demo will be available at notebooks/demo.ipynb:

Open In Colab

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 simulation
  • heston_mc.realized_variance — realized variance from simple returns
  • heston_mc.variance_swap — variance swap pricing
  • heston_mc.variance_option — variance option pricing
  • heston_mc.control_variate — control variate estimators
  • heston_mc.interfaces — shared result containers
  • heston_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

Metadata

Release files for heston-mc-variance-project 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for heston-mc-variance-project 0.1.0
File Size Uploaded Provenance Actions
heston_mc_variance_project-0.1.0.tar.gz 13.4 kB With provenance Details for heston_mc_variance_project-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for heston-mc-variance-project 0.1.0
File Interpreter ABI Platform Actions
heston_mc_variance_project-0.1.0-py3-none-any.whl Python 3 none any Details for heston_mc_variance_project-0.1.0-py3-none-any.whl

Total release size: 26.2 kB

Release files / heston_mc_variance_project-0.1.0.tar.gz

Download URL heston_mc_variance_project-0.1.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3633297d003bd0bc8985893ad84b6568b0109649fe8e5dd616abbfa5a708c525
BLAKE2b-256 checksum
How to use checksums
e51740b74b96a3bba97c83aeba74477f244b11c76a55faed5b5fedec6fd0e173
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 10, 2026.

Transparency log

Release files / heston_mc_variance_project-0.1.0-py3-none-any.whl

Download URL heston_mc_variance_project-0.1.0-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ca76d5aa51728d62a0eabdb0bf0bed498104966bffadeaaf95642c367dbed99
BLAKE2b-256 checksum
How to use checksums
340a9d4ec043931888ac2235d348987cb7394f078722d0f92f5b06303d9392e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 10, 2026.

Transparency log

Security for heston-mc-variance-project 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for heston_mc_variance_project-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page