Floating RateBond

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

Floating RateBond

amandine vincotte
Hi ,
 
I am trying to use the FloatingRateBond function.
The effective date is : 9 Sept 2007
      maturity date: 5 Feb 2012
 
And I have an Evalutation Date on the 2nd Of November.
 
So my Float Schedule starts on the 9 Sept 2007, with the first coupon being on the 5 of November.
 
And I have a discount Curve which starts on the evaluation Date.
 
My question is how does the FloatingRateBond function knows what is my Evalution Date when calculating the NPV.
I have tried this:

Settings::instance().evaluationDate() =Evaluation Date

 

But my function below still doesnt work when calling the NPV() function:

 

FloatingRateBond FRN(settlementDays,faceAmount,FloatSchedule,euriborIndex,dayCount,conv,-fixingDays,vector< Real >(1,1.0),spreads,vector< Rate >(1,0.0) ,vector< Rate >(1,0.0),false,100,Date(),dfc);

 

Thanks a lot in advance

 

Amandine

 

 
 
 

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

Luigi Ballabio

On Tue, 2007-11-06 at 05:12 -0800, amandine vincotte wrote:
> My question is how does the FloatingRateBond function knows what is my
> Evalution Date when calculating the NPV.
> I have tried this:
>
> Settings::instance().evaluationDate() =Evaluation Date

This is correct.
>
> But my function below still doesnt work when calling the NPV()
> function:
>
> FloatingRateBond
> FRN(settlementDays,faceAmount,FloatSchedule,euriborIndex,dayCount,conv,-fixingDays,vector< Real >(1,1.0),spreads,vector< Rate >(1,0.0) ,vector< Rate >(1,0.0),false,100,Date(),dfc);
>
May you post the piece of code where you initialize the schedule and
such, and the other where you call NPV()? Also, you say "doesn't work"
as in "raises an error" or as in "gives the wrong result"?

Later,
        Luigi


--

There are no rules of architecture for a castle in the clouds.
-- Gilbert K. Chesterton



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

amandine vincotte
In reply to this post by amandine vincotte
Hi  Luis,

Thank you very much for your help.
The program breaks down when evaluating the FloatingRateCoupon::amount() function in the floatingratecoupon.cpp


Here is the code below:


 ////trade 2226//////
    Date effectiveDate(5,Month(9),2007);
 Date maturityDate(5,Month(2),2012);
 Date issueDate(5,Month(2),2007);
    Date evalDate(2,Month(11),2007);
    Frequency per = Quarterly;
    Calendar calendar = TARGET();
    BusinessDayConvention conv = ModifiedFollowing;
   string currStr="EUR";
    Natural settlementDays=0;
    Real faceAmount=100;
    DayCounter dayCount = Actual360();
    Natural fixingDays=2;
    vector<Spread> spreads;
     spreads.push_back(1);
     spreads.push_back(0.002);
 //////////Building the discount curve dfc//////////////////////
 
 RelinkableHandle<YieldTermStructure> dfc;
 if(currStr=="EUR")
 {
  if(dfc.empty() || dfc->referenceDate()!=evalDate)
   buildDfC(evalDate,currStr.c_str(),dfc);///////////////////calling the BuildDfC function
     
 }
 if(currStr=="USD")
 {
  if(dfc.empty() || dfc->referenceDate()!=evalDate)
   buildDfC(evalDate,currStr.c_str(),dfc);
 }

///////////////////////////////////////////////////////////////////
 Settings::instance().evaluationDate() = evalDate;
/////////////////////////////////////////////////////////////////////////
  ////////////////schedule//////////////////////////First coupon date should be 5 Nov 2007//////////////
Schedule  FloatSchedule(effectiveDate,maturityDate,Period(per),calendar,conv,conv,true,false,Date(),Date());
  /////////////////////IborIndex////////////////////////////////////
boost::shared_ptr<IborIndex> euriborIndex(new Euribor3M(dfc));
FloatingRateBond FRN(settlementDays,faceAmount,FloatSchedule,euriborIndex,dayCount,conv,-fixingDays,vector< Real >(1,1.0),spreads,vector< Rate >(1,0.0) ,vector< Rate >(1,0.0),false,100,issueDate,dfc);
Real NPV=FRN.NPV();
 cout<<NPV<<endl;




