Skip to main content

Module montecarlo

Module montecarlo 

Source
Expand description

Monte Carlo pricing engine.

  • Terminal-value simulation (exact GBM step, 1-D Sobol) for European payoffs; path-wise simulation with Exact / Euler / Milstein stepping.
  • Parallel, streamed path generation: every path derives its own deterministic RNG stream from (seed, path index), so paths are generated in parallel with rayon, results are independent of thread scheduling, and no draw matrix is materialized.
  • Multi-dimensional quasi-Monte Carlo: with the (default) Sobol sampler, path-wise routes use a low-discrepancy sequence through a Brownian bridge, so the best coordinates carry each path’s coarse structure.
  • Dupire local vol dynamics, Brownian-bridge barrier correction, geometric control variate for arithmetic Asians.
  • American exercise via two-pass Longstaff-Schwartz (regression on one set of paths, valuation on an independent set — removes foresight bias) with a cubic polynomial basis.
  • npv_with_stats reports the standard error alongside the price.
  • Greeks by central-difference bump-and-reprice with common random numbers (deterministic draws make every reprice use identical paths).

Multi-factor models (stochastic vol) plug in by widening the per-step draw dimension and adding a second bridge; the per-path stream and stepping structure is factor-agnostic.

Structs§

McStats
Price with sampling diagnostics.
MonteCarloConfig

Enums§

DiscretizationScheme
Time-stepping scheme for path-wise simulation. Exact samples the closed-form GBM transition (no discretization bias); Euler and Milstein are the standard approximate schemes (the basis for models without closed-form transitions, e.g. local vol / Heston).
McModel
Dynamics used for path generation. Gbm diffuses at the option’s own (constant) implied vol; LocalVol diffuses at the Dupire local volatility calibrated from the option’s vol surface.
Sampler
Draw sampler. Sobol selects the low-discrepancy family: true Sobol (van der Corput) in one dimension, a scrambled multi-dimensional sequence through a Brownian bridge for path-wise simulation. PseudoRandom uses seeded per-path PCG64 streams with antithetic pairing. Longstaff-Schwarz always uses pseudo-random streams.

Constants§

HESTON_MIN_STEPS
LOCAL_VOL_MIN_STEPS
PATH_DEPENDENT_MIN_STEPS
Minimum monitoring steps for path-dependent payoffs.

Functions§

delta
gamma
npv
npv_with_stats
Price with standard error and simulation diagnostics.
option_pricing
rho
theta
vega