30 ext::shared_ptr<CashFlow>
31 createEquityCashFlow(
const Schedule& schedule,
32 const ext::shared_ptr<EquityIndex>& equityIndex,
34 const Calendar& paymentCalendar,
37 Date startDate = schedule.startDate();
38 Date endDate = schedule.endDate();
40 Calendar cal = paymentCalendar;
42 QL_REQUIRE(!schedule.calendar().empty(),
"Calendar in schedule cannot be empty");
43 cal = schedule.calendar();
46 cal.advance(endDate, paymentDelay,
Days, paymentConvention, schedule.endOfMonth());
47 return ext::make_shared<EquityCashFlow>(nominal, equityIndex, startDate, endDate,
51 template <
typename IndexType,
typename LegType>
52 Leg createInterestLeg(Schedule schedule,
53 const ext::shared_ptr<IndexType>& interestRateIndex,
55 const DayCounter& dayCounter,
58 const Calendar& paymentCalendar,
61 return LegType(std::move(schedule), interestRateIndex)
62 .withNotionals(nominal)
63 .withPaymentDayCounter(dayCounter)
65 .withGearings(gearing)
66 .withPaymentCalendar(paymentCalendar)
67 .withPaymentAdjustment(paymentConvention)
68 .withPaymentLag(paymentDelay);
73 ext::shared_ptr<EquityIndex> equityIndex,
74 ext::shared_ptr<InterestRateIndex> interestRateIndex,
84 :
Swap(2), equityIndex_(
std::move(equityIndex)),
85 interestRateIndex_(
std::move(interestRateIndex)), type_(type), nominal_(nominal),
86 schedule_(
std::move(schedule)), dayCounter_(
std::move(dayCounter)), margin_(margin),
87 gearing_(gearing), paymentCalendar_(
std::move(paymentCalendar)),
88 paymentConvention_(paymentConvention), paymentDelay_(paymentDelay) {
94 for (Leg::const_iterator i =
legs_[0].begin(); i <
legs_[0].end(); ++i)
107 QL_FAIL(
"unknown equity total return swap type");
114 ext::shared_ptr<EquityIndex> equityIndex,
115 const ext::shared_ptr<IborIndex>& interestRateIndex,
127 std::move(dayCounter),
130 std::move(paymentCalendar),
133 legs_[1] = createInterestLeg<IborIndex, IborLeg>(
136 for (Leg::const_iterator i =
legs_[1].begin(); i <
legs_[1].end(); ++i)
143 ext::shared_ptr<EquityIndex> equityIndex,
144 const ext::shared_ptr<OvernightIndex>& interestRateIndex,
156 std::move(dayCounter),
159 std::move(paymentCalendar),
162 legs_[1] = createInterestLeg<OvernightIndex, OvernightLeg>(
165 for (Leg::const_iterator i =
legs_[1].begin(); i <
legs_[1].end(); ++i)
190 const Spread basisPoint = 1.0e-4;
193 return -(
equityLegNPV() + exMarginInterestLegNpv) / interestLegBps;
Equity total return swap.
ext::shared_ptr< EquityIndex > equityIndex_
Real interestRateLegNPV() const
Calendar paymentCalendar_
Real equityLegNPV() const
BusinessDayConvention paymentConvention_
const Leg & equityLeg() const
const Leg & interestRateLeg() const
const ext::shared_ptr< InterestRateIndex > & interestRateIndex() const
EquityTotalReturnSwap(Type type, Real nominal, Schedule schedule, ext::shared_ptr< EquityIndex > equityIndex, const ext::shared_ptr< IborIndex > &interestRateIndex, DayCounter dayCounter, Rate margin, Real gearing=1.0, Calendar paymentCalendar=Calendar(), BusinessDayConvention paymentConvention=Unadjusted, Natural paymentDelay=0)
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Real legBPS(Size j) const
const Leg & leg(Size j) const
Real legNPV(Size j) const
std::vector< Real > payer_
base class for equity indexes
Equity total return swap.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
BusinessDayConvention
Business Day conventions.
unsigned QL_INTEGER Natural
positive integer
Real Spread
spreads on interest rates
Coupon paying a Libor-type index.
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
coupon paying the compounded daily overnight rate