If  you need more info ( for example about the discount curve building function) please elt me know.


Many thanks

Amandine


----- Original Message ----
From: Luigi Ballabio <[hidden email]>
To: amandine vincotte <[hidden email]>
Cc: [hidden email]
Sent: Tuesday, November 6, 2007 1:31:38 PM
Subject: Re: [Quantlib-users] Floating RateBond


On Tue, 2007-11-06 at 05:12 -0800, amandine vincotte wrote:
> My question is how does the FloatingRateBond function knows what is my
> Evalution Date when calculating the NPV.
> I have tried this:
>
> Settings::instance().evaluationDate() =Evaluation Date

This is correct.
>
> But my function below still doesnt work when calling the NPV()
> function:
>
> FloatingRateBond
> FRN(settlementDays,faceAmount,FloatSchedule,euriborIndex,dayCount,conv,-fixingDays,vector< Real >(1,1.0),spreads,vector< Rate >(1,0.0) ,vector< Rate >(1,0.0),false,100,Date(),dfc);
>
May you post the piece of code where you initialize the schedule and
such, and the other where you call NPV()? Also, you say "doesn't work"
as in "raises an error" or as in "gives the wrong result"?

Later,
    Luigi


--

There are no rules of architecture for a castle in the clouds.
-- Gilbert K. Chesterton

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

Luigi Ballabio

On Tue, 2007-11-06 at 06:43 -0800, amandine vincotte wrote:
> The program breaks down when evaluating the
> FloatingRateCoupon::amount() function in the floatingratecoupon.cpp

Try enclosing your code in:

try {
    // your code
} catch (std::exception& e) {
    cout << e.what() << endl;
}

What does it print?

Luigi


--

A debugged program is one for which you have not yet found the
conditions that make it fail.
-- Jerry Ogdin



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

amandine vincotte
In reply to this post by amandine vincotte
Hi,

It prints: "Pricer not set".
What does this mean?

Thanks
Amandine

----- Original Message ----
From: Luigi Ballabio <[hidden email]>
To: amandine vincotte <[hidden email]>
Cc: [hidden email]
Sent: Tuesday, November 6, 2007 2:53:00 PM
Subject: Re: [Quantlib-users] Floating RateBond


On Tue, 2007-11-06 at 06:43 -0800, amandine vincotte wrote:
> The program breaks down when evaluating the
> FloatingRateCoupon::amount() function in the floatingratecoupon.cpp

Try enclosing your code in:

try {
    // your code
} catch (std::exception& e) {
    cout << e.what() << endl;
}

What does it print?

Luigi


--

A debugged program is one for which you have not yet found the
conditions that make it fail.
-- Jerry Ogdin

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

Luigi Ballabio

On Tue, 2007-11-06 at 07:17 -0800, amandine vincotte wrote:
> It prints: "Pricer not set".
> What does this mean?

Oh, right. In version 0.8, there was no default for coupon pricers.
You'll have to explicitly write how to evaluate the coupon.
After you create the bond and before calling NPV(), write

boost::shared_ptr<IborCouponPricer> pricer(new BlackIborCouponPricer);
setCouponPricer(FRN.cashflows(),pricer);

In next release, this will no longer be necessary.

Luigi



--

Ogden's Law:
The sooner you fall behind, the more time you have to catch up.



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

amandine vincotte
In reply to this post by amandine vincotte
Hi again,

Do I need to set a volatility as well? It says it is missing the caplet volatility also I have defined a plain vanilla floating rate bond.

Many thanks.


Amandine

----- Original Message ----
From: Luigi Ballabio <[hidden email]>
To: amandine vincotte <[hidden email]>
Cc: [hidden email]
Sent: Tuesday, November 6, 2007 3:39:08 PM
Subject: Re: [Quantlib-users] Floating RateBond


