22#include <ql/math/comparison.hpp>
31 const Handle<YieldTermStructure> discountCurve)
32 : marketSmiles_(std::move(marketSmiles)), marketModelType_(marketModelType),
33 inputMarketQuoteType_(inputMarketQuoteType), discountCurve_(std::move(discountCurve)) {}
36 const Real inputLognormalShift,
37 const boost::optional<Option::Type> inputOptionTypeOpt,
const Real timeToExpiry,
38 const Real strike,
const Real forward,
const MarketQuoteType outputMarketQuoteType,
39 const Real outputLognormalShift,
40 const boost::optional<Option::Type> outputOptionTypeOpt)
const {
44 Option::Type otmOptionType = strike < forward ? Option::Put : Option::Call;
45 Option::Type inputOptionType = inputOptionTypeOpt ? *inputOptionTypeOpt : otmOptionType;
46 Option::Type outputOptionType = outputOptionTypeOpt ? *outputOptionTypeOpt : otmOptionType;
50 if (inputMarketQuoteType == outputMarketQuoteType &&
close_enough(inputLognormalShift, outputLognormalShift) &&
51 inputOptionType == outputOptionType) {
64 bachelierBlackFormula(inputOptionType, strike, forward, inputQuote * std::sqrt(timeToExpiry));
66 if (strike < -inputLognormalShift)
67 forwardPremium = inputOptionType == Option::Call ? forward - strike : 0.0;
69 forwardPremium = blackFormula(inputOptionType, strike, forward, inputQuote * std::sqrt(timeToExpiry),
70 1.0, inputLognormalShift);
73 QL_FAIL(
"ParametricVolatility::convert(): MarketQuoteType ("
74 <<
static_cast<int>(inputMarketQuoteType) <<
") not handled. Internal error, contact dev.");
78 QL_FAIL(
"ParametricVolatility::convert(): MarketModelType (" <<
static_cast<int>(
marketModelType_)
79 <<
") not handled. Internal error, contact dev.");
91 if (strike > -outputLognormalShift)
92 return blackFormulaImpliedStdDev(outputOptionType, strike, forward, forwardPremium, 1.0,
93 outputLognormalShift);
97 QL_FAIL(
"ParametricVolatility::convert(): MarketQuoteType ("
98 <<
static_cast<int>(outputMarketQuoteType) <<
") not handled. Internal error, contact dev.");
103 QL_FAIL(
"ParametricVolatility::convert(): MarketModelType (" <<
static_cast<int>(
marketModelType_)
104 <<
") not handled. Internal error, contact dev.");
@ ShiftedLognormalVolatility
Real convert(const Real inputQuote, const MarketQuoteType inputMarketQuoteType, const QuantLib::Real inputLognormalShift, const boost::optional< QuantLib::Option::Type > inputOptionType, const QuantLib::Real timeToExpiry, const QuantLib::Real strike, const QuantLib::Real forward, const MarketQuoteType outputMarketQuoteType, const QuantLib::Real outputLognormalShift, const boost::optional< QuantLib::Option::Type > outputOptionType=boost::none) const
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
MarketModelType marketModelType_
ParametricVolatility(const std::vector< MarketSmile > marketSmiles, const MarketModelType marketModelType, const MarketQuoteType inputMarketQuoteType, const QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve)
implied bachelier volatility based on Jaeckel, Implied Normal Volatility, 2017
bool operator<(const Dividend &d1, const Dividend &d2)
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
Real exactBachelierImpliedVolatility(Option::Type optionType, Real strike, Real forward, Real tte, Real bachelierPrice, Real discount)
cross-asset, generic volatility structure
QuantLib::Real underlyingLength
QuantLib::Real timeToExpiry