27 const vector<Date>& dates,
const vector<Real>&
strikes,
28 const vector<Volatility>& volatilities,
29 const DayCounter& dayCounter,
bool lowerStrikeConstExtrap,
30 bool upperStrikeConstExtrap,
bool timeFlatExtrapolation)
31 : BlackVarianceTermStructure(referenceDate, cal),
OptionInterpolator2d<Linear, Linear>(referenceDate, dayCounter,
32 lowerStrikeConstExtrap,
33 upperStrikeConstExtrap),
34 timeFlatExtrapolation_(timeFlatExtrapolation) {
36 QL_REQUIRE((
strikes.size() == dates.size()) && (dates.size() == volatilities.size()),
37 "dates, strikes and volatilities vectors not of equal size.");
40 vector<Real> variances(volatilities.size());
41 for (Size i = 0; i < volatilities.size(); i++) {
43 variances[i] = volatilities[i] * volatilities[i] * t;
47 vector<Date> modDates(dates.begin(), dates.end());
49 vector<Real> tempStrikes;
50 tempStrikes.push_back(1.0);
51 tempStrikes.push_back(100.0);
52 for (Size i = 0; i < tempStrikes.size(); i++) {
54 modStrikes.push_back(tempStrikes[i]);
55 variances.push_back(0.0);
63 QuantLib::Time tb =
times().back();
65 return getValue(tb, strike) * t / tb;
Black volatility surface modeled as variance surface.
virtual QuantLib::Real blackVarianceImpl(QuantLib::Time t, QuantLib::Real strike) const override
QuantLib::DayCounter dayCounter() const override
BlackVarianceSurfaceSparse(const QuantLib::Date &referenceDate, const QuantLib::Calendar &cal, const std::vector< QuantLib::Date > &dates, const std::vector< QuantLib::Real > &strikes, const std::vector< QuantLib::Volatility > &volatilities, const QuantLib::DayCounter &dayCounter, bool lowerStrikeConstExtrap=true, bool upperStrikeConstExtrap=true, bool timeFlatExtrapolation=false)
bool timeFlatExtrapolation_
const QuantLib::Date & referenceDate() const override
std::vector< std::vector< QuantLib::Real > > strikes() const
void initialise(const std::vector< QuantLib::Date > &dates, const std::vector< QuantLib::Real > &strikes, const std::vector< QuantLib::Real > &values)
Initialise.
QuantLib::Real getValue(QuantLib::Time t, QuantLib::Real strike) const override
std::vector< QuantLib::Time > times() const