31 const std::vector<Date>& dates,
32 const std::vector<Real>& strikes,
33 ext::shared_ptr<Matrix> localVolMatrix,
38 maxDate_(dates.back()), localVolMatrix_(
std::move(localVolMatrix)),
39 strikes_(dates.size(), ext::make_shared<
std::vector<
Real> >(strikes)),
40 localVolInterpol_(dates.size()), lowerExtrapolation_(lowerExtrapolation),
41 upperExtrapolation_(upperExtrapolation) {
44 "cannot have dates[0] < referenceDate");
46 times_ = std::vector<Time>(dates.size());
51 setInterpolation<Linear>();
55 const std::vector<Time>& times,
56 const std::vector<Real>& strikes,
57 ext::shared_ptr<Matrix> localVolMatrix,
63 localVolMatrix_(
std::move(localVolMatrix)),
64 strikes_(times.size(), ext::make_shared<
std::vector<
Real> >(strikes)),
65 localVolInterpol_(times.size()), lowerExtrapolation_(lowerExtrapolation),
66 upperExtrapolation_(upperExtrapolation) {
71 setInterpolation<Linear>();
75 const Date& referenceDate,
76 const std::vector<Time>& times,
77 const std::vector<ext::shared_ptr<std::vector<Real> > >& strikes,
78 ext::shared_ptr<Matrix> localVolMatrix,
84 localVolMatrix_(
std::move(localVolMatrix)), strikes_(strikes),
85 localVolInterpol_(times.size()), lowerExtrapolation_(lowerExtrapolation),
86 upperExtrapolation_(upperExtrapolation) {
90 "need strikes for every time step");
92 setInterpolation<Linear>();
98 "mismatch between date vector and vol matrix colums");
99 for (
const auto& strike :
strikes_) {
101 "mismatch between money-strike vector and "
107 "dates must be sorted unique!");
111 for (
Size j = 1; j < strike->size(); j++) {
112 QL_REQUIRE((*strike)[j] >= (*strike)[j - 1],
"strikes must be sorted");
132 const Size idx = std::distance(
times_.begin(),
142 Real earlierStrike = strike, laterStrike = strike;
144 if (strike <
strikes_[idx-1]->front())
145 earlierStrike =
strikes_[idx-1]->front();
146 if (strike <
strikes_[idx]->front())
147 laterStrike =
strikes_[idx]->front();
151 if (strike >
strikes_[idx-1]->back())
152 earlierStrike =
strikes_[idx-1]->back();
154 laterStrike =
strikes_[idx]->back();
157 const Real earlyVol =
Extrapolation upperExtrapolation_
std::vector< Interpolation > localVolInterpol_
Real minStrike() const override
the minimum strike for which the term structure can return vols
std::vector< Time > times_
Volatility localVolImpl(Time t, Real strike) const override
local vol calculation
const std::vector< ext::shared_ptr< std::vector< Real > > > strikes_
const ext::shared_ptr< Matrix > localVolMatrix_
Date maxDate() const override
the latest date for which the curve can return values
Real maxStrike() const override
the maximum strike for which the term structure can return vols
Time maxTime() const override
the latest time for which the curve can return values
Extrapolation lowerExtrapolation_
FixedLocalVolSurface(const Date &referenceDate, const std::vector< Date > &dates, const std::vector< Real > &strikes, ext::shared_ptr< Matrix > localVolMatrix, const DayCounter &dayCounter, Extrapolation lowerExtrapolation=ConstantExtrapolation, Extrapolation upperExtrapolation=ConstantExtrapolation)
Calendar for reproducing theoretical calculations.
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
Time timeFromReference(const Date &date) const
date/time conversion
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Local volatility surface based on fixed values plus interpolation.
Real Time
continuous quantity with 1-year units
Real Volatility
volatility
std::size_t Size
size of a container
linear interpolation between discrete points
Date yearFractionToDate(const DayCounter &dayCounter, const Date &referenceDate, Time t)
bool close_enough(const Quantity &m1, const Quantity &m2, Size n)
Calendar for reproducing theoretical calculations.
"inverse" of a daycounter