25#ifndef quantlib_mc_european_heston_engine_hpp
26#define quantlib_mc_european_heston_engine_hpp
49 Size timeStepsPerYear,
50 bool antitheticVariate,
52 Real requiredTolerance,
56 ext::shared_ptr<path_pricer_type>
pathPricer()
const override;
74 operator ext::shared_ptr<PricingEngine>()
const;
99 template <
class RNG,
class S,
class P>
101 const ext::shared_ptr<P>& process,
102 Size timeSteps,
Size timeStepsPerYear,
bool antitheticVariate,
103 Size requiredSamples,
Real requiredTolerance,
106 false, antitheticVariate, false,
107 requiredSamples, requiredTolerance,
111 template <
class RNG,
class S,
class P>
116 ext::shared_ptr<PlainVanillaPayoff>
payoff(
117 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
118 this->arguments_.payoff));
121 ext::shared_ptr<P> process =
122 ext::dynamic_pointer_cast<P>(this->process_);
123 QL_REQUIRE(process,
"Heston like process required");
125 return ext::shared_ptr<
130 process->riskFreeRate()->discount(
131 this->timeGrid().back())));
135 template <
class RNG,
class S,
class P>
137 ext::shared_ptr<P> process)
141 template <
class RNG,
class S,
class P>
145 "number of steps per year already set");
150 template <
class RNG,
class S,
class P>
154 "number of steps already set");
155 stepsPerYear_ = steps;
159 template <
class RNG,
class S,
class P>
163 "tolerance already set");
168 template <
class RNG,
class S,
class P>
172 "number of samples already set");
174 "chosen random generator policy "
175 "does not allow an error estimate");
176 tolerance_ = tolerance;
180 template <
class RNG,
class S,
class P>
183 maxSamples_ = samples;
187 template <
class RNG,
class S,
class P>
194 template <
class RNG,
class S,
class P>
201 template <
class RNG,
class S,
class P>
204 operator ext::shared_ptr<PricingEngine>()
const {
206 "number of steps not given");
207 return ext::shared_ptr<PricingEngine>(
212 samples_, tolerance_,
223 :
payoff_(type, strike), discount_(discount) {
225 "strike less than zero not allowed");
230 const Path& path = multiPath[0];
PlainVanillaPayoff payoff_
Real operator()(const MultiPath &Multipath) const override
EuropeanHestonPathPricer(Option::Type type, Real strike, DiscountFactor discount)
Square-root stochastic-volatility Heston process.
Monte Carlo Heston-model engine for European options.
MCVanillaEngine< MultiVariate, RNG, S >::path_pricer_type path_pricer_type
MCEuropeanHestonEngine(const ext::shared_ptr< P > &, Size timeSteps, Size timeStepsPerYear, bool antitheticVariate, Size requiredSamples, Real requiredTolerance, Size maxSamples, BigNatural seed)
ext::shared_ptr< path_pricer_type > pathPricer() const override
Pricing engine for vanilla options using Monte Carlo simulation.
McSimulation< MC, RNG, S >::path_pricer_type path_pricer_type
Monte Carlo Heston European engine factory.
MakeMCEuropeanHestonEngine & withSteps(Size steps)
MakeMCEuropeanHestonEngine(ext::shared_ptr< P >)
MakeMCEuropeanHestonEngine & withAntitheticVariate(bool b=true)
MakeMCEuropeanHestonEngine & withMaxSamples(Size samples)
MakeMCEuropeanHestonEngine & withStepsPerYear(Size steps)
MakeMCEuropeanHestonEngine & withSamples(Size samples)
ext::shared_ptr< P > process_
MakeMCEuropeanHestonEngine & withAbsoluteTolerance(Real tolerance)
MakeMCEuropeanHestonEngine & withSeed(BigNatural seed)
Correlated multiple asset paths.
template class providing a null value for a given type.
single-factor random walk
Real back() const
final asset value
base class for path pricers
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
ext::function< Real(Real)> b
const ext::shared_ptr< Payoff > payoff_
Real DiscountFactor
discount factor between dates
std::size_t Size
size of a container
Heston stochastic process.
ext::shared_ptr< QuantLib::Payoff > payoff
Monte Carlo vanilla option engine.
RiskStatistics Statistics
default statistics tool
unsigned QL_BIG_INTEGER BigNatural
large positive integer
GenericPseudoRandom< MersenneTwisterUniformRng, InverseCumulativeNormal > PseudoRandom
default traits for pseudo-random number generation
default Monte Carlo traits for multi-variate models