24#ifndef quantlib_mc_heston_hull_white_engine_hpp
25#define quantlib_mc_heston_hull_white_engine_hpp
36 template <
class RNG = PseudoRandom,
class S = Statistics>
47 const ext::shared_ptr<HybridHestonHullWhiteProcess>& process,
49 Size timeStepsPerYear,
50 bool antitheticVariate,
53 Real requiredTolerance,
61 ext::shared_ptr<HybridHestonHullWhiteProcess>
process_;
63 ext::shared_ptr<path_pricer_type>
pathPricer()
const override;
71 template <
class RNG = PseudoRandom,
class S = Statistics>
85 operator ext::shared_ptr<PricingEngine>()
const;
87 ext::shared_ptr<HybridHestonHullWhiteProcess>
process_;
98 ext::shared_ptr<Payoff>
payoff,
99 ext::shared_ptr<HybridHestonHullWhiteProcess> process);
106 ext::shared_ptr<HybridHestonHullWhiteProcess>
process_;
110 template<
class RNG,
class S>
112 const ext::shared_ptr<HybridHestonHullWhiteProcess> & process,
114 Size timeStepsPerYear,
115 bool antitheticVariate,
117 Size requiredSamples,
118 Real requiredTolerance,
121 :
base_type(process, timeSteps, timeStepsPerYear,
122 false, antitheticVariate,
123 controlVariate, requiredSamples,
124 requiredTolerance, maxSamples, seed),
127 template<
class RNG,
class S>
131 if (this->controlVariate_) {
138 template <
class RNG,
class S>
inline
139 ext::shared_ptr<typename MCHestonHullWhiteEngine<RNG,S>::path_pricer_type>
142 ext::shared_ptr<Exercise> exercise = this->arguments_.exercise;
145 "only european exercise is supported");
147 const Time exerciseTime = process_->time(exercise->lastDate());
149 return ext::shared_ptr<path_pricer_type>(
151 this->arguments_.payoff,
155 template <
class RNG,
class S>
inline
160 ext::shared_ptr<HestonProcess> hestonProcess =
161 process_->hestonProcess();
163 QL_REQUIRE(hestonProcess,
"first constituent of the joint stochastic "
164 "process need to be of type HestonProcess");
166 ext::shared_ptr<Exercise> exercise = this->arguments_.exercise;
169 "only european exercise is supported");
171 const Time exerciseTime = process_->time(exercise->lastDate());
173 return ext::shared_ptr<path_pricer_type>(
176 this->arguments_.payoff,
180 template <
class RNG,
class S>
inline
181 ext::shared_ptr<PricingEngine>
184 ext::shared_ptr<HestonProcess> hestonProcess =
185 process_->hestonProcess();
187 ext::shared_ptr<HullWhiteForwardProcess> hullWhiteProcess =
188 process_->hullWhiteProcess();
190 ext::shared_ptr<HestonModel> hestonModel(
192 ext::shared_ptr<HullWhite> hwModel(
193 new HullWhite(hestonProcess->riskFreeRate(),
194 hullWhiteProcess->a(),
195 hullWhiteProcess->sigma()));
197 return ext::shared_ptr<PricingEngine>(
201 template <
class RNG,
class S>
inline
206 Size dimensions = process_->factors();
208 typename RNG::rsg_type generator =
209 RNG::make_sequence_generator(dimensions*(grid.
size()-1),
212 ext::shared_ptr<HybridHestonHullWhiteProcess> cvProcess(
214 process_->hullWhiteProcess(),
216 process_->discretization()));
218 return ext::shared_ptr<path_generator_type>(
223 template <
class RNG,
class S>
225 ext::shared_ptr<HybridHestonHullWhiteProcess> process)
229 template <
class RNG,
class S>
236 template <
class RNG,
class S>
239 stepsPerYear_ = steps;
243 template <
class RNG,
class S>
250 template <
class RNG,
class S>
257 template <
class RNG,
class S>
261 "tolerance already set");
266 template <
class RNG,
class S>
270 "number of samples already set");
272 "chosen random generator policy "
273 "does not allow an error estimate");
274 tolerance_ = tolerance;
278 template <
class RNG,
class S>
281 maxSamples_ = samples;
285 template <
class RNG,
class S>
292 template <
class RNG,
class S>
295 ext::shared_ptr<PricingEngine>()
const {
297 "number of steps not given");
299 "number of steps overspecified");
300 return ext::shared_ptr<PricingEngine>(
new
analytic heston engine incl. stochastic interest rates
const Instrument::results * results_
Analytic Heston engine incl. stochastic interest rates.
ext::shared_ptr< Payoff > payoff_
Real operator()(const MultiPath &path) const override
ext::shared_ptr< HybridHestonHullWhiteProcess > process_
Heston model for the stochastic volatility of an asset.
Single-factor Hull-White (extended Vasicek) model class.
Hybrid Heston Hull-White stochastic process.
base_type::result_type result_type
MCVanillaEngine< MultiVariate, RNG, S > base_type
void calculate() const override
base_type::path_generator_type path_generator_type
MCHestonHullWhiteEngine(const ext::shared_ptr< HybridHestonHullWhiteProcess > &process, Size timeSteps, Size timeStepsPerYear, bool antitheticVariate, bool controlVariate, Size requiredSamples, Real requiredTolerance, Size maxSamples, BigNatural seed)
ext::shared_ptr< PricingEngine > controlPricingEngine() const override
base_type::path_pricer_type path_pricer_type
base_type::stats_type stats_type
ext::shared_ptr< path_pricer_type > controlPathPricer() const override
ext::shared_ptr< HybridHestonHullWhiteProcess > process_
ext::shared_ptr< path_pricer_type > pathPricer() const override
ext::shared_ptr< path_generator_type > controlPathGenerator() const override
Pricing engine for vanilla options using Monte Carlo simulation.
McSimulation< MC, RNG, S >::result_type result_type
McSimulation< MC, RNG, S >::path_generator_type path_generator_type
void calculate() const override
McSimulation< MC, RNG, S >::path_pricer_type path_pricer_type
Monte Carlo Heston/Hull-White engine factory.
MakeMCHestonHullWhiteEngine & withAbsoluteTolerance(Real tolerance)
MakeMCHestonHullWhiteEngine & withControlVariate(bool b=true)
MakeMCHestonHullWhiteEngine(ext::shared_ptr< HybridHestonHullWhiteProcess >)
MakeMCHestonHullWhiteEngine & withMaxSamples(Size samples)
MakeMCHestonHullWhiteEngine & withStepsPerYear(Size steps)
MakeMCHestonHullWhiteEngine & withSeed(BigNatural seed)
MakeMCHestonHullWhiteEngine & withSteps(Size steps)
MakeMCHestonHullWhiteEngine & withAntitheticVariate(bool b=true)
MakeMCHestonHullWhiteEngine & withSamples(Size samples)
ext::shared_ptr< HybridHestonHullWhiteProcess > process_
Correlated multiple asset paths.
template class providing a null value for a given type.
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
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
Heston stochastic process.
Hull-White stochastic processes.
hybrid equity (heston model) with stochastic interest rates (hull white model)
ext::shared_ptr< QuantLib::Payoff > payoff
Monte Carlo vanilla option engine.
unsigned QL_BIG_INTEGER BigNatural
large positive integer