a bug in Bonds.cpp

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

a bug in Bonds.cpp

Dagur Gunnarsson-2
hello, 

Is it ok, to post bugs in this mailgroup?  I suspect that there is a bug in the following code.

00247 
Real Bond::accruedAmount(Date settlement) const {
  Real currentNotional = notional(settlementDate());
  if (currentNotional == 0.0)
   return 0.0;

  return BondFunctions::accruedAmount(*this, settlement);
}

the code is taken from  http://quantlib.sourcearchive.com/documentation/1.1-1/bond_8cpp_source.html

notional(settlementDate()) should be notional(settlement) instead - my unit tests stopped working for a bond that had a maturity the 8th of February.

regards
Dagur G

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: a bug in Bonds.cpp

Luigi Ballabio
Yes, it's a bug.  I've fixed it on the 1.2 branch now.

Thanks for the heads-up.

Luigi


On Mon, Feb 13, 2012 at 3:15 PM, Dagur Gunnarsson <[hidden email]> wrote:

> hello,
>
> Is it ok, to post bugs in this mailgroup?  I suspect that there is a bug in
> the following code.
>
> 00247
> Real Bond::accruedAmount(Date settlement) const {
>   Real currentNotional = notional(settlementDate());
>   if (currentNotional == 0.0)
>    return 0.0;
>
>   return BondFunctions::accruedAmount(*this, settlement);
> }
>
> the code is taken from
>  http://quantlib.sourcearchive.com/documentation/1.1-1/bond_8cpp_source.html
>
> notional(settlementDate()) should be notional(settlement) instead - my unit
> tests stopped working for a bond that had a maturity the 8th of February.
>
> regards
> Dagur G
>
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: a bug in Bonds.cpp

Dagur Gunnarsson-2
Hello,

I suspect that this bug is also in 

00232     Rate Bond::yield(Real cleanPrice,
                     const DayCounter& dc,
                     Compounding comp,
                     Frequency freq,
                     Date settlement,
                     Real accuracy,
                     Size maxEvaluations) const {
        Real currentNotional = notional(settlementDate());
        if (currentNotional == 0.0)
            return 0.0;

        return BondFunctions::yield(*this, cleanPrice, dc, comp, freq,
                                    settlement, accuracy, maxEvaluations);
    }

regards 

Dagur G

On Mon, Feb 13, 2012 at 5:22 PM, Luigi Ballabio <[hidden email]> wrote:
Yes, it's a bug.  I've fixed it on the 1.2 branch now.

Thanks for the heads-up.

Luigi


On Mon, Feb 13, 2012 at 3:15 PM, Dagur Gunnarsson <[hidden email]> wrote:
> hello,
>
> Is it ok, to post bugs in this mailgroup?  I suspect that there is a bug in
> the following code.
>
> 00247
> Real Bond::accruedAmount(Date settlement) const {
>   Real currentNotional = notional(settlementDate());
>   if (currentNotional == 0.0)
>    return 0.0;
>
>   return BondFunctions::accruedAmount(*this, settlement);
> }
>
> the code is taken from
>  http://quantlib.sourcearchive.com/documentation/1.1-1/bond_8cpp_source.html
>
> notional(settlementDate()) should be notional(settlement) instead - my unit
> tests stopped working for a bond that had a maturity the 8th of February.
>
> regards
> Dagur G
>
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: a bug in Bonds.cpp

Luigi Ballabio
On Tue, Feb 14, 2012 at 12:10 PM, Dagur Gunnarsson <[hidden email]> wrote:
> Hello,
>
> I suspect that this bug is also in
>
> 00232     Rate Bond::yield(...)

Yes, and also in dirtyPrice() above.  I had fixed all three.

Luigi

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users