28 ext::shared_ptr<AmericanExercise> exercise,
30 ext::shared_ptr<StochasticProcess1D> diffProcess,
33 diffProcess_(
std::move(diffProcess)), sequenceGen_(
std::move(sequenceGen)),
34 discountTS_(
std::move(discountTS)) {}
40 Real log_asset_price = std::log(path.
front());
49 switch (
payoff_->optionType()) {
51 for (i=0; i<
n-1; i++) {
52 x = std::log(path[i+1]/path[i]);
55 std::exp(log_asset_price));
60 0.5*(x + std::sqrt(x*x-2*vol*vol*dt*std::log((1-u[i]))));
62 if (
y >= log_strike) {
78 for (i=0; i<
n-1; i++) {
79 x = std::log(path[i+1]/path[i]);
83 std::exp(log_asset_price));
88 0.5*(x - std::sqrt(x*x - 2*vol*vol*dt*std::log(u[i])));
89 if (
y <= log_strike) {
101 log_asset_price += x;
105 QL_FAIL(
"unknown option type");
ext::shared_ptr< AmericanExercise > exercise_
ext::shared_ptr< CashOrNothingPayoff > payoff_
PseudoRandom::ursg_type sequenceGen_
Handle< YieldTermStructure > discountTS_
DigitalPathPricer(ext::shared_ptr< CashOrNothingPayoff > payoff, ext::shared_ptr< AmericanExercise > exercise, Handle< YieldTermStructure > discountTS, ext::shared_ptr< StochasticProcess1D > diffProcess, PseudoRandom::ursg_type sequenceGen)
Real operator()(const Path &path) const override
ext::shared_ptr< StochasticProcess1D > diffProcess_
Shared handle to an observable.
single-factor random walk
const TimeGrid & timeGrid() const
time grid
Real front() const
initial asset value
Random sequence generator based on a pseudo-random number generator.
const sample_type & nextSequence() const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
const ext::shared_ptr< Payoff > payoff_
Real Time
continuous quantity with 1-year units
Real Volatility
volatility
std::size_t Size
size of a container
ext::shared_ptr< QuantLib::Payoff > payoff
digital option Monte Carlo engine
const ParametricExercise & exercise_