From fffcb9f5fb6dd53dea39eca51aeb1ec82f40fec1 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Fri, 22 Mar 2024 12:00:39 +0100 Subject: [PATCH] Use fixed vs floater swap --- ql/cashflows/lineartsrpricer.cpp | 17 ++++++----------- ql/cashflows/lineartsrpricer.hpp | 4 ++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/ql/cashflows/lineartsrpricer.cpp b/ql/cashflows/lineartsrpricer.cpp index da07bc46d6e..3eb0701cc19 100644 --- a/ql/cashflows/lineartsrpricer.cpp +++ b/ql/cashflows/lineartsrpricer.cpp @@ -146,19 +146,14 @@ namespace QuantLib { swapTenor_ = swapIndex_->tenor(); - Leg swapFixedLeg; - if(auto on = ext::dynamic_pointer_cast(swapIndex_)) { - onSwap_ = on->underlyingSwap(fixingDate_); - swapRateValue_ = onSwap_->fairRate(); - annuity_ = 1.0E4 * std::fabs(onSwap_->fixedLegBPS()); - swapFixedLeg = onSwap_->fixedLeg(); - } - else { + if (auto on = ext::dynamic_pointer_cast(swapIndex_)) { + swap_ = on->underlyingSwap(fixingDate_); + } else { swap_ = swapIndex_->underlyingSwap(fixingDate_); - swapRateValue_ = swap_->fairRate(); - annuity_ = 1.0E4 * std::fabs(swap_->fixedLegBPS()); - swapFixedLeg = swap_->fixedLeg(); } + swapRateValue_ = swap_->fairRate(); + annuity_ = 1.0E4 * std::fabs(swap_->fixedLegBPS()); + Leg swapFixedLeg = swap_->fixedLeg(); ext::shared_ptr sectionTmp = swaptionVolatility()->smileSection(fixingDate_, swapTenor_); diff --git a/ql/cashflows/lineartsrpricer.hpp b/ql/cashflows/lineartsrpricer.hpp index eda7b3d49c8..6e8affcabae 100644 --- a/ql/cashflows/lineartsrpricer.hpp +++ b/ql/cashflows/lineartsrpricer.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include namespace QuantLib { @@ -237,8 +238,7 @@ namespace QuantLib { annuity_; ext::shared_ptr swapIndex_; - ext::shared_ptr swap_; - ext::shared_ptr onSwap_; + ext::shared_ptr swap_; ext::shared_ptr smileSection_; Settings settings_;