diff --git a/SWIG/inflation.i b/SWIG/inflation.i index 22bcb6694..bc95b20c4 100644 --- a/SWIG/inflation.i +++ b/SWIG/inflation.i @@ -278,6 +278,11 @@ struct CPI { const Date& date, const Period& observationLag, InterpolationType interpolationType); + + static Real laggedYoYRate(const ext::shared_ptr& index, + const Date& date, + const Period& observationLag, + InterpolationType interpolationType); }; // cashflows @@ -542,6 +547,15 @@ class ZeroCouponInflationSwapHelper : public BootstrapHelper { public: + YearOnYearInflationSwapHelper(const Handle& quote, + const Period& lag, + const Date& maturity, + const Calendar& calendar, + BusinessDayConvention bdc, + const DayCounter& dayCounter, + const ext::shared_ptr& index, + CPI::InterpolationType interpolation, + const Handle& nominalTS); YearOnYearInflationSwapHelper(const Handle& quote, const Period& lag, const Date& maturity, @@ -694,6 +708,19 @@ void setCouponPricer(const Leg&, const ext::shared_ptr %shared_ptr(YoYInflationCoupon) class YoYInflationCoupon : public InflationCoupon { public: + YoYInflationCoupon(const Date& paymentDate, + Real nominal, + const Date& startDate, + const Date& endDate, + Natural fixingDays, + const ext::shared_ptr& index, + const Period& observationLag, + CPI::InterpolationType interpolation, + const DayCounter& dayCounter, + Real gearing = 1.0, + Spread spread = 0.0, + const Date& refPeriodStart = Date(), + const Date& refPeriodEnd = Date()); YoYInflationCoupon(const Date& paymentDate, Real nominal, const Date& startDate, @@ -710,6 +737,7 @@ class YoYInflationCoupon : public InflationCoupon { Spread spread() const; Rate adjustedFixing() const; ext::shared_ptr yoyIndex() const; + CPI::InterpolationType interpolation() const; }; %inline %{ @@ -722,6 +750,21 @@ class YoYInflationCoupon : public InflationCoupon { %shared_ptr(CappedFlooredYoYInflationCoupon) class CappedFlooredYoYInflationCoupon : public YoYInflationCoupon { public: + CappedFlooredYoYInflationCoupon(const Date& paymentDate, + Real nominal, + const Date& startDate, + const Date& endDate, + Natural fixingDays, + const ext::shared_ptr& index, + const Period& observationLag, + CPI::InterpolationType interpolation, + const DayCounter& dayCounter, + Real gearing = 1.0, + Spread spread = 0.0, + const Rate cap = Null(), + const Rate floor = Null(), + const Date& refPeriodStart = Date(), + const Date& refPeriodEnd = Date()); CappedFlooredYoYInflationCoupon(const Date& paymentDate, Real nominal, const Date& startDate, @@ -754,6 +797,29 @@ class CappedFlooredYoYInflationCoupon : public YoYInflationCoupon { %} %{ +Leg _yoyInflationLeg(const Schedule& schedule, + const Calendar& calendar, + const ext::shared_ptr& index, + const Period& observationLag, + CPI::InterpolationType interpolation, + const std::vector& notionals, + const DayCounter& paymentDayCounter, + BusinessDayConvention paymentAdjustment = Following, + Natural fixingDays = 0, + const std::vector& gearings = std::vector(), + const std::vector& spreads = std::vector(), + const std::vector& caps = std::vector(), + const std::vector& floors = std::vector()) { + return QuantLib::yoyInflationLeg(schedule, calendar, index, observationLag, interpolation) + .withNotionals(notionals) + .withPaymentDayCounter(paymentDayCounter) + .withPaymentAdjustment(paymentAdjustment) + .withFixingDays(fixingDays) + .withGearings(gearings) + .withSpreads(spreads) + .withCaps(caps) + .withFloors(floors); +} Leg _yoyInflationLeg(const Schedule& schedule, const Calendar& calendar, const ext::shared_ptr& index, @@ -779,6 +845,19 @@ Leg _yoyInflationLeg(const Schedule& schedule, %} %feature("kwargs") _yoyInflationLeg; %rename(yoyInflationLeg) _yoyInflationLeg; +Leg _yoyInflationLeg(const Schedule& schedule, + const Calendar& calendar, + const ext::shared_ptr& index, + const Period& observationLag, + CPI::InterpolationType interpolation, + const std::vector& notionals, + const DayCounter& paymentDayCounter, + BusinessDayConvention paymentAdjustment = Following, + Natural fixingDays = 0, + const std::vector& gearings = std::vector(), + const std::vector& spreads = std::vector(), + const std::vector& caps = std::vector(), + const std::vector& floors = std::vector()); Leg _yoyInflationLeg(const Schedule& schedule, const Calendar& calendar, const ext::shared_ptr& index, @@ -854,6 +933,20 @@ class ZeroCouponInflationSwap : public Swap { %shared_ptr(YearOnYearInflationSwap) class YearOnYearInflationSwap : public Swap { public: + YearOnYearInflationSwap( + Type type, + Real nominal, + const Schedule& fixedSchedule, + Rate fixedRate, + const DayCounter& fixedDayCounter, + const Schedule& yoySchedule, + const ext::shared_ptr& index, + const Period& lag, + CPI::InterpolationType interpolation, + Spread spread, + const DayCounter& yoyDayCounter, + const Calendar& paymentCalendar, + BusinessDayConvention paymentConvention = Following); YearOnYearInflationSwap( Type type, Real nominal, @@ -1091,24 +1184,43 @@ class Name : public YoYCapFloorTermPriceSurface { public: %extend { Name(Natural fixingDays, - const Period &yyLag, // observation lag - const ext::shared_ptr& yii, - Rate baseRate, - const Handle &nominal, - const DayCounter &dc, - const Calendar &cal, - const BusinessDayConvention &bdc, - const std::vector &cStrikes, - const std::vector &fStrikes, - const std::vector &cfMaturities, - const Matrix &cPrice, - const Matrix &fPrice, - const Interpolator2D &interpolator2d = Interpolator2D(), - const Interpolator1D &interpolator1d = Interpolator1D()) { + const Period &yyLag, // observation lag + const ext::shared_ptr& yii, + Rate baseRate, + const Handle &nominal, + const DayCounter &dc, + const Calendar &cal, + const BusinessDayConvention &bdc, + const std::vector &cStrikes, + const std::vector &fStrikes, + const std::vector &cfMaturities, + const Matrix &cPrice, + const Matrix &fPrice, + const Interpolator2D &interpolator2d = Interpolator2D(), + const Interpolator1D &interpolator1d = Interpolator1D()) { return new Name(fixingDays, yyLag, yii, baseRate, nominal, dc, cal, bdc, cStrikes, fStrikes, cfMaturities, cPrice, fPrice); } + Name(Natural fixingDays, + const Period &yyLag, // observation lag + const ext::shared_ptr& yii, + CPI::InterpolationType interpolation, + const Handle &nominal, + const DayCounter &dc, + const Calendar &cal, + const BusinessDayConvention &bdc, + const std::vector &cStrikes, + const std::vector &fStrikes, + const std::vector &cfMaturities, + const Matrix &cPrice, + const Matrix &fPrice, + const Interpolator2D &interpolator2d = Interpolator2D(), + const Interpolator1D &interpolator1d = Interpolator1D()) { + return new Name(fixingDays, yyLag, yii, interpolation, nominal, + dc, cal, bdc, cStrikes, fStrikes, cfMaturities, + cPrice, fPrice); + } } }; %enddef @@ -1151,6 +1263,22 @@ class YoYInflationBachelierCapFloorEngine : public PricingEngine { class YoYOptionletHelper : public BootstrapHelper { public: %extend { + YoYOptionletHelper( + const Handle& price, + Real notional, + YoYInflationCapFloor::Type capFloorType, + Period &lag, + const DayCounter& yoyDayCounter, + const Calendar& paymentCalendar, + Natural fixingDays, + const ext::shared_ptr& index, + CPI::InterpolationType interpolation, + Rate strike, Size n, + const ext::shared_ptr &pricer) { + auto engine = ext::dynamic_pointer_cast(pricer); + return new YoYOptionletHelper(price, notional, capFloorType, lag, yoyDayCounter, paymentCalendar, + fixingDays, index, interpolation, strike, n, engine); + } YoYOptionletHelper( const Handle& price, Real notional,