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

Pricer for equity margin coupons. More...

#include <qle/cashflows/equitymargincouponpricer.hpp>

+ Inheritance diagram for EquityMarginCouponPricer:
+ Collaboration diagram for EquityMarginCouponPricer:

Public Member Functions

virtual ~EquityMarginCouponPricer ()
 
Interface
virtual Rate rate () const
 
virtual void initialize (const EquityMarginCoupon &coupon)
 

Observer interface

const EquityMarginCouponcoupon_
 
Real marginFactor_
 
InterestRate fixedRate_
 
QuantLib::ext::shared_ptr< EquityIndex2equityCurve_
 
QuantLib::ext::shared_ptr< FxIndexfxIndex_
 
bool isTotalReturn_
 
Real dividendFactor_
 
Real initialPrice_
 
virtual void update () override
 

Detailed Description

Pricer for equity margin coupons.

Definition at line 36 of file equitymargincouponpricer.hpp.

Constructor & Destructor Documentation

◆ ~EquityMarginCouponPricer()

virtual ~EquityMarginCouponPricer ( )
virtual

Definition at line 38 of file equitymargincouponpricer.hpp.

38{}

Member Function Documentation

◆ rate()

Rate rate ( ) const
virtual

Definition at line 23 of file equitymargincouponpricer.cpp.

23 {
24
25 Calendar calendar = equityCurve_->fixingCalendar();
26
27 Date startDate = coupon_->fixingStartDate();
28 // the final date in the period is treated differently
29 Date endDate = equityCurve_->fixingCalendar().advance(coupon_->fixingEndDate(), -1 * Days);
30
31 Real equityPrice = equityCurve_->fixing(endDate, false, false);
32 Real dividends = 0.0;
33 Real fx = fxIndex_ ? fxIndex_->fixing(coupon_->fixingEndDate()) : 1.0;
34 // Dividends that are already fixed dividends + yield accrued over remaining period.
35 // yield accrued = Forward without dividend yield - Forward with dividend yield
36 if (isTotalReturn_) {
37 // projected dividends from today until the fixing end date
38 dividends = equityCurve_->fixing(endDate, false, true) -
39 equityCurve_->fixing(endDate, false, false);
40 // subtract projected dividends from today until the fixing start date
41 if (coupon_->fixingStartDate() > Settings::instance().evaluationDate()) {
42 dividends -= (equityCurve_->fixing(startDate, false, true) -
43 equityCurve_->fixing(startDate, false, false));
44 }
45 // add historical dividends
46 dividends += equityCurve_->dividendsBetweenDates(startDate, endDate);
47 }
48
49 Real rate = (equityPrice + dividends * dividendFactor_) * fx * fixedRate_.dayCounter().yearFraction(startDate, endDate) * marginFactor_;
50
51 // on the valuation date we return the initialPrice
52 startDate = endDate;
53 endDate = coupon_->fixingEndDate();
54 fx = fxIndex_ ? fxIndex_->fixing(coupon_->fixingEndDate()) : 1.0;
55 rate += initialPrice_ * fx * fixedRate_.dayCounter().yearFraction(startDate, endDate) * marginFactor_;
56
57 return rate * fixedRate_;
58}
Date fixingEndDate() const
The date at which performance is measured.
Date fixingStartDate() const
The date at which the starting equity price is fixed.
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
QuantLib::ext::shared_ptr< EquityIndex2 > equityCurve_
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialize()

void initialize ( const EquityMarginCoupon coupon)
virtual

Definition at line 60 of file equitymargincouponpricer.cpp.

60 {
61
62 coupon_ = &coupon;
63
64 marginFactor_ = coupon.marginFactor();
65 fixedRate_ = coupon.fixedRate();
66 equityCurve_ = QuantLib::ext::dynamic_pointer_cast<EquityIndex2>(coupon.equityCurve());
67 fxIndex_ = QuantLib::ext::dynamic_pointer_cast<FxIndex>(coupon.fxIndex());
68 isTotalReturn_ = coupon.isTotalReturn();
69 dividendFactor_ = coupon.dividendFactor();
70 initialPrice_ = coupon.initialPrice();
71}
+ Here is the call graph for this function:

◆ update()

virtual void update ( )
overridevirtual

Definition at line 47 of file equitymargincouponpricer.hpp.

47{ notifyObservers(); }

Member Data Documentation

◆ coupon_

const EquityMarginCoupon* coupon_
protected

Definition at line 50 of file equitymargincouponpricer.hpp.

◆ marginFactor_

Real marginFactor_
protected

Definition at line 51 of file equitymargincouponpricer.hpp.

◆ fixedRate_

InterestRate fixedRate_
protected

Definition at line 52 of file equitymargincouponpricer.hpp.

◆ equityCurve_

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

Definition at line 53 of file equitymargincouponpricer.hpp.

◆ fxIndex_

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

Definition at line 54 of file equitymargincouponpricer.hpp.

◆ isTotalReturn_

bool isTotalReturn_
protected

Definition at line 55 of file equitymargincouponpricer.hpp.

◆ dividendFactor_

Real dividendFactor_
protected

Definition at line 56 of file equitymargincouponpricer.hpp.

◆ initialPrice_

Real initialPrice_
protected

Definition at line 57 of file equitymargincouponpricer.hpp.