diff --git a/ql/termstructures/yield/ratehelpers.cpp b/ql/termstructures/yield/ratehelpers.cpp index 1dd62febbad..199f0415967 100644 --- a/ql/termstructures/yield/ratehelpers.cpp +++ b/ql/termstructures/yield/ratehelpers.cpp @@ -613,7 +613,7 @@ namespace QuantLib { .withSettlementDays(settlementDays_) .withDiscountingTermStructure(discountRelinkableHandle_) .withFixedLegDayCount(fixedDayCount_) - .withFixedLegTenor(Period(fixedFrequency_)) + .withFixedLegTenor(fixedFrequency_ == Once ? tenor_ : Period(fixedFrequency_)) .withFixedLegConvention(fixedConvention_) .withFixedLegTerminationDateConvention(fixedConvention_) .withFixedLegCalendar(calendar_) diff --git a/test-suite/piecewiseyieldcurve.cpp b/test-suite/piecewiseyieldcurve.cpp index d71f4428085..b19fc558cb2 100644 --- a/test-suite/piecewiseyieldcurve.cpp +++ b/test-suite/piecewiseyieldcurve.cpp @@ -22,6 +22,7 @@ #include "utilities.hpp" #include #include +#include #include #include #include @@ -40,12 +41,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -1544,6 +1547,22 @@ BOOST_AUTO_TEST_CASE(testCustomFuturesHelpers) { } } + +BOOST_AUTO_TEST_CASE(testSwapHelpersWithOnceFrequency) { + BOOST_TEST_MESSAGE("Testing single-coupon swap rate helpers..."); + + auto index = ext::make_shared( + "TestIndex", 4*Weeks, 1, MXNCurrency(), + Mexico(), Following, false, Actual360()); + + Handle r(ext::make_shared(0.02)); + + BOOST_CHECK_NO_THROW(SwapRateHelper(r, 4*Weeks, Mexico(), Once, Following, Actual360(), index)); + + BOOST_CHECK_NO_THROW(OISRateHelper(2, 4*Weeks, r, ext::make_shared(), {}, false, 0, Following, Once)); +} + + BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/schedule.cpp b/test-suite/schedule.cpp index 4419bdff70f..0e836fe21c3 100644 --- a/test-suite/schedule.cpp +++ b/test-suite/schedule.cpp @@ -943,6 +943,21 @@ BOOST_AUTO_TEST_CASE(testFourWeeksTenor) { } } +BOOST_AUTO_TEST_CASE(testOnceFrequency) { + BOOST_TEST_MESSAGE( + "Testing that Once frequency works..."); + + Schedule s = + MakeSchedule().from(Date(13,January,2016)) + .to(Date(13,January,2019)) + .withFrequency(Once) + .forwards(); + + BOOST_CHECK(s.size() == 2); + BOOST_CHECK(s[0] == Date(13,January,2016)); + BOOST_CHECK(s[1] == Date(13,January,2019)); +} + BOOST_AUTO_TEST_CASE(testScheduleAlwaysHasAStartDate) { BOOST_TEST_MESSAGE("Testing that variations of MakeSchedule " "always produce a schedule with a start date...");