Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
deposit.cpp File Reference
#include "toplevelfixture.hpp"
#include <boost/test/unit_test.hpp>
#include <ql/termstructures/yield/piecewiseyieldcurve.hpp>
#include <ql/termstructures/yield/ratehelpers.hpp>
#include <ql/time/calendars/target.hpp>
#include <ql/time/daycounters/actual360.hpp>
#include <qle/pricingengines/depositengine.hpp>
#include <boost/make_shared.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testRepricing)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( testRepricing  )

Definition at line 37 of file deposit.cpp.

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}
Deposit Instrument.
Definition: deposit.hpp:43
QuantLib::BootstrapHelper< QuantLib::OptionletVolatilityStructure > helper
+ Here is the call graph for this function: