quant-pricer-cpp
Loading...
Searching...
No Matches
heston.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include <complex>
5#include <cstdint>
6
7#include "quant/rng.hpp"
8
9namespace quant::heston {
10
11struct Params {
12 double kappa; // mean reversion speed
13 double theta; // long-run variance
14 double sigma; // vol of vol
15 double rho; // correlation
16 double v0; // initial variance
17};
18
20 double spot;
21 double strike;
22 double rate;
23 double dividend;
24 double time;
25};
26
27// Analytic European call via Heston characteristic function and Gauss-Laguerre
28double call_analytic(const MarketParams& mkt, const Params& h);
29
31std::complex<double> characteristic_function(double u, const MarketParams& mkt, const Params& h);
32
34double implied_vol_call(const MarketParams& mkt, const Params& h);
35
36struct McResult {
37 double price;
38 double std_error;
39};
40
41struct McParams {
44 std::uint64_t num_paths;
45 std::uint64_t seed;
46 int num_steps; // QE time steps
47 bool antithetic{true};
49 enum class Scheme { Euler, QE };
51};
52
53// Andersen QE Monte Carlo pricing of European call
54McResult call_qe_mc(const McParams& p);
55
56} // namespace quant::heston
Heston model: analytic European call and QE Monte Carlo.
Definition heston.hpp:9
McResult call_qe_mc(const McParams &p)
Definition heston.cpp:124
double implied_vol_call(const MarketParams &mkt, const Params &h)
Black–Scholes implied volatility implied by the Heston analytic call price.
Definition heston.cpp:119
std::complex< double > characteristic_function(double u, const MarketParams &mkt, const Params &h)
Risk-neutral characteristic function φ(u) = E[e^{iu ln S_T}].
Definition heston.cpp:115
double call_analytic(const MarketParams &mkt, const Params &h)
Definition heston.cpp:101
Mode
RNG mode selection: traditional PRNG or deterministic counter-based.
Definition rng.hpp:13
@ Counter
Counter-based, reproducible across threading schedules.
Definition heston.hpp:19
double time
Definition heston.hpp:24
double rate
Definition heston.hpp:22
double spot
Definition heston.hpp:20
double strike
Definition heston.hpp:21
double dividend
Definition heston.hpp:23
Definition heston.hpp:41
bool antithetic
Definition heston.hpp:47
Scheme scheme
Definition heston.hpp:50
int num_steps
Definition heston.hpp:46
Scheme
Definition heston.hpp:49
quant::rng::Mode rng
Definition heston.hpp:48
MarketParams mkt
Definition heston.hpp:42
Params h
Definition heston.hpp:43
std::uint64_t seed
Definition heston.hpp:45
std::uint64_t num_paths
Definition heston.hpp:44
Definition heston.hpp:36
double price
Definition heston.hpp:37
double std_error
Definition heston.hpp:38
Definition heston.hpp:11
double kappa
Definition heston.hpp:12
double v0
Definition heston.hpp:16
double rho
Definition heston.hpp:15
double sigma
Definition heston.hpp:14
double theta
Definition heston.hpp:13