Could someone post or e-mail an example of yield calculation of a fixed rate coupon bond?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Could someone post or e-mail an example of yield calculation of a fixed rate coupon bond?

mariav
I am a very experienced programmer in fortran, but I know very little of objected oriented programming.To help me to get started using QuantLib, could someone post or send to me ([hidden email]) a simple example of yield calculation of a fixed rate coupon bond? I was told to look at the "test suite" but I am so new to all this, including QuantLib, that this advice did not help me much. I need a complete code such as the "ConvertibleBonds.cpp", which comes in the QuantLib package. That is, a code in which I just have to compile and run. Of course, I would also appreciate receiving other examples of code, but the one mentioned above would already be very helpful. Thanks!
   Maria Vieira


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Could someone post or e-mail an example of yield calculation of a fixed rate coupon bond?

Luigi Ballabio

On Aug 17, 2008, at 3:47 AM, maria vieira wrote:

> I am a very experienced programmer in fortran, but I know very  
> little of objected oriented programming.To help me to get started  
> using QuantLib, could someone post or send to me  
> ([hidden email]) a simple example of yield calculation of a  
> fixed rate coupon bond? I was told to look at the "test suite" but I  
> am so new to all this, including QuantLib, that this advice did not  
> help me much. I need a complete code such as the  
> "ConvertibleBonds.cpp", which comes in the QuantLib package. That  
> is, a code in which I just have to compile and run. Of course, I  
> would also appreciate receiving other examples of code, but the one  
> mentioned above would already be very helpful. Thanks!

A quick note: if anyone wants to write a bond example, post it here---
I'll be happy to include it in next release.

Thanks,
        Luigi

P.S. Maria: in the meantime, you can start looking at the file test-
suite/bonds.cpp.
It cannot be compiled as it is, but chances are that you can can take  
any of the functions in there, copy it in a separate file, rename it  
as main() and obtain a running program. (You'll probably have to  
remove the BOOST_ERROR function calls, too.)



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Could someone post or e-mail an example of yield calculation of a fixed rate coupon bond?

Florent Grenier
Dear Luigi, quantlib-users,

I'm currently in the process of writing such a sample (it's almost over in fact). I'm still having small discrepancies between direct calculations of the prices and yields, and the results of yield to price/price to yield computations. I'm going to investigate them as soon as I have some time.

By the way I enclosed the code I wrote to this e-mail (as well as the result of its execution). It gives a good idea on how Maria could compute the yield of her bond.

If someone has some remarks regarding the quality or the completeness of my sample, do not hesitate to tell me. Just to add that my code compiles against Quantlib 0.9.6

Thanks,
Florent



2008/8/18 Luigi Ballabio <[hidden email]>

On Aug 17, 2008, at 3:47 AM, maria vieira wrote:
> I am a very experienced programmer in fortran, but I know very
> little of objected oriented programming.To help me to get started
> using QuantLib, could someone post or send to me
> ([hidden email]) a simple example of yield calculation of a
> fixed rate coupon bond? I was told to look at the "test suite" but I
> am so new to all this, including QuantLib, that this advice did not
> help me much. I need a complete code such as the
> "ConvertibleBonds.cpp", which comes in the QuantLib package. That
> is, a code in which I just have to compile and run. Of course, I
> would also appreciate receiving other examples of code, but the one
> mentioned above would already be very helpful. Thanks!

A quick note: if anyone wants to write a bond example, post it here---
I'll be happy to include it in next release.

Thanks,
       Luigi

P.S. Maria: in the meantime, you can start looking at the file test-
suite/bonds.cpp.
It cannot be compiled as it is, but chances are that you can can take
any of the functions in there, copy it in a separate file, rename it
as main() and obtain a running program. (You'll probably have to
remove the BOOST_ERROR function calls, too.)



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev

bond.cpp (20K) Download Attachment
bond.txt (996 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Could someone post or e-mail an example of yield calculation of a fixed rate coupon bond?

Luigi Ballabio
On Tue, 2008-08-19 at 11:23 +0200, Florent Grenier wrote:
> I'm currently in the process of writing such a sample (it's almost
> over in fact). I'm still having small discrepancies between direct
> calculations of the prices and yields, and the results of yield to
> price/price to yield computations. I'm going to investigate them as
> soon as I have some time.

