Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
payment.cpp File Reference
#include "toplevelfixture.hpp"
#include <boost/test/unit_test.hpp>
#include <ql/currencies/europe.hpp>
#include <ql/quotes/simplequote.hpp>
#include <ql/termstructures/yield/flatforward.hpp>
#include <ql/time/calendars/target.hpp>
#include <ql/time/daycounters/actualactual.hpp>
#include <qle/instruments/payment.hpp>
#include <qle/pricingengines/paymentdiscountingengine.hpp>
#include <boost/make_shared.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testDomesicPayment)
 
 BOOST_AUTO_TEST_CASE (testForeignPayment)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( testDomesicPayment  )

Definition at line 39 of file payment.cpp.

39 {
40
41 BOOST_TEST_MESSAGE("Testing Domestic Payment NPV...");
42
43 SavedSettings backup;
44
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);
53
54 Real expectedNpv = 100.0 * yts->discount(paymentDate);
55
56 BOOST_CHECK_SMALL(payment.NPV() - expectedNpv, 0.000001);
57}
Payment Instrument.
Definition: payment.hpp:43
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( testForeignPayment  )

Definition at line 59 of file payment.cpp.

59 {
60
61 BOOST_TEST_MESSAGE("Testing Foreign Payment NPV...");
62
63 SavedSettings backup;
64
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);
73
74 Real expectedNpv = 100.0 * yts->discount(paymentDate) * fx->value();
75
76 BOOST_CHECK_SMALL(payment.NPV() - expectedNpv, 0.000001);
77}