Proposed change to RangeAccrual classes

Posted by Andreas Spengler-2 on
URL: http://quantlib.414.s1.nabble.com/Proposed-change-to-RangeAccrual-classes-tp8905.html

Hi,

I am currently looking into the classes surrounding the RangeAccrualLeg;
as there are variations of those on the market which (at times) pay out a
portion of a fixed coupon instead of a portion of an index, I would
propose the addition of an "alternativeFixedRate" member as outlined
below.

Could someone give me a hint as to how I would integrate this alternative
into the "RangeAccrualPricer"s; also, how would I go about integrating the
spread into the accrual formula? [(3M-Libor + x% spread) * n/N - where n
is the # of days in the period that satisfy the range condition and N is
the total # of days in the period...]

Rgds,

Andreas


*** rangeaccrual.hpp    2010-04-19 12:49:17.000000000 +0200
--- rangeaccrual.hpp.new        2010-12-22 13:08:23.000000000 +0100
***************
*** 45,50 ****
--- 45,51 ----
                  const Date& paymentDate,
                  Real nominal,
                  const boost::shared_ptr<IborIndex>& index,
+                 Rate alternativeFixedRate,
                  const Date& startDate,
                  const Date& endDate,
                  Natural fixingDays,
***************
*** 59,64 ****
--- 60,68 ----

          Real startTime() const {return startTime_; }
          Real endTime() const {return endTime_; }
+
+         Rate alternativeFixedRate() const {return alternativeFixedRate_; }
+
          Real lowerTrigger() const {return lowerTrigger_; }
          Real upperTrigger() const {return upperTrigger_; }
          Size observationsNo() const {return observationsNo_; }
***************
*** 88,93 ****
--- 92,99 ----
          std::vector<Real> observationTimes_;
          Size observationsNo_;

+         Rate alternativeFixedRate_;
+
          Real lowerTrigger_;
          Real upperTrigger_;
       };
***************
*** 113,118 ****
--- 119,125 ----
          std::vector<Real> observationTimes_;               // U
          std::vector<Real> initialValues_;
          Size observationsNo_;
+         Rate alternativeFixedRate_;
          Real lowerTrigger_;
          Real upperTrigger_;
          Real discount_;
***************
*** 213,218 ****
--- 220,227 ----
          RangeAccrualLeg& withGearings(const std::vector<Real>& gearings);
          RangeAccrualLeg& withSpreads(Spread spread);
          RangeAccrualLeg& withSpreads(const std::vector<Spread>& spreads);
+         RangeAccrualLeg& withAlternativeFixedRates(Rate fixedRate);
+         RangeAccrualLeg& withAlternativeFixedRates(const
std::vector<Rate>& fixedRates);
          RangeAccrualLeg& withLowerTriggers(Rate trigger);
          RangeAccrualLeg& withLowerTriggers(const std::vector<Rate>&
triggers);
          RangeAccrualLeg& withUpperTriggers(Rate trigger);
***************
*** 229,234 ****
--- 238,244 ----
          std::vector<Natural> fixingDays_;
          std::vector<Real> gearings_;
          std::vector<Spread> spreads_;
+         std::vector<Rate> alternativeFixedRates_;
          std::vector<Rate> lowerTriggers_, upperTriggers_;
          Period observationTenor_;
          BusinessDayConvention observationConvention_;



*** rangeaccrual.cpp    2010-04-19 12:49:17.000000000 +0200
--- rangeaccrual.cpp.new        2010-12-22 13:11:48.000000000 +0100
***************
*** 39,44 ****
--- 39,45 ----
                  const Date& paymentDate,
                  Real nominal,
                  const boost::shared_ptr<IborIndex>& index,
+                 Rate alternativeFixedRate,
                  const Date& startDate,                                
// S
                  const Date& endDate,                                  
// T
                  Natural fixingDays,
***************
*** 55,60 ****
--- 56,62 ----
                           fixingDays, index, gearing, spread,
                           refPeriodStart, refPeriodEnd, dayCounter),
      observationsSchedule_(observationsSchedule),
+     alternativeFixedRate_(alternativeFixedRate),
      lowerTrigger_(lowerTrigger),
      upperTrigger_(upperTrigger){

***************
*** 94,101 ****

      Real RangeAccrualFloatersCoupon::priceWithoutOptionality(
             const Handle<YieldTermStructure>& discountingCurve) const {
!         return accrualPeriod() * (gearing_*indexFixing()+spread_) *
!                nominal() * discountingCurve->discount(date());
      }


--- 96,109 ----

      Real RangeAccrualFloatersCoupon::priceWithoutOptionality(
             const Handle<YieldTermStructure>& discountingCurve) const {
!
!         if (alternativeFixedRate_ > .0) {
!             return accrualPeriod() * (alternativeFixedRate_  + spread_) *
!                 nominal() * discountingCurve->discount(date());
!         } else {
!             return accrualPeriod() * (gearing_*indexFixing() + spread_) *
!                 nominal() * discountingCurve->discount(date());
!         }
      }


***************
*** 122,129 ****
--- 130,140 ----
          startTime_ = coupon_->startTime();
          endTime_ = coupon_->endTime();
          observationTimes_ = coupon_->observationTimes();
+
+         alternativeFixedRate_ = coupon_->alternativeFixedRate();
          lowerTrigger_ = coupon_->lowerTrigger();
          upperTrigger_ = coupon_->upperTrigger();
+
          observationsNo_ = coupon_->observationsNo();

          const std::vector<Date> &observationDates =
***************
*** 590,595 ****
--- 601,616 ----
          return *this;
      }

+     RangeAccrualLeg& RangeAccrualLeg::withAlternativeFixedRates(Rate
fixedRate) {
+         alternativeFixedRates_ = std::vector<Rate>(1, fixedRate);
+         return *this;
+     }
+
+     RangeAccrualLeg& RangeAccrualLeg::withAlternativeFixedRates(const
std::vector<Rate>& fixedRates) {
+         alternativeFixedRates_ = fixedRates;
+         return *this;
+     }
+
      RangeAccrualLeg& RangeAccrualLeg::withLowerTriggers(Rate trigger) {
          lowerTriggers_ = std::vector<Rate>(1,trigger);
          return *this;
***************
*** 690,695 ****
--- 711,717 ----
                              paymentDate,
                              detail::get(notionals_, i, Null<Real>()),
                              index_,
+                             detail::get(alternativeFixedRates_, i, 0.0),
                              start, end,
                              detail::get(fixingDays_, i, 2),
                              paymentDayCounter_,




------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months.  Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev