Posted by
Luigi Ballabio on
Aug 20, 2007; 4:01pm
URL: http://quantlib.414.s1.nabble.com/Yield-term-structure-tp1265p1267.html
On Mon, 2007-08-20 at 16:45 +0200,
[hidden email]
wrote:
>
> Hi, you could try something like this:
> suppose you define (according to your data):
>
> Calendar cal = ...;
> DayCounter dc = ...;
> vector<Date> dates = ...;
> vector<DiscountFactor> dfs = ...;
>
> remember that the first date must have unit discount factor.
> Define also
>
> LogLinear ln;
> Linear l;
>
> Now suppose for example you want a term structure interpolating
> linearly on rate * time (equivalently loglinearly on discounts)
> You have:
>
> shared_ptr<YieldTermStructure> curve(new
> InterpolatedDiscountCurve<LogLinear>(dates, dfs, dc, cal, ln));
>
> Or, for linear interpolation on discount factors
>
> shared_ptr<YieldTermStructure> curve(new
> InterpolatedDiscountCurve<Linear>(dates, dfs, dc, cal, l));
>
> Also, for linear interpolation on zero rates:
>
> shared_ptr<YieldTermStructure> curve(new
> InterpolatedZeroCurve<Linear>(dates, dfs, dc, l));
True, but you don't need the explicit interpolation arguments. You can
avoid declaring ln and l and simply write:
shared_ptr<YieldTermStructure> curve(new
InterpolatedDiscountCurve<LogLinear>(dates, dfs, dc, cal));
shared_ptr<YieldTermStructure> curve(new
InterpolatedDiscountCurve<Linear>(dates, dfs, dc, cal));
shared_ptr<YieldTermStructure> curve(new
InterpolatedZeroCurve<Linear>(dates, dfs, dc));
Luigi
--
I hate quotations.
-- Ralph Waldo Emerson
-------------------------------------------------------------------------
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