Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
ratehelpers.cpp File Reference
#include "toplevelfixture.hpp"
#include <boost/test/unit_test.hpp>
#include <ql/indexes/ibor/usdlibor.hpp>
#include <ql/termstructures/yield/flatforward.hpp>
#include <ql/termstructures/yield/piecewiseyieldcurve.hpp>
#include <qle/termstructures/tenorbasisswaphelper.hpp>
#include <boost/make_shared.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testTenorBasisSwapHelperLastRelevantDate)
 
 BOOST_AUTO_TEST_CASE (testTenorBasisSwapHelperDegenerateSchedule)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( testTenorBasisSwapHelperLastRelevantDate  )

Definition at line 36 of file ratehelpers.cpp.

36 {
37
38 BOOST_TEST_MESSAGE("Testing QuantExt::TenorBasisSwapHelper last relevant date (regression test case)...");
39
40 SavedSettings backup;
41 Settings::instance().evaluationDate() = Date(8, Dec, 2016);
42 Date today = Settings::instance().evaluationDate();
43
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);
48
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);
51
52 PiecewiseYieldCurve<Discount, LogLinear> curve(today, std::vector<QuantLib::ext::shared_ptr<RateHelper> >(1, helper),
53 Actual365Fixed());
54 BOOST_CHECK_NO_THROW(curve.discount(1.0));
55}
QuantLib::BootstrapHelper< QuantLib::OptionletVolatilityStructure > helper

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( testTenorBasisSwapHelperDegenerateSchedule  )

Definition at line 57 of file ratehelpers.cpp.

57 {
58
59 BOOST_TEST_MESSAGE("Testing QuantExt::TenorBasisSwapHelper degenerate schedule (regression test case)...");
60
61 SavedSettings backup;
62 Settings::instance().evaluationDate() = Date(28, Dec, 2016);
63 Date today = Settings::instance().evaluationDate();
64
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);
69
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);
72
73 PiecewiseYieldCurve<Discount, LogLinear> curve(today, std::vector<QuantLib::ext::shared_ptr<RateHelper> >(1, helper),
74 Actual365Fixed());
75 BOOST_CHECK_NO_THROW(curve.discount(1.0));
76}