Re: YieldCurve from discount factors

Posted by javit on
URL: http://quantlib.414.s1.nabble.com/YieldCurve-from-discount-factors-tp7795p7796.html

Build two vectors of types Rate and Date. Call them dates and rates. Find the rate for that particular date by using your discount curve data. Define a day counter (termStructureDayCounter) and a calendar. Initiate an instant of the termstructure class as below.

        Handle<YieldTermStructure> refTermStructure(boost::shared_ptr<YieldTermStructure>(
                new InterpolatedZeroCurve<LogLinear>(dates, rates, termStructureDayCounter)));

To get your discount rate for a particular date, you can use something like this:

refTermStructure->discount(Date(11,July,2010))

You can also use interpolation methods other than LogLinear. Go through the source code, you will see.

Javit

Shuaib Osman wrote
Hi,

Is there any way in quantlib not to create a yieldcurve from ratehelpers (the usual depo/fra/future/swap ones) but instead to import an existing yield curve (a zero curve that starts today and has every point till 20 years from now). I've tried creating deposit rate helpers for each day but I keep getting the "two instruments have the same maturity" error.

So, in short, I've got all the discount factors - I need to create a yieldcurve object.

Thanks.