|
From: Dirk E. <ed...@de...> - 2009-10-17 15:50:08
|
While working on RQuantLib [1], Khanh and I discovered a number of numerical
issues with Cubic interpolation on yield curves. The RQuantLib side of the
code that triggers it is actually pretty old and used to run so I am confused
as to when this changed.
A relatively simple way to trigger the same issue is to modify the
swapvaluation.cpp example as follows:
edd@ron:~/svn/quantlib/Examples/Swap$ diff -u swapvaluation.cpp.orig swapvaluation.cpp
--- swapvaluation.cpp.orig 2008-08-01 03:55:43.000000000 -0500
+++ swapvaluation.cpp 2009-10-17 10:08:42.000000000 -0500
@@ -316,7 +316,7 @@
depoSwapInstruments.push_back(s10y);
depoSwapInstruments.push_back(s15y);
boost::shared_ptr<YieldTermStructure> depoSwapTermStructure(
- new PiecewiseYieldCurve<Discount,LogLinear>(
+ new PiecewiseYieldCurve<Discount,Cubic>(
settlementDate, depoSwapInstruments,
termStructureDayCounter,
std::vector<Handle<Quote> >(),
and you get to trigger the bug as easily as
edd@ron:~/svn/quantlib/Examples/Swap$ g++ -o newswap swapvaluation.cpp -lQuantLib -lm && ./newswap
Today: Monday, September 20th, 2004
Settlement date: Wednesday, September 22nd, 2004
====================================================================
5-year market swap-rate = 4.43 %
====================================================================
5-years swap paying 4.00 %
term structure | net present value | fair spread | fair fixed rate |
--------------------------------------------------------------------
1st iteration: could not bootstrap the 1st instrument, maturity September 29th, 2004: root not bracketed: f[2.22045e-16,1] -> [1.116106e+18,3.820000e-02]
edd@ron:~/svn/quantlib/Examples/Swap$
We used to do this quite regularly and combine Discount with Linear,
LogLinear and Cubic with no issues. Now it seems to throw errors. Should we
stop using Cubic interpolation here?
In other words, did something change that we need to accomodate? Or should
we simply not combine the Piecewise interpolation with the Cubic argument ?
I also noticed the messages on Cubic interpolation in the list archives but
from I gathered this is for new code rather than this curve-building
functionality.
Many thanks for any pointers, Dirk
[1] http://dirk.eddelbuettel.com/code/rquantlib.html
--
Three out of two people have difficulties with fractions.
|