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; under Heston the paths and the regression basis carry the (spot, variance) state, stepping the Andersen QE scheme.
  • 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).

Path dynamics come from the stochastic-process layer (core::montecarlo::process + equity::processes): the SDE’s drift/diffusion live in the process object (GBM / local vol as a BlackScholesProcess, Heston as the two-factor HestonProcess), and Euler / Milstein / exact stepping are generic over it. A new model plugs in by implementing the process trait; the per-path stream and stepping structure is factor-agnostic.

Re-exports§

pub use crate::core::montecarlo::process::DiscretizationScheme;
pub use crate::core::montecarlo::paths::Sampler;

Structs§

McStats
Price with sampling diagnostics.
MonteCarloConfig
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.

Constants§

HESTON_MIN_STEPS
Step floor for full-truncation Euler, whose O(dt) variance-truncation bias needs a fine grid.
HESTON_QE_MIN_STEPS
Step floor under Andersen QE, which is near bias-free on coarse grids (that is its point) — the floor only keeps enough resolution for the vol path itself.
LOCAL_VOL_MIN_STEPS
PATH_DEPENDENT_MIN_STEPS
Minimum monitoring steps for path-dependent payoffs.

Functions§

npv
npv_with_stats
Price with standard error and simulation diagnostics.