Monte Carlo Option Pricer
Overview
A C++ Monte Carlo engine for pricing European and path-dependent options, accelerated with OpenMP and standard variance-reduction techniques.
1Price Dynamics
The underlying follows geometric Brownian motion:
$$ dS_t = r S_t\, dt + \sigma S_t\, dW_t, \qquad S_T = S_0 \exp\!\left[(r - \tfrac{1}{2}\sigma^2)T + \sigma W_T\right]. $$
2Monte Carlo Estimator
The discounted payoff is averaged over simulated paths:
$$ \hat{V} = e^{-rT}\,\frac{1}{N}\sum_{i=1}^{N} f\!\left(S_T^{(i)}\right), \qquad \mathrm{SE} = \frac{\hat\sigma_f}{\sqrt{N}}. $$
3Variance Reduction
Antithetic variates pair each draw \(Z\) with \(-Z\); control variates subtract a correlated quantity with known expectation to reduce estimator variance.
4Parallelism
double price = 0.0;
#pragma omp parallel for reduction(+ : price)
for (long i = 0; i < n_paths; ++i) {
double z = rng.normal();
double sT = s0 * std::exp((r - 0.5 * vol * vol) * T + vol * std::sqrt(T) * z);
price += std::max(sT - K, 0.0);
}
price = std::exp(-r * T) * price / n_paths;
5Greeks
Delta and Vega are computed by pathwise differentiation where smooth, falling back to bump-and-revalue for discontinuous payoffs.
6Results
For a European call, the engine matches the Black–Scholes price within Monte Carlo error, with near-linear speedup across cores.
| Threads | Paths/s | Speedup |
|---|---|---|
| 1 | 12M | 1.0× |
| 4 | 46M | 3.8× |
| 8 | 88M | 7.3× |
7Limitations
Scope
Assumes constant volatility and rates; stochastic-vol and local-vol models are future extensions.
AAPI Reference
struct PricingResult { double price, stderr, delta, gamma, vega; };
PricingResult price_european(double s0, double K, double r,
double vol, double T,
long n_paths, int n_threads);