33 ext::shared_ptr<GeneralizedBlackScholesProcess> process)
34 : process_(
std::move(process)) {
57 ext::shared_ptr<PlainVanillaPayoff>
payoff =
58 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
arguments_.payoff);
68 constexpr double minusInf = -std::numeric_limits<double>::infinity();
70 Real y1 = this->
y1(payoff->optionType()),
71 y2 = this->
y2(payoff->optionType());
74 ext::shared_ptr<PlainVanillaPayoff> vanillaCallPayoff =
79 - X2*exp(-
r*T2)*
M2(
y1 - vol*sqrt(t1),
y2 - vol*sqrt(t1), minusInf,
z1 - vol*sqrt(T2),
rho)
80 -
S*exp((
b -
r)*t1)*
N2(
y1,
z2) + X1*exp(-
r*t1)*
N2(
y1 - vol*sqrt(t1),
z2 - vol*sqrt(t1))
81 - A*exp(-
r*t1)*
N2(
y1 - vol*sqrt(t1),
y2 - vol*sqrt(t1));
84 ext::shared_ptr<PlainVanillaPayoff> vanillaPutPayoff =
85 ext::make_shared<PlainVanillaPayoff>(
Option::Put, X1);
88 + X2*exp(-
r*T2)*
M2(
y1 - vol*sqrt(t1),
y2 - vol*sqrt(t1), minusInf, -
z1 + vol*sqrt(T2),
rho)
89 +
S*exp((
b -
r)*t1)*
N2(
z2,
y2) - X1*exp(-
r*t1)*
N2(
z2 - vol*sqrt(t1),
y2 - vol*sqrt(t1))
90 - A*exp(-
r*t1)*
N2(
y1 - vol*sqrt(t1),
y2 - vol*sqrt(t1));
112 Real epsilon = 0.001;
115 while (std::fabs(yi) > epsilon){
138 Real val=X1-X2*std::exp(-
r*(T2-t1));
140 return std::numeric_limits<Real>::infinity();
146 Real yi = ci - A - Sv + X1;
149 Real epsilon = 0.001;
152 while (std::fabs(yi) > epsilon){
159 yi = ci - A - Sv + X1;
177 Real yi = pi - A + Sv - X1;
180 Real epsilon = 0.001;
183 while (std::fabs(yi) > epsilon){
190 yi = pi - A + Sv - X1;
200 return std::numeric_limits<Real>::infinity();
210 Real epsilon = 0.001;
213 while (std::fabs(yi) > epsilon){
240 ext::shared_ptr<PlainVanillaPayoff > vanillaPayoff =
241 ext::make_shared<PlainVanillaPayoff>(optionType, X2);
256 return CmlNormDist(
b,
d) - CmlNormDist(a,
d) - CmlNormDist(
b, c) + CmlNormDist(a,c);
261 return NormDist(
b) - NormDist(a);
265 ext::shared_ptr<PlainVanillaPayoff>
payoff =
266 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
arguments_.payoff);
292 return process_->dividendYield()->discount(
t);
296 return process_->riskFreeRate()->discount(
t);
307 return (log(
S / I2) + (
b + pow(vol, 2) / 2)*t1) / (vol*sqrt(t1));
318 return (log(
S / I1) + (
b + pow(vol, 2) / 2)*t1) / (vol*sqrt(t1));
328 return (log(
S / X2) + (
b + pow(vol, 2) / 2)*T2) / (vol*sqrt(T2));
339 return (log(
S / X1) + (
b + pow(vol, 2) / 2)*t1) / (vol*sqrt(t1));
Analytic engine for holder-extensible options.
bivariate cumulative normal distribution
DiscountFactor riskFreeDiscount(Time t) const
Real y2(Option::Type) const
Real y1(Option::Type) const
Volatility volatility() const
AnalyticHolderExtensibleOptionEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process)
Time secondExpiryTime() const
void calculate() const override
Time firstExpiryTime() const
BlackScholesCalculator bsCalculator(Real spot, Option::Type optionType) const
Rate riskFreeRate() const
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Real N2(Real a, Real b) const
Rate dividendYield() const
DiscountFactor dividendDiscount(Time t) const
Real M2(Real a, Real b, Real c, Real d, Real rho) const
Cumulative bivariate normal distribution function.
Black-Scholes 1973 calculator class.
Cumulative normal distribution function.
HolderExtensibleOption::results results_
HolderExtensibleOption::arguments arguments_
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.
ext::function< Real(Real)> b
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
Real Volatility
volatility
ext::shared_ptr< QuantLib::Payoff > payoff
ext::shared_ptr< YieldTermStructure > r