Proposed change to RangeAccrual classes

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Proposed change to RangeAccrual classes

Andreas Spengler-2
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
Reply | Threaded
Open this post in threaded view
|

Re: Proposed change to RangeAccrual classes

Luigi Ballabio
On Wed, 2010-12-22 at 14:17 +0100, Andreas Spengler wrote:

> 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...]

You might consider writing a different coupon class instead of adding
another parameter to the existing one---especially since the formula for
pricing the coupon with alternative spread would be different (a sum of
digital options on Libor, possibly?)  Trying to shoehorn both inside the
pricer might be a bit of a tall order, seeing as it's quite complex
already.  Also, inheriting your new class from Coupon instead of
FloatingRateCoupon might allow you to skip the pricer machinery and just
override the rate() method, which would be simpler.  You might switch to
a pricer later, if you need more methods to price the coupon.

Luigi


--

A debugged program is one for which you have not yet found the
conditions that make it fail.
-- Jerry Ogdin



------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to
best implement a security strategy that keeps consumers' information secure
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev