From cec441d22655f019f2b33d88abf2e83f1bf293cf Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Fri, 23 Sep 2022 10:11:42 +0200 Subject: [PATCH 1/2] Extract helper functions, deprecate a couple of constructors --- .../amortizingbonds/amortizingcmsratebond.hpp | 10 +- .../amortizingfixedratebond.cpp | 182 +++++----- .../amortizingfixedratebond.hpp | 31 +- .../amortizingfloatingratebond.hpp | 8 +- test-suite/amortizingbond.cpp | 322 +++++++++--------- 5 files changed, 285 insertions(+), 268 deletions(-) diff --git a/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp b/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp index 6f7d7b19e5f..0a045d4e9c5 100644 --- a/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp +++ b/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp @@ -42,12 +42,10 @@ namespace QuantLib { const DayCounter& paymentDayCounter, BusinessDayConvention paymentConvention = Following, Natural fixingDays = Null(), - const std::vector& gearings = - std::vector(1, 1.0), - const std::vector& spreads = - std::vector(1, 0.0), - const std::vector& caps = std::vector(), - const std::vector& floors = std::vector(), + const std::vector& gearings = { 1.0 }, + const std::vector& spreads = { 0.0 }, + const std::vector& caps = {}, + const std::vector& floors = {}, bool inArrears = false, const Date& issueDate = Date()); }; diff --git a/ql/experimental/amortizingbonds/amortizingfixedratebond.cpp b/ql/experimental/amortizingbonds/amortizingfixedratebond.cpp index 619fe7c32b7..580aa4f92f2 100644 --- a/ql/experimental/amortizingbonds/amortizingfixedratebond.cpp +++ b/ql/experimental/amortizingbonds/amortizingfixedratebond.cpp @@ -56,98 +56,6 @@ namespace QuantLib { QL_ENSURE(!cashflows().empty(), "bond with no cashflows!"); } - namespace { - - std::pair daysMinMax(const Period& p) { - switch (p.units()) { - case Days: - return std::make_pair(p.length(), p.length()); - case Weeks: - return std::make_pair(7*p.length(), 7*p.length()); - case Months: - return std::make_pair(28*p.length(), 31*p.length()); - case Years: - return std::make_pair(365*p.length(), 366*p.length()); - default: - QL_FAIL("unknown time unit (" << Integer(p.units()) << ")"); - } - } - - bool isSubPeriod(const Period& subPeriod, - const Period& superPeriod, - Integer& numSubPeriods) { - - std::pair superDays(daysMinMax(superPeriod)); - std::pair subDays(daysMinMax(subPeriod)); - - //obtain the approximate time ratio - Real minPeriodRatio = - ((Real)superDays.first)/((Real)subDays.second); - Real maxPeriodRatio = - ((Real)superDays.second)/((Real)subDays.first); - auto lowRatio = static_cast(std::floor(minPeriodRatio)); - auto highRatio = static_cast(std::ceil(maxPeriodRatio)); - - try { - for(Integer i=lowRatio; i <= highRatio; ++i) { - Period testPeriod = subPeriod * i; - if(testPeriod == superPeriod) { - numSubPeriods = i; - return true; - } - } - } catch(Error&) { - return false; - } - - return false; - } - - Schedule sinkingSchedule(const Date& startDate, - const Period& maturityTenor, - const Frequency& sinkingFrequency, - const Calendar& paymentCalendar) { - Period freqPeriod(sinkingFrequency); - Date maturityDate(startDate + maturityTenor); - Schedule retVal(startDate, maturityDate, freqPeriod, - paymentCalendar, Unadjusted, Unadjusted, - DateGeneration::Backward, false); - return retVal; - } - - std::vector sinkingNotionals(const Period& maturityTenor, - const Frequency& sinkingFrequency, - Rate couponRate, - Real initialNotional) { - Period freqPeriod(sinkingFrequency); - Integer nPeriods; - QL_REQUIRE(isSubPeriod(freqPeriod, maturityTenor, nPeriods), - "Bond frequency is incompatible with the maturity tenor"); - - std::vector notionals(nPeriods+1); - notionals.front() = initialNotional; - Real coupon = couponRate / static_cast(sinkingFrequency); - Real compoundedInterest = 1.0; - Real totalValue = std::pow(1.0+coupon, nPeriods); - for(Size i = 0; i < (Size)nPeriods-1; ++i) { - compoundedInterest *= (1.0 + coupon); - Real currentNotional = 0.0; - if(coupon < 1.0e-12) { - currentNotional = - initialNotional*(1.0 - (i+1.0)/nPeriods); - } - else { - currentNotional = - initialNotional*(compoundedInterest - (compoundedInterest-1.0)/(1.0 - 1.0/totalValue)); - } - notionals[i+1] = currentNotional; - } - notionals.back() = 0.0; - return notionals; - } - - } - AmortizingFixedRateBond::AmortizingFixedRateBond( Natural settlementDays, @@ -215,4 +123,94 @@ namespace QuantLib { QL_ENSURE(!cashflows().empty(), "bond with no cashflows!"); } + + Schedule sinkingSchedule(const Date& startDate, + const Period& bondLength, + const Frequency& frequency, + const Calendar& paymentCalendar) { + Date maturityDate = startDate + bondLength; + Schedule retVal(startDate, maturityDate, Period(frequency), + paymentCalendar, Unadjusted, Unadjusted, + DateGeneration::Backward, false); + return retVal; + } + + namespace { + + std::pair daysMinMax(const Period& p) { + switch (p.units()) { + case Days: + return std::make_pair(p.length(), p.length()); + case Weeks: + return std::make_pair(7*p.length(), 7*p.length()); + case Months: + return std::make_pair(28*p.length(), 31*p.length()); + case Years: + return std::make_pair(365*p.length(), 366*p.length()); + default: + QL_FAIL("unknown time unit (" << Integer(p.units()) << ")"); + } + } + + bool isSubPeriod(const Period& subPeriod, + const Period& superPeriod, + Integer& numSubPeriods) { + + std::pair superDays(daysMinMax(superPeriod)); + std::pair subDays(daysMinMax(subPeriod)); + + //obtain the approximate time ratio + Real minPeriodRatio = + ((Real)superDays.first)/((Real)subDays.second); + Real maxPeriodRatio = + ((Real)superDays.second)/((Real)subDays.first); + auto lowRatio = static_cast(std::floor(minPeriodRatio)); + auto highRatio = static_cast(std::ceil(maxPeriodRatio)); + + try { + for(Integer i=lowRatio; i <= highRatio; ++i) { + Period testPeriod = subPeriod * i; + if(testPeriod == superPeriod) { + numSubPeriods = i; + return true; + } + } + } catch(Error&) { + return false; + } + + return false; + } + + } + + std::vector sinkingNotionals(const Period& bondLength, + const Frequency& sinkingFrequency, + Rate couponRate, + Real initialNotional) { + Integer nPeriods; + QL_REQUIRE(isSubPeriod(Period(sinkingFrequency), bondLength, nPeriods), + "Bond frequency is incompatible with the maturity tenor"); + + std::vector notionals(nPeriods+1); + notionals.front() = initialNotional; + Real coupon = couponRate / static_cast(sinkingFrequency); + Real compoundedInterest = 1.0; + Real totalValue = std::pow(1.0+coupon, nPeriods); + for (Size i = 0; i < (Size)nPeriods-1; ++i) { + compoundedInterest *= (1.0 + coupon); + Real currentNotional = 0.0; + if(coupon < 1.0e-12) { + currentNotional = initialNotional*(1.0 - (i+1.0)/nPeriods); + } else { + currentNotional = + initialNotional*(compoundedInterest - (compoundedInterest-1.0)/(1.0 - 1.0/totalValue)); + } + notionals[i+1] = currentNotional; + } + notionals.back() = 0.0; + + return notionals; + } + } diff --git a/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp b/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp index 9092cdcff23..56e52ec0070 100644 --- a/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp +++ b/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp @@ -26,12 +26,11 @@ #include #include +#include #include namespace QuantLib { - class Schedule; - //! amortizing fixed-rate bond class AmortizingFixedRateBond : public Bond { public: @@ -46,11 +45,12 @@ namespace QuantLib { const Calendar& exCouponCalendar = Calendar(), BusinessDayConvention exCouponConvention = Unadjusted, bool exCouponEndOfMonth = false); - /*! Automatically generates a set of equal coupons, with an - amortizing bond. The coupons are equal and the accrual - daycount is only used for quoting/settlement purposes - - not for calculating the coupons. + + /*! \deprecated Use the other constructor after calling sinkingSchedule + and sinkingNotionals to generate the required parameters. + Deprecated in version 1.28. */ + QL_DEPRECATED AmortizingFixedRateBond(Natural settlementDays, const Calendar& calendar, Real faceAmount, @@ -61,6 +61,12 @@ namespace QuantLib { const DayCounter& accrualDayCounter, BusinessDayConvention paymentConvention = Following, const Date& issueDate = Date()); + + /*! \deprecated Build a FixedRateLeg instead and use it + to create an instance of the base Bond class. + Deprecated in version 1.28. + */ + QL_DEPRECATED AmortizingFixedRateBond(Natural settlementDays, const std::vector& notionals, const Schedule& schedule, @@ -72,6 +78,7 @@ namespace QuantLib { const Calendar& exCouponCalendar = Calendar(), BusinessDayConvention exCouponConvention = Unadjusted, bool exCouponEndOfMonth = false); + Frequency frequency() const { return frequency_; } const DayCounter& dayCounter() const { return dayCounter_; } protected: @@ -79,6 +86,18 @@ namespace QuantLib { DayCounter dayCounter_; }; + //! returns a schedule for French amortization + Schedule sinkingSchedule(const Date& startDate, + const Period& bondLength, + const Frequency& frequency, + const Calendar& paymentCalendar); + + //! returns a sequence of notionals for French amortization + std::vector sinkingNotionals(const Period& bondLength, + const Frequency& frequency, + Rate couponRate, + Real initialNotional); + } #endif diff --git a/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp b/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp index 87eea85629d..071cad71f47 100644 --- a/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp +++ b/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp @@ -41,10 +41,10 @@ namespace QuantLib { const DayCounter& accrualDayCounter, BusinessDayConvention paymentConvention = Following, Natural fixingDays = Null(), - const std::vector& gearings = std::vector(1, 1.0), - const std::vector& spreads = std::vector(1, 0.0), - const std::vector& caps = std::vector(), - const std::vector& floors = std::vector(), + const std::vector& gearings = { 1.0 }, + const std::vector& spreads = { 0.0 }, + const std::vector& caps = {}, + const std::vector& floors = {}, bool inArrears = false, const Date& issueDate = Date(), const Period& exCouponPeriod = Period(), diff --git a/test-suite/amortizingbond.cpp b/test-suite/amortizingbond.cpp index 26eb5af68c2..27c4b8e0aac 100644 --- a/test-suite/amortizingbond.cpp +++ b/test-suite/amortizingbond.cpp @@ -18,6 +18,7 @@ #include "amortizingbond.hpp" #include "utilities.hpp" #include +#include #include #include #include @@ -29,183 +30,184 @@ using namespace QuantLib; using namespace boost::unit_test_framework; void AmortizingBondTest::testAmortizingFixedRateBond() { - BOOST_TEST_MESSAGE("Testing amortizing fixed rate bond..."); + BOOST_TEST_MESSAGE("Testing amortizing fixed rate bond..."); - /* - * Following data is generated from Excel using function pmt with Nper = 360, PV = 100.0 - */ + /* + * Following data is generated from Excel using function pmt with Nper = 360, PV = 100.0 + */ - Real rates[] = {0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12}; - Real amounts[] = {0.277777778, 0.321639520, 0.369619473, 0.421604034, - 0.477415295, 0.536821623, 0.599550525, - 0.665302495, 0.733764574, 0.804622617, - 0.877571570, 0.952323396, 1.028612597}; + Real rates[] = {0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12}; + Real amounts[] = {0.277777778, 0.321639520, 0.369619473, 0.421604034, + 0.477415295, 0.536821623, 0.599550525, + 0.665302495, 0.733764574, 0.804622617, + 0.877571570, 0.952323396, 1.028612597}; - Frequency freq = Monthly; + Frequency freq = Monthly; - Date refDate = Settings::instance().evaluationDate(); + Date refDate = Settings::instance().evaluationDate(); - const Real tolerance = 1.0e-6; + const Real tolerance = 1.0e-6; - for(Size i=0; i notionals = myBond.notionals(); + Leg cashflows = myBond.cashflows(); - for(Size k=0; k < cashflows.size() / 2; ++k) { - Real coupon = cashflows[2*k]->amount(); - Real principal = cashflows[2*k+1]->amount(); - Real totalAmount = coupon + principal; + for (Size k=0; k < cashflows.size() / 2; ++k) { + Real coupon = cashflows[2*k]->amount(); + Real principal = cashflows[2*k+1]->amount(); + Real totalAmount = coupon + principal; - // Check the amount is same as pmt returned + // Check the amount is same as pmt returned - Real error = std::fabs(totalAmount-amounts[i]); - if (error > tolerance) { - BOOST_ERROR("\n" << - " Rate: " << rates[i] << - " " << k << "th cash flow " - " Failed!" << - " Expected Amount: " << amounts[i] << - " Calculated Amount: " << totalAmount); - } + Real error = std::fabs(totalAmount-amounts[i]); + if (error > tolerance) { + BOOST_ERROR("\n" << + " Rate: " << rates[i] << + " " << k << "th cash flow " + " Failed!" << + " Expected Amount: " << amounts[i] << + " Calculated Amount: " << totalAmount); + } - // Check the coupon result - Real expectedCoupon = notionals[k] * rates[i] / Integer(freq); - error = std::fabs(coupon- expectedCoupon); + // Check the coupon result + Real expectedCoupon = notionals[k] * rates[i] / Integer(freq); + error = std::fabs(coupon - expectedCoupon); - if(error > tolerance) { - BOOST_ERROR("\n" << - " Rate: " << rates[i] << - " " << k << "th cash flow " - " Failed!" << - " Expected Coupon: " << expectedCoupon << - " Calculated Coupon: " << coupon); - } - - } - } + if (error > tolerance) { + BOOST_ERROR("\n" << + " Rate: " << rates[i] << + " " << k << "th cash flow " + " Failed!" << + " Expected Coupon: " << expectedCoupon << + " Calculated Coupon: " << coupon); + } + } + } } void AmortizingBondTest::testBrazilianAmortizingFixedRateBond() { - BOOST_TEST_MESSAGE("Testing Brazilian amortizing fixed rate bond..."); - - /* - * Following data is based on the following Brazilian onshore corporate bond code: - * SND Code - RISF11 - * ISIN Code - BRRISFDBS005 - * Fiduciary Agent URL - https://www.pentagonotrustee.com.br/Site/DetalhesEmissor?ativo=RISF11&aba=tab-5&tipo=undefined - */ - - static const Real arr[] = { - 1000 , 983.33300000, 966.66648898, 950.00019204, - 933.33338867, 916.66685434, 900.00001759, 883.33291726, - 866.66619177, 849.99933423, 833.33254728, 816.66589633, - 799.99937871, 783.33299165, 766.66601558, 749.99946306, - 733.33297499, 716.66651646, 699.99971995, 683.33272661, - 666.66624140, 649.99958536, 633.33294599, 616.66615618, - 599.99951997, 583.33273330, 566.66633377, 549.99954356, - 533.33290739, 516.66625403, 499.99963400, 483.33314619, - 466.66636930, 449.99984658, 433.33320226, 416.66634063, - 399.99968700, 383.33290004, 366.66635221, 349.99953317, - 333.33290539, 316.66626012, 299.99948151, 283.33271031, - 266.66594695, 249.99932526, 233.33262024, 216.66590450, - 199.99931312, 183.33277035, 166.66617153, 149.99955437, - 133.33295388, 116.66633464, 99.99973207, 83.33307672, - 66.66646137, 49.99984602, 33.33324734, 16.66662367 - }; - std::vector notionals (arr, arr + sizeof(arr) / sizeof(arr[0]) ); - - Real expected_amortizations[] = { - 16.66700000, 16.66651102, 16.66629694, 16.66680337, - 16.66653432, 16.66683675, 16.66710033, 16.66672548, - 16.66685753, 16.66678695, 16.66665095, 16.66651761, - 16.66638706, 16.66697606, 16.66655251, 16.66648807, - 16.66645852, 16.66679651, 16.66699333, 16.66648520, - 16.66665604, 16.66663937, 16.66678981, 16.66663620, - 16.66678667, 16.66639952, 16.66679021, 16.66663617, - 16.66665336, 16.66662002, 16.66648780, 16.66677688, - 16.66652271, 16.66664432, 16.66686163, 16.66665363, - 16.66678696, 16.66654783, 16.66681904, 16.66662777, - 16.66664527, 16.66677860, 16.66677119, 16.66676335, - 16.66662168, 16.66670502, 16.66671573, 16.66659137, - 16.66654276, 16.66659882, 16.66661715, 16.66660049, - 16.66661924, 16.66660257, 16.66665534, 16.66661534, - 16.66661534, 16.66659867, 16.66662367, 16.66662367 - }; - - Real expected_coupons[] = { - 5.97950399, 4.85474255, 5.27619136, 5.18522454, - 5.33753111, 5.24221882, 4.91231709, 4.59116258, - 4.73037674, 4.63940686, 4.54843737, 3.81920094, - 4.78359948, 3.86733691, 4.38439657, 4.09359456, - 4.00262671, 4.28531030, 3.82068947, 3.55165259, - 3.46502778, 3.71720657, 3.62189368, 2.88388676, - 3.58769952, 2.72800044, 3.38838360, 3.00196900, - 2.91100034, 3.08940793, 2.59877059, 2.63809514, - 2.42551945, 2.45615766, 2.59111761, 1.94857222, - 2.28751141, 1.79268582, 2.19248291, 1.81913832, - 1.90625855, 1.89350716, 1.48110584, 1.62031828, - 1.38600825, 1.23425366, 1.39521333, 1.06968563, - 1.03950542, 1.00065409, 0.90968563, 0.81871706, - 0.79726493, 0.63678002, 0.57187676, 0.49829046, - 0.32913418, 0.27290565, 0.19062560, 0.08662552 - }; - - Natural settlementDays = 0; - Date issueDate(2, March, 2020); - Date maturityDate(2, March, 2025); - - Schedule schedule(issueDate, - maturityDate, - Period(Monthly), - Brazil(Brazil::Settlement), - Unadjusted, - Unadjusted, - DateGeneration::Backward, - false); - - std::vector couponRates(1); - couponRates[0] = InterestRate(0.0675, - Business252(Brazil()), - Compounded, Annual); - - AmortizingFixedRateBond risf11( - settlementDays, - notionals, - schedule, - couponRates, - Following, - issueDate, - Brazil(Brazil::Settlement) - ); - - const Real tolerance = 1.0e-6; - Real error; - Leg cashflows = risf11.cashflows(); - for(Size k=0; k < cashflows.size() / 2; ++k) { - error = std::fabs(expected_coupons[k]- cashflows[2*k]->amount()); - if(error > tolerance) { - BOOST_ERROR("\n" << - " " << k << "th cash flow " - " Failed!" << - " Expected Coupon: " << expected_coupons[k] << - " Calculated Coupon: " << cashflows[2*k]->amount()); - } - - error = std::fabs(expected_amortizations[k]- cashflows[2*k+1]->amount()); - if(error > tolerance) { - BOOST_ERROR("\n" << - " " << k << "th cash flow " - " Failed!" << - " Expected Amortization: " << expected_amortizations[k] << - " Calculated Amortization: " << cashflows[2*k+1]->amount()); - } - - } + BOOST_TEST_MESSAGE("Testing Brazilian amortizing fixed rate bond..."); + + /* + * Following data is based on the following Brazilian onshore corporate bond code: + * SND Code - RISF11 + * ISIN Code - BRRISFDBS005 + * Fiduciary Agent URL - https://www.pentagonotrustee.com.br/Site/DetalhesEmissor?ativo=RISF11&aba=tab-5&tipo=undefined + */ + + static const Real arr[] = { + 1000 , 983.33300000, 966.66648898, 950.00019204, + 933.33338867, 916.66685434, 900.00001759, 883.33291726, + 866.66619177, 849.99933423, 833.33254728, 816.66589633, + 799.99937871, 783.33299165, 766.66601558, 749.99946306, + 733.33297499, 716.66651646, 699.99971995, 683.33272661, + 666.66624140, 649.99958536, 633.33294599, 616.66615618, + 599.99951997, 583.33273330, 566.66633377, 549.99954356, + 533.33290739, 516.66625403, 499.99963400, 483.33314619, + 466.66636930, 449.99984658, 433.33320226, 416.66634063, + 399.99968700, 383.33290004, 366.66635221, 349.99953317, + 333.33290539, 316.66626012, 299.99948151, 283.33271031, + 266.66594695, 249.99932526, 233.33262024, 216.66590450, + 199.99931312, 183.33277035, 166.66617153, 149.99955437, + 133.33295388, 116.66633464, 99.99973207, 83.33307672, + 66.66646137, 49.99984602, 33.33324734, 16.66662367 + }; + std::vector notionals (arr, arr + sizeof(arr) / sizeof(arr[0]) ); + + Real expected_amortizations[] = { + 16.66700000, 16.66651102, 16.66629694, 16.66680337, + 16.66653432, 16.66683675, 16.66710033, 16.66672548, + 16.66685753, 16.66678695, 16.66665095, 16.66651761, + 16.66638706, 16.66697606, 16.66655251, 16.66648807, + 16.66645852, 16.66679651, 16.66699333, 16.66648520, + 16.66665604, 16.66663937, 16.66678981, 16.66663620, + 16.66678667, 16.66639952, 16.66679021, 16.66663617, + 16.66665336, 16.66662002, 16.66648780, 16.66677688, + 16.66652271, 16.66664432, 16.66686163, 16.66665363, + 16.66678696, 16.66654783, 16.66681904, 16.66662777, + 16.66664527, 16.66677860, 16.66677119, 16.66676335, + 16.66662168, 16.66670502, 16.66671573, 16.66659137, + 16.66654276, 16.66659882, 16.66661715, 16.66660049, + 16.66661924, 16.66660257, 16.66665534, 16.66661534, + 16.66661534, 16.66659867, 16.66662367, 16.66662367 + }; + + Real expected_coupons[] = { + 5.97950399, 4.85474255, 5.27619136, 5.18522454, + 5.33753111, 5.24221882, 4.91231709, 4.59116258, + 4.73037674, 4.63940686, 4.54843737, 3.81920094, + 4.78359948, 3.86733691, 4.38439657, 4.09359456, + 4.00262671, 4.28531030, 3.82068947, 3.55165259, + 3.46502778, 3.71720657, 3.62189368, 2.88388676, + 3.58769952, 2.72800044, 3.38838360, 3.00196900, + 2.91100034, 3.08940793, 2.59877059, 2.63809514, + 2.42551945, 2.45615766, 2.59111761, 1.94857222, + 2.28751141, 1.79268582, 2.19248291, 1.81913832, + 1.90625855, 1.89350716, 1.48110584, 1.62031828, + 1.38600825, 1.23425366, 1.39521333, 1.06968563, + 1.03950542, 1.00065409, 0.90968563, 0.81871706, + 0.79726493, 0.63678002, 0.57187676, 0.49829046, + 0.32913418, 0.27290565, 0.19062560, 0.08662552 + }; + + Natural settlementDays = 0; + Date issueDate(2, March, 2020); + Date maturityDate(2, March, 2025); + + Schedule schedule(issueDate, + maturityDate, + Period(Monthly), + Brazil(Brazil::Settlement), + Unadjusted, + Unadjusted, + DateGeneration::Backward, + false); + + std::vector couponRates = { + InterestRate(0.0675, + Business252(Brazil()), + Compounded, Annual) + }; + + Leg coupons = FixedRateLeg(schedule) + .withNotionals(notionals) + .withCouponRates(couponRates) + .withPaymentAdjustment(Following); + + Bond risf11(settlementDays, + schedule.calendar(), + issueDate, + coupons); + + const Real tolerance = 1.0e-6; + Real error; + Leg cashflows = risf11.cashflows(); + for (Size k=0; k < cashflows.size() / 2; ++k) { + error = std::fabs(expected_coupons[k] - cashflows[2*k]->amount()); + if(error > tolerance) { + BOOST_ERROR("\n" << + " " << k << "th cash flow " + " Failed!" << + " Expected Coupon: " << expected_coupons[k] << + " Calculated Coupon: " << cashflows[2*k]->amount()); + } + + error = std::fabs(expected_amortizations[k]- cashflows[2*k+1]->amount()); + if(error > tolerance) { + BOOST_ERROR("\n" << + " " << k << "th cash flow " + " Failed!" << + " Expected Amortization: " << expected_amortizations[k] << + " Calculated Amortization: " << cashflows[2*k+1]->amount()); + } + + } } From f8204422ac4d7f5b74ae78e01b8e00e81c283a96 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Fri, 23 Sep 2022 11:26:14 +0200 Subject: [PATCH 2/2] Move amortizing bonds from experimental to core --- QuantLib.vcxproj | 9 +- QuantLib.vcxproj.filters | 27 +++-- ql/CMakeLists.txt | 9 +- ql/experimental/Makefile.am | 1 - ql/experimental/amortizingbonds/Makefile.am | 27 ----- .../amortizingbonds/amortizingcmsratebond.hpp | 38 +------ .../amortizingfixedratebond.hpp | 86 +-------------- .../amortizingfloatingratebond.hpp | 41 +------ ql/instruments/bonds/Makefile.am | 6 + ql/instruments/bonds/all.hpp | 3 + .../bonds}/amortizingcmsratebond.cpp | 2 +- .../bonds/amortizingcmsratebond.hpp | 55 ++++++++++ .../bonds}/amortizingfixedratebond.cpp | 2 +- .../bonds/amortizingfixedratebond.hpp | 103 ++++++++++++++++++ .../bonds}/amortizingfloatingratebond.cpp | 2 +- .../bonds/amortizingfloatingratebond.hpp | 58 ++++++++++ test-suite/amortizingbond.cpp | 2 +- test-suite/quantlibtestsuite.cpp | 2 +- 18 files changed, 269 insertions(+), 204 deletions(-) rename ql/{experimental/amortizingbonds => instruments/bonds}/amortizingcmsratebond.cpp (97%) create mode 100644 ql/instruments/bonds/amortizingcmsratebond.hpp rename ql/{experimental/amortizingbonds => instruments/bonds}/amortizingfixedratebond.cpp (99%) create mode 100644 ql/instruments/bonds/amortizingfixedratebond.hpp rename ql/{experimental/amortizingbonds => instruments/bonds}/amortizingfloatingratebond.cpp (97%) create mode 100644 ql/instruments/bonds/amortizingfloatingratebond.hpp diff --git a/QuantLib.vcxproj b/QuantLib.vcxproj index e0201ebb61c..771b573c6a0 100644 --- a/QuantLib.vcxproj +++ b/QuantLib.vcxproj @@ -903,6 +903,9 @@ + + + @@ -1920,9 +1923,6 @@ - - - @@ -2158,6 +2158,9 @@ + + + diff --git a/QuantLib.vcxproj.filters b/QuantLib.vcxproj.filters index 483c88ac1b2..c77110c42d0 100644 --- a/QuantLib.vcxproj.filters +++ b/QuantLib.vcxproj.filters @@ -915,6 +915,15 @@ instruments\bonds + + instruments\bonds + + + instruments\bonds + + + instruments\bonds + instruments\bonds @@ -4718,6 +4727,15 @@ instruments + + instruments\bonds + + + instruments\bonds + + + instruments\bonds + instruments\bonds @@ -6500,15 +6518,6 @@ experimental\commodities - - experimental\amortizingbonds - - - experimental\amortizingbonds - - - experimental\amortizingbonds - experimental\averageois diff --git a/ql/CMakeLists.txt b/ql/CMakeLists.txt index 0a6a89f51da..4ef0189d383 100644 --- a/ql/CMakeLists.txt +++ b/ql/CMakeLists.txt @@ -44,9 +44,6 @@ set(QL_SOURCES event.cpp exchangerate.cpp exercise.cpp - experimental/amortizingbonds/amortizingcmsratebond.cpp - experimental/amortizingbonds/amortizingfixedratebond.cpp - experimental/amortizingbonds/amortizingfloatingratebond.cpp experimental/asian/analytic_cont_geom_av_price_heston.cpp experimental/asian/analytic_discr_geom_av_price_heston.cpp experimental/averageois/arithmeticaverageois.cpp @@ -282,6 +279,9 @@ set(QL_SOURCES instruments/bmaswap.cpp instruments/bond.cpp instruments/bondforward.cpp + instruments/bonds/amortizingcmsratebond.cpp + instruments/bonds/amortizingfixedratebond.cpp + instruments/bonds/amortizingfloatingratebond.cpp instruments/bonds/btp.cpp instruments/bonds/cmsratebond.cpp instruments/bonds/convertiblebonds.cpp @@ -1307,6 +1307,9 @@ set(QL_HEADERS instruments/bmaswap.hpp instruments/bond.hpp instruments/bondforward.hpp + instruments/bonds/amortizingcmsratebond.hpp + instruments/bonds/amortizingfixedratebond.hpp + instruments/bonds/amortizingfloatingratebond.hpp instruments/bonds/btp.hpp instruments/bonds/cmsratebond.hpp instruments/bonds/convertiblebonds.hpp diff --git a/ql/experimental/Makefile.am b/ql/experimental/Makefile.am index 3eed42b7f80..00a74072a40 100644 --- a/ql/experimental/Makefile.am +++ b/ql/experimental/Makefile.am @@ -14,7 +14,6 @@ this_include_HEADERS = \ libExperimental_la_SOURCES = libExperimental_la_LIBADD = \ - amortizingbonds/libAmortizingBonds.la \ asian/libAsian.la \ averageois/libAverageOIS.la \ barrieroption/libBarrierOption.la \ diff --git a/ql/experimental/amortizingbonds/Makefile.am b/ql/experimental/amortizingbonds/Makefile.am index f54f18fe89b..769fe770d73 100644 --- a/ql/experimental/amortizingbonds/Makefile.am +++ b/ql/experimental/amortizingbonds/Makefile.am @@ -8,33 +8,6 @@ this_include_HEADERS = \ amortizingfixedratebond.hpp \ amortizingfloatingratebond.hpp -cpp_files = \ - amortizingcmsratebond.cpp \ - amortizingfixedratebond.cpp \ - amortizingfloatingratebond.cpp - -if UNITY_BUILD - -nodist_libAmortizingBonds_la_SOURCES = unity.cpp - -unity.cpp: Makefile.am - echo "/* This file is automatically generated; do not edit. */" > $@ - echo "/* Add the files to be included into Makefile.am instead. */" >> $@ - echo >> $@ - for i in $(cpp_files); do \ - echo "#include \"${subdir}/$$i\"" >> $@; \ - done - -EXTRA_DIST = $(cpp_files) - -else - -libAmortizingBonds_la_SOURCES = $(cpp_files) - -endif - -noinst_LTLIBRARIES = libAmortizingBonds.la - all.hpp: Makefile.am echo "/* This file is automatically generated; do not edit. */" > ${srcdir}/$@ echo "/* Add the files to be included into Makefile.am instead. */" >> ${srcdir}/$@ diff --git a/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp b/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp index 0a045d4e9c5..8f09cd72c7e 100644 --- a/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp +++ b/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp @@ -17,39 +17,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -/*! \file amortizingcmsratebond.hpp - \brief amortizing CMS-rate bond -*/ - -#ifndef quantlib_amortizing_cms_rate_bond_hpp -#define quantlib_amortizing_cms_rate_bond_hpp - -#include - -namespace QuantLib { - - class Schedule; - class SwapIndex; - - //! amortizing CMS-rate bond - class AmortizingCmsRateBond : public Bond { - public: - AmortizingCmsRateBond( - Natural settlementDays, - const std::vector& notionals, - const Schedule& schedule, - const ext::shared_ptr& index, - const DayCounter& paymentDayCounter, - BusinessDayConvention paymentConvention = Following, - Natural fixingDays = Null(), - const std::vector& gearings = { 1.0 }, - const std::vector& spreads = { 0.0 }, - const std::vector& caps = {}, - const std::vector& floors = {}, - bool inArrears = false, - const Date& issueDate = Date()); - }; - -} +// Deprecated in version 1.28 +#pragma message("Warning: this file will disappear in a future release; include .") -#endif +#include diff --git a/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp b/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp index 56e52ec0070..24e1dea2ac4 100644 --- a/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp +++ b/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp @@ -17,87 +17,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -/*! \file amortizingfixedratebond.hpp - \brief amortizing fixed-rate bond -*/ - -#ifndef quantlib_amortizing_fixed_rate_bond_hpp -#define quantlib_amortizing_fixed_rate_bond_hpp - -#include -#include -#include -#include - -namespace QuantLib { - - //! amortizing fixed-rate bond - class AmortizingFixedRateBond : public Bond { - public: - AmortizingFixedRateBond(Natural settlementDays, - const std::vector& notionals, - const Schedule& schedule, - const std::vector& coupons, - const DayCounter& accrualDayCounter, - BusinessDayConvention paymentConvention = Following, - const Date& issueDate = Date(), - const Period& exCouponPeriod = Period(), - const Calendar& exCouponCalendar = Calendar(), - BusinessDayConvention exCouponConvention = Unadjusted, - bool exCouponEndOfMonth = false); - - /*! \deprecated Use the other constructor after calling sinkingSchedule - and sinkingNotionals to generate the required parameters. - Deprecated in version 1.28. - */ - QL_DEPRECATED - AmortizingFixedRateBond(Natural settlementDays, - const Calendar& calendar, - Real faceAmount, - const Date& startDate, - const Period& bondTenor, - const Frequency& sinkingFrequency, - Rate coupon, - const DayCounter& accrualDayCounter, - BusinessDayConvention paymentConvention = Following, - const Date& issueDate = Date()); - - /*! \deprecated Build a FixedRateLeg instead and use it - to create an instance of the base Bond class. - Deprecated in version 1.28. - */ - QL_DEPRECATED - AmortizingFixedRateBond(Natural settlementDays, - const std::vector& notionals, - const Schedule& schedule, - const std::vector& coupons, - BusinessDayConvention paymentConvention = Following, - const Date& issueDate = Date(), - const Calendar& paymentCalendar = Calendar(), - const Period& exCouponPeriod = Period(), - const Calendar& exCouponCalendar = Calendar(), - BusinessDayConvention exCouponConvention = Unadjusted, - bool exCouponEndOfMonth = false); - - Frequency frequency() const { return frequency_; } - const DayCounter& dayCounter() const { return dayCounter_; } - protected: - Frequency frequency_; - DayCounter dayCounter_; - }; - - //! returns a schedule for French amortization - Schedule sinkingSchedule(const Date& startDate, - const Period& bondLength, - const Frequency& frequency, - const Calendar& paymentCalendar); - - //! returns a sequence of notionals for French amortization - std::vector sinkingNotionals(const Period& bondLength, - const Frequency& frequency, - Rate couponRate, - Real initialNotional); - -} +// Deprecated in version 1.28 +#pragma message("Warning: this file will disappear in a future release; include .") -#endif +#include diff --git a/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp b/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp index 071cad71f47..6c105f97156 100644 --- a/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp +++ b/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp @@ -17,42 +17,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -/*! \file amortizingfloatingratebond.hpp - \brief amortizing floating-rate bond -*/ - -#ifndef quantlib_amortizing_floating_rate_bond_hpp -#define quantlib_amortizing_floating_rate_bond_hpp - -#include - -namespace QuantLib { - - class Schedule; - class IborIndex; - - //! amortizing floating-rate bond (possibly capped and/or floored) - class AmortizingFloatingRateBond : public Bond { - public: - AmortizingFloatingRateBond(Natural settlementDays, - const std::vector& notional, - const Schedule& schedule, - const ext::shared_ptr& index, - const DayCounter& accrualDayCounter, - BusinessDayConvention paymentConvention = Following, - Natural fixingDays = Null(), - const std::vector& gearings = { 1.0 }, - const std::vector& spreads = { 0.0 }, - const std::vector& caps = {}, - const std::vector& floors = {}, - bool inArrears = false, - const Date& issueDate = Date(), - const Period& exCouponPeriod = Period(), - const Calendar& exCouponCalendar = Calendar(), - BusinessDayConvention exCouponConvention = Unadjusted, - bool exCouponEndOfMonth = false); - }; - -} +// Deprecated in version 1.28 +#pragma message("Warning: this file will disappear in a future release; include .") -#endif +#include diff --git a/ql/instruments/bonds/Makefile.am b/ql/instruments/bonds/Makefile.am index 18d4171dfee..c8609f3b0e1 100644 --- a/ql/instruments/bonds/Makefile.am +++ b/ql/instruments/bonds/Makefile.am @@ -4,6 +4,9 @@ AM_CPPFLAGS = -I${top_builddir} -I${top_srcdir} this_includedir=${includedir}/${subdir} this_include_HEADERS = \ all.hpp \ + amortizingcmsratebond.hpp \ + amortizingfixedratebond.hpp \ + amortizingfloatingratebond.hpp \ btp.hpp \ cmsratebond.hpp \ convertiblebonds.hpp \ @@ -13,6 +16,9 @@ this_include_HEADERS = \ zerocouponbond.hpp cpp_files = \ + amortizingcmsratebond.cpp \ + amortizingfixedratebond.cpp \ + amortizingfloatingratebond.cpp \ btp.cpp \ cmsratebond.cpp \ convertiblebonds.cpp \ diff --git a/ql/instruments/bonds/all.hpp b/ql/instruments/bonds/all.hpp index 3a6083dae85..3934a949222 100644 --- a/ql/instruments/bonds/all.hpp +++ b/ql/instruments/bonds/all.hpp @@ -1,6 +1,9 @@ /* This file is automatically generated; do not edit. */ /* Add the files to be included into Makefile.am instead. */ +#include +#include +#include #include #include #include diff --git a/ql/experimental/amortizingbonds/amortizingcmsratebond.cpp b/ql/instruments/bonds/amortizingcmsratebond.cpp similarity index 97% rename from ql/experimental/amortizingbonds/amortizingcmsratebond.cpp rename to ql/instruments/bonds/amortizingcmsratebond.cpp index de355b9315f..cce3e5638f9 100644 --- a/ql/experimental/amortizingbonds/amortizingcmsratebond.cpp +++ b/ql/instruments/bonds/amortizingcmsratebond.cpp @@ -17,7 +17,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -#include +#include #include #include #include diff --git a/ql/instruments/bonds/amortizingcmsratebond.hpp b/ql/instruments/bonds/amortizingcmsratebond.hpp new file mode 100644 index 00000000000..0a045d4e9c5 --- /dev/null +++ b/ql/instruments/bonds/amortizingcmsratebond.hpp @@ -0,0 +1,55 @@ +/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + Copyright (C) 2008 Simon Ibbotson + + This file is part of QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + + QuantLib is free software: you can redistribute it and/or modify it + under the terms of the QuantLib license. You should have received a + copy of the license along with this program; if not, please email + . The license is also available online at + . + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ + +/*! \file amortizingcmsratebond.hpp + \brief amortizing CMS-rate bond +*/ + +#ifndef quantlib_amortizing_cms_rate_bond_hpp +#define quantlib_amortizing_cms_rate_bond_hpp + +#include + +namespace QuantLib { + + class Schedule; + class SwapIndex; + + //! amortizing CMS-rate bond + class AmortizingCmsRateBond : public Bond { + public: + AmortizingCmsRateBond( + Natural settlementDays, + const std::vector& notionals, + const Schedule& schedule, + const ext::shared_ptr& index, + const DayCounter& paymentDayCounter, + BusinessDayConvention paymentConvention = Following, + Natural fixingDays = Null(), + const std::vector& gearings = { 1.0 }, + const std::vector& spreads = { 0.0 }, + const std::vector& caps = {}, + const std::vector& floors = {}, + bool inArrears = false, + const Date& issueDate = Date()); + }; + +} + +#endif diff --git a/ql/experimental/amortizingbonds/amortizingfixedratebond.cpp b/ql/instruments/bonds/amortizingfixedratebond.cpp similarity index 99% rename from ql/experimental/amortizingbonds/amortizingfixedratebond.cpp rename to ql/instruments/bonds/amortizingfixedratebond.cpp index 580aa4f92f2..8d912dd3ae6 100644 --- a/ql/experimental/amortizingbonds/amortizingfixedratebond.cpp +++ b/ql/instruments/bonds/amortizingfixedratebond.cpp @@ -17,7 +17,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -#include +#include #include #include #include diff --git a/ql/instruments/bonds/amortizingfixedratebond.hpp b/ql/instruments/bonds/amortizingfixedratebond.hpp new file mode 100644 index 00000000000..56e52ec0070 --- /dev/null +++ b/ql/instruments/bonds/amortizingfixedratebond.hpp @@ -0,0 +1,103 @@ +/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + Copyright (C) 2008 Simon Ibbotson + + This file is part of QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + + QuantLib is free software: you can redistribute it and/or modify it + under the terms of the QuantLib license. You should have received a + copy of the license along with this program; if not, please email + . The license is also available online at + . + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ + +/*! \file amortizingfixedratebond.hpp + \brief amortizing fixed-rate bond +*/ + +#ifndef quantlib_amortizing_fixed_rate_bond_hpp +#define quantlib_amortizing_fixed_rate_bond_hpp + +#include +#include +#include +#include + +namespace QuantLib { + + //! amortizing fixed-rate bond + class AmortizingFixedRateBond : public Bond { + public: + AmortizingFixedRateBond(Natural settlementDays, + const std::vector& notionals, + const Schedule& schedule, + const std::vector& coupons, + const DayCounter& accrualDayCounter, + BusinessDayConvention paymentConvention = Following, + const Date& issueDate = Date(), + const Period& exCouponPeriod = Period(), + const Calendar& exCouponCalendar = Calendar(), + BusinessDayConvention exCouponConvention = Unadjusted, + bool exCouponEndOfMonth = false); + + /*! \deprecated Use the other constructor after calling sinkingSchedule + and sinkingNotionals to generate the required parameters. + Deprecated in version 1.28. + */ + QL_DEPRECATED + AmortizingFixedRateBond(Natural settlementDays, + const Calendar& calendar, + Real faceAmount, + const Date& startDate, + const Period& bondTenor, + const Frequency& sinkingFrequency, + Rate coupon, + const DayCounter& accrualDayCounter, + BusinessDayConvention paymentConvention = Following, + const Date& issueDate = Date()); + + /*! \deprecated Build a FixedRateLeg instead and use it + to create an instance of the base Bond class. + Deprecated in version 1.28. + */ + QL_DEPRECATED + AmortizingFixedRateBond(Natural settlementDays, + const std::vector& notionals, + const Schedule& schedule, + const std::vector& coupons, + BusinessDayConvention paymentConvention = Following, + const Date& issueDate = Date(), + const Calendar& paymentCalendar = Calendar(), + const Period& exCouponPeriod = Period(), + const Calendar& exCouponCalendar = Calendar(), + BusinessDayConvention exCouponConvention = Unadjusted, + bool exCouponEndOfMonth = false); + + Frequency frequency() const { return frequency_; } + const DayCounter& dayCounter() const { return dayCounter_; } + protected: + Frequency frequency_; + DayCounter dayCounter_; + }; + + //! returns a schedule for French amortization + Schedule sinkingSchedule(const Date& startDate, + const Period& bondLength, + const Frequency& frequency, + const Calendar& paymentCalendar); + + //! returns a sequence of notionals for French amortization + std::vector sinkingNotionals(const Period& bondLength, + const Frequency& frequency, + Rate couponRate, + Real initialNotional); + +} + +#endif diff --git a/ql/experimental/amortizingbonds/amortizingfloatingratebond.cpp b/ql/instruments/bonds/amortizingfloatingratebond.cpp similarity index 97% rename from ql/experimental/amortizingbonds/amortizingfloatingratebond.cpp rename to ql/instruments/bonds/amortizingfloatingratebond.cpp index a58eb0a8d81..be7366d3a05 100644 --- a/ql/experimental/amortizingbonds/amortizingfloatingratebond.cpp +++ b/ql/instruments/bonds/amortizingfloatingratebond.cpp @@ -17,7 +17,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -#include +#include #include #include #include diff --git a/ql/instruments/bonds/amortizingfloatingratebond.hpp b/ql/instruments/bonds/amortizingfloatingratebond.hpp new file mode 100644 index 00000000000..071cad71f47 --- /dev/null +++ b/ql/instruments/bonds/amortizingfloatingratebond.hpp @@ -0,0 +1,58 @@ +/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + Copyright (C) 2008 Simon Ibbotson + + This file is part of QuantLib, a free-software/open-source library + for financial quantitative analysts and developers - http://quantlib.org/ + + QuantLib is free software: you can redistribute it and/or modify it + under the terms of the QuantLib license. You should have received a + copy of the license along with this program; if not, please email + . The license is also available online at + . + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the license for more details. +*/ + +/*! \file amortizingfloatingratebond.hpp + \brief amortizing floating-rate bond +*/ + +#ifndef quantlib_amortizing_floating_rate_bond_hpp +#define quantlib_amortizing_floating_rate_bond_hpp + +#include + +namespace QuantLib { + + class Schedule; + class IborIndex; + + //! amortizing floating-rate bond (possibly capped and/or floored) + class AmortizingFloatingRateBond : public Bond { + public: + AmortizingFloatingRateBond(Natural settlementDays, + const std::vector& notional, + const Schedule& schedule, + const ext::shared_ptr& index, + const DayCounter& accrualDayCounter, + BusinessDayConvention paymentConvention = Following, + Natural fixingDays = Null(), + const std::vector& gearings = { 1.0 }, + const std::vector& spreads = { 0.0 }, + const std::vector& caps = {}, + const std::vector& floors = {}, + bool inArrears = false, + const Date& issueDate = Date(), + const Period& exCouponPeriod = Period(), + const Calendar& exCouponCalendar = Calendar(), + BusinessDayConvention exCouponConvention = Unadjusted, + bool exCouponEndOfMonth = false); + }; + +} + +#endif diff --git a/test-suite/amortizingbond.cpp b/test-suite/amortizingbond.cpp index 27c4b8e0aac..c6c051c026f 100644 --- a/test-suite/amortizingbond.cpp +++ b/test-suite/amortizingbond.cpp @@ -17,7 +17,7 @@ #include "amortizingbond.hpp" #include "utilities.hpp" -#include +#include #include #include #include diff --git a/test-suite/quantlibtestsuite.cpp b/test-suite/quantlibtestsuite.cpp index 7c1b66232b7..90d3fa29a94 100644 --- a/test-suite/quantlibtestsuite.cpp +++ b/test-suite/quantlibtestsuite.cpp @@ -359,6 +359,7 @@ test_suite* init_unit_test_suite(int, char* []) { test->add(QUANTLIB_TEST_CASE(startTimer)); test->add(AmericanOptionTest::suite(speed)); + test->add(AmortizingBondTest::suite()); test->add(AndreasenHugeVolatilityInterplTest::suite(speed)); test->add(ArrayTest::suite()); test->add(AsianOptionTest::suite(speed)); @@ -482,7 +483,6 @@ test_suite* init_unit_test_suite(int, char* []) { test->add(ZeroCouponSwapTest::suite()); // tests for experimental classes - test->add(AmortizingBondTest::suite()); test->add(AsianOptionTest::experimental(speed)); test->add(BasismodelsTest::suite()); test->add(BasisSwapRateHelpersTest::suite());