Documentation build: 2ad88e973293
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
30// Analytic European put from the Heston call and discounted put-call parity
31double put_analytic(const MarketParams& mkt, const Params& h);
32
34std::complex<double> characteristic_function(double u, const MarketParams& mkt, const Params& h);
35
37double implied_vol_call(const MarketParams& mkt, const Params& h);
38
39struct McResult {
40 double price;
41 double std_error;
42};
43
44struct McParams {
47 std::uint64_t num_paths;
48 std::uint64_t seed;
49 int num_steps; // QE time steps
50 bool antithetic{true};
52 enum class Scheme { Euler, QE };
54};
55
56// Andersen QE Monte Carlo pricing of European call
57McResult call_qe_mc(const McParams& p);
58
59} // 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:129
double implied_vol_call(const MarketParams &mkt, const Params &h)
Black–Scholes implied volatility implied by the Heston analytic call price.
Definition heston.cpp:124
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:120
double call_analytic(const MarketParams &mkt, const Params &h)
Definition heston.cpp:101
double put_analytic(const MarketParams &mkt, const Params &h)
Definition heston.cpp:115
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:44
bool antithetic
Definition heston.hpp:50
Scheme scheme
Definition heston.hpp:53
int num_steps
Definition heston.hpp:49
Scheme
Definition heston.hpp:52
quant::rng::Mode rng
Definition heston.hpp:51
MarketParams mkt
Definition heston.hpp:45
Params h
Definition heston.hpp:46
std::uint64_t seed
Definition heston.hpp:48
std::uint64_t num_paths
Definition heston.hpp:47
Definition heston.hpp:39
double price
Definition heston.hpp:40
double std_error
Definition heston.hpp:41
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