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

floating annuity coupon More...

#include <qle/cashflows/floatingannuitycoupon.hpp>

+ Inheritance diagram for FloatingAnnuityCoupon:
+ Collaboration diagram for FloatingAnnuityCoupon:

Public Member Functions

 FloatingAnnuityCoupon (Real annuity, bool underflow, const QuantLib::ext::shared_ptr< Coupon > &previousCoupon, const Date &paymentDate, const Date &startDate, const Date &endDate, Natural fixingDays, const QuantLib::ext::shared_ptr< InterestRateIndex > &index, Real gearing=1.0, Spread spread=0.0, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const DayCounter &dayCounter=DayCounter(), bool isInArrears=false)
 
Cashflow interface
Rate amount () const override
 
Inspectors
Real accruedAmount (const Date &d) const override
 
Rate nominal () const override
 
Rate previousNominal () const
 
Rate rate () const override
 
Real price (const Handle< YieldTermStructure > &discountingCurve) const
 
const QuantLib::ext::shared_ptr< InterestRateIndex > & index () const
 
DayCounter dayCounter () const override
 
Rate indexFixing () const
 
Natural fixingDays () const
 
Date fixingDate () const
 
Real gearing () const
 
Spread spread () const
 
virtual Rate convexityAdjustment () const
 
virtual Rate adjustedFixing () const
 
bool isInArrears () const
 
Visitor interface
virtual void accept (AcyclicVisitor &) override
 

LazyObject interface

Real annuity_
 
bool underflow_
 
QuantLib::ext::shared_ptr< CouponpreviousCoupon_
 
Real nominal_
 
int fixingDays_
 
QuantLib::ext::shared_ptr< InterestRateIndexindex_
 
Real gearing_
 
Real spread_
 
DayCounter dayCounter_
 
bool isInArrears_
 
void performCalculations () const override
 

Detailed Description

floating annuity coupon

Coupon paying a Libor-type index on a variable nominal such that total flows are constant

Definition at line 38 of file floatingannuitycoupon.hpp.

Constructor & Destructor Documentation

◆ FloatingAnnuityCoupon()

FloatingAnnuityCoupon ( Real  annuity,
bool  underflow,
const QuantLib::ext::shared_ptr< Coupon > &  previousCoupon,
const Date &  paymentDate,
const Date &  startDate,
const Date &  endDate,
Natural  fixingDays,
const QuantLib::ext::shared_ptr< InterestRateIndex > &  index,
Real  gearing = 1.0,
Spread  spread = 0.0,
const Date &  refPeriodStart = Date(),
const Date &  refPeriodEnd = Date(),
const DayCounter &  dayCounter = DayCounter(),
bool  isInArrears = false 
)

Definition at line 26 of file floatingannuitycoupon.cpp.

32 : Coupon(paymentDate, 0.0, startDate, endDate, refPeriodStart, refPeriodEnd), annuity_(annuity),
35
36 if (dayCounter_ == DayCounter())
37 dayCounter_ = index_->dayCounter();
38
39 QL_REQUIRE(previousCoupon, "Non-empty previous coupon required for FloatingAnnuityCoupon");
40 registerWith(previousCoupon);
41 registerWith(index);
42 registerWith(Settings::instance().evaluationDate());
43}
QuantLib::ext::shared_ptr< Coupon > previousCoupon_
const QuantLib::ext::shared_ptr< InterestRateIndex > & index() const
QuantLib::ext::shared_ptr< InterestRateIndex > index_
DayCounter dayCounter() const override
+ Here is the call graph for this function:

Member Function Documentation

◆ amount()

Real amount ( ) const
override

Definition at line 71 of file floatingannuitycoupon.cpp.

71 {
72 calculate();
73 return rate() * accrualPeriod() * this->nominal_;
74}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ accruedAmount()

Real accruedAmount ( const Date &  d) const
override

Definition at line 76 of file floatingannuitycoupon.cpp.

76 {
77 if (d <= accrualStartDate_ || d > paymentDate_) {
78 return 0.0;
79 } else {
80 return this->nominal_ * rate() *
81 dayCounter().yearFraction(accrualStartDate_, std::min(d, accrualEndDate_), refPeriodStart_,
82 refPeriodEnd_);
83 }
84}
+ Here is the call graph for this function:

◆ nominal()

Rate nominal ( ) const
override

Definition at line 65 of file floatingannuitycoupon.cpp.

65 {
66 calculate(); // lazy
67 // performCalculations(); // not lazy
68 return this->nominal_;
69}

◆ previousNominal()

Rate previousNominal ( ) const

Definition at line 63 of file floatingannuitycoupon.cpp.

63{ return previousCoupon_->nominal(); }

◆ rate()

Rate rate ( ) const
override

Definition at line 86 of file floatingannuitycoupon.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ price()

Real price ( const Handle< YieldTermStructure > &  discountingCurve) const

Definition at line 96 of file floatingannuitycoupon.cpp.

96 {
97 return amount() * discountingCurve->discount(date());
98}
+ Here is the call graph for this function:

