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

equity coupon More...

#include <qle/cashflows/equitymargincoupon.hpp>

+ Inheritance diagram for EquityMarginCoupon:
+ Collaboration diagram for EquityMarginCoupon:

Public Member Functions

 EquityMarginCoupon (const Date &paymentDate, Real nominal, Rate rate, Real marginFactor, const Date &startDate, const Date &endDate, Natural fixingDays, const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &equityCurve, const DayCounter &dayCounter, bool isTotalReturn=false, 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(), Real multiplier=Null< Real >(), const QuantLib::ext::shared_ptr< FxIndex > &fxIndex=nullptr, const bool initialPriceIsInTargetCcy=false)
 
Coupon interface
DayCounter dayCounter () const override
 
Real accruedAmount (const Date &) const override
 
Real amount () 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...
 
bool isTotalReturn () const
 total return or price return? 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 marginFactor () const
 
InterestRate fixedRate () const
 
Real multiplier () const
 
Observer interface
void update () override
 

Visitability

QuantLib::ext::shared_ptr< EquityMarginCouponPricerpricer_
 
Natural fixingDays_
 
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2equityCurve_
 
DayCounter dayCounter_
 
bool isTotalReturn_
 
Real dividendFactor_
 
bool notionalReset_
 
Real initialPrice_
 
bool initialPriceIsInTargetCcy_
 
Real quantity_
 
Date fixingStartDate_
 
Date fixingEndDate_
 
Natural paymentLag_
 
QuantLib::ext::shared_ptr< FxIndexfxIndex_
 
Real marginFactor_
 
InterestRate fixedRate_
 
Real multiplier_
 
virtual void accept (AcyclicVisitor &) override
 
void setPricer (const QuantLib::ext::shared_ptr< EquityMarginCouponPricer > &)
 
QuantLib::ext::shared_ptr< EquityMarginCouponPricerpricer () const
 

Detailed Description

equity coupon

Definition at line 48 of file equitymargincoupon.hpp.

Constructor & Destructor Documentation

◆ EquityMarginCoupon()

EquityMarginCoupon ( const Date &  paymentDate,
Real  nominal,
Rate  rate,
Real  marginFactor,
const Date &  startDate,
const Date &  endDate,
Natural  fixingDays,
const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &  equityCurve,
const DayCounter &  dayCounter,
bool  isTotalReturn = false,
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(),
Real  multiplier = Null<Real>(),
const QuantLib::ext::shared_ptr< FxIndex > &  fxIndex = nullptr,
const bool  initialPriceIsInTargetCcy = false 
)

Definition at line 28 of file equitymargincoupon.cpp.

34 : Coupon(paymentDate, nominal, startDate, endDate, refPeriodStart, refPeriodEnd, exCouponDate),
39 fixedRate_(InterestRate(rate, dayCounter, Simple, Annual)), multiplier_(multiplier) {
40
41 QL_REQUIRE(dividendFactor_ > 0.0, "Dividend factor should not be negative. It is expected to be between 0 and 1.");
42 QL_REQUIRE(equityCurve_, "Equity underlying an equity swap coupon cannot be empty.");
43
44 // If a fixing start / end date is provided, use these
45 // else adjust the start/endDate by the FixingDays - defaulted to 0
46 if (fixingStartDate_ == Date())
48 equityCurve_->fixingCalendar().advance(startDate, -static_cast<Integer>(fixingDays_), Days, Preceding);
49
50 if (fixingEndDate_ == Date())
52 equityCurve_->fixingCalendar().advance(endDate, -static_cast<Integer>(fixingDays_), Days, Preceding);
53
54 registerWith(equityCurve_);
55 registerWith(fxIndex_);
56 registerWith(Settings::instance().evaluationDate());
57
58 QL_REQUIRE(!notionalReset_ || quantity_ != Null<Real>(), "EquityCoupon: quantity required if notional resets");
59 QL_REQUIRE(notionalReset_ || nominal_ != Null<Real>(),
60 "EquityCoupon: notional required if notional does not reset");
61
62}
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > equityCurve_
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > & equityCurve() const
equity reference rate curve
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.
DayCounter dayCounter() const override
bool isTotalReturn() const
total return or price return?
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

◆ dayCounter()

DayCounter dayCounter ( ) const
override

Definition at line 64 of file equitymargincoupon.hpp.

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

◆ accruedAmount()

Real accruedAmount ( const Date &  d) const
override

Definition at line 96 of file equitymargincoupon.cpp.

96 {
97 if (d <= accrualStartDate_ || d > paymentDate_) {
98 return 0.0;
99 } else {
100 Time fullPeriod = dayCounter().yearFraction(accrualStartDate_, accrualEndDate_, refPeriodStart_, refPeriodEnd_);
101 Time thisPeriod =
102 dayCounter().yearFraction(accrualStartDate_, std::min(d, accrualEndDate_), refPeriodStart_, refPeriodEnd_);
103 return nominal() * rate() * thisPeriod / fullPeriod;
104 }
105}
+ Here is the call graph for this function:

◆ amount()

Real amount ( ) const
override

Definition at line 116 of file equitymargincoupon.cpp.

116 {
117 return rate() * nominal() * multiplier();
118}
+ Here is the call graph for this function:

◆ rate()

Rate rate ( ) const
override

Definition at line 120 of file equitymargincoupon.cpp.

120 {
121 QL_REQUIRE(pricer_, "pricer not set");
122 pricer_->initialize(*this);
123 return pricer_->rate();
124}
QuantLib::ext::shared_ptr< EquityMarginCouponPricer > pricer_
+ Here is the caller graph for this function:

◆ nominal()

Real nominal ( ) const
override

Definition at line 73 of file equitymargincoupon.cpp.

73 {
74 if (notionalReset_) {
75 Real mult = (initialPrice_ == 0) ? 1 : initialPrice();
76 return mult * (initialPriceIsInTargetCcy_ ? 1.0 : fxRate()) * quantity_;
77 } else {
78 return nominal_;
79 }
80}
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 76 of file equitymargincoupon.hpp.

76{ 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 78 of file equitymargincoupon.hpp.

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

◆ isTotalReturn()

bool isTotalReturn ( ) const

total return or price return?

Definition at line 80 of file equitymargincoupon.hpp.

80{ return isTotalReturn_; }
+ Here is the caller graph for this function:

◆ dividendFactor()

Real dividendFactor ( ) const

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

Definition at line 82 of file equitymargincoupon.hpp.

82{ 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 84 of file equitymargincoupon.hpp.

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

◆ fixingEndDate()

Date fixingEndDate ( ) const

The date at which performance is measured.

Definition at line 86 of file equitymargincoupon.hpp.

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

◆ fixingDates()

std::vector< Date > fixingDates ( ) const

return both fixing dates

Definition at line 107 of file equitymargincoupon.cpp.

107 {
108 std::vector<Date> fixingDates;
109
110 fixingDates.push_back(fixingStartDate_);
111 fixingDates.push_back(fixingEndDate_);
112
113 return fixingDates;
114};
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 87 of file equitymargincoupon.cpp.

87 {
88 if (initialPrice_ != Null<Real>())
89 return initialPrice_;
90 else
91 return equityCurve_->fixing(fixingStartDate(), false, false);
92}
+ 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 94 of file equitymargincoupon.cpp.

◆ quantity()

Real quantity ( ) const

Number of equity shares held.

Definition at line 94 of file equitymargincoupon.hpp.

94{ return quantity_; }

◆ fxRate()

Real fxRate ( ) const

FX conversion rate (or 1.0 if not applicable)

Definition at line 82 of file equitymargincoupon.cpp.

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

◆ fixingDate()

Date fixingDate ( ) const

This function is called for other coupon types.

Definition at line 98 of file equitymargincoupon.hpp.

98 {
99 QL_FAIL("Equity Coupons have 2 fixings, not 1.");
100 return Date();
101 }

◆ marginFactor()

Real marginFactor ( ) const

Definition at line 102 of file equitymargincoupon.hpp.

102{ return marginFactor_; }
+ Here is the caller graph for this function:

◆ fixedRate()

InterestRate fixedRate ( ) const

Definition at line 103 of file equitymargincoupon.hpp.

103{ return fixedRate_; }
+ Here is the caller graph for this function:

◆ multiplier()

Real multiplier ( ) const

Definition at line 104 of file equitymargincoupon.hpp.

104{ return multiplier_; }
+ Here is the caller graph for this function:

◆ update()

void update ( )
override

Definition at line 109 of file equitymargincoupon.hpp.

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

◆ accept()

void accept ( AcyclicVisitor &  v)
overridevirtual

Definition at line 142 of file equitymargincoupon.hpp.

142 {
143 Visitor<EquityMarginCoupon>* v1 = dynamic_cast<Visitor<EquityMarginCoupon>*>(&v);
144 if (v1 != 0)
145 v1->visit(*this);
146 else
147 Coupon::accept(v);
148}

◆ setPricer()

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

Definition at line 64 of file equitymargincoupon.cpp.

64 {
65 if (pricer_)
66 unregisterWith(pricer_);
68 if (pricer_)
69 registerWith(pricer_);
70 update();
71}
QuantLib::ext::shared_ptr< EquityMarginCouponPricer > pricer() const
+ Here is the call graph for this function:

◆ pricer()

QuantLib::ext::shared_ptr< EquityMarginCouponPricer > pricer ( ) const
+ Here is the caller graph for this function:

Member Data Documentation

◆ pricer_

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

Definition at line 121 of file equitymargincoupon.hpp.

◆ fixingDays_

Natural fixingDays_
protected

Definition at line 122 of file equitymargincoupon.hpp.

◆ equityCurve_

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

Definition at line 123 of file equitymargincoupon.hpp.

◆ dayCounter_

DayCounter dayCounter_
protected

Definition at line 124 of file equitymargincoupon.hpp.

◆ isTotalReturn_

bool isTotalReturn_
protected

Definition at line 125 of file equitymargincoupon.hpp.

◆ dividendFactor_

Real dividendFactor_
protected

Definition at line 126 of file equitymargincoupon.hpp.

◆ notionalReset_

bool notionalReset_
protected

Definition at line 127 of file equitymargincoupon.hpp.

◆ initialPrice_

Real initialPrice_
protected

Definition at line 128 of file equitymargincoupon.hpp.

◆ initialPriceIsInTargetCcy_

bool initialPriceIsInTargetCcy_
protected

Definition at line 129 of file equitymargincoupon.hpp.

◆ quantity_

Real quantity_
protected

Definition at line 130 of file equitymargincoupon.hpp.

◆ fixingStartDate_

Date fixingStartDate_
protected

Definition at line 131 of file equitymargincoupon.hpp.

◆ fixingEndDate_

Date fixingEndDate_
protected

Definition at line 132 of file equitymargincoupon.hpp.

◆ paymentLag_

Natural paymentLag_
protected

Definition at line 133 of file equitymargincoupon.hpp.

◆ fxIndex_

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

Definition at line 134 of file equitymargincoupon.hpp.

◆ marginFactor_

Real marginFactor_
protected

Definition at line 135 of file equitymargincoupon.hpp.

◆ fixedRate_

InterestRate fixedRate_
protected

Definition at line 136 of file equitymargincoupon.hpp.

◆ multiplier_

Real multiplier_
protected

Definition at line 137 of file equitymargincoupon.hpp.