Hi Yuanhao,
As you are actually finding a root within some interval (e.g. (0.0, inf)), you can’t expect to find a “root” for sure. What you can do is to minimize the error within this interval.
In such case I suggest you to use optimizer instead of root finder. QuantLib has a built-in framework for optimizer with constraint. E.g. you can use BFGS optimizer with boundary constraint like (0.0, inf).
Under such setting, when optimizer hit the boundary it will stay there or try to find a better solution instead of throwing an error.
Regards,
Cheng
发件人: Yuanhao Zhang [mailto:[hidden email]]
发送时间: 2014年5月28日 10:19
收件人: QuantLib QuantLib
主题: [Quantlib-users] negative discount rate
Hi,
I try to use the solver function like Bisection or Newton method to find the root of the curve parallel shift to make sure the valuation result is very close to the market quotation.
But, when I set the minimum boundary to -0.1, QuantLib throw out the exception the discount rate can not be the negative one. I know Quantlib allow user to set the discount rate to be negative one, But, I just want the RootFunction to find the result to the lowest one, but never to be negative one.
How can I achieve it?
Many thanks
regards
Alex
| Free forum by Nabble | Edit this page |