◆ index()

const QuantLib::ext::shared_ptr< InterestRateIndex > & index ( ) const

Definition at line 87 of file floatingannuitycoupon.hpp.

87{ return index_; }
+ Here is the caller graph for this function:

◆ dayCounter()

DayCounter dayCounter ( ) const
override

Definition at line 89 of file floatingannuitycoupon.hpp.

89{ return dayCounter_; }
+ Here is the caller graph for this function:

◆ indexFixing()

Real indexFixing ( ) const

Definition at line 94 of file floatingannuitycoupon.cpp.

94{ return index_->fixing(fixingDate()); }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fixingDays()

Natural fixingDays ( ) const

Definition at line 91 of file floatingannuitycoupon.hpp.

91{ return fixingDays_; }

◆ fixingDate()

Date fixingDate ( ) const

Definition at line 88 of file floatingannuitycoupon.cpp.

88 {
89 // if isInArrears_ fix at the end of period
90 Date refDate = isInArrears_ ? accrualEndDate_ : accrualStartDate_;
91 return index_->fixingCalendar().advance(refDate, -static_cast<Integer>(fixingDays_), Days, Preceding);
92}
+ Here is the caller graph for this function:

◆ gearing()

Real gearing ( ) const

Definition at line 93 of file floatingannuitycoupon.hpp.

93{ return gearing_; }

◆ spread()

Spread spread ( ) const

Definition at line 95 of file floatingannuitycoupon.hpp.

95{ return spread_; }

◆ convexityAdjustment()

virtual Rate convexityAdjustment ( ) const
virtual

Definition at line 61 of file floatingannuitycoupon.hpp.

61{ return 0.0; } // FIXME

◆ adjustedFixing()

virtual Rate adjustedFixing ( ) const
virtual

Definition at line 62 of file floatingannuitycoupon.hpp.

62{ return indexFixing(); } // FIXME
+ Here is the call graph for this function:

◆ isInArrears()

bool isInArrears ( ) const

Definition at line 97 of file floatingannuitycoupon.hpp.

97{ return isInArrears_; }

◆ accept()

void accept ( AcyclicVisitor &  v)
overridevirtual

Definition at line 100 of file floatingannuitycoupon.cpp.

100 {
101 Visitor<FloatingAnnuityCoupon>* v1 = dynamic_cast<Visitor<FloatingAnnuityCoupon>*>(&v);
102 if (v1 != 0)
103 v1->visit(*this);
104 else
105 Coupon::accept(v);
106}

◆ performCalculations()

void performCalculations ( ) const
override

Definition at line 45 of file floatingannuitycoupon.cpp.

45 {
46 // If the previous coupon was a FloatingAnnuityCoupon we need to cast here in order to get its mutable nominal.
47 // Using the Coupon interface previousCoupon_->nominal() would return zero.
48 QuantLib::ext::shared_ptr<FloatingAnnuityCoupon> c = QuantLib::ext::dynamic_pointer_cast<FloatingAnnuityCoupon>(previousCoupon_);
49 if (c)
50 this->nominal_ = c->nominal() + c->amount() - annuity_;
51 else
52 this->nominal_ = previousCoupon_->nominal() + previousCoupon_->amount() - annuity_;
53
54 // The following requires a QuantLib change (expected in 1.11), making the Coupon nominal() interface virtual
55 // so that it can be overridden by this class.
56 // this->nominal_ = previousCoupon_->nominal() + previousCoupon_->amount() - annuity_;
57 if (this->nominal_ < 0.0 && underflow_ == false)
58 this->nominal_ = 0.0;
59 // std::cout << "FloatingAnnuityCoupon called() for startDate " << QuantLib::io::iso_date(accrualStartDate_) << " "
60 // << "Nominal " << this->nominal_ << std::endl;
61}

Member Data Documentation

◆ annuity_

Real annuity_
private

Definition at line 73 of file floatingannuitycoupon.hpp.

◆ underflow_

bool underflow_
private

Definition at line 74 of file floatingannuitycoupon.hpp.

◆ previousCoupon_

QuantLib::ext::shared_ptr<Coupon> previousCoupon_
private

Definition at line 75 of file floatingannuitycoupon.hpp.

◆ nominal_

Real nominal_
mutableprivate

Definition at line 76 of file floatingannuitycoupon.hpp.

◆ fixingDays_

int fixingDays_
private

Definition at line 79 of file floatingannuitycoupon.hpp.

◆ index_

QuantLib::ext::shared_ptr<InterestRateIndex> index_
private

Definition at line 80 of file floatingannuitycoupon.hpp.

◆ gearing_

Real gearing_
private

Definition at line 81 of file floatingannuitycoupon.hpp.

◆ spread_

Real spread_
private

Definition at line 82 of file floatingannuitycoupon.hpp.

◆ dayCounter_

DayCounter dayCounter_
private

Definition at line 83 of file floatingannuitycoupon.hpp.

◆ isInArrears_

bool isInArrears_
private

Definition at line 84 of file floatingannuitycoupon.hpp.