39 const std::vector<Period>& optionT,
40 const std::vector<Period>& swapT,
43 const bool flatExtrapolation,
45 const std::vector<std::vector<Real> >& shifts)
47 volHandles_(vols), shiftValues_(shifts),
48 volatilities_(vols.size(), vols.front().size()),
49 shifts_(vols.size(), vols.front().size(), 0.0), volatilityType_(type) {
51 shifts.empty() ? 0 : shifts.front().size());
53 if (flatExtrapolation) {
77 const std::vector<Period>& optionT,
78 const std::vector<Period>& swapT,
81 const bool flatExtrapolation,
83 const std::vector<std::vector<Real> >& shifts)
85 volHandles_(vols), shiftValues_(shifts),
86 volatilities_(vols.size(), vols.front().size()),
87 shifts_(vols.size(), vols.front().size(), 0.0), volatilityType_(type) {
89 shifts.empty() ? 0 : shifts.front().size());
91 if (flatExtrapolation) {
114 const std::vector<Period>& optionT,
115 const std::vector<Period>& swapT,
118 const bool flatExtrapolation,
122 volHandles_(vols.rows()), shiftValues_(vols.rows()),
123 volatilities_(vols.rows(), vols.columns()),
124 shifts_(vols.rows(), vols.columns(), 0.0), volatilityType_(type) {
130 for (
Size i=0; i<vols.
rows(); ++i) {
139 if (flatExtrapolation) {
163 const std::vector<Period>& optionT,
164 const std::vector<Period>& swapT,
167 const bool flatExtrapolation,
171 volHandles_(vols.rows()), shiftValues_(vols.rows()),
172 volatilities_(vols.rows(), vols.columns()),
173 shifts_(shifts.rows(), shifts.columns(), 0.0), volatilityType_(type) {
179 for (
Size i=0; i<vols.
rows(); ++i) {
188 if (flatExtrapolation) {
212 const std::vector<Date>& optionDates,
213 const std::vector<Period>& swapT,
216 const bool flatExtrapolation,
220 volHandles_(vols.rows()), shiftValues_(vols.rows()),
221 volatilities_(vols.rows(), vols.columns()),
222 shifts_(shifts.rows(),shifts.columns(),0.0), volatilityType_(type) {
228 for (
Size i=0; i<vols.
rows(); ++i) {
237 if (flatExtrapolation) {
260 Size shiftsColumns)
const {
262 "mismatch between number of option dates (" <<
264 ") in the vol matrix");
266 "mismatch between number of swap tenors (" <<
267 nSwapTenors_ <<
") and number of columns (" << volsColumns <<
268 ") in the vol matrix");
270 if(shiftRows==0 && shiftsColumns==0) {
273 shiftsColumns = volsColumns;
277 "mismatch between number of option dates (" <<
279 ") in the shift matrix");
281 "mismatch between number of swap tenors (" <<
282 nSwapTenors_ <<
") and number of columns (" << shiftsColumns <<
283 ") in the shift matrix");
319 ext::shared_ptr<SmileSection>
321 Time swapLength)
const {
bilinear interpolation between discrete points
bilinear interpolation between discrete points
Shared handle to an observable.
Matrix used in linear algebra.
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
market element returning a stored value
void performCalculations() const override
std::vector< Time > swapLengths_
std::vector< Time > optionTimes_
void registerWithMarketData()
void performCalculations() const override
Volatility volatilityImpl(Time optionTime, Time swapLength, Rate strike) const override
std::vector< std::vector< Handle< Quote > > > volHandles_
ext::shared_ptr< SmileSection > smileSectionImpl(Time, Time) const override
Interpolation2D interpolation_
Interpolation2D interpolationShifts_
SwaptionVolatilityMatrix(const Calendar &calendar, BusinessDayConvention bdc, const std::vector< Period > &optionTenors, const std::vector< Period > &swapTenors, const std::vector< std::vector< Handle< Quote > > > &vols, const DayCounter &dayCounter, bool flatExtrapolation=false, VolatilityType type=ShiftedLognormal, const std::vector< std::vector< Real > > &shifts=std::vector< std::vector< Real > >())
floating reference date, floating market data
VolatilityType volatilityType() const override
volatility type
void checkInputs(Size volRows, Size volsColumns, Size shiftRows, Size shiftsColumns) const
std::vector< std::vector< Real > > shiftValues_
Real shift(const Period &optionTenor, const Period &swapTenor, bool extrapolate=false) const
returns the shift for a given option tenor and swap tenor
Time swapLength(const Period &swapTenor) const
implements the conversion between swap tenor and swap (time) length
virtual DayCounter dayCounter() const
the day counter used for date/time conversion
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
BusinessDayConvention
Business Day conventions.
Real Time
continuous quantity with 1-year units
Real Volatility
volatility
std::size_t Size
size of a container
Calendar for reproducing theoretical calculations.
Swaption at-the-money volatility matrix.