21#include <ql/experimental/inflation/cpicapfloortermpricesurface.hpp>
30 const Period& observationLag,
34 const ext::shared_ptr<ZeroInflationIndex>& zii,
37 const std::vector<Rate>& cStrikes,
38 const std::vector<Rate>& fStrikes,
39 const std::vector<Period>& cfMaturities,
43 zii_(zii), interpolationType_(interpolationType), nominalTS_(
std::move(yts)),
44 cStrikes_(cStrikes), fStrikes_(fStrikes), cfMaturities_(cfMaturities),
45 cPrice_(cPrice), fPrice_(fPrice), nominal_(nominal), bdc_(bdc) {
48 QL_REQUIRE(!
zii_->zeroInflationTermStructure().empty(),
"ZITS missing from index");
49 QL_REQUIRE(!
nominalTS_.empty(),
"nominal TS missing");
52 QL_REQUIRE(
fStrikes_.size() > 1,
"not enough floor strikes");
53 QL_REQUIRE(
cStrikes_.size() > 1,
"not enough cap strikes");
54 QL_REQUIRE(
cfMaturities_.size() > 1,
"not enough maturities");
56 "floor strikes vs floor price rows not equal");
58 "cap strikes vs cap price rows not equal");
60 "maturities vs floor price columns not equal");
62 "maturities vs cap price columns not equal");
66 QL_REQUIRE( cfMaturities[j] >
Period(0,
Days),
"non-positive maturities");
68 QL_REQUIRE( cfMaturities[j] > cfMaturities[j-1],
69 "non-increasing maturities");
72 QL_REQUIRE(
fPrice_[i][j] > 0.0,
73 "non-positive floor price: " <<
fPrice_[i][j] );
76 "non-increasing floor prices");
80 QL_REQUIRE(
cPrice_[i][j] > 0.0,
81 "non-positive cap price: " <<
cPrice_[i][j] );
84 "non-decreasing cap prices: "
100 Rate k = cStrikes[i];
101 if (k > maxFstrike + eps)
cfStrikes_.push_back(k);
105 QL_REQUIRE(
cfStrikes_.size() > 2,
"overall not enough strikes");
108 "cfStrikes not increasing");
120 return T > 0.0 ? std::pow(F1 / F0, 1 / T) - 1.0 :
baseRate();
virtual Date cpiOptionDateFromTenor(const Period &p) const
std::vector< Rate > cfStrikes_
std::vector< Period > cfMaturities_
std::vector< Rate > fStrikes_
Handle< YieldTermStructure > nominalTS_
std::vector< Rate > cStrikes_
Rate atmRate(Date maturity) const
CPICapFloorTermPriceSurface(Real nominal, Real baseRate, const Period &observationLag, const Calendar &cal, const BusinessDayConvention &bdc, const DayCounter &dc, const ext::shared_ptr< ZeroInflationIndex > &zii, CPI::InterpolationType interpolationType, Handle< YieldTermStructure > yts, const std::vector< Rate > &cStrikes, const std::vector< Rate > &fStrikes, const std::vector< Period > &cfMaturities, const Matrix &cPrice, const Matrix &fPrice)
virtual Real capPrice(const Period &d, Rate k) const
ext::shared_ptr< ZeroInflationIndex > zii_
virtual Real price(const Period &d, Rate k) const
CPI::InterpolationType interpolationType_
virtual BusinessDayConvention businessDayConvention() const
virtual Real floorPrice(const Period &d, Rate k) const
Date adjust(const Date &, BusinessDayConvention convention=Following) const
Shared handle to an observable.
Interface for inflation term structures.
virtual Rate baseRate() const
Matrix used in linear algebra.
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
virtual Calendar calendar() const
the calendar used for reference and/or option date calculation
virtual DayCounter dayCounter() const
the day counter used for date/time conversion
BusinessDayConvention
Business Day conventions.
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
bool isInterpolated(const ext::shared_ptr< ZeroInflationIndex > &index, const QuantLib::CPI::InterpolationType &type=QuantLib::CPI::AsIndex)
Time inflationYearFraction(Frequency f, bool indexIsInterpolated, const DayCounter &dayCounter, const Date &d1, const Date &d2)
static Real laggedFixing(const ext::shared_ptr< ZeroInflationIndex > &index, const Date &date, const Period &observationLag, InterpolationType interpolationType)
interpolated inflation fixing
InterpolationType
when you observe an index, how do you interpolate between fixings?