From b0a40f0f7d337a7b917477efb4bf0cf2a705b015 Mon Sep 17 00:00:00 2001 From: Eugene Toder Date: Fri, 9 Feb 2024 13:46:08 -0500 Subject: [PATCH] Add MakeVanillaSwap.withPaymentConvention --- ql/instruments/makevanillaswap.cpp | 9 +++++++-- ql/instruments/makevanillaswap.hpp | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ql/instruments/makevanillaswap.cpp b/ql/instruments/makevanillaswap.cpp index ed8e43accec..ac329f29f74 100644 --- a/ql/instruments/makevanillaswap.cpp +++ b/ql/instruments/makevanillaswap.cpp @@ -153,7 +153,7 @@ namespace QuantLib { VanillaSwap temp(type_, 100.00, fixedSchedule, 0.0, // fixed rate fixedDayCount, floatSchedule, iborIndex_, floatSpread_, floatDayCount_, - ext::nullopt, useIndexedCoupons_); + paymentConvention_, useIndexedCoupons_); if (engine_ == nullptr) { Handle disc = iborIndex_->forwardingTermStructure(); @@ -172,7 +172,7 @@ namespace QuantLib { ext::shared_ptr swap(new VanillaSwap( type_, nominal_, fixedSchedule, usedFixedRate, fixedDayCount, floatSchedule, iborIndex_, - floatSpread_, floatDayCount_, ext::nullopt, useIndexedCoupons_)); + floatSpread_, floatDayCount_, paymentConvention_, useIndexedCoupons_)); if (engine_ == nullptr) { Handle disc = @@ -227,6 +227,11 @@ namespace QuantLib { return *this; } + MakeVanillaSwap& MakeVanillaSwap::withPaymentConvention(BusinessDayConvention bdc) { + paymentConvention_ = bdc; + return *this; + } + MakeVanillaSwap& MakeVanillaSwap::withDiscountingTermStructure( const Handle& d) { bool includeSettlementDateFlows = false; diff --git a/ql/instruments/makevanillaswap.hpp b/ql/instruments/makevanillaswap.hpp index dfa04bd4108..291ea55ef31 100644 --- a/ql/instruments/makevanillaswap.hpp +++ b/ql/instruments/makevanillaswap.hpp @@ -54,6 +54,7 @@ namespace QuantLib { MakeVanillaSwap& withEffectiveDate(const Date&); MakeVanillaSwap& withTerminationDate(const Date&); MakeVanillaSwap& withRule(DateGeneration::Rule r); + MakeVanillaSwap& withPaymentConvention(BusinessDayConvention bdc); MakeVanillaSwap& withFixedLegTenor(const Period& t); MakeVanillaSwap& withFixedLegCalendar(const Calendar& cal); @@ -108,6 +109,7 @@ namespace QuantLib { Spread floatSpread_ = 0.0; DayCounter fixedDayCount_, floatDayCount_; ext::optional useIndexedCoupons_; + ext::optional paymentConvention_; ext::shared_ptr engine_; };