Skip to main content

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.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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

heston_mc_variance_project-0.1.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

heston_mc_variance_project-0.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file heston_mc_variance_project-0.1.0.tar.gz.

File metadata

File hashes

Hashes for heston_mc_variance_project-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3633297d003bd0bc8985893ad84b6568b0109649fe8e5dd616abbfa5a708c525
MD5 601920738697d90e6706049379ec886e
BLAKE2b-256 e51740b74b96a3bba97c83aeba74477f244b11c76a55faed5b5fedec6fd0e173

See more details on using hashes here.

Provenance

The following attestation bundles were made for heston_mc_variance_project-0.1.0.tar.gz:

Publisher: publish.yml on htp2105/MATH5030GR-project

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file heston_mc_variance_project-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for heston_mc_variance_project-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ca76d5aa51728d62a0eabdb0bf0bed498104966bffadeaaf95642c367dbed99
MD5 a6469f87ac09078a7f78a546164caedb
BLAKE2b-256 340a9d4ec043931888ac2235d348987cb7394f078722d0f92f5b06303d9392e0

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page