20#include <boost/test/unit_test.hpp>
21#include <ql/indexes/ibor/usdlibor.hpp>
22#include <ql/termstructures/yield/flatforward.hpp>
23#include <ql/termstructures/yield/piecewiseyieldcurve.hpp>
27#include <boost/make_shared.hpp>
29using namespace boost::unit_test_framework;
34BOOST_AUTO_TEST_SUITE(RateHelpersTest)
38 BOOST_TEST_MESSAGE(
"Testing QuantExt::TenorBasisSwapHelper last relevant date (regression test case)...");
41 Settings::instance().evaluationDate() = Date(8, Dec, 2016);
42 Date today = Settings::instance().evaluationDate();
44 Handle<YieldTermStructure> flat6m(
45 QuantLib::ext::make_shared<FlatForward>(today, Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.02)), Actual365Fixed()));
46 QuantLib::ext::shared_ptr<IborIndex> usdLibor6m = QuantLib::ext::make_shared<USDLibor>(6 * Months, flat6m);
47 QuantLib::ext::shared_ptr<IborIndex> usdLibor1m = QuantLib::ext::make_shared<USDLibor>(1 * Months);
49 QuantLib::ext::shared_ptr<RateHelper>
helper = QuantLib::ext::make_shared<QuantExt::TenorBasisSwapHelper>(
50 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.0)), 30 * Years, usdLibor6m, usdLibor1m, Handle<YieldTermStructure>(),
true,
false, 6 * Months);
52 PiecewiseYieldCurve<Discount, LogLinear> curve(today, std::vector<QuantLib::ext::shared_ptr<RateHelper> >(1,
helper),
54 BOOST_CHECK_NO_THROW(curve.discount(1.0));
59 BOOST_TEST_MESSAGE(
"Testing QuantExt::TenorBasisSwapHelper degenerate schedule (regression test case)...");
62 Settings::instance().evaluationDate() = Date(28, Dec, 2016);
63 Date today = Settings::instance().evaluationDate();
65 Handle<YieldTermStructure> flat6m(
66 QuantLib::ext::make_shared<FlatForward>(today, Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.02)), Actual365Fixed()));
67 QuantLib::ext::shared_ptr<IborIndex> usdLibor6m = QuantLib::ext::make_shared<USDLibor>(6 * Months, flat6m);
68 QuantLib::ext::shared_ptr<IborIndex> usdLibor3m = QuantLib::ext::make_shared<USDLibor>(3 * Months);
70 QuantLib::ext::shared_ptr<RateHelper>
helper = QuantLib::ext::make_shared<QuantExt::TenorBasisSwapHelper>(
71 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.0)), 18 * Months, usdLibor6m, usdLibor3m, Handle<YieldTermStructure>(),
true,
false, 6 * Months);
73 PiecewiseYieldCurve<Discount, LogLinear> curve(today, std::vector<QuantLib::ext::shared_ptr<RateHelper> >(1,
helper),
75 BOOST_CHECK_NO_THROW(curve.discount(1.0));
78BOOST_AUTO_TEST_SUITE_END()
80BOOST_AUTO_TEST_SUITE_END()
QuantLib::BootstrapHelper< QuantLib::OptionletVolatilityStructure > helper
BOOST_AUTO_TEST_CASE(testTenorBasisSwapHelperLastRelevantDate)
Single currency tenor basis swap helper.
Fixture that can be used at top level.