On Tue, 2007-11-06 at 07:17 -0800, amandine vincotte wrote:
> It prints: "Pricer not set".
> What does this mean?

Oh, right. In version 0.8, there was no default for coupon pricers.
You'll have to explicitly write how to evaluate the coupon.
After you create the bond and before calling NPV(), write

boost::shared_ptr<IborCouponPricer> pricer(new BlackIborCouponPricer);
setCouponPricer(FRN.cashflows(),pricer);

In next release, this will no longer be necessary.

Luigi



--

Ogden's Law:
The sooner you fall behind, the more time you have to catch up.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

amandine vincotte
In reply to this post by amandine vincotte
Luigi, I tried this but version 0.8.1 doesn't seem to find this function setCouponPricer.  Any other suggestions?

Thanks a lot

Amandine

----- Original Message ----
From: Luigi Ballabio <[hidden email]>
To: amandine vincotte <[hidden email]>
Cc:
Sent: Tuesday, November 6, 2007 3:39:08 PM
Subject: Re: [Quantlib-users] Floating RateBond


On Tue, 2007-11-06 at 07:17 -0800, amandine vincotte wrote:
> It prints: "Pricer not set".
> What does this mean?

Oh, right. In version 0.8, there was no default for coupon pricers.
You'll have to explicitly write how to evaluate the coupon.
After you create the bond and before calling NPV(), write

boost::shared_ptr<IborCouponPricer> pricer(new BlackIborCouponPricer);
setCouponPricer(FRN.cashflows(),pricer);

In next release, this will no longer be necessary.

Luigi



--

Ogden's Law:
The sooner you fall behind, the more time you have to catch up.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

amandine vincotte
In reply to this post by amandine vincotte
Sorry for bombarding you with mails .... but there is a 3rd error type I get that I do not understand when running the NPV function.

I get the error message which says " Missing Euribor3M Actual/360 fixing for November 1st ,2007"

So to double check I use the function ForecastFixing(date)  for the 1rst of November and it does return a results.
boost::shared_ptr<IborIndex> euriborIndex(new Euribor3M(dfc));
Date test(1,Month(11),2007);
cout<<euriborIndex->forecastFixing(test)<<endl;
cout<<test<<endl;

I find it puzzling...

Thank you


Amandine


----- Original Message ----
From: amandine vincotte <[hidden email]>
To: [hidden email]
Cc: [hidden email]
Sent: Tuesday, November 6, 2007 5:26:13 PM
Subject: Re: [Quantlib-users] Floating RateBond

Hi again,

Do I need to set a volatility as well? It says it is missing the caplet volatility also I have defined a plain vanilla floating rate bond.

Many thanks.


Amandine

----- Original Message ----
From: Luigi Ballabio <[hidden email]>
To: amandine vincotte <[hidden email]>
Cc: [hidden email]
Sent: Tuesday, November 6, 2007 3:39:08 PM
Subject: Re: [Quantlib-users] Floating RateBond


On Tue, 2007-11-06 at 07:17 -0800, amandine vincotte wrote:
> It prints: "Pricer not set".
> What does this mean?

Oh, right. In version 0.8, there was no default for coupon pricers.
You'll have to explicitly write how to evaluate the coupon.
After you create the bond and before calling NPV(), write

boost::shared_ptr<IborCouponPricer> pricer(new BlackIborCouponPricer);
setCouponPricer(FRN.cashflows(),pricer);

In next release, this will no longer be necessary.

Luigi



--

Ogden's Law:
The sooner you fall behind, the more time you have to catch up.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

Luigi Ballabio
In reply to this post by amandine vincotte

On Tue, 2007-11-06 at 09:26 -0800, amandine vincotte wrote:
> Do I need to set a volatility as well?

No---it is only used if the coupons fix in arrears.

Luigi


--

There are no rules of architecture for a castle in the clouds.
-- Gilbert K. Chesterton



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

Luigi Ballabio
In reply to this post by amandine vincotte

On Tue, 2007-11-06 at 10:13 -0800, amandine vincotte wrote:
> Luigi, I tried this but version 0.8.1 doesn't seem to find this
> function setCouponPricer.

