quant-pricer-cpp
Loading...
Searching...
No Matches
mc.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include <cstdint>
5#include <optional>
6#include <random>
7#include <vector>
8
9#include "quant/rng.hpp"
11
12namespace quant::mc {
13
17struct McParams {
18 double spot; // S0
19 double strike; // K
20 double rate; // r
21 double dividend; // q
22 double vol; // sigma
23 double time; // T
24 std::uint64_t num_paths; // number of primary paths (antithetic doubles effective)
25 std::uint64_t seed; // RNG seed
26 bool antithetic{true};
27 bool control_variate{true}; // control variate on discounted S_T vs E[S_T]
29 enum class Qmc { None, Sobol, SobolScrambled };
30 enum class Bridge { None, BrownianBridge };
33 int num_steps{1};
34 // Optional piecewise-constant schedules; when set, override scalar rate/div/vol
35 std::optional<quant::PiecewiseConstant> rate_schedule{};
36 std::optional<quant::PiecewiseConstant> dividend_schedule{};
37 std::optional<quant::PiecewiseConstant> vol_schedule{};
38};
39
42 double value; // sample mean
43 double std_error; // standard error of the estimate
44 double ci_low; // 95% confidence interval lower bound
45 double ci_high; // 95% confidence interval upper bound
46};
47
49struct McResult {
50 McStatistic estimate; // price estimate and uncertainty
51};
52
59
62 McStatistic delta; // pathwise
63 McStatistic vega; // pathwise
64 McStatistic gamma_lrm; // likelihood-ratio
65 McStatistic gamma_mixed; // mixed (pathwise × LR)
66 McStatistic theta; // finite-difference in time with common RNG
67};
68
74
75} // namespace quant::mc
Monte Carlo GBM pricer with antithetic variates and optional control variate.
Definition mc.hpp:12
McResult price_european_call(const McParams &p)
Definition mc.cpp:370
GreeksResult greeks_european_call(const McParams &p)
Definition mc.cpp:474
Mode
RNG mode selection: traditional PRNG or deterministic counter-based.
Definition rng.hpp:13
@ Counter
Counter-based, reproducible across threading schedules.
Monte Carlo Greeks result (mean/SE/CI per estimator).
Definition mc.hpp:61
McStatistic gamma_mixed
Definition mc.hpp:65
McStatistic vega
Definition mc.hpp:63
McStatistic gamma_lrm
Definition mc.hpp:64
McStatistic delta
Definition mc.hpp:62
McStatistic theta
Definition mc.hpp:66
Definition mc.hpp:17
double spot
Definition mc.hpp:18
Bridge
Definition mc.hpp:30
Qmc qmc
Definition mc.hpp:31
Qmc
Definition mc.hpp:29
Bridge bridge
Definition mc.hpp:32
std::uint64_t seed
Definition mc.hpp:25
double vol
Definition mc.hpp:22
int num_steps
Definition mc.hpp:33
bool control_variate
Definition mc.hpp:27
std::optional< quant::PiecewiseConstant > vol_schedule
Definition mc.hpp:37
double strike
Definition mc.hpp:19
bool antithetic
Definition mc.hpp:26
std::uint64_t num_paths
Definition mc.hpp:24
std::optional< quant::PiecewiseConstant > dividend_schedule
Definition mc.hpp:36
quant::rng::Mode rng
Definition mc.hpp:28
std::optional< quant::PiecewiseConstant > rate_schedule
Definition mc.hpp:35
double time
Definition mc.hpp:23
double dividend
Definition mc.hpp:21
double rate
Definition mc.hpp:20
Monte Carlo pricing result.
Definition mc.hpp:49
McStatistic estimate
Definition mc.hpp:50
Summary of a Monte Carlo estimator (mean, standard error, 95% CI)
Definition mc.hpp:41
double std_error
Definition mc.hpp:43
double ci_high
Definition mc.hpp:45
double value
Definition mc.hpp:42
double ci_low
Definition mc.hpp:44