Re: YieldCurve from discount factors (2)

Posted by Giorgio Pazmandi on
URL: http://quantlib.414.s1.nabble.com/YieldCurve-from-discount-factors-tp7795p7800.html

Sorry, I did not see that QL uses the frequency passed in input for the
calculation of the parrate, i.e. the formula is correct and is

ParRate = (DF_start - DF_end) * frequency / \SUM(DF_i),

This is equivalent to my formula if (t_i - t_{i-1}) = 1/frequency (as it
should for a "normal" swap :-) )

Basically, you are evaluating a rate for a 1 year period that accrues the
same as the 8-day period:

R * t * DF = 0.50251256281407079% * 1 * 0.995 = 22.6131% * 0.022222222 *
0.995

Regards,

Giorgio Pazmandi



> -----Original Message-----
> From: Giorgio Pazmandi [mailto:[hidden email]]
> Sent: giovedì, 19. novembre 2009 10:58
> To: 'Cliffy'; [hidden email]
> Subject: Re: [Quantlib-users] YieldCurve from discount factors
>
> Hi Cliffy, the par rate is calculated in QL with the formula
> ParRate = (DF_start - DF_end) / \SUM(DF_i) = (1 - 0.995) / (0.995) =
> 0.0050251256281407079
>
> Maybe I'm wrong, but I would have expected:
> ParRate = (DF_start - DF_end) / \SUM(DF_i * (T_i - T_{i-1})) = (1 -
> 0.995) /
> (0.995 * 0.02222222) = 22.6131%
>
>
> If you simply wanted to evaluate a zero rate (instead of the par rate)
> the
> call would be, for example:
> r2 = refTermStructure->zeroRate(QuantLib::Date(1, October, 2004),
> termStructureDayCounterX, Simple, Annual, true);
> wich also gives 22.6131%
>
>
> Hope that helps
>
> Best regards,
>
> Giorgio
>
>
> > -----Original Message-----
> > From: Cliffy [mailto:[hidden email]]
> > Sent: mercoledì, 18. novembre 2009 21:02
> > To: [hidden email]
> > Subject: Re: [Quantlib-users] YieldCurve from discount factors
> >
> >
> > 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
> >
> > --
> > View this message in context: http://old.nabble.com/YieldCurve-from-
> > discount-factors-tp26375800p26414696.html
> > Sent from the quantlib-users mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> --
> > -------
> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> > 30-Day
> > trial. Simplify your report design, integration and deployment - and
> > focus on
> > what you do best, core application coding. Discover what's new with
> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> > _______________________________________________
> > QuantLib-users mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>
> -----------------------------------------------------------------------
> -------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users