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

equity coupon More...

#include <qle/cashflows/equitycoupon.hpp>

+ Inheritance diagram for EquityCoupon:
+ Collaboration diagram for EquityCoupon:

Public Member Functions

 EquityCoupon (const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, Natural fixingDays, const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &equityCurve, const DayCounter &dayCounter, EquityReturnType returnType, Real dividendFactor=1.0, bool notionalReset=false, Real initialPrice=Null< Real >(), Real quantity=Null< Real >(), const Date &fixingStartDate=Date(), const Date &fixingEndDate=Date(), const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const Date &exCouponDate=Date(), const QuantLib::ext::shared_ptr< FxIndex > &fxIndex=nullptr, const bool initialPriceIsInTargetCcy=false, Real legInitialNotional=Null< Real >(), const Date &legFixingDate=Date())
 
CashFlow interface
Real amount () const override
 
Coupon interface
DayCounter dayCounter () const override
 
Real accruedAmount (const Date &) const override
 
Rate rate () const override
 
Real nominal () const override
 
Inspectors
const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > & equityCurve () const
 equity reference rate curve More...
 
const QuantLib::ext::shared_ptr< FxIndex > & fxIndex () const
 fx index curve More...
 
EquityReturnType returnType () const
 the return type of the coupon More...
 
Real dividendFactor () const
 are dividends scaled (e.g. to account for tax) More...
 
Date fixingStartDate () const
 The date at which the starting equity price is fixed. More...
 
Date fixingEndDate () const
 The date at which performance is measured. More...
 
std::vector< Date > fixingDates () const
 return both fixing dates More...
 
Real initialPrice () const
 initial price More...
 
bool initialPriceIsInTargetCcy () const
 initial price is in target ccy (if applicable, i.e. if fxIndex != null, otherwise ignored) More...
 
Real quantity () const
 Number of equity shares held. More...
 
Real fxRate () const
 FX conversion rate (or 1.0 if not applicable) More...
 
Date fixingDate () const
 This function is called for other coupon types. More...
 
Real legInitialNotional () const
 Initial notional of the equity leg, to compute quantity if not provided in the resetting case. More...
 
Date legFixingDate () const
 Fixing date of the first equity coupon, to compute quantity if not provided in the resetting case. More...
 
Observer interface
void update () override
 

Visitability

QuantLib::ext::shared_ptr< EquityCouponPricerpricer_
 
Natural fixingDays_
 
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2equityCurve_
 
DayCounter dayCounter_
 
EquityReturnType returnType_
 
Real dividendFactor_
 
bool notionalReset_
 
Real initialPrice_
 
bool initialPriceIsInTargetCcy_
 
Real quantity_
 
Date fixingStartDate_
 
Date fixingEndDate_
 
Natural paymentLag_
 
QuantLib::ext::shared_ptr< FxIndexfxIndex_
 
Real legInitialNotional_
 
Date legFixingDate_
 
virtual void accept (AcyclicVisitor &) override
 
void setPricer (const QuantLib::ext::shared_ptr< EquityCouponPricer > &)
 
QuantLib::ext::shared_ptr< EquityCouponPricerpricer () const
 

Detailed Description

equity coupon

Definition at line 53 of file equitycoupon.hpp.

Constructor & Destructor Documentation

◆ EquityCoupon()

EquityCoupon ( const Date &  paymentDate,
Real  nominal,
const Date &  startDate,
const Date &  endDate,
Natural  fixingDays,
const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &  equityCurve,
const DayCounter &  dayCounter,
EquityReturnType  returnType,
Real  dividendFactor = 1.0,
bool  notionalReset = false,
Real  initialPrice = Null<Real>(),
Real  quantity = Null<Real>(),
const Date &  fixingStartDate = Date(),
const Date &  fixingEndDate = Date(),
const Date &  refPeriodStart = Date(),
const Date &  refPeriodEnd = Date(),
const Date &  exCouponDate = Date(),
const QuantLib::ext::shared_ptr< FxIndex > &  fxIndex = nullptr,
const bool  initialPriceIsInTargetCcy = false,
Real  legInitialNotional = Null<Real>(),
const Date &  legFixingDate = Date() 
)

