20#ifndef quantlib_mc_forward_european_heston_engine_hpp
21#define quantlib_mc_forward_european_heston_engine_hpp
61 const ext::shared_ptr<P>& process,
63 Size timeStepsPerYear,
64 bool antitheticVariate,
66 Real requiredTolerance,
69 bool controlVariate =
false);
71 ext::shared_ptr<path_pricer_type>
pathPricer()
const override;
77 ext::shared_ptr<P> process = ext::dynamic_pointer_cast<P>(this->
process_);
78 QL_REQUIRE(process,
"Heston-like process required");
80 ext::shared_ptr<HestonModel> hestonModel(
new HestonModel(process));
81 return ext::shared_ptr<PricingEngine>(
new
102 operator ext::shared_ptr<PricingEngine>()
const;
130 template <
class RNG,
class S,
class P>
132 const ext::shared_ptr<P>& process,
134 Size timeStepsPerYear,
135 bool antitheticVariate,
136 Size requiredSamples,
137 Real requiredTolerance,
153 template <
class RNG,
class S,
class P>
154 inline ext::shared_ptr<typename MCForwardEuropeanHestonEngine<RNG,S,P>::path_pricer_type>
157 TimeGrid timeGrid = this->timeGrid();
159 Time resetTime = this->process_->time(this->arguments_.resetDate);
162 ext::shared_ptr<PlainVanillaPayoff>
payoff =
163 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
164 this->arguments_.payoff);
167 ext::shared_ptr<EuropeanExercise> exercise =
168 ext::dynamic_pointer_cast<EuropeanExercise>(
169 this->arguments_.exercise);
172 ext::shared_ptr<P> process =
173 ext::dynamic_pointer_cast<P>(this->process_);
174 QL_REQUIRE(process,
"Heston like process required");
176 return ext::shared_ptr<
typename
180 this->arguments_.moneyness,
182 process->riskFreeRate()->discount(
186 template <
class RNG,
class S,
class P>
187 inline ext::shared_ptr<typename MCForwardEuropeanHestonEngine<RNG,S,P>::path_pricer_type>
193 TimeGrid timeGrid = this->timeGrid();
195 ext::shared_ptr<PlainVanillaPayoff>
payoff =
196 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
197 this->arguments_.payoff);
200 ext::shared_ptr<EuropeanExercise> exercise =
201 ext::dynamic_pointer_cast<EuropeanExercise>(
202 this->arguments_.exercise);
205 ext::shared_ptr<P> process =
206 ext::dynamic_pointer_cast<P>(this->process_);
207 QL_REQUIRE(process,
"Heston like process required");
209 return ext::shared_ptr<
typename
213 this->arguments_.moneyness,
215 process->riskFreeRate()->discount(
219 template <
class RNG,
class S,
class P>
221 ext::shared_ptr<P> process)
225 template <
class RNG,
class S,
class P>
232 template <
class RNG,
class S,
class P>
235 stepsPerYear_ = steps;
239 template <
class RNG,
class S,
class P>
243 "tolerance already set");
248 template <
class RNG,
class S,
class P>
253 "number of samples already set");
255 "chosen random generator policy "
256 "does not allow an error estimate");
257 tolerance_ = tolerance;
261 template <
class RNG,
class S,
class P>
264 maxSamples_ = samples;
268 template <
class RNG,
class S,
class P>
275 template <
class RNG,
class S,
class P>
282 template <
class RNG,
class S,
class P>
289 template <
class RNG,
class S,
class P>
293 "number of steps not given");
295 "number of steps overspecified - set EITHER steps OR stepsPerYear");
296 return ext::shared_ptr<PricingEngine>(
new
analytic Heston-model engine
analytic Heston-model engine based on Fourier transform
Real operator()(const MultiPath &multiPath) const override
Heston model for the stochastic volatility of an asset.
MCForwardEuropeanHestonEngine(const ext::shared_ptr< P > &process, Size timeSteps, Size timeStepsPerYear, bool antitheticVariate, Size requiredSamples, Real requiredTolerance, Size maxSamples, BigNatural seed, bool controlVariate=false)
ext::shared_ptr< path_pricer_type > pathPricer() const override
MCForwardVanillaEngine< MultiVariate, RNG, S >::path_pricer_type path_pricer_type
MCForwardVanillaEngine< MultiVariate, RNG, S >::path_generator_type path_generator_type
ext::shared_ptr< PricingEngine > controlPricingEngine() const override
ext::shared_ptr< path_pricer_type > controlPathPricer() const override
MCForwardVanillaEngine< MultiVariate, RNG, S >::stats_type stats_type
Monte Carlo engine for forward-starting vanilla options.
ext::shared_ptr< StochasticProcess > process_
McSimulation< MC, RNG, S >::path_generator_type path_generator_type
McSimulation< MC, RNG, S >::path_pricer_type path_pricer_type
MakeMCForwardEuropeanHestonEngine & withSeed(BigNatural seed)
MakeMCForwardEuropeanHestonEngine & withAntitheticVariate(bool b=true)
MakeMCForwardEuropeanHestonEngine & withControlVariate(bool b=false)
MakeMCForwardEuropeanHestonEngine & withMaxSamples(Size samples)
MakeMCForwardEuropeanHestonEngine & withStepsPerYear(Size steps)
MakeMCForwardEuropeanHestonEngine & withSamples(Size samples)
ext::shared_ptr< P > process_
MakeMCForwardEuropeanHestonEngine & withSteps(Size steps)
MakeMCForwardEuropeanHestonEngine(ext::shared_ptr< P > process)
MakeMCForwardEuropeanHestonEngine & withAbsoluteTolerance(Real tolerance)
Correlated multiple asset paths.
template class providing a null value for a given type.
base class for path pricers
Size closestIndex(Time t) const
returns the index i such that grid[i] is closest to t
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
ext::function< Real(Real)> b
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
std::size_t Size
size of a container
Heston model for the stochastic volatility of an asset.
Heston stochastic process.
ext::shared_ptr< QuantLib::Payoff > payoff
Monte Carlo engine for forward-starting strike-reset vanilla options.
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