help with amortizing notionals

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

help with amortizing notionals

japari

Hi all, I am failing to create an amortizing notional bond schedule and I am not
sure whether I am misinterpreting the way I have to pass the data or a REQUIRE
is written with the test condition in the reverse direction.

I create the bond:

    DayCounter dayCtr = ActualActual();

    Real bondFaceVal = 1000000.0;
    Real redemption  = 100.0;
    Date bondMaturity(todaysDate + Period(3, Years));

    Schedule scheFix(todaysDate,
                     bondMaturity,
                     Period(3,TimeUnit::Months),
                     TARGET(),
                     ModifiedFollowing,
                     ModifiedFollowing,
                     DateGeneration::Backward,
                     false);

    std::vector<Real> notionls(5, bondFaceVal);
    notionls.insert(notionls.end(), 4, bondFaceVal/10.);
    notionls.insert(notionls.end(), 4, bondFaceVal/100.);

    boost::shared_ptr<AmortizingFixedRateBond> amortFix(
      new AmortizingFixedRateBond(0,
        notionls, scheFix, std::vector<Rate>(1, 0.05),
        dayCtr, ModifiedFollowing,
        std::vector<Real>(1, 100.)));


I fail the REQUIRE (line 508 in bond.cpp) at the second notional insertion in

void Bond::calculateNotionalsFromCashflows()


When constructing the bond with a sinking freq I get the same test failure:

    boost::shared_ptr<AmortizingFixedRateBond> amortFix(
      new AmortizingFixedRateBond(0,
        TARGET(), bondFaceVal, todaysDate,
        Period(3, Months), Frequency::Monthly, 0.05,
        dayCtr, ModifiedFollowing, todaysDate));


Regards
Pepe


-------------------------------------------------------------------------
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: help with amortizing notionals

Simon Ibbotson
Hi Pepe,
 
I'm afraid that I'm on holiday at the moment - won't be back at my desk for about 10 days. Also, after I wrote the code, Luigi did some modifications - so I can't be certain that the code in the library will work.
As the code that uses a simple sinking schedule also doesn't work (and therefore has nothing to do with how you've input the notional schedule) I'd guess that there is a problem with the code.
Can you send me the full file - I can't get to the repository on this PC?
Thanks,
Simon

On Wed, Nov 5, 2008 at 7:01 AM, Jose Aparicio-Navarro <[hidden email]> wrote:

Hi all, I am failing to create an amortizing notional bond schedule and I am not
sure whether I am misinterpreting the way I have to pass the data or a REQUIRE
is written with the test condition in the reverse direction.

I create the bond:

   DayCounter dayCtr = ActualActual();

   Real bondFaceVal = 1000000.0;
   Real redemption  = 100.0;
   Date bondMaturity(todaysDate + Period(3, Years));

   Schedule scheFix(todaysDate,
                    bondMaturity,
                    Period(3,TimeUnit::Months),
                    TARGET(),
                    ModifiedFollowing,
                    ModifiedFollowing,
                    DateGeneration::Backward,
                    false);

   std::vector<Real> notionls(5, bondFaceVal);
   notionls.insert(notionls.end(), 4, bondFaceVal/10.);
   notionls.insert(notionls.end(), 4, bondFaceVal/100.);

   boost::shared_ptr<AmortizingFixedRateBond> amortFix(
     new AmortizingFixedRateBond(0,
       notionls, scheFix, std::vector<Rate>(1, 0.05),
       dayCtr, ModifiedFollowing,
       std::vector<Real>(1, 100.)));


I fail the REQUIRE (line 508 in bond.cpp) at the second notional insertion in

void Bond::calculateNotionalsFromCashflows()


When constructing the bond with a sinking freq I get the same test failure:

   boost::shared_ptr<AmortizingFixedRateBond> amortFix(
     new AmortizingFixedRateBond(0,
       TARGET(), bondFaceVal, todaysDate,
       Period(3, Months), Frequency::Monthly, 0.05,
       dayCtr, ModifiedFollowing, todaysDate));


Regards
Pepe



-------------------------------------------------------------------------
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: help with amortizing notionals

Luigi Ballabio
In reply to this post by japari
On Wed, 2008-11-05 at 08:01 +0100, Jose Aparicio-Navarro wrote:
> Hi all, I am failing to create an amortizing notional bond schedule and I am not
> sure whether I am misinterpreting the way I have to pass the data or a REQUIRE
> is written with the test condition in the reverse direction.

No, of course the REQUIRE should be reversed. My mistake. I've fixed it
on the 0.9.7 branch---may you check it?

Thanks,
        Luigi


--

Greenspun's Tenth Rule of Programming:
Any sufficiently complicated C or Fortran program contains an
ad-hoc, informally-specified bug-ridden slow implementation of
half of Common Lisp.



-------------------------------------------------------------------------
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