Definition at line 57 of file equitycoupon.cpp.

64 : Coupon(paymentDate, nominal, startDate, endDate, refPeriodStart, refPeriodEnd, exCouponDate),
70 QL_REQUIRE(dividendFactor_ > 0.0, "Dividend factor should not be negative. It is expected to be between 0 and 1.");
71 QL_REQUIRE(equityCurve_, "Equity underlying an equity swap coupon cannot be empty.");
72
73 // set up fixing calendar as combined eq / fx calendar
74 Calendar eqCalendar = NullCalendar();
75 Calendar fxCalendar = NullCalendar();
76 if (!equityCurve_->fixingCalendar().empty()) {
77 eqCalendar = equityCurve_->fixingCalendar();
78 }
79 if (fxIndex_ && !fxIndex_->fixingCalendar().empty()) {
80 fxCalendar = fxIndex_->fixingCalendar();
81 }
82 Calendar fixingCalendar = JointCalendar(eqCalendar, fxCalendar);
83
84 // If a fixing start / end date is provided, use these
85 // else adjust the start/endDate by the FixingDays - defaulted to 0
86 if (fixingStartDate_ == Date())
88 fixingCalendar.advance(startDate, -static_cast<Integer>(fixingDays_), Days, Preceding);
89
90 if (fixingEndDate_ == Date())
92 fixingCalendar.advance(endDate, -static_cast<Integer>(fixingDays_), Days, Preceding);
93
94 registerWith(equityCurve_);
95 registerWith(fxIndex_);
96 registerWith(Settings::instance().evaluationDate());
97
98 // QL_REQUIRE(!notionalReset_ || quantity_ != Null<Real>(), "EquityCoupon: quantity required if notional resets");
99 QL_REQUIRE(notionalReset_ || nominal_ != Null<Real>(),
100 "EquityCoupon: notional required if notional does not reset");
101}
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > equityCurve_
EquityReturnType returnType() const
the return type of the coupon
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > & equityCurve() const
equity reference rate curve
Date legFixingDate() const
Fixing date of the first equity coupon, to compute quantity if not provided in the resetting case.
const QuantLib::ext::shared_ptr< FxIndex > & fxIndex() const
fx index curve
Real dividendFactor() const
are dividends scaled (e.g. to account for tax)
bool initialPriceIsInTargetCcy() const
initial price is in target ccy (if applicable, i.e. if fxIndex != null, otherwise ignored)
Date fixingEndDate() const
The date at which performance is measured.
Real nominal() const override
EquityReturnType returnType_
Real legInitialNotional() const
Initial notional of the equity leg, to compute quantity if not provided in the resetting case.
DayCounter dayCounter() const override
Real quantity() const
Number of equity shares held.
Date fixingStartDate() const
The date at which the starting equity price is fixed.
Real initialPrice() const
initial price

Member Function Documentation

◆ amount()

Real amount ( ) const
override

Definition at line 66 of file equitycoupon.hpp.

66{ return rate() * nominal(); }
Rate rate() const override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dayCounter()

DayCounter dayCounter ( ) const
override

Definition at line 72 of file equitycoupon.hpp.

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

◆ accruedAmount()

Real accruedAmount ( const Date &  d) const
override

Definition at line 148 of file equitycoupon.cpp.

148 {
149 if (d <= accrualStartDate_ || d > paymentDate_) {
150 return 0.0;
151 } else {
152 Time fullPeriod = dayCounter().yearFraction(accrualStartDate_, accrualEndDate_, refPeriodStart_, refPeriodEnd_);
153 Time thisPeriod =
154 dayCounter().yearFraction(accrualStartDate_, std::min(d, accrualEndDate_), refPeriodStart_, refPeriodEnd_);
155 return nominal() * rate() * thisPeriod / fullPeriod;
156 }
157}
+ Here is the call graph for this function:

◆ rate()

Rate rate ( ) const
override

Definition at line 159 of file equitycoupon.cpp.

159 {
160 QL_REQUIRE(pricer_, "pricer not set");
161 // we know it is the correct type because checkPricerImpl checks on setting
162 // in general pricer_ will be a derived class, as will *this on calling
163 pricer_->initialize(*this);
164 return pricer_->swapletRate();
165}
QuantLib::ext::shared_ptr< EquityCouponPricer > pricer_
+ Here is the caller graph for this function:

◆ nominal()

Real nominal ( ) const
override

Definition at line 121 of file equitycoupon.cpp.

121 {
122 // use quantity for dividend swaps, this ensures notional resetting is not relevant
123 // swaplet rate returns the absolute dividend to match
125 return quantity();
126 else if(notionalReset_) {
127 Real mult = (initialPrice_ == 0) ? 1 : initialPrice();
128 return mult * (initialPriceIsInTargetCcy_ ? 1.0 : fxRate()) * quantity();
129 } else {
130 return nominal_;
131 }
132}
Real fxRate() const
FX conversion rate (or 1.0 if not applicable)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ equityCurve()

const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > & equityCurve ( ) const

equity reference rate curve

Definition at line 83 of file equitycoupon.hpp.

83{ return equityCurve_; }
+ Here is the caller graph for this function:

◆ fxIndex()

const QuantLib::ext::shared_ptr< FxIndex > & fxIndex ( ) const

fx index curve

Definition at line 85 of file equitycoupon.hpp.

85{ return fxIndex_; }
+ Here is the caller graph for this function:

◆ returnType()

EquityReturnType returnType ( ) const

the return type of the coupon

Definition at line 87 of file equitycoupon.hpp.

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

◆ dividendFactor()

Real dividendFactor ( ) const

are dividends scaled (e.g. to account for tax)

Definition at line 89 of file equitycoupon.hpp.

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

◆ fixingStartDate()

Date fixingStartDate ( ) const

The date at which the starting equity price is fixed.

Definition at line 91 of file equitycoupon.hpp.

91{ return fixingStartDate_; }
+ Here is the caller graph for this function:

◆ fixingEndDate()

Date fixingEndDate ( ) const

The date at which performance is measured.

Definition at line 93 of file equitycoupon.hpp.

93{ return fixingEndDate_; }
+ Here is the caller graph for this function:

◆ fixingDates()

std::vector< Date > fixingDates ( ) const

return both fixing dates

Definition at line 167 of file equitycoupon.cpp.

167 {
168 std::vector<Date> fixingDates;
169
170 fixingDates.push_back(fixingStartDate_);
171 fixingDates.push_back(fixingEndDate_);
172 // We may need a fixing date at the leg start date if it a notionalReset and the quantity is null
173 // Quantity is null if no initial price was given for the Swap
174 if (notionalReset_ && quantity_ == Null<Real>())
175 fixingDates.push_back(legFixingDate_);
176 return fixingDates;
177};
std::vector< Date > fixingDates() const
return both fixing dates
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialPrice()

Real initialPrice ( ) const

initial price

Definition at line 139 of file equitycoupon.cpp.

139 {
140 if (initialPrice_ != Null<Real>())
141 return initialPrice_;
142 else
143 return equityCurve_->fixing(fixingStartDate(), false, false);
144}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialPriceIsInTargetCcy()

bool initialPriceIsInTargetCcy ( ) const

initial price is in target ccy (if applicable, i.e. if fxIndex != null, otherwise ignored)

Definition at line 146 of file equitycoupon.cpp.

+ Here is the caller graph for this function:

◆ quantity()

Real quantity ( ) const

Number of equity shares held.

Definition at line 112 of file equitycoupon.cpp.

112 {
113 if (notionalReset_ && quantity_ == Null<Real>()) {
114 QL_REQUIRE(legInitialNotional_ != Null<Real>() && legFixingDate_ != Date(),
115 "leg initial notional and fixing date required to compute the missing quantity in case of a resetting equity leg");
116 quantity_ = legInitialNotional_ / equityCurve_->fixing(legFixingDate_, false, false);
117 }
118 return quantity_;
119}
+ Here is the caller graph for this function:

◆ fxRate()

Real fxRate ( ) const

FX conversion rate (or 1.0 if not applicable)

Definition at line 134 of file equitycoupon.cpp.

