/usr/include/ql/experimental/inflation/yoyinflationoptionletvolatilitystructure2.hpp is in libquantlib0-dev 1.7.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2009 Chris Kenyon
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
/*! \file yoyinflationoptionletvolatilitystructure2.hpp
\brief experimental yoy inflation volatility structures
*/
#ifndef quantlib_yoy_optionlet_volatility_structures2_hpp
#define quantlib_yoy_optionlet_volatility_structures2_hpp
#include <ql/termstructures/voltermstructure.hpp>
#include <ql/math/interpolation.hpp>
#include <ql/time/calendars/target.hpp>
#include <ql/termstructures/inflationtermstructure.hpp>
#include <ql/termstructures/interpolatedcurve.hpp>
#include <ql/termstructures/volatility/inflation/yoyinflationoptionletvolatilitystructure.hpp>
namespace QuantLib {
//! Interpolated flat smile surface
/*! Interpolated in T direction and constant in K direction. */
template <class Interpolator1D>
class InterpolatedYoYOptionletVolatilityCurve
: public YoYOptionletVolatilitySurface,
protected InterpolatedCurve<Interpolator1D> {
public:
//! \name Constructor
//@{
//! calculate the reference date based on the global evaluation date
/*! The dates are those of the volatility ... there is no lag
on the dates <b>but</b> they are relative to a start date
earlier than the reference date as always for inflation.
*/
InterpolatedYoYOptionletVolatilityCurve(Natural settlementDays,
const Calendar&,
BusinessDayConvention bdc,
const DayCounter& dc,
const Period &lag,
Frequency frequency,
bool indexIsInterpolated,
const std::vector<Date> &d,
const std::vector<Volatility> &v,
Rate minStrike,
Rate maxStrike,
const Interpolator1D &i =
Interpolator1D());
//@}
virtual ~InterpolatedYoYOptionletVolatilityCurve() {}
//! \name Limits
//@{
//! the minimum strike for which the term structure can return vols
virtual Real minStrike() const {return minStrike_;}
//! the maximum strike for which the term structure can return vols
virtual Real maxStrike() const {return maxStrike_;}
virtual Date maxDate() const {
//FIXME approx
return optionDateFromTenor(Period((int)ceil(this->interpolation_.xMax()),Years));
}
//@}
//! \name Bootstrap interface
//@{
virtual const std::vector<Time>& times() const {return this->times_;}
virtual const std::vector<Date>& dates() const {return dates_;}
virtual const std::vector<Real>& data() const {return this->data_;}
virtual std::vector<std::pair<Date, Real> > nodes() const {return nodes_;}
//@}
protected:
// we need a second constructor for when we have no data
// this is protected as we only expect to use it in the
// piecewise versions
InterpolatedYoYOptionletVolatilityCurve(Natural settlementDays,
const Calendar&,
BusinessDayConvention bdc,
const DayCounter& dc,
const Period &lag,
Frequency frequency,
bool indexIsInterpolated,
Rate minStrike,
Rate maxStrike,
Volatility baseYoYVolatility,
const Interpolator1D &i =
Interpolator1D());
// we do specify data representation here
// because the bootstrapper needs this specifically
mutable std::vector<Date> dates_;
std::vector<std::pair<Date, Real> > nodes_;
//@}
//! implements the actual volatility calculation in derived classes
virtual Volatility volatilityImpl(Time length, Rate strike) const;
Rate minStrike_, maxStrike_;
};
template<class Interpolator1D>
InterpolatedYoYOptionletVolatilityCurve<Interpolator1D>::
InterpolatedYoYOptionletVolatilityCurve(Natural settlementDays,
const Calendar &cal,
BusinessDayConvention bdc,
const DayCounter& dc,
const Period &lag,
Frequency frequency,
bool indexIsInterpolated,
const std::vector<Date> &d,
const std::vector<Volatility> &v,
Rate minStrike,
Rate maxStrike,
const Interpolator1D &i)
: YoYOptionletVolatilitySurface(settlementDays, cal, bdc, dc, lag,
frequency, indexIsInterpolated),
InterpolatedCurve<Interpolator1D>(i),
dates_(d), minStrike_(minStrike), maxStrike_(maxStrike) {
QL_REQUIRE(d.size() == v.size(),
"must have same number of dates and vols: "
<< d.size() << " vs " << v.size());
QL_REQUIRE(d.size() > 1,
"must have at least two dates: " << d.size());
for (Size i = 0; i < d.size(); i++ ){
this->times_.push_back( this->timeFromReference(dates_[i]) );
this->data_.push_back(v[i]),
nodes_.push_back( std::make_pair( dates_[i], this->data_[i]) );
}
this->setupInterpolation();
// set the base vol level to that predicted by the interpolation
// this is allowed by the extrapolation
Time baseTime = this->timeFromReference(baseDate());
setBaseLevel(this->interpolation_(baseTime,true));
}
template<class Interpolator1D>
InterpolatedYoYOptionletVolatilityCurve<Interpolator1D>::
InterpolatedYoYOptionletVolatilityCurve(Natural settlementDays,
const Calendar &cal,
BusinessDayConvention bdc,
const DayCounter& dc,
const Period &lag,
Frequency frequency,
bool indexIsInterpolated,
Rate minStrike,
Rate maxStrike,
Volatility baseYoYVolatility,
const Interpolator1D &i)
: YoYOptionletVolatilitySurface(settlementDays, cal, bdc, dc, lag,
frequency, indexIsInterpolated),
InterpolatedCurve<Interpolator1D>(i),
minStrike_(minStrike), maxStrike_(maxStrike) {
// don't have the data yet except for the base volatility
// must set to communicate with bootstrap
setBaseLevel(baseYoYVolatility);
}
//! For the curve strike is ignored because the smile is (can only be) flat.
template<class Interpolator1D>
inline Volatility InterpolatedYoYOptionletVolatilityCurve<Interpolator1D>::
volatilityImpl(const Time t,
Rate) const {
return this->interpolation_(t);
}
} // namespace QuantLib
#endif
|