22#include <ql/payoff.hpp>
23#include <ql/pricingengines/blackformula.hpp>
28 const QuantLib::ext::shared_ptr<CrossAssetModel>& model,
const Size equityIndex, BusinessDayConvention bdc,
29 const DayCounter& dc,
const bool purelyTimeBased)
30 :
BlackVolTermStructure(bdc, dc == DayCounter() ? model->irlgm1f(0)->termStructure()->dayCounter() : dc),
31 model_(model), eqIndex_(equityIndex), purelyTimeBased_(purelyTimeBased),
33 referenceDate_(purelyTimeBased ? Null<Date>() : model_->irlgm1f(0)->termStructure()->referenceDate()) {
38 QL_REQUIRE(eqSpot > 0,
"EQ Spot for index " <<
eqIndex_ <<
" must be positive");
39 state(0.0, std::log(eqSpot));
45 Real tmpStrike = strike;
47 Real eqSpot = std::exp(
eq_);
49 Real divDisc =
model_->eqbs(
eqIndex_)->equityDivYieldCurveToday()->discount(t);
51 Real atm = eqSpot * divDisc / rateDisc;
53 if (tmpStrike == Null<Real>()) {
57 Option::Type type = tmpStrike >= atm ? Option::Call : Option::Put;
59 QuantLib::ext::shared_ptr<StrikedTypePayoff> payoff = QuantLib::ext::make_shared<PlainVanillaPayoff>(type, tmpStrike);
63 Real impliedStdDev = 0.0;
65 impliedStdDev = blackFormulaImpliedStdDev(type, tmpStrike, atm, premium, rateDisc);
69 return impliedStdDev * impliedStdDev;
73 Real tmp = std::max(1.0E-6, t);
79 "time based term structure");
85 "time based term structure");
92 "time based term structure");
analytic cross-asset lgm eq option engine
QuantLib::ext::shared_ptr< PricingEngine > engine_
Analytic cross-asset lgm equity option engine.
const Date & referenceDate() const override
Real minStrike() const override
void move(const Date &d, const Real eqIr, const Real logEq)
const QuantLib::ext::shared_ptr< AnalyticXAssetLgmEquityOptionEngine > engine_
Date maxDate() const override
const QuantLib::ext::shared_ptr< CrossAssetModel > model_
Real blackVarianceImpl(Time t, Real strike) const override
void referenceTime(const Time t)
Volatility blackVolImpl(Time t, Real strike) const override
void state(const Real eqIr, const Real logEq)
Real maxStrike() const override
const bool purelyTimeBased_
CrossAssetModelImpliedEqVolTermStructure(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, const Size equityIndex, BusinessDayConvention bdc=Following, const DayCounter &dc=DayCounter(), const bool purelyTimeBased=false)
Time maxTime() const override
dynamic black volatility term structure