22#include <ql/payoff.hpp>
23#include <ql/pricingengines/blackformula.hpp>
28 const QuantLib::ext::shared_ptr<CrossAssetModel>& model,
const Size foreignCurrencyIndex, BusinessDayConvention bdc,
29 const DayCounter& dc,
const bool purelyTimeBased)
30 :
BlackVolTermStructure(bdc, dc == DayCounter() ? model->irlgm1f(0)->termStructure()->dayCounter() : dc),
31 model_(model), fxIndex_(foreignCurrencyIndex), purelyTimeBased_(purelyTimeBased),
33 referenceDate_(purelyTimeBased ? Null<Date>() : model_->irlgm1f(0)->termStructure()->referenceDate()) {
38 QL_REQUIRE(fxSpot > 0,
"FX Spot for index " <<
fxIndex_ <<
" must be positive");
39 state(0.0, 0.0, std::log(fxSpot));
45 Real tmpStrike = strike;
47 Real fxSpot = std::exp(
fx_);
50 Real atm = fxSpot * forDisc / domDisc;
52 if (tmpStrike == Null<Real>()) {
56 Option::Type type = tmpStrike >= atm ? Option::Call : Option::Put;
58 QuantLib::ext::shared_ptr<StrikedTypePayoff> payoff = QuantLib::ext::make_shared<PlainVanillaPayoff>(type, tmpStrike);
62 Real impliedStdDev = 0.0;
64 impliedStdDev = blackFormulaImpliedStdDev(type, tmpStrike, atm, premium, domDisc);
68 return impliedStdDev * impliedStdDev;
72 Real tmp = std::max(1.0E-6, t);
78 "time based term structure");
84 "time based term structure");
91 "time based term structure");
103 state(domesticIr, foreignIr, logFx);
109 state(domesticIr, foreignIr, logFx);
analytic cc lgm fx option engine
QuantLib::ext::shared_ptr< PricingEngine > engine_
Analytic cc lgm fx option engine.
const Date & referenceDate() const override
Real minStrike() const override
CrossAssetModelImpliedFxVolTermStructure(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, const Size foreignCurrencyIndex, BusinessDayConvention bdc=Following, const DayCounter &dc=DayCounter(), const bool purelyTimeBased=false)
Date maxDate() const override
const QuantLib::ext::shared_ptr< CrossAssetModel > model_
void state(const Real domesticIr, const Real foreignIr, const Real logFx)
Real blackVarianceImpl(Time t, Real strike) const override
const QuantLib::ext::shared_ptr< AnalyticCcLgmFxOptionEngine > engine_
void referenceTime(const Time t)
void move(const Date &d, const Real domesticIr, const Real foreignIr, const Real logFx)
Volatility blackVolImpl(Time t, Real strike) const override
Real maxStrike() const override
const bool purelyTimeBased_
Time maxTime() const override
dynamic black volatility term structure