20#include <boost/test/unit_test.hpp>
21#include <ql/currencies/europe.hpp>
22#include <ql/quotes/simplequote.hpp>
23#include <ql/termstructures/yield/flatforward.hpp>
24#include <ql/time/calendars/target.hpp>
25#include <ql/time/daycounters/actualactual.hpp>
29#include <boost/make_shared.hpp>
33using namespace boost::unit_test_framework;
37BOOST_AUTO_TEST_SUITE(PaymentTest)
41 BOOST_TEST_MESSAGE(
"Testing Domestic Payment NPV...");
45 Date refDate = Date(8, Dec, 2016);
46 Settings::instance().evaluationDate() = refDate;
47 Date paymentDate = refDate + 10 * Years;
48 Payment payment(100.0, EURCurrency(), paymentDate);
49 BOOST_CHECK_EQUAL(payment.
cashFlow()->amount(), 100.0);
50 Handle<YieldTermStructure> yts(QuantLib::ext::make_shared<FlatForward>(0, TARGET(), 0.03, ActualActual(ActualActual::ISDA)));
51 QuantLib::ext::shared_ptr<PricingEngine> engine = QuantLib::ext::make_shared<PaymentDiscountingEngine>(yts);
52 payment.setPricingEngine(engine);
54 Real expectedNpv = 100.0 * yts->discount(paymentDate);
56 BOOST_CHECK_SMALL(payment.NPV() - expectedNpv, 0.000001);
61 BOOST_TEST_MESSAGE(
"Testing Foreign Payment NPV...");
65 Date refDate = Date(8, Dec, 2016);
66 Settings::instance().evaluationDate() = refDate;
67 Date paymentDate = refDate + 10 * Years;
68 Payment payment(100.0, EURCurrency(), paymentDate);
69 Handle<YieldTermStructure> yts(QuantLib::ext::make_shared<FlatForward>(0, TARGET(), 0.03, ActualActual(ActualActual::ISDA)));
70 Handle<Quote> fx(QuantLib::ext::make_shared<SimpleQuote>(0.789));
71 QuantLib::ext::shared_ptr<PricingEngine> engine = QuantLib::ext::make_shared<PaymentDiscountingEngine>(yts, fx);
72 payment.setPricingEngine(engine);
74 Real expectedNpv = 100.0 * yts->discount(paymentDate) * fx->value();
76 BOOST_CHECK_SMALL(payment.NPV() - expectedNpv, 0.000001);
79BOOST_AUTO_TEST_SUITE_END()
81BOOST_AUTO_TEST_SUITE_END()
const QuantLib::ext::shared_ptr< SimpleCashFlow > & cashFlow() const
Single payment discounting engine.
BOOST_AUTO_TEST_CASE(testDomesicPayment)
Fixture that can be used at top level.