20#include <boost/test/unit_test.hpp>
21#include <ql/quotes/simplequote.hpp>
22#include <ql/termstructures/yield/discountcurve.hpp>
23#include <ql/time/calendars/nullcalendar.hpp>
24#include <ql/time/daycounters/actualactual.hpp>
27using namespace boost::unit_test_framework;
33BOOST_AUTO_TEST_SUITE(DiscountCurveTest)
38 BOOST_TEST_MESSAGE(
"Testing QuantExt::InteroplatedDiscountCurve2...");
41 Settings::instance().evaluationDate() = Date(1, Dec, 2015);
42 Date today = Settings::instance().evaluationDate();
46 vector<DiscountFactor> dfs;
47 vector<Handle<Quote> > quotes;
51 DayCounter dc = ActualActual(ActualActual::ISDA);
52 Calendar cal = NullCalendar();
54 for (Size i = 0; i < numYears; i++) {
57 Real rate = 0.01 + i * 0.001;
59 dates.push_back(Date(1, Dec, startYear + i));
60 Time t = dc.yearFraction(today, dates.back());
64 DiscountFactor df = ::exp(-rate * t);
65 Handle<Quote> q(QuantLib::ext::make_shared<SimpleQuote>(df));
71 QuantLib::ext::shared_ptr<YieldTermStructure> ytsBase;
73 QuantLib::ext::shared_ptr<YieldTermStructure>(
new QuantLib::InterpolatedDiscountCurve<LogLinear>(dates, dfs, dc, cal));
74 ytsBase->enableExtrapolation();
79 for (Time t = 0.1; t < numYears + 10.0; t += 0.1) {
80 BOOST_CHECK_CLOSE(ytsBase->discount(t), ytsTest->discount(t), 1e-12);
84BOOST_AUTO_TEST_SUITE_END()
86BOOST_AUTO_TEST_SUITE_END()
InterpolatedDiscountCurve2 as in QuantLib, but with floating discount quotes and floating reference d...
BOOST_AUTO_TEST_CASE(testDiscountCurve)
interpolated discount term structure
Fixture that can be used at top level.