20#include <boost/test/unit_test.hpp>
21#include <ql/termstructures/yield/piecewiseyieldcurve.hpp>
22#include <ql/termstructures/yield/ratehelpers.hpp>
23#include <ql/time/calendars/target.hpp>
24#include <ql/time/daycounters/actual360.hpp>
27#include <boost/make_shared.hpp>
31using namespace boost::unit_test_framework;
35BOOST_AUTO_TEST_SUITE(DepositTest)
39 BOOST_TEST_MESSAGE(
"Testing Repricing of a Deposit on a depo curve...");
43 Date refDate = Date(8, Dec, 2016);
44 Settings::instance().evaluationDate() = refDate;
46 std::vector<QuantLib::ext::shared_ptr<RateHelper> >
helper;
47 helper.push_back(QuantLib::ext::make_shared<DepositRateHelper>(Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.02)),
48 7 * Months, 2, TARGET(), ModifiedFollowing,
false,
51 Handle<YieldTermStructure> curve(
52 QuantLib::ext::make_shared<PiecewiseYieldCurve<Discount, LogLinear> >(refDate,
helper, Actual365Fixed()));
54 QuantLib::ext::shared_ptr<PricingEngine> engine = QuantLib::ext::make_shared<DepositEngine>(curve);
56 Deposit depo(100.0, 0.02, 7 * Months, 2, TARGET(), ModifiedFollowing,
false, Actual360(), refDate,
true, 0 * Days);
57 depo.setPricingEngine(engine);
60 BOOST_CHECK_MESSAGE(std::abs(depo.NPV()) <= tol,
61 "Deposit NPV(" << depo.NPV() <<
") could not be verified, expected 0.0");
63 BOOST_CHECK_MESSAGE(std::abs(depo.
fairRate() - 0.02) <= tol,
64 "Deposit fair rate (" << depo.
fairRate() <<
") could not be verified, expected 0.02");
67BOOST_AUTO_TEST_SUITE_END()
69BOOST_AUTO_TEST_SUITE_END()
QuantLib::BootstrapHelper< QuantLib::OptionletVolatilityStructure > helper
BOOST_AUTO_TEST_CASE(testRepricing)
Fixture that can be used at top level.