Posted by
amandine vincotte on
Nov 06, 2007; 2:43pm
URL: http://quantlib.414.s1.nabble.com/Floating-RateBond-tp1544p1555.html
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