Login  Register

Re: Python Saving Interest Rate Curve Objects to File

Posted by Luigi Ballabio on Sep 26, 2016; 7:16pm
URL: http://quantlib.414.s1.nabble.com/Python-Saving-Interest-Rate-Curve-Objects-to-File-tp17751p17758.html

You can instantiate an interpolated curve. The actual type depends on which kind of curve you bootstrapped to begin with. If you used a PiecewiseFlatForward and you stored the (date, forward) nodes, you can use them to create a ForwardCurve instance. If you bootstrapped a curve that interpolates discounts or zero yields, you might have to add the corresponding class to the SWIG interfaces and export it.  In general: first, look at piecewiseyieldcurve.i and find out what kind of curve you used; for instance, the lines 

    export_piecewise_curve(PiecewiseFlatForward,ForwardRate,BackwardFlat);
    export_piecewise_curve(PiecewiseLogCubicDiscount,Discount,MonotonicLogCubic);

tell you that PiecewiseFlatForward uses BackwardFlat interpolation on (instantaneous) forward rates, and PiecewiseLogCubicDiscount uses MonotonicLogCubic interpolation on discounts.  Then look into forwardcurve.i if you're interpolating forwards, discountcurve.i for discounts and zerocurve.i for zero rates. If you find a line in there corresponding to the interpolation you used for the bootstrap, you're all set; for instance, if you used PiecewiseFlatForward, you'll see 

    export_forward_curve(ForwardCurve,BackwardFlat);

that tells you that you can use ForwardCurve, which has the same interpolation.  If there's no such line, you'll have to add it; for instance, if you used PiecewiseLogCubicDiscount, you'll have to add a line like

    export_discount_curve(MyDiscountCurve,MonotonicLogCubic);

to discount.i and rebuild the interfaces (MonotonicLogCubic is the interpolation; MyDiscountCurve is the name that you want to use for the curve and you can change it to whatever you want).

Hope this helps,
    Luigi


On Mon, Sep 26, 2016 at 8:51 PM TSchulz85 <[hidden email]> wrote:
Hi,

I managed to save the nodes into a file with the method you suggested
(converting to datetime).
What would be now the best method to recreate the curves with the nodes? Is
there a ready-to-go method or should I for example convert the discount
factors into an equivalent of e.g. depo rates and then bootstrap the curve
again?





--
View this message in context: http://quantlib.10058.n7.nabble.com/Python-Saving-Interest-Rate-Curve-Objects-to-File-tp17751p17757.html
Sent from the quantlib-users mailing list archive at Nabble.com.

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


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

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