Some q's

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

Some q's

Andre Louw-2
Hi,

1) Do you have an implementation of float/float i.e 'Basis' swaps? If not,
how difficult to implement?
2) If I have a strip of discount factors, is it possible to use it to
instantiate a termstructure and subsequently use in pricing a swap for
instance?

Thanx,
Andre
 
-------------------------------------------------------------------------
This e-mail is intended only for the use of the individual or entity named
above and may contain information that is confidential and privileged,
proprietary to the company and protected by law. If you are not the intended
recipient, you are hereby notified that any dissemination, distribution or
copying of this e-mail is strictly prohibited. Opinions, conclusions and
other information in this message that do not relate to the official
business of our company shall be understood as neither given nor endorsed by
it.


Reply | Threaded
Open this post in threaded view
|

Re: Some q's

Luigi Ballabio-4
Hi Andre,

At 11:59 AM 3/22/02 +0200, Andre Louw wrote:
>1) Do you have an implementation of float/float i.e 'Basis' swaps? If not,
>how difficult to implement?

Warning: rant ahead.
Right now the basic brick is missing, namely, a decent implementation of an
indexed coupon. What we have is a par coupon which we extended a bit, thus
making it neither a coupon really at par nor a full-fledged indexed coupon.
I've been intending to write a mail to the list asking for counsel, but
something always got in the way. I'll try and come up with something.
End of rant.

Once we have such a coupon, a basis swap is a walk in the park. As a matter
of fact, it shouldn't take more than a couple of hours to hack it up right
now, but I would prefer to think a bit about this indexed coupon thing first.

>2) If I have a strip of discount factors, is it possible to use it to
>instantiate a termstructure and subsequently use in pricing a swap for
>instance?

It's not there right now. But it is only a matter of putting pieces
together, and is sketched below. Completing it (and correcting bugs) is
left as an exercise to the reader. And once it is finished, you can submit
it, too...

Bye,
         Luigi

class MyDiscountCurve : public DiscountTermStructure {
   public:
     MyDiscountCurve(const Date& today, const Calendar& cal,
                     int settlementDays, const DayCounter& dc,
                     Currency, const std::vector<Date>& dates,
                     const std::vector<DiscountFactor>& discounts)
     : (copy the data members) {
         settlementDate_ = calendar_.advance(today_,settlementDays_,Days);
         times_.resize(dates.size());
         for (int i=0; i<dates.size(); i++)
             times_[i] = dayCounter_.yearFraction(settlementDate_,dates_[i]);
         interpolation_ = Handle<Math::Interpolation>(
             new Math::LinearInterpolation(times_.begin(),times_.end(),
                                           discounts.begin(),true));
     }
     Date todaysDate() const { return today_; }
     // same for settlement days/date, calendar, day counter, currency
     // min/max date are settlement and last element of dates_
     // min/max time are 0.0 and last element of times_
   private:
     // data members: today, calendar, settlementDays, settlementDate,
     //               dayCounter, currency, dates, times, discounts
     Handle<Math::Interpolation> interpolation_;
     // implementation:
     DiscountFactor discountImpl(Time t, bool extrapolate = false) const {
         // if !extrapolate check range
         return interpolation_(t);
     }
};