26#ifndef quantlib_mcdiscreteasian_engine_base_hpp
27#define quantlib_mcdiscreteasian_engine_base_hpp
42 :
Error(
"n/a", 0,
"n/a",
43 "all fixings are in the past") {}
53 template<
template <
class>
class MC,
69 bool antitheticVariate,
72 Real requiredTolerance,
98 if (RNG::allowsErrorEstimate)
100 this->
mcModel_->sampleAccumulator().errorEstimate();
113 typename RNG::rsg_type gen =
114 RNG::make_sequence_generator(dimensions*(grid.
size()-1),
seed_);
115 return ext::shared_ptr<path_generator_type>(
131 template <
template <
class>
class MC,
class RNG,
class S>
133 ext::shared_ptr<StochasticProcess> process,
135 bool antitheticVariate,
137 Size requiredSamples,
138 Real requiredTolerance,
142 Size timeStepsPerYear)
143 :
McSimulation<MC, RNG,
S>(antitheticVariate, controlVariate), process_(
std::move(process)),
144 requiredSamples_(requiredSamples), maxSamples_(maxSamples), timeSteps_(timeSteps),
145 timeStepsPerYear_(timeStepsPerYear), requiredTolerance_(requiredTolerance),
146 brownianBridge_(brownianBridge), seed_(seed) {
150 template <
template <
class>
class MC,
class RNG,
class S>
153 std::vector<Time> fixingTimes;
155 for (i=0; i<arguments_.fixingDates.size(); i++) {
156 Time t = process_->time(arguments_.fixingDates[i]);
158 fixingTimes.push_back(
t);
162 if (fixingTimes.empty() ||
163 (fixingTimes.size() == 1 && fixingTimes.front() == 0.0))
168 Date lastExerciseDate = this->arguments_.exercise->lastDate();
169 Time t = process_->time(lastExerciseDate);
172 return TimeGrid(fixingTimes.begin(), fixingTimes.end(), timeSteps_);
173 }
else if (this->timeStepsPerYear_ !=
Null<Size>()) {
174 return TimeGrid(fixingTimes.begin(), fixingTimes.end(),
175 static_cast<Size>(this->timeStepsPerYear_*
t));
178 return TimeGrid(fixingTimes.begin(), fixingTimes.end());
181 template<
template <
class>
class MC,
class RNG,
class S>
185 ext::shared_ptr<PricingEngine> controlPE =
186 this->controlPricingEngine();
188 "engine does not provide "
189 "control variation pricing engine");
191 auto* controlArguments =
193 *controlArguments = arguments_;
194 controlPE->calculate();
196 const auto* controlResults =
199 return controlResults->
value;
Asian option on a single asset.
Extra arguments for single-asset discrete-average Asian option.
Discrete-averaging Asian engine base class.
DiscreteAveragingAsianOption::results results_
std::map< std::string, ext::any > additionalResults
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
MCDiscreteAveragingAsianEngineBase(ext::shared_ptr< StochasticProcess > process, bool brownianBridge, bool antitheticVariate, bool controlVariate, Size requiredSamples, Real requiredTolerance, Size maxSamples, BigNatural seed, Size timeSteps=Null< Size >(), Size timeStepsPerYear=Null< Size >())
ext::shared_ptr< path_generator_type > pathGenerator() const override
void calculate() const override
McSimulation< MC, RNG, S >::path_pricer_type path_pricer_type
McSimulation< MC, RNG, S >::stats_type stats_type
Real controlVariateValue() const override
TimeGrid timeGrid() const override
base class for Monte Carlo engines
MonteCarloModel< MC, RNG, S >::path_generator_type path_generator_type
ext::shared_ptr< MonteCarloModel< MC, RNG, S > > mcModel_
void calculate(Real requiredTolerance, Size requiredSamples, Size maxSamples) const
basic calculate method provided to inherited pricing engines
MonteCarloModel< MC, RNG, S >::path_pricer_type path_pricer_type
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Option exercise classes and payoff function.
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
framework for Monte Carlo engines
RiskStatistics Statistics
default statistics tool
unsigned QL_BIG_INTEGER BigNatural
large positive integer
GenericPseudoRandom< MersenneTwisterUniformRng, InverseCumulativeNormal > PseudoRandom
default traits for pseudo-random number generation