Thanks, Florent. It was sorely missed. I'll look at your code as soon as
I get some time.

Luigi


--

fix, n.,v.
What one does when a problem has been reported too many times
to be ignored.
-- the Jargon file



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Could someone post or e-mail an example of yield calculation of a fixed rate coupon bond?

adamquestio
In reply to this post by Florent Grenier
Hi Florent

your settlement days are 3, but fixing days are 2. If you make both 3, you will get same results in your floater check

Thanks
Adam

Florent Grenier wrote
Dear Luigi, quantlib-users,

I'm currently in the process of writing such a sample (it's almost over in
fact). I'm still having small discrepancies between direct calculations of
the prices and yields, and the results of yield to price/price to yield
computations. I'm going to investigate them as soon as I have some time.

By the way I enclosed the code I wrote to this e-mail (as well as the result
of its execution). It gives a good idea on how Maria could compute the yield
of her bond.

If someone has some remarks regarding the quality or the completeness of my
sample, do not hesitate to tell me. Just to add that my code compiles
against Quantlib 0.9.6

Thanks,
Florent



2008/8/18 Luigi Ballabio <luigi.ballabio@gmail.com>

>
> On Aug 17, 2008, at 3:47 AM, maria vieira wrote:
> > I am a very experienced programmer in fortran, but I know very
> > little of objected oriented programming.To help me to get started
> > using QuantLib, could someone post or send to me
> > (mariav_us@yahoo.com) a simple example of yield calculation of a
> > fixed rate coupon bond? I was told to look at the "test suite" but I
> > am so new to all this, including QuantLib, that this advice did not
> > help me much. I need a complete code such as the
> > "ConvertibleBonds.cpp", which comes in the QuantLib package. That
> > is, a code in which I just have to compile and run. Of course, I
> > would also appreciate receiving other examples of code, but the one
> > mentioned above would already be very helpful. Thanks!
>
> A quick note: if anyone wants to write a bond example, post it here---
> I'll be happy to include it in next release.
>
> Thanks,
>        Luigi
>
> P.S. Maria: in the meantime, you can start looking at the file test-
> suite/bonds.cpp.
> It cannot be compiled as it is, but chances are that you can can take
> any of the functions in there, copy it in a separate file, rename it
> as main() and obtain a running program. (You'll probably have to
> remove the BOOST_ERROR function calls, too.)
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> QuantLib-dev mailing list
> QuantLib-dev@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>

 

Today: Wednesday, June 18th, 2008
Settlement date: Friday, June 20th, 2008

                          ZC     Fixed  Floating
------------------------------------------------
 Net present value     94.24     99.66    101.49
       Clean price     94.24     99.18    101.09
       Dirty price     94.24     99.66    101.49
    Accrued coupon      0.00      0.48      0.40
   Previous coupon    0.00 %    4.50 %    5.23 %
       Next coupon       xxx    4.50 %    2.67 %
             Yield    4.22 %    4.60 %    3.64 %

Sample indirect computations (for the floating rate bond):
------------------------------------------------
Yield to Clean Price: 101.08
Clean Price to Yield: 3.63 %

Run completed in 0 s


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
QuantLib-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Could someone post or e-mail an example of yield calculation of a fixed rate coupon bond?

Florent Grenier
Hi Adam,

Thanks you indeed it was the reason :)

I send you the corrected code.

Thanks,
Florent

2008/8/25 adam99 <[hidden email]>

Hi Florent

your settlement days are 3, but fixing days are 2. If you make both 3, you
will get same results in your floater check

Thanks
Adam


Florent Grenier wrote:
>
> Dear Luigi, quantlib-users,
>
> I'm currently in the process of writing such a sample (it's almost over in
> fact). I'm still having small discrepancies between direct calculations of
> the prices and yields, and the results of yield to price/price to yield
> computations. I'm going to investigate them as soon as I have some time.
>
> By the way I enclosed the code I wrote to this e-mail (as well as the
> result
> of its execution). It gives a good idea on how Maria could compute the
> yield
> of her bond.
>
> If someone has some remarks regarding the quality or the completeness of
> my
> sample, do not hesitate to tell me. Just to add that my code compiles
> against Quantlib 0.9.6
>
> Thanks,
> Florent
>
>
>
> 2008/8/18 Luigi Ballabio <[hidden email]>
>
>>
>> On Aug 17, 2008, at 3:47 AM, maria vieira wrote:
>> > I am a very experienced programmer in fortran, but I know very
>> > little of objected oriented programming.To help me to get started
>> > using QuantLib, could someone post or send to me
>> > ([hidden email]) a simple example of yield calculation of a
>> > fixed rate coupon bond? I was told to look at the "test suite" but I
>> > am so new to all this, including QuantLib, that this advice did not
>> > help me much. I need a complete code such as the
>> > "ConvertibleBonds.cpp", which comes in the QuantLib package. That
>> > is, a code in which I just have to compile and run. Of course, I
>> > would also appreciate receiving other examples of code, but the one
>> > mentioned above would already be very helpful. Thanks!
>>
>> A quick note: if anyone wants to write a bond example, post it here---
>> I'll be happy to include it in next release.
>>
>> Thanks,
>>        Luigi
>>
>> P.S. Maria: in the meantime, you can start looking at the file test-
>> suite/bonds.cpp.
>> It cannot be compiled as it is, but chances are that you can can take
>> any of the functions in there, copy it in a separate file, rename it
>> as main() and obtain a running program. (You'll probably have to
>> remove the BOOST_ERROR function calls, too.)
>>
>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win great
>> prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the
>> world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> QuantLib-dev mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>>
>
>
>
> Today: Wednesday, June 18th, 2008
> Settlement date: Friday, June 20th, 2008
>
>                           ZC     Fixed  Floating
> ------------------------------------------------
>  Net present value     94.24     99.66    101.49
>        Clean price     94.24     99.18    101.09
>        Dirty price     94.24     99.66    101.49
>     Accrued coupon      0.00      0.48      0.40
>    Previous coupon    0.00 %    4.50 %    5.23 %
>        Next coupon       xxx    4.50 %    2.67 %
>              Yield    4.22 %    4.60 %    3.64 %
>
> Sample indirect computations (for the floating rate bond):
> ------------------------------------------------
> Yield to Clean Price: 101.08
> Clean Price to Yield: 3.63 %
>
> Run completed in 0 s
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>
>

--
View this message in context: http://www.nabble.com/Could-someone-post-or-e-mail-an-example-of-yield-calculation-of-a-fixed-rate-coupon-bond--tp19016811p19138186.html
Sent from the quantlib-dev mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev

bond.cpp (21K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Could someone post or e-mail an example of yield calculation of a fixed rate coupon bond?

Luigi Ballabio

On Aug 27, 2008, at 7:21 PM, Florent Grenier wrote:
> I send you the corrected code.

Florent,
        I see that you're using a depo-swap curve for forecasting LIBOR  
fixings and for dscounting.  If you have time to do so, and if you  
think that it makes sense, it might be interesting to use a bond curve  
for discounting instead; you can build one with a few  
FixedRateBondHelpers.

Other than that, the example looks ok.  I'll add it to the library  
when you think it's finalized.

Thanks,
        Luigi



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Could someone post or e-mail an example of yield calculation of a fixed rate coupon bond?

Florent Grenier
Hi Luigi,

Yes good idea, I'll do it as soon as I can. Just a small question: do you already know when the next release will take place? I would like to bring my modifications to the example before that release.

Thanks,
Florent

2008/8/27 Luigi Ballabio <[hidden email]>

On Aug 27, 2008, at 7:21 PM, Florent Grenier wrote:
I send you the corrected code.

Florent,
       I see that you're using a depo-swap curve for forecasting LIBOR fixings and for dscounting.  If you have time to do so, and if you think that it makes sense, it might be interesting to use a bond curve for discounting instead; you can build one with a few FixedRateBondHelpers.

Other than that, the example looks ok.  I'll add it to the library when you think it's finalized.

Thanks,
       Luigi




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Could someone post or e-mail an example of yield calculation of a fixed rate coupon bond?

Luigi Ballabio

On Aug 28, 2008, at 11:14 AM, Florent Grenier wrote:
> Yes good idea, I'll do it as soon as I can. Just a small question:  
> do you already know when the next release will take place? I would  
> like to bring my modifications to the example before that release.

I'd like to finalize the release by the end of September (see the mail  
i just posted to QuantLib-users for details.)

Luigi


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev