24#include <ql/exercise.hpp>
25#include <ql/pricingengines/barrier/analyticbarrierengine.hpp>
31 ext::shared_ptr<GeneralizedBlackScholesProcess> process)
32 : process_(
std::move(process)) {
38 ext::shared_ptr<PlainVanillaPayoff> payoff =
39 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
arguments_.payoff);
40 QL_REQUIRE(payoff,
"non-plain payoff given");
41 QL_REQUIRE(payoff->strike()>0.0,
42 "strike must be positive");
45 "only european style option are supported");
49 QL_REQUIRE(spot > 0.0,
"negative or null underlying given");
50 QL_REQUIRE(!
triggered(spot),
"barrier touched");
54 switch (payoff->optionType()) {
56 switch (barrierType) {
84 switch (barrierType) {
112 QL_FAIL(
"unknown type");
122 ext::shared_ptr<PlainVanillaPayoff> payoff =
123 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
arguments_.payoff);
124 QL_REQUIRE(payoff,
"non-plain payoff given");
125 return payoff->strike();
129 return process_->blackVolatility()->blackVol(
135 return std::sqrt(
process_->blackVolatility()->blackVariance(
149 return process_->riskFreeRate()->zeroRate(
151 process_->riskFreeRate()->dayCounter(),
156 return process_->riskFreeRate()->discount(
161 return process_->dividendYield()->zeroRate(
163 process_->dividendYield()->dayCounter(),
168 return process_->dividendYield()->discount(
202 Real powHS0 = std::pow(HS, 2 *
mu());
203 Real powHS1 = powHS0 * HS * HS;
215 Real powHS0 = std::pow(HS, 2 *
mu());
216 Real powHS1 = powHS0 * HS * HS;
249 Real powHSplus = std::pow(HS, m + lambda);
250 Real powHSminus = std::pow(HS, m - lambda);
254 + lambda * sigmaSqrtT;
257 Real N2 =
f_(eta * (z - 2.0 * lambda * sigmaSqrtT));
260 return rebate() * ((N1 == 0.0 ?
Real(0.0) :
Real(powHSplus * N1)) + (N2 == 0.0 ?
Real(0.0) :
Real(powHSminus * N2)));
Real C(Real eta, Real phi) const
CumulativeNormalDistribution f_
Volatility volatility() const
DiscountFactor dividendDiscount() const
void calculate() const override
Real D(Real eta, Real phi) const
Real stdDeviation() const
Rate riskFreeRate() const
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Rate dividendYield() const
AnalyticBarrierEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process)
DiscountFactor riskFreeDiscount() const
Barrier::Type barrierType
bool triggered(Real underlying) const
BarrierOption::results results_
BarrierOption::arguments arguments_
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
@ NoFrequency
null frequency
Real DiscountFactor
discount factor between dates
Real Volatility
volatility