Re: YieldCurve from discount factors
Posted by Cliffy on
URL: http://quantlib.414.s1.nabble.com/YieldCurve-from-discount-factors-tp7795p7798.html
Hi, I am new to quantlib, read this post and out of curiosity want to try it out.
I thought the usage of "InterpolatedDiscountCurve" is to provide a set of "discount factors" and
be able to calculate par rates on the curve.
I use a simple unrealistic discount curve (to 30 days) -
Date Disc factor
Sep 23 1
Oct 1 0.995
Nov 3 0.992
try to calculate par rate as of Oct 1, I got
0.0050251256281407079
it seemd to be too small, shouldn't be around 20%??
here are the codes,
vector<Date> dates;
vector<DiscountFactor> rates;
vector<Date> datesIn;
DayCounter termStructureDayCounterX = Actual360();;
Calendar calendarX = TARGET();
Date settlementDateX(22, September, 2004);
Date d1 = calendarX.advance(settlementDateX, 1,Days);
dates.push_back(d1);
d1 = calendarX.advance(settlementDateX, 7,Days);
dates.push_back(d1);
d1 = calendarX.advance(settlementDateX, 30,Days);
dates.push_back(d1);
Rate r1 = 1;
rates.push_back(r1);
r1 = 0.995;
rates.push_back(r1);
r1 = 0.992;
rates.push_back(r1);
Handle<YieldTermStructure>
refTermStructure(boost::shared_ptr<YieldTermStructure>(
new InterpolatedDiscountCurve<LogLinear>(dates, rates,
termStructureDayCounterX)));
d1 = calendarX.advance(settlementDateX, 1,Days);
datesIn.push_back(d1);
d1 = calendarX.advance(settlementDateX, 7,Days);
datesIn.push_back(d1);
Rate r2;
r2 = refTermStructure->parRate(datesIn,Annual,true);
cout << r2; // r2 = 0.0050251256281407079
What did I do wrong here??
Regards,
Cliff