27#ifndef quantlib_digital_mc_engine_hpp
28#define quantlib_digital_mc_engine_hpp
60 template<
class RNG = PseudoRandom,
class S = Statistics>
73 const ext::shared_ptr<GeneralizedBlackScholesProcess>&,
75 Size timeStepsPerYear,
77 bool antitheticVariate,
79 Real requiredTolerance,
84 ext::shared_ptr<path_pricer_type>
pathPricer()
const override;
88 template <
class RNG = PseudoRandom,
class S = Statistics>
102 operator ext::shared_ptr<PricingEngine>()
const;
104 ext::shared_ptr<GeneralizedBlackScholesProcess>
process_;
115 ext::shared_ptr<AmericanExercise> exercise,
117 ext::shared_ptr<StochasticProcess1D> diffProcess,
133 template<
class RNG,
class S>
135 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
137 Size timeStepsPerYear,
139 bool antitheticVariate,
140 Size requiredSamples,
141 Real requiredTolerance,
155 template <
class RNG,
class S>
157 ext::shared_ptr<typename MCDigitalEngine<RNG,S>::path_pricer_type>
160 ext::shared_ptr<CashOrNothingPayoff>
payoff =
161 ext::dynamic_pointer_cast<CashOrNothingPayoff>(
162 this->arguments_.payoff);
165 ext::shared_ptr<AmericanExercise> exercise =
166 ext::dynamic_pointer_cast<AmericanExercise>(
167 this->arguments_.exercise);
170 ext::shared_ptr<GeneralizedBlackScholesProcess> process =
171 ext::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
173 QL_REQUIRE(process,
"Black-Scholes process required");
179 return ext::shared_ptr<
183 process->riskFreeRate(),
189 template <
class RNG,
class S>
191 ext::shared_ptr<GeneralizedBlackScholesProcess> process)
195 template <
class RNG,
class S>
202 template <
class RNG,
class S>
205 stepsPerYear_ = steps;
209 template <
class RNG,
class S>
213 "tolerance already set");
218 template <
class RNG,
class S>
222 "number of samples already set");
224 "chosen random generator policy "
225 "does not allow an error estimate");
226 tolerance_ = tolerance;
230 template <
class RNG,
class S>
233 maxSamples_ = samples;
237 template <
class RNG,
class S>
244 template <
class RNG,
class S>
247 brownianBridge_ = brownianBridge;
251 template <
class RNG,
class S>
258 template <
class RNG,
class S>
263 "number of steps not given");
265 "number of steps overspecified");
266 return ext::shared_ptr<PricingEngine>(
new
272 samples_, tolerance_,
Black volatility term structure base classes.
ext::shared_ptr< AmericanExercise > exercise_
ext::shared_ptr< CashOrNothingPayoff > payoff_
PseudoRandom::ursg_type sequenceGen_
Handle< YieldTermStructure > discountTS_
Real operator()(const Path &path) const override
ext::shared_ptr< StochasticProcess1D > diffProcess_
Shared handle to an observable.
Pricing engine for digital options using Monte Carlo simulation.
ext::shared_ptr< path_pricer_type > pathPricer() const override
MCDigitalEngine(const ext::shared_ptr< GeneralizedBlackScholesProcess > &, Size timeSteps, Size timeStepsPerYear, bool brownianBridge, bool antitheticVariate, Size requiredSamples, Real requiredTolerance, Size maxSamples, BigNatural seed)
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 digital engine factory.
MakeMCDigitalEngine & withAntitheticVariate(bool b=true)
MakeMCDigitalEngine & withSteps(Size steps)
MakeMCDigitalEngine(ext::shared_ptr< GeneralizedBlackScholesProcess >)
MakeMCDigitalEngine & withStepsPerYear(Size steps)
MakeMCDigitalEngine & withBrownianBridge(bool b=true)
MakeMCDigitalEngine & withMaxSamples(Size samples)
MakeMCDigitalEngine & withSamples(Size samples)
MakeMCDigitalEngine & withSeed(BigNatural seed)
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
MakeMCDigitalEngine & withAbsoluteTolerance(Real tolerance)
template class providing a null value for a given type.
single-factor random walk
base class for path pricers
Random sequence generator based on a pseudo-random number generator.
#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
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
Interest-rate term structure.