convergence error for flat yield curve using cubic spline

Posted by jlee on
URL: http://quantlib.414.s1.nabble.com/convergence-error-for-flat-yield-curve-using-cubic-spline-tp15858.html

Hi all,
Can someone help point out what I am doing wrong? I am getting convergence errors when trying to bootstrap a yield curve using cubic spline. I have narrowed it down to a test case which is just a flat yield curve with 3 instruments (1w and 1m cash and 2y swap) all at 6%. 

The main code is:

depoFRASwapInstruments.push_back(d1w);
depoFRASwapInstruments.push_back(d1m);
depoFRASwapInstruments.push_back(s2y);

boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructure(new PiecewiseYieldCurve<ZeroYield, Cubic>(settlementDate, depoFRASwapInstruments, termStructureDayCounter, tolerance, Cubic(CubicInterpolation::Spline, false, CubicInterpolation::SecondDerivative, 0.0, CubicInterpolation::SecondDerivative, 0.0)));

// get 1 month discfact
std::cout << "1-month discount factor: " << std::setprecision(8) << depoFRASwapTermStructure->discount(1 / 12.0, false);

the error it returns is "convergence not reached after 99 iterations".

I think the code is fine as sometimes it does work (ie. if I use flat 5% it works). But I often get convergence errors making things unstable. Am i missing something? Does it just not converge?

Have attached the entire code.

Thanks,
Jon

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

swap.cpp (16K) Download Attachment