134 {
135 // fxRate applied if equity underlying currency differs from leg
136 return fxIndex_ ? fxIndex_->fixing(fixingStartDate_) : 1.0;
137}
+ Here is the caller graph for this function:

◆ fixingDate()

Date fixingDate ( ) const

This function is called for other coupon types.

Definition at line 105 of file equitycoupon.hpp.

105 {
106 QL_FAIL("Equity Coupons have 2 fixings, not 1.");
107 return Date();
108 }

◆ legInitialNotional()

Real legInitialNotional ( ) const

Initial notional of the equity leg, to compute quantity if not provided in the resetting case.

Definition at line 110 of file equitycoupon.hpp.

110{ return legInitialNotional_; }

◆ legFixingDate()

Date legFixingDate ( ) const

Fixing date of the first equity coupon, to compute quantity if not provided in the resetting case.

Definition at line 112 of file equitycoupon.hpp.

112{ return legFixingDate_; }

◆ update()

void update ( )
override

Definition at line 117 of file equitycoupon.hpp.

117{ notifyObservers(); }
+ Here is the caller graph for this function:

◆ accept()

void accept ( AcyclicVisitor &  v)
overridevirtual

Definition at line 148 of file equitycoupon.hpp.

148 {
149 Visitor<EquityCoupon>* v1 = dynamic_cast<Visitor<EquityCoupon>*>(&v);
150 if (v1 != 0)
151 v1->visit(*this);
152 else
153 Coupon::accept(v);
154}

◆ setPricer()

void setPricer ( const QuantLib::ext::shared_ptr< EquityCouponPricer > &  pricer)

Definition at line 103 of file equitycoupon.cpp.

103 {
104 if (pricer_)
105 unregisterWith(pricer_);
106 pricer_ = pricer;
107 if (pricer_)
108 registerWith(pricer_);
109 update();
110}
QuantLib::ext::shared_ptr< EquityCouponPricer > pricer() const
void update() override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pricer()

QuantLib::ext::shared_ptr< EquityCouponPricer > pricer ( ) const

Definition at line 156 of file equitycoupon.hpp.

156{ return pricer_; }
+ Here is the caller graph for this function:

Member Data Documentation

◆ pricer_

QuantLib::ext::shared_ptr<EquityCouponPricer> pricer_
protected

Definition at line 128 of file equitycoupon.hpp.

◆ fixingDays_

Natural fixingDays_
protected

Definition at line 129 of file equitycoupon.hpp.

◆ equityCurve_

QuantLib::ext::shared_ptr<QuantExt::EquityIndex2> equityCurve_
protected

Definition at line 130 of file equitycoupon.hpp.

◆ dayCounter_

DayCounter dayCounter_
protected

Definition at line 131 of file equitycoupon.hpp.

◆ returnType_

EquityReturnType returnType_
protected

Definition at line 132 of file equitycoupon.hpp.

◆ dividendFactor_

Real dividendFactor_
protected

Definition at line 133 of file equitycoupon.hpp.

◆ notionalReset_

bool notionalReset_
protected

Definition at line 134 of file equitycoupon.hpp.

◆ initialPrice_

Real initialPrice_
protected

Definition at line 135 of file equitycoupon.hpp.

◆ initialPriceIsInTargetCcy_

bool initialPriceIsInTargetCcy_
protected

Definition at line 136 of file equitycoupon.hpp.

◆ quantity_

Real quantity_
mutableprotected

Definition at line 137 of file equitycoupon.hpp.

◆ fixingStartDate_

Date fixingStartDate_
protected

Definition at line 138 of file equitycoupon.hpp.

◆ fixingEndDate_

Date fixingEndDate_
protected

Definition at line 139 of file equitycoupon.hpp.

◆ paymentLag_

Natural paymentLag_
protected

Definition at line 140 of file equitycoupon.hpp.

◆ fxIndex_

QuantLib::ext::shared_ptr<FxIndex> fxIndex_
protected

Definition at line 141 of file equitycoupon.hpp.

◆ legInitialNotional_

Real legInitialNotional_
protected

Definition at line 142 of file equitycoupon.hpp.

◆ legFixingDate_

Date legFixingDate_
protected

Definition at line 143 of file equitycoupon.hpp.