20#include <ql/indexes/inflationindex.hpp>
21#include <ql/time/calendars/jointcalendar.hpp>
22#include <ql/cashflows/inflationcouponpricer.hpp>
24using QuantLib::BusinessDayConvention;
25using QuantLib::Calendar;
26using QuantLib::DateGeneration;
27using QuantLib::DayCounter;
29using QuantLib::Handle;
30using QuantLib::JointCalendar;
31using QuantLib::Natural;
32using QuantLib::Period;
33using QuantLib::PricingEngine;
36using QuantLib::Schedule;
37using QuantLib::Settings;
38using QuantLib::YearOnYearInflationSwap;
39using QuantLib::YieldTermStructure;
40using QuantLib::YoYInflationIndex;
45 Natural settlementDays,
47 const QuantLib::ext::shared_ptr<YoYInflationIndex>& yoyIndex,
48 const Handle<YieldTermStructure>& rateCurve,
49 const Period& observationLag,
50 const Calendar& yoyCalendar,
51 BusinessDayConvention yoyConvention,
52 const DayCounter& yoyDayCount,
53 const Calendar& fixedCalendar,
54 BusinessDayConvention fixedConvention,
55 const DayCounter& fixedDayCount,
56 const Calendar& paymentCalendar,
57 BusinessDayConvention paymentConvention,
58 const Period& fixedTenor,
59 const Period& yoyTenor)
61 evaluationDate_(Settings::instance().evaluationDate()),
62 settlementDays_(settlementDays),
65 rateCurve_(rateCurve),
66 observationLag_(observationLag),
67 yoyCalendar_(yoyCalendar),
68 yoyConvention_(yoyConvention),
69 yoyDayCount_(yoyDayCount),
70 fixedCalendar_(fixedCalendar),
71 fixedConvention_(fixedConvention),
72 fixedDayCount_(fixedDayCount),
73 paymentCalendar_(paymentCalendar),
74 paymentConvention_(paymentConvention),
75 fixedTenor_(fixedTenor),
79 registerWith(Settings::instance().evaluationDate());
107 return rate_->value();
120 auto end = start +
tenor_;
131 yoySwap_ = QuantLib::ext::make_shared<YearOnYearInflationSwap>(YearOnYearInflationSwap::Payer, 1.0,
136 auto pricer = QuantLib::ext::make_shared<QuantLib::YoYInflationCouponPricer>(
rateCurve_);
137 for (
auto& c :
yoySwap_->yoyLeg()) {
138 if (
auto cpn = QuantLib::ext::dynamic_pointer_cast<QuantLib::YoYInflationCoupon>(c))
139 cpn->setPricer(pricer);
QuantLib::DayCounter fixedDayCount_
QuantLib::Period observationLag_
QuantLib::Real modelRate() const
Return the model implied fair year on year rate.
QuantLib::ext::shared_ptr< QuantLib::PricingEngine > engine_
The pricing engine used to value the YoY swap.
QuantLib::BusinessDayConvention paymentConvention_
QuantLib::Period yoyTenor_
QuantLib::Period fixedTenor_
QuantLib::Real marketRate() const
Return the market fair year on year rate.
QuantLib::ext::shared_ptr< QuantLib::YearOnYearInflationSwap > yoySwap() const
QuantLib::Date evaluationDate_
QuantLib::ext::shared_ptr< QuantLib::YearOnYearInflationSwap > yoySwap_
The underlying YoY swap.
void createSwap()
Create the underlying YoY swap.
QuantLib::Real calibrationError() override
QuantLib::DayCounter yoyDayCount_
QuantLib::Natural settlementDays_
QuantLib::ext::shared_ptr< QuantLib::YoYInflationIndex > yoyIndex_
QuantLib::BusinessDayConvention yoyConvention_
void setPricingEngine(const QuantLib::ext::shared_ptr< QuantLib::PricingEngine > &engine)
Set the pricing engine to be used by the underlying YoY swap.
QuantLib::Calendar paymentCalendar_
QuantLib::BusinessDayConvention fixedConvention_
QuantLib::Handle< QuantLib::YieldTermStructure > rateCurve_
QuantLib::Calendar yoyCalendar_
QuantLib::Handle< QuantLib::Quote > rate_
The YoY market swap quote.
QuantLib::Calendar fixedCalendar_
YoYSwapHelper(const QuantLib::Handle< QuantLib::Quote > &rate, QuantLib::Natural settlementDays, const QuantLib::Period &tenor, const QuantLib::ext::shared_ptr< QuantLib::YoYInflationIndex > &yoyIndex, const QuantLib::Handle< QuantLib::YieldTermStructure > &rateCurve, const QuantLib::Period &observationLag, const QuantLib::Calendar &yoyCalendar, QuantLib::BusinessDayConvention yoyConvention, const QuantLib::DayCounter &yoyDayCount, const QuantLib::Calendar &fixedCalendar, QuantLib::BusinessDayConvention fixedConvention, const QuantLib::DayCounter &fixedDayCount, const QuantLib::Calendar &paymentCalendar, QuantLib::BusinessDayConvention paymentConvention, const QuantLib::Period &fixedTenor=1 *QuantLib::Years, const QuantLib::Period &yoyTenor=1 *QuantLib::Years)
Year on year helper constructor.
Year on year inflation swap calibration helper.