26#ifndef quantlib_montecarlo_european_engine_hpp
27#define quantlib_montecarlo_european_engine_hpp
42 template <
class RNG = PseudoRandom,
class S = Statistics>
55 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
57 Size timeStepsPerYear,
59 bool antitheticVariate,
61 Real requiredTolerance,
65 ext::shared_ptr<path_pricer_type>
pathPricer()
const override;
69 template <
class RNG = PseudoRandom,
class S = Statistics>
83 operator ext::shared_ptr<PricingEngine>()
const;
85 ext::shared_ptr<GeneralizedBlackScholesProcess>
process_;
108 template <
class RNG,
class S>
111 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
113 Size timeStepsPerYear,
115 bool antitheticVariate,
116 Size requiredSamples,
117 Real requiredTolerance,
132 template <
class RNG,
class S>
134 ext::shared_ptr<typename MCEuropeanEngine<RNG,S>::path_pricer_type>
137 ext::shared_ptr<PlainVanillaPayoff>
payoff =
138 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
139 this->arguments_.payoff);
142 ext::shared_ptr<GeneralizedBlackScholesProcess> process =
143 ext::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
145 QL_REQUIRE(process,
"Black-Scholes process required");
147 return ext::shared_ptr<
152 process->riskFreeRate()->discount(this->timeGrid().back())));
156 template <
class RNG,
class S>
158 ext::shared_ptr<GeneralizedBlackScholesProcess> process)
162 template <
class RNG,
class S>
169 template <
class RNG,
class S>
172 stepsPerYear_ = steps;
176 template <
class RNG,
class S>
180 "tolerance already set");
185 template <
class RNG,
class S>
189 "number of samples already set");
191 "chosen random generator policy "
192 "does not allow an error estimate");
193 tolerance_ = tolerance;
197 template <
class RNG,
class S>
200 maxSamples_ = samples;
204 template <
class RNG,
class S>
211 template <
class RNG,
class S>
214 brownianBridge_ = brownianBridge;
218 template <
class RNG,
class S>
225 template <
class RNG,
class S>
230 "number of steps not given");
232 "number of steps overspecified");
233 return ext::shared_ptr<PricingEngine>(
new
239 samples_, tolerance_,
249 :
payoff_(type, strike), discount_(discount) {
251 "strike less than zero not allowed");
Black constant volatility, no time dependence, no strike dependence.
Black volatility curve modelled as variance curve.
PlainVanillaPayoff payoff_
EuropeanPathPricer(Option::Type type, Real strike, DiscountFactor discount)
Real operator()(const Path &path) const override
European option pricing engine using Monte Carlo simulation.
MCEuropeanEngine(const ext::shared_ptr< GeneralizedBlackScholesProcess > &process, Size timeSteps, Size timeStepsPerYear, bool brownianBridge, bool antitheticVariate, Size requiredSamples, Real requiredTolerance, Size maxSamples, BigNatural seed)
ext::shared_ptr< path_pricer_type > pathPricer() const override
MCVanillaEngine< SingleVariate, RNG, S >::stats_type stats_type
MCVanillaEngine< SingleVariate, RNG, S >::path_generator_type path_generator_type
MCVanillaEngine< SingleVariate, RNG, S >::path_pricer_type path_pricer_type
Pricing engine for vanilla options using Monte Carlo simulation.
McSimulation< MC, RNG, S >::path_generator_type path_generator_type
McSimulation< MC, RNG, S >::path_pricer_type path_pricer_type
Monte Carlo European engine factory.
MakeMCEuropeanEngine & withSeed(BigNatural seed)
MakeMCEuropeanEngine & withMaxSamples(Size samples)
MakeMCEuropeanEngine(ext::shared_ptr< GeneralizedBlackScholesProcess >)
MakeMCEuropeanEngine & withSteps(Size steps)
MakeMCEuropeanEngine & withAbsoluteTolerance(Real tolerance)
MakeMCEuropeanEngine & withAntitheticVariate(bool b=true)
MakeMCEuropeanEngine & withStepsPerYear(Size steps)
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
MakeMCEuropeanEngine & withSamples(Size samples)
MakeMCEuropeanEngine & withBrownianBridge(bool b=true)
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
ext::shared_ptr< QuantLib::Payoff > payoff
Monte Carlo vanilla option engine.
unsigned QL_BIG_INTEGER BigNatural
large positive integer
default Monte Carlo traits for single-variate models