From b07faa43bba9053f2bcc88757542dc87675af9a4 Mon Sep 17 00:00:00 2001 From: sophistis42 <136467220+sophistis42@users.noreply.github.com> Date: Fri, 1 Nov 2024 09:35:17 +0100 Subject: [PATCH 1/2] added DateGeneration rule as kwarg to oisratehelper to allow to use MakeOIS consistently with the bootstrapped instruments --- ql/termstructures/yield/oisratehelper.cpp | 11 +++++++---- ql/termstructures/yield/oisratehelper.hpp | 8 ++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ql/termstructures/yield/oisratehelper.cpp b/ql/termstructures/yield/oisratehelper.cpp index 39a9575382..e14ebafac3 100644 --- a/ql/termstructures/yield/oisratehelper.cpp +++ b/ql/termstructures/yield/oisratehelper.cpp @@ -49,7 +49,8 @@ namespace QuantLib { Natural lookbackDays, Natural lockoutDays, bool applyObservationShift, - ext::shared_ptr pricer) + ext::shared_ptr pricer, + DateGeneration::Rule rule) : RelativeDateRateHelper(fixedRate), settlementDays_(settlementDays), tenor_(tenor), discountHandle_(std::move(discount)), telescopicValueDates_(telescopicValueDates), paymentLag_(paymentLag), paymentConvention_(paymentConvention), @@ -58,7 +59,7 @@ namespace QuantLib { averagingMethod_(averagingMethod), endOfMonth_(endOfMonth), fixedPaymentFrequency_(fixedPaymentFrequency), fixedCalendar_(std::move(fixedCalendar)), lookbackDays_(lookbackDays), lockoutDays_(lockoutDays), applyObservationShift_(applyObservationShift), - pricer_(std::move(pricer)) { + pricer_(std::move(pricer)), rule_(rule) { initialize(overnightIndex, customPillarDate); } @@ -82,7 +83,8 @@ namespace QuantLib { Natural lookbackDays, Natural lockoutDays, bool applyObservationShift, - ext::shared_ptr pricer) + ext::shared_ptr pricer, + DateGeneration::Rule rule) : RelativeDateRateHelper(fixedRate, false), startDate_(startDate), endDate_(endDate), discountHandle_(std::move(discount)), telescopicValueDates_(telescopicValueDates), paymentLag_(paymentLag), paymentConvention_(paymentConvention), @@ -91,7 +93,7 @@ namespace QuantLib { averagingMethod_(averagingMethod), endOfMonth_(endOfMonth), fixedPaymentFrequency_(fixedPaymentFrequency), fixedCalendar_(std::move(fixedCalendar)), lookbackDays_(lookbackDays), lockoutDays_(lockoutDays), applyObservationShift_(applyObservationShift), - pricer_(std::move(pricer)) { + pricer_(std::move(pricer)), rule_(rule) { initialize(overnightIndex, customPillarDate); } @@ -128,6 +130,7 @@ namespace QuantLib { .withAveragingMethod(averagingMethod_) .withLookbackDays(lookbackDays_) .withLockoutDays(lockoutDays_) + .withRule(rule_) .withObservationShift(applyObservationShift_); if (endOfMonth_) { tmp.withEndOfMonth(*endOfMonth_); diff --git a/ql/termstructures/yield/oisratehelper.hpp b/ql/termstructures/yield/oisratehelper.hpp index a65ff3ae53..4c3f62e88a 100644 --- a/ql/termstructures/yield/oisratehelper.hpp +++ b/ql/termstructures/yield/oisratehelper.hpp @@ -58,7 +58,8 @@ namespace QuantLib { Natural lookbackDays = Null(), Natural lockoutDays = 0, bool applyObservationShift = false, - ext::shared_ptr pricer = {}); + ext::shared_ptr pricer = {}, + DateGeneration::Rule rule = DateGeneration::Backward); OISRateHelper(const Date& startDate, const Date& endDate, const Handle& fixedRate, @@ -80,7 +81,8 @@ namespace QuantLib { Natural lookbackDays = Null(), Natural lockoutDays = 0, bool applyObservationShift = false, - ext::shared_ptr pricer = {}); + ext::shared_ptr pricer = {}, + DateGeneration::Rule rule = DateGeneration::Backward)); //! \name RateHelper interface //@{ Real impliedQuote() const override; @@ -127,6 +129,8 @@ namespace QuantLib { Natural lockoutDays_; bool applyObservationShift_; ext::shared_ptr pricer_; + DateGeneration::Rule rule_ = DateGeneration::Backward; + }; /*! \deprecated Use OISRateHelper instead. From de190cc00ea7b866aadd84b1e9f743ad2c1168c7 Mon Sep 17 00:00:00 2001 From: sophistis42 <136467220+sophistis42@users.noreply.github.com> Date: Fri, 1 Nov 2024 14:23:37 +0100 Subject: [PATCH 2/2] fix syntax error --- ql/termstructures/yield/oisratehelper.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/termstructures/yield/oisratehelper.hpp b/ql/termstructures/yield/oisratehelper.hpp index 4c3f62e88a..77c4326933 100644 --- a/ql/termstructures/yield/oisratehelper.hpp +++ b/ql/termstructures/yield/oisratehelper.hpp @@ -82,7 +82,7 @@ namespace QuantLib { Natural lockoutDays = 0, bool applyObservationShift = false, ext::shared_ptr pricer = {}, - DateGeneration::Rule rule = DateGeneration::Backward)); + DateGeneration::Rule rule = DateGeneration::Backward); //! \name RateHelper interface //@{ Real impliedQuote() const override;