Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
ratehelpers.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19#include "toplevelfixture.hpp"
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>
24
26
27#include <boost/make_shared.hpp>
28
29using namespace boost::unit_test_framework;
30using namespace QuantLib;
31
32BOOST_FIXTURE_TEST_SUITE(QuantExtTestSuite, qle::test::TopLevelFixture)
33
34BOOST_AUTO_TEST_SUITE(RateHelpersTest)
35
36BOOST_AUTO_TEST_CASE(testTenorBasisSwapHelperLastRelevantDate) {
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}
56
57BOOST_AUTO_TEST_CASE(testTenorBasisSwapHelperDegenerateSchedule) {
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}
77
78BOOST_AUTO_TEST_SUITE_END()
79
80BOOST_AUTO_TEST_SUITE_END()
QuantLib::BootstrapHelper< QuantLib::OptionletVolatilityStructure > helper
BOOST_AUTO_TEST_CASE(testTenorBasisSwapHelperLastRelevantDate)
Definition: ratehelpers.cpp:36
Single currency tenor basis swap helper.
Fixture that can be used at top level.