Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
DepositEngine Class Reference

#include <qle/pricingengines/depositengine.hpp>

+ Inheritance diagram for DepositEngine:
+ Collaboration diagram for DepositEngine:

Public Member Functions

 DepositEngine (const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), boost::optional< bool > includeSettlementDateFlows=boost::none, Date settlementDate=Date(), Date npvDate=Date())
 
void calculate () const override
 
Handle< YieldTermStructure > discountCurve () const
 

Private Attributes

Handle< YieldTermStructure > discountCurve_
 
boost::optional< boolincludeSettlementDateFlows_
 
Date settlementDate_
 
Date npvDate_
 

Detailed Description

Deposit engine

Definition at line 34 of file depositengine.hpp.

Constructor & Destructor Documentation

◆ DepositEngine()

DepositEngine ( const Handle< YieldTermStructure > &  discountCurve = Handle<YieldTermStructure>(),
boost::optional< bool includeSettlementDateFlows = boost::none,
Date  settlementDate = Date(),
Date  npvDate = Date() 
)

Definition at line 24 of file depositengine.cpp.

26 : discountCurve_(discountCurve), includeSettlementDateFlows_(includeSettlementDateFlows),
27 settlementDate_(settlementDate), npvDate_(npvDate) {
28 registerWith(discountCurve_);
29}
Handle< YieldTermStructure > discountCurve_
Handle< YieldTermStructure > discountCurve() const
boost::optional< bool > includeSettlementDateFlows_

Member Function Documentation

◆ calculate()

void calculate ( ) const
override

Definition at line 31 of file depositengine.cpp.

31 {
32 QL_REQUIRE(!discountCurve_.empty(), "discounting term structure handle is empty");
33
34 results_.value = 0.0;
35 results_.errorEstimate = Null<Real>();
36
37 Date refDate = discountCurve_->referenceDate();
38
39 Date settlementDate = settlementDate_;
40 if (settlementDate_ == Date()) {
41 settlementDate = refDate;
42 } else {
43 QL_REQUIRE(settlementDate >= refDate, "settlement date (" << settlementDate
44 << ") before "
45 "discount curve reference date ("
46 << refDate << ")");
47 }
48
49 Date valuationDate = npvDate_;
50 if (npvDate_ == Date()) {
51 valuationDate = refDate;
52 } else {
53 QL_REQUIRE(npvDate_ >= refDate, "npv date (" << npvDate_
54 << ") before "
55 "discount curve reference date ("
56 << refDate << ")");
57 }
58
59 bool includeRefDateFlows =
60 includeSettlementDateFlows_ ? *includeSettlementDateFlows_ : Settings::instance().includeReferenceDateEvents();
61
62 results_.value =
63 CashFlows::npv(arguments_.leg, **discountCurve_, includeRefDateFlows, settlementDate, valuationDate);
64
65 // calculate the fair rate of a hypothetical deposit instrument traded on the refDate with maturity as the original
66 // instrument; this is only possible if the maturity date is later than the start date of that new deposit
67 Date startDate = arguments_.index->valueDate(arguments_.index->fixingCalendar().adjust(refDate));
68 if (arguments_.maturityDate > startDate)
69 results_.fairRate =
70 (discountCurve_->discount(startDate) / discountCurve_->discount(arguments_.maturityDate) - 1.0) /
71 arguments_.index->dayCounter().yearFraction(startDate, arguments_.maturityDate);
72
73} // calculate
const Instrument::results * results_
Definition: cdsoption.cpp:81
Swap::arguments * arguments_

◆ discountCurve()

Handle< YieldTermStructure > discountCurve ( ) const

Definition at line 40 of file depositengine.hpp.

40{ return discountCurve_; }

Member Data Documentation

◆ discountCurve_

Handle<YieldTermStructure> discountCurve_
private

Definition at line 43 of file depositengine.hpp.

◆ includeSettlementDateFlows_

boost::optional<bool> includeSettlementDateFlows_
private

Definition at line 44 of file depositengine.hpp.

◆ settlementDate_

Date settlementDate_
private

Definition at line 45 of file depositengine.hpp.

◆ npvDate_

Date npvDate_
private

Definition at line 45 of file depositengine.hpp.