37 {
38
39 BOOST_TEST_MESSAGE("Testing Repricing of a Deposit on a depo curve...");
40
41 SavedSettings backup;
42
43 Date refDate = Date(8, Dec, 2016);
44 Settings::instance().evaluationDate() = refDate;
45
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,
49 Actual360()));
50
51 Handle<YieldTermStructure> curve(
52 QuantLib::ext::make_shared<PiecewiseYieldCurve<Discount, LogLinear> >(refDate,
helper, Actual365Fixed()));
53
54 QuantLib::ext::shared_ptr<PricingEngine> engine = QuantLib::ext::make_shared<DepositEngine>(curve);
55
56 Deposit depo(100.0, 0.02, 7 * Months, 2, TARGET(), ModifiedFollowing,
false, Actual360(), refDate,
true, 0 * Days);
57 depo.setPricingEngine(engine);
58
59 Real tol = 1.0E-8;
60 BOOST_CHECK_MESSAGE(std::abs(depo.NPV()) <= tol,
61 "Deposit NPV(" << depo.NPV() << ") could not be verified, expected 0.0");
62
63 BOOST_CHECK_MESSAGE(std::abs(depo.fairRate() - 0.02) <= tol,
64 "Deposit fair rate (" << depo.fairRate() << ") could not be verified, expected 0.02");
65}
QuantLib::BootstrapHelper< QuantLib::OptionletVolatilityStructure > helper