Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
List of all members
PaymentDiscountingEngine Class Reference

Payment discounting engine. More...

#include <qle/pricingengines/paymentdiscountingengine.hpp>

+ Inheritance diagram for PaymentDiscountingEngine:
+ Collaboration diagram for PaymentDiscountingEngine:

Public Member Functions

Constructors
 PaymentDiscountingEngine (const Handle< YieldTermStructure > &discountCurve, const Handle< Quote > &spotFX=Handle< Quote >(), boost::optional< bool > includeSettlementDateFlows=boost::none, const Date &settlementDate=Date(), const Date &npvDate=Date())
 
PricingEngine interface
void calculate () const override
 

Inspectors

Handle< YieldTermStructure > discountCurve_
 
Handle< Quote > spotFX_
 
boost::optional< boolincludeSettlementDateFlows_
 
Date settlementDate_
 
Date npvDate_
 
const Handle< YieldTermStructure > & discountCurve () const
 
const Handle< Quote > & spotFX () const
 

Detailed Description

Payment discounting engine.

This class implements a discounting engine for a single cash flow. The cash flow is discounted using its currency's discount curve. Optionally, the NPV is converted into a different NPV currency. The FX spot rate for that purpose converts the in-currency NPV by multiplication.

Definition at line 42 of file paymentdiscountingengine.hpp.

Constructor & Destructor Documentation

◆ PaymentDiscountingEngine()

PaymentDiscountingEngine ( const Handle< YieldTermStructure > &  discountCurve,
const Handle< Quote > &  spotFX = Handle<Quote>(),
boost::optional< bool includeSettlementDateFlows = boost::none,
const Date &  settlementDate = Date(),
const Date &  npvDate = Date() 
)
Parameters
discountCurveDiscount curve for the cash flow
spotFXThe market spot rate quote for multiplicative conversion into the NPV currency, can be empty
includeSettlementDateFlows,settlementDateIf includeSettlementDateFlows is true (false), cashflows on the settlementDate are (not) included in the NPV. If not given the settlement date is set to the npv date.
npvDateDiscount to this date. If not given the npv date is set to the evaluation date

Definition at line 24 of file paymentdiscountingengine.cpp.

29 settlementDate_(settlementDate), npvDate_(npvDate) {
30 QL_REQUIRE(!discountCurve_.empty(), "empty discount curve");
31 registerWith(discountCurve_);
32 if (!spotFX.empty())
33 registerWith(spotFX);
34}
Handle< YieldTermStructure > discountCurve_
const Handle< Quote > & spotFX() const
boost::optional< bool > includeSettlementDateFlows_
const Handle< YieldTermStructure > & discountCurve() const
+ Here is the call graph for this function:

Member Function Documentation

◆ calculate()

void calculate ( ) const
override

Definition at line 36 of file paymentdiscountingengine.cpp.

36 {
37 QL_REQUIRE(!discountCurve_.empty(), "discounting term structure handle is empty");
38
39 results_.value = 0.0;
40 results_.errorEstimate = Null<Real>();
41
42 Date refDate = discountCurve_->referenceDate();
43
44 Date settlementDate = settlementDate_;
45 if (settlementDate_ == Date()) {
46 settlementDate = refDate;
47 } else {
48 QL_REQUIRE(settlementDate >= refDate, "settlement date (" << settlementDate
49 << ") before discount curve reference date ("
50 << refDate << ")");
51 }
52
53 Date valuationDate = npvDate_;
54 if (npvDate_ == Date()) {
55 valuationDate = refDate;
56 } else {
57 QL_REQUIRE(npvDate_ >= refDate,
58 "npv date (" << npvDate_ << ") before discount curve reference date (" << refDate << ")");
59 }
60
61 bool includeRefDateFlows =
62 includeSettlementDateFlows_ ? *includeSettlementDateFlows_ : Settings::instance().includeReferenceDateEvents();
63
64 Real NPV = 0.0;
65 if (!arguments_.cashflow->hasOccurred(settlementDate, includeRefDateFlows))
66 NPV = arguments_.cashflow->amount() * discountCurve_->discount(arguments_.cashflow->date());
67
68 if (!spotFX_.empty())
69 NPV *= spotFX_->value();
70
71 results_.value = NPV / discountCurve_->discount(valuationDate);
72
73} // calculate
const Instrument::results * results_
Definition: cdsoption.cpp:81
Swap::arguments * arguments_

◆ discountCurve()

const Handle< YieldTermStructure > & discountCurve ( ) const

Definition at line 72 of file paymentdiscountingengine.hpp.

72{ return discountCurve_; }

◆ spotFX()

const Handle< Quote > & spotFX ( ) const

Definition at line 73 of file paymentdiscountingengine.hpp.

73{ return spotFX_; }
+ Here is the caller graph for this function:

Member Data Documentation

◆ discountCurve_

Handle<YieldTermStructure> discountCurve_
private

Definition at line 77 of file paymentdiscountingengine.hpp.

◆ spotFX_

Handle<Quote> spotFX_
private

Definition at line 78 of file paymentdiscountingengine.hpp.

◆ includeSettlementDateFlows_

boost::optional<bool> includeSettlementDateFlows_
private

Definition at line 79 of file paymentdiscountingengine.hpp.

◆ settlementDate_

Date settlementDate_
private

Definition at line 80 of file paymentdiscountingengine.hpp.

◆ npvDate_

Date npvDate_
private

Definition at line 81 of file paymentdiscountingengine.hpp.