Hi,
I am trying to implement an example out of a textbook (Modeling Derivatives with C++, London - Chapter 14 713pp). The code delivered there was somehow useful to understand how to implement a piecewiseflatforward term structure. I thought I can use the market data (since I'm wondering where to get useful market data). When my sample program is bootstrapping the yield curve, I get the following error message: Today: Friday, February 15th, 2002 Settlement date: Wednesday, February 19th, 2003 could not bootstrap the 13th instrument, maturity March 8th, 2021 error message: root not bracketed: f[2.22045e-016,0.427359] -> [-1.139246e-001, -5.133138e-002] Does anybody has suggestions how to solve this problem? If necessary, I show you my c++ code. Btw. where do I get usefully market data for model calibration? I'm a student writing a diploma work which goal is to show with several examples how to use the c++/quantlib environment. Greetz Greg ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Gregor, On Wed, 2007-03-07 at 09:58 +0100, Gregor Gutzelnig wrote: > I am trying to implement an example out of a textbook (Modeling Derivatives > with C++, London - Chapter 14 713pp). The code delivered there was somehow > useful to understand how to implement a piecewiseflatforward term > structure. I thought I can use the market data (since I'm wondering where to > get useful market data). First of all, a word of advice: the code in London's book is a very outdated version of the library. I suggest that you download and use the latest version of QuantLib instead. Also, you can look in the Example directory for code that bootstraps a curve, in particular the swap evaluation example. > When my sample program is bootstrapping the yield curve, I get the following > error message: > > could not bootstrap the 13th instrument, maturity March 8th, 2021 > error message: root not bracketed: f[2.22045e-016,0.427359] -> > [-1.139246e-001, -5.133138e-002] I'm afraid it depends on the market data. What the error is saying is that the internal solver cannot find a rate for the 13th interval which allows the curve to reprice the 13th instrument (a swap, I guess) exactly. At the point where the error is raised, the term structure is fixed up to its 12th node (i.e., the maturity of the 12th instrument); in turn, this fixes the NPV of the fixed and floating payments of the swap up to the same date. The solver is now trying to find a rate up to the 13th node; such rate, together with the rest of the curve, will determine the NPV of the payments occurring between the 12th and 13th nodes and hence the total NPV of the swap. For the bootstrap to be successful, a rate should be found such that the total NPV is 0. What is happening is that the NPV up to the 12th date is so far from 0 that no such rate can be found, i.e., no matter what the rate is, the NPV of the payments between the 12th and 13th node cannot cancel out the payments up to the 12th node. > Does anybody has suggestions how to solve this problem? If necessary, I show > you my c++ code. It is more likely that the problem is in the market data; it looks like the 13th rate is not consistent with the previous 12. Were those real market data, of course I would be talking nonsense; the market data are what they are. But since they're from a book, there might have been a transcription error. Also, looking at your code might help; please send it to the mailing list. There might be problems in it, such as using the right rates with the wrong conventions. > I'm a student writing a diploma work which goal is to show with > several examples how to use the c++/quantlib environment. Great to hear this---please keep me informed on it. For obvious reasons, I'm interested in the end result. It would be nice to make it available from the QuantLib site. Later, Luigi ---------------------------------------- So little done, so much to do. -- Cecil Rhodes ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Luigi,
> -----Original Message----- > From: Luigi Ballabio [mailto:[hidden email]] > Sent: Wednesday, March 07, 2007 10:44 AM > To: Gregor Gutzelnig > Cc: [hidden email] > Subject: Re: [Quantlib-users] Problems with building yield curve // > Hull White model > > > Hi Gregor, > > On Wed, 2007-03-07 at 09:58 +0100, Gregor Gutzelnig wrote: > > I am trying to implement an example out of a textbook (Modeling > Derivatives > > with C++, London - Chapter 14 713pp). The code delivered there was > somehow > > useful to understand how to implement a piecewiseflatforward term > > structure. I thought I can use the market data (since I'm wondering > where to > > get useful market data). > > First of all, a word of advice: the code in London's book is a very > outdated version of the library. I suggest that you download and use > the > latest version of QuantLib instead. Also, you can look in the Example > directory for code that bootstraps a curve, in particular the swap > evaluation example. example code provided by quantlib.org which was quite useful, since I appreciate to learn new things from experienced users. I have quickly found out that London's code is outdated but I thought it might be good to get some nice market data or some hints on how to implement C++/QuantLib code. > > > When my sample program is bootstrapping the yield curve, I get the > following > > error message: > > > > could not bootstrap the 13th instrument, maturity March 8th, 2021 > > error message: root not bracketed: f[2.22045e-016,0.427359] -> > > [-1.139246e-001, -5.133138e-002] > > I'm afraid it depends on the market data. > > What the error is saying is that the internal solver cannot find a rate > for the 13th interval which allows the curve to reprice the 13th > instrument (a swap, I guess) exactly. At the point where the error is > raised, the term structure is fixed up to its 12th node (i.e., the > maturity of the 12th instrument); in turn, this fixes the NPV of the > fixed and floating payments of the swap up to the same date. The solver > is now trying to find a rate up to the 13th node; such rate, together > with the rest of the curve, will determine the NPV of the payments > occurring between the 12th and 13th nodes and hence the total NPV of > the > swap. > > For the bootstrap to be successful, a rate should be found such that > the > total NPV is 0. What is happening is that the NPV up to the 12th date > is > so far from 0 that no such rate can be found, i.e., no matter what the > rate is, the NPV of the payments between the 12th and 13th node cannot > cancel out the payments up to the 12th node. > things and now it turns out that I wasted time because the market data given in the book is not useful to implement the term structure...anyway it was a good way to learn at least. Thank you for your detailed information about the boostrapping mechanism of QuantLib, now I understand why I have troubles... > > Does anybody has suggestions how to solve this problem? If necessary, > I show > > you my c++ code. > > It is more likely that the problem is in the market data; it looks like > the 13th rate is not consistent with the previous 12. Were those real > market data, of course I would be talking nonsense; the market data are > what they are. But since they're from a book, there might have been a > transcription error. Also, looking at your code might help; please send > it to the mailing list. There might be problems in it, such as using > the > right rates with the wrong conventions. > > > I'm a student writing a diploma work which goal is to show with > > several examples how to use the c++/quantlib environment. > > Great to hear this---please keep me informed on it. For obvious > reasons, > I'm interested in the end result. It would be nice to make it available > from the QuantLib site. > > Later, > Luigi > > > ---------------------------------------- > > So little done, so much to do. > -- Cecil Rhodes > Gregor ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users Swaption.cpp (22K) Download Attachment |
On Wed, 2007-03-07 at 11:24 +0100, Gregor Gutzelnig wrote:
> Hi Luigi, > > > First of all, a word of advice: the code in London's book is a very > > outdated version of the library. I suggest that you download and use > > the > > latest version of QuantLib instead. Also, you can look in the Example > > directory for code that bootstraps a curve, in particular the swap > > evaluation example. > > Of course I'm using the latest version of QuantLib and I worked through the > example code provided by quantlib.org which was quite useful, since I > appreciate to learn new things from experienced users. Ok, it was just to make sure. > I'm wondering now how London's code could ever work. I had to adopt many > things and now it turns out that I wasted time because the market data given > in the book is not useful to implement the term structure... The problem might not be in the data. From a look at the code you attached, I see that you put today's date somewhere in the past. However, you're missing the line: Settings::instance().evaluationDate() = todaysDate; which tells the library to use it. This might cause problems when you bootstrap, since the system will assume we're in 2007---you haven't told it otherwise. Later, Luigi ---------------------------------------- The Feynman Problem Solving Algorithm: 1) Write down the problem. 2) Think very hard. 3) Write down the solution. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
> -----Original Message----- > From: Luigi Ballabio [mailto:[hidden email]] > Sent: Wednesday, March 07, 2007 12:41 PM > To: Gregor Gutzelnig > Cc: [hidden email] > Subject: RE: [Quantlib-users] Problems with building yield curve // > Hull White model > > On Wed, 2007-03-07 at 11:24 +0100, Gregor Gutzelnig wrote: > > Hi Luigi, > > > > > First of all, a word of advice: the code in London's book is a very > > > outdated version of the library. I suggest that you download and > use > > > the > > > latest version of QuantLib instead. Also, you can look in the > Example > > > directory for code that bootstraps a curve, in particular the swap > > > evaluation example. > > > > Of course I'm using the latest version of QuantLib and I worked > through the > > example code provided by quantlib.org which was quite useful, since I > > appreciate to learn new things from experienced users. > > Ok, it was just to make sure. > > > I'm wondering now how London's code could ever work. I had to adopt > many > > things and now it turns out that I wasted time because the market > data given > > in the book is not useful to implement the term structure... > > The problem might not be in the data. From a look at the code you > attached, I see that you put today's date somewhere in the past. > However, you're missing the line: > > Settings::instance().evaluationDate() = todaysDate; > > which tells the library to use it. This might cause problems when you > bootstrap, since the system will assume we're in 2007---you haven't > told > it otherwise. > after the line where todaysDate is computed) but unfortunately the same error message occurs. > Later, > Luigi > > > ---------------------------------------- > > The Feynman Problem Solving Algorithm: > 1) Write down the problem. > 2) Think very hard. > 3) Write down the solution. > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |