Frn Bonds in Python

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Frn Bonds in Python

Lluis Pujol Bajador

Hi,

 

Finally I managed to get FRN Bonds working in Python/SWIG.

 

To test it, I translated the C++ Bonds example to Python.

 

I attach it just in case anyone is interested on it. Feel free to include it in Quantlib-SWIG.

 

To get it working you need to include the couponpricer interface attached and make the following changes to other interfaces files.

 

1. piecewiseyieldcurve.i:  include at the end of the file the following.

 

export_piecewise_curve(PiecewiseLogLinearDiscount,Discount,LogLinear)

 

2. make ql.i aware of the couponpricer interface.

 

%include couponpricer.i

 

3. Substitute first constructor of SwapRateHelperPtr in ratehelpers.i  for the following.

 

SwapRateHelperPtr(
                const Handle<Quote>& rate,
                const Period& tenor,
                const Calendar& calendar,
                Frequency fixedFrequency,
                BusinessDayConvention fixedConvention,
                const DayCounter& fixedDayCount,
                const IborIndexPtr& index,
  const Handle<Quote>& spread = Handle<Quote>(),
                const Period& fwdStart = 0*Days) {
            boost::shared_ptr<IborIndex> libor =
                boost::dynamic_pointer_cast<IborIndex>(index);
            return new SwapRateHelperPtr(
                new SwapRateHelper(rate, tenor, calendar,
                                   fixedFrequency, fixedConvention,
                                   fixedDayCount, libor,spread,fwdStart));

 

I think that I haven't changed anything else. If you get an error let me know.

 

Lluís



------------------------------------------------------------------------------


_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

couponpricer.i (2K) Download Attachment
bonds.py (19K) Download Attachment