Re: QuantLib-dev Digest, Vol 34, Issue 9

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib-dev Digest, Vol 34, Issue 9

Theo Boafo
Dear All,

I have installed Quantlibxl 9.7 and have opened work book option.xls and cant get the example sheet to calculate.

Despite hitting ctrl-alt-f9 to force a recalculate cell B10 has value #NUM and cells b13 and c13 have value #VALUE!

Can anyone help?

Regards

Theo



-----Original Message-----
From: [hidden email]
To: [hidden email]
Sent: Wed, 25 Mar 2009 11:34
Subject: QuantLib-dev Digest, Vol 34, Issue 9

Send QuantLib-dev mailing list submissions to
    [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
    https://lists.sourceforge.net/lists/listinfo/quantlib-dev
or, via email, send a message with subject or body 'help' to
    [hidden email]

You can reach the person managing the list at
    [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of QuantLib-dev digest..."


Today's Topics:

   1. [ quantlib-Bugs-2691902 ] Bootstrapping for bonds:
      Inconsistency in the clean price (SourceForge.net)
   2. [ quantlib-Bugs-2691902 ] Bootstrapping for bonds:
      Inconsistency in the clean price (SourceForge.net)
   3. [ quantlib-Bugs-2691902 ] Bootstrapping for bonds:
      Inconsistency in the clean price (SourceForge.net)
   4. Re: How to use test suite (Luigi Ballabio)
   5. Re: [QuantLib-svn] SF.net SVN: quantlib:[16065]
      trunk/QuantLib/ql/termstructures/yield/ forwardcurve.hpp
      (Luigi Ballabio)
   6. Re: [QuantLib-svn] SF.net SVN: quantlib:[16065]
      trunk/QuantLib/ql/termstructures/yield/ forwardcurve.hpp
      (Ferdinando Ametrano)
   7. Re: [QuantLib-svn] SF.net SVN: quantlib:[16065]
      trunk/QuantLib/ql/termstructures/yield/ forwardcurve.hpp
      (Luigi Ballabio)


----------------------------------------------------------------------

Message: 1
Date: Wed, 18 Mar 2009 14:28:22 +0000
From: "SourceForge.net" <[hidden email]>
Subject: [Quantlib-dev] [ quantlib-Bugs-2691902 ] Bootstrapping for
    bonds:  Inconsistency in the clean price
To: [hidden email]
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="UTF-8"

Bugs item #2691902, was opened at 2009-03-18 15:28
Message generated for change (Tracker Item Submitted) made by klriedel
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=2691902&group_id=12740

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Karl Riedel (klriedel)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bootstrapping for bonds: Inconsistency in the clean price

Initial Comment:
Dear ladies and gentlemen,

when considering the bootstrapping of a coupon bond according to the example 
"FittedBondCurve.cpp" I found an inconsistency in the results of the 
bootstrapper according to
        boost::shared_ptr<YieldTermStructure> ts0 (
              new PiecewiseYieldCurve<Discount,LogLinear>(curveSettlementDays,
                                                          calendar,
                                                          instrumentsB,
                                                          bondDayCount));

This inconsistency was as follows: For simplicity I considered a coupon bond 
with only one remaining payment date t_1, at which the coupon c and the 
redemption 1 will be paid. Let t_0 be the last coupon date and today t is within 
the interval [t_0,t_1]. For this situation the discount factor df(t,t_1) was 
calculated according to
Clean Price = df(t,t_1) * [ 1 + c*(t_1-t) ].      (1)
This formula refers to a Clean Price which is theoretically correct, i.e. the 
accrued amount is discounted. 
On the other hand, what has actually to be paid (marked standard) for a bond is 
the Clean price + the accrued amount according to the simple formula c*(t-t_0) 
which does not take into account discounting the accrued amount. The net present 
value of future payments must equal the spot price:
Clean Price + c * (t-t_0) = df(t,t_1) * [1+c].   (2)

In the middle of a payment period the resulting discount factors df(t,t_1) of 
(1) and (2) differ most. In my example this lead to a difference in the zero 
rate of around 10 BIPs.

Best regards,
Karl Riedel 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=2691902&group_id=12740



------------------------------

Message: 2
Date: Wed, 18 Mar 2009 16:14:15 +0000
From: "SourceForge.net" <[hidden email]>
Subject: [Quantlib-dev] [ quantlib-Bugs-2691902 ] Bootstrapping for
    bonds:  Inconsistency in the clean price
To: [hidden email]
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="UTF-8"

Bugs item #2691902, was opened at 2009-03-18 15:28
Message generated for change (Comment added) made by lballabio
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=2691902&group_id=12740

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Karl Riedel (klriedel)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bootstrapping for bonds: Inconsistency in the clean price

Initial Comment:
Dear ladies and gentlemen,

when considering the bootstrapping of a coupon bond according to the example 
"FittedBondCurve.cpp" I found an inconsistency in the results of the 
bootstrapper according to
        boost::shared_ptr<YieldTermStructure> ts0 (
              new PiecewiseYieldCurve<Discount,LogLinear>(curveSettlementDays,
                                                          calendar,
                                                          instrumentsB,
                                                          bondDayCount));

This inconsistency was as follows: For simplicity I considered a coupon bond 
with only one remaining payment date t_1, at which the coupon c and the 
redemption 1 will be paid. Let t_0 be the last coupon date and today t is within 
the interval [t_0,t_1]. For this situation the discount factor df(t,t_1) was 
calculated according to
Clean Price = df(t,t_1) * [ 1 + c*(t_1-t) ].      (1)
This formula refers to a Clean Price which is theoretically correct, i.e. the 
accrued amount is discounted. 
On the other hand, what has actually to be paid (marked standard) for a bond is 
the Clean price + the accrued amount according to the simple formula c*(t-t_0) 
which does not take into account discounting the accrued amount. The net present 
value of future payments must equal the spot price:
Clean Price + c * (t-t_0) = df(t,t_1) * [1+c].   (2)

In the middle of a payment period the resulting discount factors df(t,t_1) of 
(1) and (2) differ most. In my example this lead to a difference in the zero 
rate of around 10 BIPs.

Best regards,
Karl Riedel 

----------------------------------------------------------------------

>Comment By: Luigi Ballabio (lballabio)
Date: 2009-03-18 17:14

Message:
Karl,
   may you point out the places in the code where the calculations (1) and
(2) are performed?
Also, do you have some code to reproduce the error?

Luigi


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=2691902&group_id=12740



------------------------------

Message: 3
Date: Thu, 19 Mar 2009 10:28:43 +0000
From: "SourceForge.net" <[hidden email]>
Subject: [Quantlib-dev] [ quantlib-Bugs-2691902 ] Bootstrapping for
    bonds:  Inconsistency in the clean price
To: [hidden email]
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="UTF-8"

Bugs item #2691902, was opened at 2009-03-18 15:28
Message generated for change (Comment added) made by klriedel
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=2691902&group_id=12740

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Karl Riedel (klriedel)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bootstrapping for bonds: Inconsistency in the clean price

Initial Comment:
Dear ladies and gentlemen,

when considering the bootstrapping of a coupon bond according to the example 
"FittedBondCurve.cpp" I found an inconsistency in the results of the 
bootstrapper according to
        boost::shared_ptr<YieldTermStructure> ts0 (
              new PiecewiseYieldCurve<Discount,LogLinear>(curveSettlementDays,
                                                          calendar,
                                                          instrumentsB,
                                                          bondDayCount));

This inconsistency was as follows: For simplicity I considered a coupon bond 
with only one remaining payment date t_1, at which the coupon c and the 
redemption 1 will be paid. Let t_0 be the last coupon date and today t is within 
the interval [t_0,t_1]. For this situation the discount factor df(t,t_1) was 
calculated according to
Clean Price = df(t,t_1) * [ 1 + c*(t_1-t) ].      (1)
This formula refers to a Clean Price which is theoretically correct, i.e. the 
accrued amount is discounted. 
On the other hand, what has actually to be paid (marked standard) for a bond is 
the Clean price + the accrued amount according to the simple formula c*(t-t_0) 
which does not take into account discounting the accrued amount. The net present 
value of future payments must equal the spot price:
Clean Price + c * (t-t_0) = df(t,t_1) * [1+c].   (2)

In the middle of a payment period the resulting discount factors df(t,t_1) of 
(1) and (2) differ most. In my example this lead to a difference in the zero 
rate of around 10 BIPs.

Best regards,
Karl Riedel 

----------------------------------------------------------------------

>Comment By: Karl Riedel (klriedel)
Date: 2009-03-19 11:28

Message:
Hello Luigi,

unfortunately I did not have the time to search the relevant position(s)
in the code. I just compared the results of Quantlib bootstrapping to
formula (1) and (2) considering an easy example. The bootstrapper
calculates results according to formula (1) while formula (2) describes the
correct net present value. 

Please find the example code attached. The produced output is as follows:

Today's date: January 2nd, 2009
Bootstrapping 1 bond with 0.5 years tenor and 4% coupon ...

According to
Clean Price = df(t,t_1) * [ 1 + c*(t_1-t) ].      (1)
df = 1 / (1+0.5*c) = 1 / 1.02 = 0.980392156863
ts0->discount(maturity) =       0.980392156863
r = -log(df)/0.5 =              0.0396052545924
ts0->zeroRate(... =             0.0396052545924

According to correct net present value
Clean Price + c * (t-t_0) = df(t,t_1) * [1+c].   (2)
df = (1+0.5*c)/(1+c) = 1.02/1.04 = 0.980769230769
r = -log(df)/0.5 =                 0.0388361717142
Dr?cken Sie eine beliebige Taste . . .



Karl

File Added: CleanpriceInconsistencyExample.txt

----------------------------------------------------------------------

Comment By: Luigi Ballabio (lballabio)
Date: 2009-03-18 17:14

Message:
Karl,
   may you point out the places in the code where the calculations (1) and
(2) are performed?
Also, do you have some code to reproduce the error?

Luigi


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=2691902&group_id=12740



------------------------------

Message: 4
Date: Fri, 20 Mar 2009 11:05:13 +0100
From: Luigi Ballabio <[hidden email]>
Subject: Re: [Quantlib-dev] How to use test suite
To: Ramesh Pedhamalla <[hidden email]>
Cc: [hidden email]
Message-ID: <1237543513.4669.21.camel@ITSUP001>
Content-Type: text/plain

On Mon, 2009-03-16 at 14:47 +0530, Ramesh Pedhamalla wrote:
>   Iam useing Quantilib in my application,i want to test some API in
> Quantlib.Please let me know how to use test suite.

Sorry, I'm not following.  May you add some details and/or some context?

Luigi


-- 

These are my principles, and if you don't like them... Well, I have
others. 
-- Groucho Marx 





------------------------------

Message: 5
Date: Wed, 25 Mar 2009 11:38:53 +0100
From: Luigi Ballabio <[hidden email]>
Subject: Re: [Quantlib-dev] [QuantLib-svn] SF.net SVN:
    quantlib:[16065] trunk/QuantLib/ql/termstructures/yield/
    forwardcurve.hpp
To: [hidden email]
Message-ID: <1237977533.18502.0.camel@ITSUP001>
Content-Type: text/plain

On Wed, 2009-03-25 at 10:31 +0000, [hidden email] wrote:
> Revision: 16065
>           http://quantlib.svn.sourceforge.net/quantlib/?rev=16065&view=rev
> Author:   nando
> Date:     2009-03-25 10:31:08 +0000 (Wed, 25 Mar 2009)
> 
> Log Message:
> -----------
> added flat extrapolation

Care to discuss?

Luigi


-- 

The shortest way to do many things is to do only one thing at once. 
-- Samuel Smiles 





------------------------------

Message: 6
Date: Wed, 25 Mar 2009 12:23:21 +0100
From: Ferdinando Ametrano <[hidden email]>
Subject: Re: [Quantlib-dev] [QuantLib-svn] SF.net SVN:
    quantlib:[16065]    trunk/QuantLib/ql/termstructures/yield/
    forwardcurve.hpp
To: [hidden email]
Cc: [hidden email]
Message-ID:
    <[hidden email]>
Content-Type: text/plain; charset=ISO-8859-1

On Wed, Mar 25, 2009 at 11:38 AM, Luigi Ballabio
<[hidden email]> wrote:
> On Wed, 2009-03-25 at 10:31 +0000, [hidden email] wrote:
>> Revision: 16065
>>
>> Log Message:
>> -----------
>> added flat extrapolation
>>
>>  Modified Paths:
>> --------------
>>    trunk/QuantLib/ql/termstructures/yield/forwardcurve.hpp
>
> Care to discuss?

glad to oblige.

The InterpolatedForwardCurve used the interpolant to extrapolate,
which easily leads to implausible rates, unless one used
piecewise-constant interpolation. Even "basic" linear interpolation
could lead to negative rates or implausible high rates depending on
its slope in the final segment

Flat forward rate extrapolation keeps forward rate continuous, at the
cost of an angular point for non piecewise-constant interpolations.
This is a non-issue for linear interpolation since in this case the
curve already has an angular point at every knot. When it comes to
higher order interpolation it is still a bearable cost compared to
implausible extrapolation values.

In any case this cost is negligible in the overall smoothness
evaluation of the curve, as the forward rate curve is integrated in
order to obtain zero rate (and then discount factor)

Of course extrapolation is always a dangerous exercise, but if one
needs it then flat extrapolation of instantaneous forward rates is
usually the preferred approach, with no real feasible alternatives I
know of.

This is also the approach adopted in the InterpolatedHazardRateCurve.

Any contrarian out there?

ciao -- Nando



------------------------------

Message: 7
Date: Wed, 25 Mar 2009 12:33:05 +0100
From: Luigi Ballabio <[hidden email]>
Subject: Re: [Quantlib-dev] [QuantLib-svn] SF.net SVN:
    quantlib:[16065] trunk/QuantLib/ql/termstructures/yield/
    forwardcurve.hpp
To: Ferdinando Ametrano <[hidden email]>
Cc: [hidden email]
Message-ID: <1237980785.18502.4.camel@ITSUP001>
Content-Type: text/plain

On Wed, 2009-03-25 at 12:23 +0100, Ferdinando Ametrano wrote:
> glad to oblige.

Thanks.  I agreed with the change, but I though it would have been a
good thing to have its rationale explained---which you did nicely.

Luigi


-- 

I'd never join any club that would have the likes of me as a member. 
-- Groucho Marx 





------------------------------

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com

------------------------------

_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev


End of QuantLib-dev Digest, Vol 34, Issue 9
*******************************************

------------------------------------------------------------------------------

_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev