22#ifndef quantlib_mc_discrete_arithmetic_average_price_asian_heston_engine_hpp
23#define quantlib_mc_discrete_arithmetic_average_price_asian_heston_engine_hpp
59 const ext::shared_ptr<P>& process,
60 bool antitheticVariate,
62 Real requiredTolerance,
67 bool controlVariate =
false);
69 ext::shared_ptr<path_pricer_type>
pathPricer()
const override;
74 ext::shared_ptr<P> process = ext::dynamic_pointer_cast<P>(this->
process_);
75 QL_REQUIRE(process,
"Heston-like process required");
77 return ext::shared_ptr<PricingEngine>(
new
98 operator ext::shared_ptr<PricingEngine>()
const;
113 std::vector<Size> fixingIndices,
114 Real runningSum = 0.0,
115 Size pastFixings = 0);
129 template <
class RNG,
class S,
class P>
132 const ext::shared_ptr<P>& process,
133 bool antitheticVariate,
134 Size requiredSamples,
135 Real requiredTolerance,
139 Size timeStepsPerYear,
152 "both time steps and time steps per year were provided");
155 template <
class RNG,
class S,
class P>
156 inline ext::shared_ptr<
161 TimeGrid timeGrid = this->timeGrid();
163 std::vector<Size> fixingIndexes;
164 fixingIndexes.reserve(fixingTimes.size());
165 for (
Real fixingTime : fixingTimes) {
166 fixingIndexes.push_back(timeGrid.
closestIndex(fixingTime));
169 ext::shared_ptr<PlainVanillaPayoff>
payoff =
170 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
171 this->arguments_.payoff);
174 ext::shared_ptr<EuropeanExercise> exercise =
175 ext::dynamic_pointer_cast<EuropeanExercise>(
176 this->arguments_.exercise);
179 ext::shared_ptr<P> process =
180 ext::dynamic_pointer_cast<P>(this->process_);
181 QL_REQUIRE(process,
"Heston like process required");
183 return ext::shared_ptr<
typename
188 process->riskFreeRate()->discount(exercise->lastDate()),
190 this->arguments_.runningAccumulator,
191 this->arguments_.pastFixings));
194 template <
class RNG,
class S,
class P>
195 inline ext::shared_ptr<
200 TimeGrid timeGrid = this->timeGrid();
202 std::vector<Size> fixingIndexes;
203 fixingIndexes.reserve(fixingTimes.size());
204 for (
Real fixingTime : fixingTimes) {
205 fixingIndexes.push_back(timeGrid.
closestIndex(fixingTime));
208 ext::shared_ptr<PlainVanillaPayoff>
payoff =
209 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
210 this->arguments_.payoff);
213 ext::shared_ptr<EuropeanExercise> exercise =
214 ext::dynamic_pointer_cast<EuropeanExercise>(
215 this->arguments_.exercise);
218 ext::shared_ptr<P> process =
219 ext::dynamic_pointer_cast<P>(this->process_);
220 QL_REQUIRE(process,
"Heston like process required");
227 return ext::shared_ptr<
typename
232 process->riskFreeRate()->discount(exercise->lastDate()),
236 template <
class RNG,
class S,
class P>
242 template<
class RNG,
class S,
class P>
246 "tolerance already set");
251 template <
class RNG,
class S,
class P>
256 "number of samples already set");
258 "chosen random generator policy "
259 "does not allow an error estimate");
260 tolerance_ = tolerance;
264 template <
class RNG,
class S,
class P>
267 maxSamples_ = samples;
271 template <
class RNG,
class S,
class P>
278 template <
class RNG,
class S,
class P>
285 template<
class RNG,
class S,
class P>
289 "number of steps per year already set");
294 template<
class RNG,
class S,
class P>
298 "number of steps already set");
299 stepsPerYear_ = steps;
303 template<
class RNG,
class S,
class P>
310 template <
class RNG,
class S,
class P>
312 return ext::shared_ptr<PricingEngine>(
new
Analytic engine for discrete geometric average price Asian in the Heston model.
Pricing engine for European discrete geometric average price Asian.
PlainVanillaPayoff payoff_
std::vector< Size > fixingIndices_
Real operator()(const MultiPath &multiPath) const override
Heston MC pricing engine for discrete arithmetic average price Asian.
MCDiscreteAveragingAsianEngineBase< MultiVariate, RNG, S >::path_generator_type path_generator_type
MCDiscreteAveragingAsianEngineBase< MultiVariate, RNG, S >::path_pricer_type path_pricer_type
ext::shared_ptr< PricingEngine > controlPricingEngine() const override
ext::shared_ptr< path_pricer_type > controlPathPricer() const override
MCDiscreteAveragingAsianEngineBase< MultiVariate, RNG, S >::stats_type stats_type
MCDiscreteArithmeticAPHestonEngine(const ext::shared_ptr< P > &process, bool antitheticVariate, Size requiredSamples, Real requiredTolerance, Size maxSamples, BigNatural seed, Size timeSteps=Null< Size >(), Size timeStepsPerYear=Null< Size >(), bool controlVariate=false)
ext::shared_ptr< path_pricer_type > pathPricer() const override
Pricing engine for discrete average Asians using Monte Carlo simulation.
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
MakeMCDiscreteArithmeticAPHestonEngine & withSamples(Size samples)
MakeMCDiscreteArithmeticAPHestonEngine & withStepsPerYear(Size steps)
MakeMCDiscreteArithmeticAPHestonEngine & withSeed(BigNatural seed)
MakeMCDiscreteArithmeticAPHestonEngine & withControlVariate(bool b=false)
MakeMCDiscreteArithmeticAPHestonEngine(ext::shared_ptr< P > process)
MakeMCDiscreteArithmeticAPHestonEngine & withAntitheticVariate(bool b=true)
MakeMCDiscreteArithmeticAPHestonEngine & withSteps(Size steps)
ext::shared_ptr< P > process_
MakeMCDiscreteArithmeticAPHestonEngine & withAbsoluteTolerance(Real tolerance)
MakeMCDiscreteArithmeticAPHestonEngine & withMaxSamples(Size samples)
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
Heston MC engine for discrete geometric average price Asian.
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