38 const Date& startDate,
44 const ext::shared_ptr<ZeroInflationIndex>& infIndex,
45 const Period& observationLag,
47 bool adjustInfObsDates,
50 :
Swap(2), type_(type), nominal_(nominal), startDate_(startDate), maturityDate_(maturity),
51 fixCalendar_(
std::move(fixCalendar)), fixConvention_(fixConvention), fixedRate_(fixedRate),
52 infIndex_(infIndex), observationLag_(observationLag),
53 observationInterpolation_(observationInterpolation), adjustInfObsDates_(adjustInfObsDates),
54 infCalendar_(
std::move(infCalendar)), infConvention_(infConvention),
55 dayCounter_(
std::move(dayCounter)) {
60 "inconsistency between swap observation lag "
62 << pShift <<
" and index availability " <<
infIndex_->availabilityLag()
63 <<
": need (obsLag-index period) >= availLag");
66 "index tries to observe inflation fixings that do not yet exist: "
67 <<
" availability lag " <<
infIndex_->availabilityLag()
79 bool growthOnly =
true;
81 auto inflationCashFlow =
84 infPayDate, growthOnly);
86 baseDate_ = inflationCashFlow->baseDate();
87 obsDate_ = inflationCashFlow->fixingDate();
99 auto fixedCashFlow = ext::make_shared<SimpleCashFlow>(fixedAmount, fixedPayDate);
101 legs_[0].push_back(fixedCashFlow);
102 legs_[1].push_back(inflationCashFlow);
116 QL_FAIL(
"Unknown zero-inflation-swap type");
127 ext::shared_ptr<IndexedCashFlow> icf =
128 ext::dynamic_pointer_cast<IndexedCashFlow>(
legs_[1].at(0));
129 QL_REQUIRE(icf,
"failed to downcast to IndexedCashFlow in ::fairRate()");
132 Real growth = icf->amount() / icf->notional() + 1.0;
138 return std::pow(growth,1.0/
T) - 1.0;
Date adjust(const Date &, BusinessDayConvention convention=Following) const
void calculate() const override
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
std::vector< Real > legNPV_
std::vector< Real > payer_
Rate fixedRate() const
in the above formula.
BusinessDayConvention infConvention_
Date startDate() const override
Real inflationLegNPV() const
CPI::InterpolationType observationInterpolation_
const Leg & fixedLeg() const
just one cashflow (that is not a coupon) in each leg
ext::shared_ptr< ZeroInflationIndex > infIndex_
ZeroCouponInflationSwap(Type type, Real nominal, const Date &startDate, const Date &maturity, Calendar fixCalendar, BusinessDayConvention fixConvention, DayCounter dayCounter, Rate fixedRate, const ext::shared_ptr< ZeroInflationIndex > &infIndex, const Period &observationLag, CPI::InterpolationType observationInterpolation, bool adjustInfObsDates=false, Calendar infCalendar=Calendar(), BusinessDayConvention infConvention=BusinessDayConvention())
BusinessDayConvention fixConvention_
const Leg & inflationLeg() const
just one cashflow (that is not a coupon) in each leg
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
BusinessDayConvention
Business Day conventions.
QuantLib::CPI::InterpolationType effectiveInterpolationType(const QuantLib::CPI::InterpolationType &type=QuantLib::CPI::AsIndex)
bool isInterpolated(const QuantLib::CPI::InterpolationType &type=QuantLib::CPI::AsIndex)
Time inflationYearFraction(Frequency f, bool indexIsInterpolated, const DayCounter &dayCounter, const Date &d1, const Date &d2)
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Calendar for reproducing theoretical calculations.
InterpolationType
when you observe an index, how do you interpolate between fixings?
@ Linear
linearly between bracketing fixings
Zero-coupon inflation-indexed swap.
Cash flow dependent on an inflation index ratio (NOT a coupon, i.e. no accruals).