20#include <ql/pricingengines/americanpayoffathit.hpp>
21#include <ql/math/distributions/normaldistribution.hpp>
27 Real variance,
const ext::shared_ptr<StrikedTypePayoff>& payoff)
28 : spot_(spot), discount_(discount), dividendDiscount_(dividendDiscount),
32 "positive spot value required");
35 "positive discount required");
38 "positive dividend discount required");
41 "negative variance not allowed");
57 QL_FAIL(
"null discount not handled yet");
67 n_d1 = f.derivative(
D1_);
68 n_d2 = f.derivative(
D2_);
117 QL_FAIL(
"invalid option type");
138 ext::shared_ptr<CashOrNothingPayoff> coo =
139 ext::dynamic_pointer_cast<CashOrNothingPayoff>(payoff);
140 if (coo !=
nullptr) {
141 K_ = coo->cashPayoff();
146 ext::shared_ptr<AssetOrNothingPayoff> aoo =
147 ext::dynamic_pointer_cast<AssetOrNothingPayoff>(payoff);
148 if (aoo !=
nullptr) {
165 Real DforwardDs, DXDs;
188 Real DforwardDs, DXDs, D2forwardDs2, D2XDs2;
202 D2alphaDs2 *
forward_ + DalphaDs * DforwardDs
203 + DalphaDs * DforwardDs +
alpha_ * D2forwardDs2
204 + D2betaDs2 *
X_ + DbetaDs * DXDs
205 + DbetaDs * DXDs +
beta_ * D2XDs2
212 QL_REQUIRE(maturity>=0.0,
213 "negative maturity not allowed");
218 Real DforwardDr, DXDr;
227 return maturity *
K_ * (
AmericanPayoffAtHit(Real spot, DiscountFactor discount, DiscountFactor dividendDiscount, Real variance, const ext::shared_ptr< StrikedTypePayoff > &payoff)
DiscountFactor dividendDiscount_
Real rho(Time maturity) const
Cumulative normal distribution function.
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates