25#ifndef quantlib_mc_discrete_arithmetic_average_price_asian_engine_hpp
26#define quantlib_mc_discrete_arithmetic_average_price_asian_engine_hpp
28#include <ql/exercise.hpp>
29#include <ql/pricingengines/asian/analytic_discr_geom_av_price.hpp>
30#include <ql/pricingengines/asian/mc_discr_geom_av_price.hpp>
31#include <ql/processes/blackscholesprocess.hpp>
48 template <
class RNG = PseudoRandom,
class S = Statistics>
62 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
64 bool antitheticVariate,
67 Real requiredTolerance,
71 ext::shared_ptr<path_pricer_type>
pathPricer()
const override;
74 ext::shared_ptr<GeneralizedBlackScholesProcess> process =
75 ext::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
77 QL_REQUIRE(process,
"Black-Scholes process required");
78 return ext::shared_ptr<PricingEngine>(
new
89 Real runningSum = 0.0,
90 Size pastFixings = 0);
103 template <
class RNG,
class S>
106 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
108 bool antitheticVariate,
110 Size requiredSamples,
111 Real requiredTolerance,
123 template <
class RNG,
class S>
129 ext::shared_ptr<PlainVanillaPayoff> payoff =
130 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
131 this->arguments_.payoff);
132 QL_REQUIRE(payoff,
"non-plain payoff given");
134 ext::shared_ptr<EuropeanExercise> exercise =
135 ext::dynamic_pointer_cast<EuropeanExercise>(
136 this->arguments_.exercise);
137 QL_REQUIRE(exercise,
"wrong exercise given");
139 ext::shared_ptr<GeneralizedBlackScholesProcess> process =
140 ext::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
142 QL_REQUIRE(process,
"Black-Scholes process required");
144 return ext::shared_ptr<
typename
147 payoff->optionType(),
149 process->riskFreeRate()->discount(exercise->lastDate()),
150 this->arguments_.runningAccumulator,
151 this->arguments_.pastFixings));
154 template <
class RNG,
class S>
160 ext::shared_ptr<PlainVanillaPayoff> payoff =
161 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
162 this->arguments_.payoff);
163 QL_REQUIRE(payoff,
"non-plain payoff given");
165 ext::shared_ptr<EuropeanExercise> exercise =
166 ext::dynamic_pointer_cast<EuropeanExercise>(
167 this->arguments_.exercise);
168 QL_REQUIRE(exercise,
"wrong exercise given");
170 ext::shared_ptr<GeneralizedBlackScholesProcess> process =
171 ext::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
173 QL_REQUIRE(process,
"Black-Scholes process required");
178 return ext::shared_ptr<
typename
181 payoff->optionType(),
183 process->riskFreeRate()->discount(this->timeGrid().back())));
186 template <
class RNG = PseudoRandom,
class S = Statistics>
190 ext::shared_ptr<GeneralizedBlackScholesProcess> process);
200 operator ext::shared_ptr<PricingEngine>()
const;
202 ext::shared_ptr<GeneralizedBlackScholesProcess>
process_;
210 template <
class RNG,
class S>
212 ext::shared_ptr<GeneralizedBlackScholesProcess> process)
216 template <
class RNG,
class S>
220 "tolerance already set");
225 template <
class RNG,
class S>
230 "number of samples already set");
231 QL_REQUIRE(RNG::allowsErrorEstimate,
232 "chosen random generator policy "
233 "does not allow an error estimate");
234 tolerance_ = tolerance;
238 template <
class RNG,
class S>
241 maxSamples_ = samples;
245 template <
class RNG,
class S>
252 template <
class RNG,
class S>
259 template <
class RNG,
class S>
266 template <
class RNG,
class S>
273 template <
class RNG,
class S>
277 return ext::shared_ptr<PricingEngine>(
new
280 antithetic_, controlVariate_,
281 samples_, tolerance_,
Pricing engine for European discrete geometric average price Asian.
PlainVanillaPayoff payoff_
Real operator()(const Path &path) const override
Monte Carlo pricing engine for discrete arithmetic average price Asian.
MCDiscreteAveragingAsianEngineBase< SingleVariate, RNG, S >::path_pricer_type path_pricer_type
MCDiscreteAveragingAsianEngineBase< SingleVariate, RNG, S >::path_generator_type path_generator_type
MCDiscreteArithmeticAPEngine(const ext::shared_ptr< GeneralizedBlackScholesProcess > &process, bool brownianBridge, bool antitheticVariate, bool controlVariate, Size requiredSamples, Real requiredTolerance, Size maxSamples, BigNatural seed)
ext::shared_ptr< path_pricer_type > pathPricer() const override
ext::shared_ptr< PricingEngine > controlPricingEngine() const override
ext::shared_ptr< path_pricer_type > controlPathPricer() const override
MCDiscreteAveragingAsianEngineBase< SingleVariate, RNG, S >::stats_type stats_type
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
MakeMCDiscreteArithmeticAPEngine & withControlVariate(bool b=true)
MakeMCDiscreteArithmeticAPEngine & withSamples(Size samples)
MakeMCDiscreteArithmeticAPEngine & withSeed(BigNatural seed)
MakeMCDiscreteArithmeticAPEngine & withAntitheticVariate(bool b=true)
MakeMCDiscreteArithmeticAPEngine & withAbsoluteTolerance(Real tolerance)
MakeMCDiscreteArithmeticAPEngine & withMaxSamples(Size samples)
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
MakeMCDiscreteArithmeticAPEngine & withBrownianBridge(bool b=true)
MakeMCDiscreteArithmeticAPEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process)
template class providing a null value for a given type.
single-factor random walk
base class for path pricers
Real DiscountFactor
discount factor between dates
std::size_t Size
size of a container
unsigned QL_BIG_INTEGER BigNatural
large positive integer
default Monte Carlo traits for single-variate models