What's the error exactly?

Luigi


--

The first rule of intelligent tinkering is to save all the parts.
-- Paul Erlich



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

amandine vincotte
In reply to this post by amandine vincotte
Hi Luigi,


I get two types of errors:
- when I set the effective date and the evaluation date to be different :
I get the Euribor3M fixing missing  for the 1rst of November ( although I can print it with the forecastFixing function)
- when I set the effective date and the evaluation date to be the same
I get the the missing caplet volatility error only



I have noticed that the function " setCoupon Pricer"  is not used when debugging the code as it does not step into it. Then I did a search in the code version 0.8.1 and it could not find it.



Thank you

Amandine


----- Original Message ----
From: Luigi Ballabio <[hidden email]>
To: amandine vincotte <[hidden email]>
Cc: [hidden email]
Sent: Wednesday, November 7, 2007 10:05:38 AM
Subject: Re: [Quantlib-users] Floating RateBond


On Tue, 2007-11-06 at 09:26 -0800, amandine vincotte wrote:
> Do I need to set a volatility as well?

No---it is only used if the coupons fix in arrears.

Luigi


--

There are no rules of architecture for a castle in the clouds.
-- Gilbert K. Chesterton

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

amandine vincotte
In reply to this post by amandine vincotte
My apologies although the debugger doesn't step into it I did find it in Quantlib.

The two other errors remain.


Thank you

Amandine

----- Original Message ----
From: amandine vincotte <[hidden email]>
To: Luigi Ballabio <[hidden email]>
Cc: [hidden email]
Sent: Wednesday, November 7, 2007 10:36:12 AM
Subject: Re: [Quantlib-users] Floating RateBond

Hi Luigi,


I get two types of errors:
- when I set the effective date and the evaluation date to be different :
I get the Euribor3M fixing missing  for the 1rst of November ( although I can print it with the forecastFixing function)
- when I set the effective date and the evaluation date to be the same
I get the the missing caplet volatility error only



I have noticed that the function " setCoupon Pricer"  is not used when debugging the code as it does not step into it. Then I did a search in the code version 0.8.1 and it could not find it.



Thank you

Amandine


----- Original Message ----
From: Luigi Ballabio <[hidden email]>
To: amandine vincotte <[hidden email]>
Cc: [hidden email]
Sent: Wednesday, November 7, 2007 10:05:38 AM
Subject: Re: [Quantlib-users] Floating RateBond


On Tue, 2007-11-06 at 09:26 -0800, amandine vincotte wrote:
> Do I need to set a volatility as well?

No---it is only used if the coupons fix in arrears.

Luigi


--

There are no rules of architecture for a castle in the clouds.
-- Gilbert K. Chesterton

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating RateBond

Luigi Ballabio
In reply to this post by amandine vincotte

On Wed, 2007-11-07 at 02:36 -0800, amandine vincotte wrote:
> I get two types of errors:
> - when I set the effective date and the evaluation date to be
> different :
> I get the Euribor3M fixing missing  for the 1rst of November
> ( although I can print it with the forecastFixing function)

November 1st is in the past, so you have to provide the fixing (even
though it could forecast it somehow---but I wouldn't trust
forecastFixing() in this case. It should probably be in the private
interface.) You can do it by adding

euriborIndex->addFixing(Date(1,November,2007), rate);

where rate is the fixing value.

> - when I set the effective date and the evaluation date to be the same
> I get the the missing caplet volatility error only

Hmm. I thought we didn't need a volatility in this case. Apparently, we
did a very thorough job of making simple things difficult. Let me
check... No, I see it now. When you initialize your FRN, you're passing
vector<Rate>(1,0.0) as both caps and floors---which doesn't make much
sense. If you want to say "no caps" or "no floors", pass an empty vector
instead, i.e., vector<Rate>().

If you do want to pass a cap and/or a floor (not both 0.0, though...)
you'll need a caplet volatility.

Luigi


--

The economy depends about as much on economists as the weather does on
weather forecasters.
-- Jean-Paul Kauffmann



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users