@@ -112,8 +112,8 @@ void EquityCoupon::setPricer(const boost::shared_ptr<EquityCouponPricer>& pricer
112112Real EquityCoupon::quantity () const {
113113 if (notionalReset_ && quantity_ == Null<Real>()) {
114114 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 );
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 );
117117 }
118118 return quantity_;
119119}
@@ -169,7 +169,9 @@ std::vector<Date> EquityCoupon::fixingDates() const {
169169
170170 fixingDates.push_back (fixingStartDate_);
171171 fixingDates.push_back (fixingEndDate_);
172- if (initialPrice_ == Null<Real>())
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>())
173175 fixingDates.push_back (legFixingDate_);
174176 return fixingDates;
175177};
@@ -289,29 +291,29 @@ EquityLeg::operator Leg() const {
289291 quantity = quantity_;
290292 QL_REQUIRE (notionals_.empty (), " EquityLeg: notional and quantity are given at the same time" );
291293 } else {
292- // If we have a notional, but no quantity is given:
293- // a) Compute quantity from notional and initial price
294- // b) If initial price is missing, leave quantity undefined here:
295- // The coupon will compute it from legInitialNotional=notional and legFixingDate
296- QL_REQUIRE (!notionals_.empty (), " EquityLeg: can not compute qunantity, since no notional is given" );
297- QL_REQUIRE (fxIndex_ == nullptr || initialPriceIsInTargetCcy_,
298- " EquityLeg: can not compute quantity from nominal when fx conversion is required" );
299- notional = notionals_.front ();
300- legInitialNotional = notional;
301- if (initialPrice_ != Null<Real>())
302- quantity = (initialPrice_ == 0 ) ? notional : notional / initialPrice_;
303- }
294+ // If we have a notional, but no quantity is given:
295+ // a) Compute quantity from notional and initial price
296+ // b) If initial price is missing, leave quantity undefined here:
297+ // The coupon will compute it from legInitialNotional=notional and legFixingDate
298+ QL_REQUIRE (!notionals_.empty (), " EquityLeg: can not compute qunantity, since no notional is given" );
299+ QL_REQUIRE (fxIndex_ == nullptr || initialPriceIsInTargetCcy_,
300+ " EquityLeg: can not compute quantity from nominal when fx conversion is required" );
301+ notional = notionals_.front ();
302+ legInitialNotional = notional;
303+ if (initialPrice_ != Null<Real>())
304+ quantity = (initialPrice_ == 0 ) ? notional : notional / initialPrice_;
305+ }
304306 } else {
305307 if (!notionals_.empty ()) {
306308 QL_REQUIRE (quantity_ == Null<Real>(), " EquityLeg: notional and quantity are given at the same time" );
307309 // notional is determined below in the loop over the periods
308- legInitialNotional = notionals_.front ();
310+ legInitialNotional = notionals_.front ();
309311 } else {
310- QL_REQUIRE (initialPrice_ != Null<Real>(), " EquityLeg: can not compute notional, since no intialPrice is given" );
311- QL_REQUIRE (quantity_ != Null<Real>(), " EquityLeg: can not compute notional, since no quantity is given" );
312- QL_REQUIRE (fxIndex_ == nullptr || initialPriceIsInTargetCcy_,
313- " EquityLeg: can not compute notional from quantity when fx conversion is required" );
314- notional = (initialPrice_ == 0 ) ? quantity_ : quantity_ * initialPrice_;
312+ QL_REQUIRE (initialPrice_ != Null<Real>(), " EquityLeg: can not compute notional, since no intialPrice is given" );
313+ QL_REQUIRE (quantity_ != Null<Real>(), " EquityLeg: can not compute notional, since no quantity is given" );
314+ QL_REQUIRE (fxIndex_ == nullptr || initialPriceIsInTargetCcy_,
315+ " EquityLeg: can not compute notional from quantity when fx conversion is required" );
316+ notional = (initialPrice_ == 0 ) ? quantity_ : quantity_ * initialPrice_;
315317 }
316318 }
317319
0 commit comments