20#include <ql/exercise.hpp>
21#include <ql/pricingengines/barrier/analyticdoublebarrierengine.hpp>
22#include <ql/pricingengines/blackcalculator.hpp>
28 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
int series)
29 : process_(
std::move(process)), series_(series) {
36 "this engine handles only european options");
38 ext::shared_ptr<PlainVanillaPayoff> payoff =
39 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
arguments_.payoff);
40 QL_REQUIRE(payoff,
"non-plain payoff given");
44 "strike must be positive");
47 QL_REQUIRE(spot > 0.0,
"negative or null underlying given");
48 QL_REQUIRE(!
triggered(spot),
"barrier(s) already touched");
58 switch (payoff->optionType()) {
60 switch (barrierType) {
69 QL_FAIL(
"unsupported double-barrier type: "
72 QL_FAIL(
"unknown double-barrier type: "
77 switch (barrierType) {
86 QL_FAIL(
"unsupported double-barrier type: "
89 QL_FAIL(
"unknown double-barrier type: "
94 QL_FAIL(
"unknown type");
105 ext::shared_ptr<PlainVanillaPayoff> payoff =
106 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
arguments_.payoff);
107 QL_REQUIRE(payoff,
"non-plain payoff given");
108 return payoff->strike();
159 ext::shared_ptr<StrikedTypePayoff> payoff =
160 ext::dynamic_pointer_cast<StrikedTypePayoff>(
arguments_.payoff);
197 return std::max(0.0, kov);
233 return std::max(0.0, kov);
CumulativeNormalDistribution f_
Time residualTime() const
Volatility volatility() const
Real vanillaEquivalent() const
DiscountFactor dividendDiscount() const
void calculate() const override
Real stdDeviation() const
Real volatilitySquared() const
Rate riskFreeRate() const
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Rate dividendYield() const
AnalyticDoubleBarrierEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process, int series=5)
DiscountFactor riskFreeDiscount() const
Black 1976 calculator class.
DoubleBarrier::Type barrierType
bool triggered(Real underlying) const
DoubleBarrierOption::results results_
DoubleBarrierOption::arguments arguments_
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
Real Volatility
volatility
@ KOKI
lower barrier KI, upper KO