24#ifndef quantlib_mc_discrete_geometric_average_price_asian_heston_engine_hpp
25#define quantlib_mc_discrete_geometric_average_price_asian_heston_engine_hpp
56 bool antitheticVariate,
58 Real requiredTolerance,
64 ext::shared_ptr<path_pricer_type>
pathPricer()
const override;
82 operator ext::shared_ptr<PricingEngine>()
const;
96 std::vector<Size> fixingIndices,
97 Real runningProduct = 1.0,
98 Size pastFixings = 0);
112 template <
class RNG,
class S,
class P>
115 const ext::shared_ptr<P>& process,
116 bool antitheticVariate,
117 Size requiredSamples,
118 Real requiredTolerance,
122 Size timeStepsPerYear)
134 "both time steps and time steps per year were provided");
137 template <
class RNG,
class S,
class P>
138 inline ext::shared_ptr<
143 TimeGrid timeGrid = this->timeGrid();
145 std::vector<Size> fixingIndexes;
146 fixingIndexes.reserve(fixingTimes.size());
147 for (
Real fixingTime : fixingTimes) {
148 fixingIndexes.push_back(timeGrid.
closestIndex(fixingTime));
151 ext::shared_ptr<PlainVanillaPayoff>
payoff =
152 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
153 this->arguments_.payoff);
156 ext::shared_ptr<EuropeanExercise> exercise =
157 ext::dynamic_pointer_cast<EuropeanExercise>(
158 this->arguments_.exercise);
161 ext::shared_ptr<P> process =
162 ext::dynamic_pointer_cast<P>(this->process_);
163 QL_REQUIRE(process,
"Heston like process required");
165 return ext::shared_ptr<
typename
170 process->riskFreeRate()->discount(exercise->lastDate()),
172 this->arguments_.runningAccumulator,
173 this->arguments_.pastFixings));
176 template <
class RNG,
class S,
class P>
178 ext::shared_ptr<P> process)
182 template<
class RNG,
class S,
class P>
186 "tolerance already set");
191 template <
class RNG,
class S,
class P>
196 "number of samples already set");
198 "chosen random generator policy "
199 "does not allow an error estimate");
200 tolerance_ = tolerance;
204 template <
class RNG,
class S,
class P>
207 maxSamples_ = samples;
211 template <
class RNG,
class S,
class P>
218 template <
class RNG,
class S,
class P>
225 template<
class RNG,
class S,
class P>
229 "number of steps per year already set");
234 template<
class RNG,
class S,
class P>
238 "number of steps already set");
239 stepsPerYear_ = steps;
243 template <
class RNG,
class S,
class P>
245 return ext::shared_ptr<PricingEngine>(
new
PlainVanillaPayoff payoff_
std::vector< Size > fixingIndices_
Real operator()(const MultiPath &multiPath) const override
Square-root stochastic-volatility Heston process.
Pricing engine for discrete average Asians using Monte Carlo simulation.
McSimulation< MC, RNG, S >::path_generator_type path_generator_type
McSimulation< MC, RNG, S >::path_pricer_type path_pricer_type
Heston MC pricing engine for discrete geometric average price Asian.
MCDiscreteAveragingAsianEngineBase< MultiVariate, RNG, S >::path_generator_type path_generator_type
ext::shared_ptr< path_pricer_type > pathPricer() const override
MCDiscreteAveragingAsianEngineBase< MultiVariate, RNG, S >::path_pricer_type path_pricer_type
MCDiscreteAveragingAsianEngineBase< MultiVariate, RNG, S >::stats_type stats_type
MCDiscreteGeometricAPHestonEngine(const ext::shared_ptr< P > &process, bool antitheticVariate, Size requiredSamples, Real requiredTolerance, Size maxSamples, BigNatural seed, Size timeSteps=Null< Size >(), Size timeStepsPerYear=Null< Size >())
MakeMCDiscreteGeometricAPHestonEngine & withSteps(Size steps)
MakeMCDiscreteGeometricAPHestonEngine & withAbsoluteTolerance(Real tolerance)
MakeMCDiscreteGeometricAPHestonEngine & withAntitheticVariate(bool b=true)
MakeMCDiscreteGeometricAPHestonEngine & withSeed(BigNatural seed)
MakeMCDiscreteGeometricAPHestonEngine(ext::shared_ptr< P > process)
MakeMCDiscreteGeometricAPHestonEngine & withStepsPerYear(Size steps)
MakeMCDiscreteGeometricAPHestonEngine & withMaxSamples(Size samples)
MakeMCDiscreteGeometricAPHestonEngine & withSamples(Size samples)
ext::shared_ptr< P > process_
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
const std::vector< Time > & mandatoryTimes() const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Option exercise classes and payoff function.
ext::function< Real(Real)> b
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 pricing engine for discrete average Asians.
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