Posted by
Peter Caspers-4 on
Oct 23, 2015; 5:50am
URL: http://quantlib.414.s1.nabble.com/Passing-on-a-discount-curve-without-interpolating-tp16956p16959.html
Hi Teejayu,
you could implement a new class doing that. Note that the
YieldTermStructure interface requires the implementation of a
time-based discount factor implementation, so you have to convert a
time back to a date in every case. Also be aware of instantaneous
forward rate calculations that are implemented by a finite difference
logic, so if you return the same discount factor throughout a day you
would get zero as the instantaneous forward.
I once implemented a similar kind of class (with a different objective
though) here
https://github.com/pcaspers/quantlib/blob/master/QuantLib/ql/experimental/yield/clonedyieldtermstructure.hppif you are interested to have a look.
In the end I wouldn't expect too much performance gain from such a
specialized class. Even if you feed like 10,000 days the linear
interpolation lookup would have a complexity of around 10 double -
comparisons, so not that bad. The memory footprint seems a more
serious issue for such a representation.
Best regards
Peter
On 21 October 2015 at 22:54, teejayu <
[hidden email]> wrote:
> Hi All,
>
> I have question regarding the YieldTermStructure instance in QuantLib.
> Basically, I would like to construct a YieldTermStructure instance by
> feeding in a vector of discount factors and corresponding dates. What is the
> simplest way to do that?
>
> Currently I am doing is by constructing an InterpolatedDiscountCurve but
> that has to come with interpolation, and since my inputs are already daily
> discount factors I would like to avoid this step and thus save some
> calculation.
>
> The code looks like this:
> *boost::shared_ptr<YieldTermStructure> discountingCrv(new
> InterpolatedDiscountCurve<Linear>(dates, discounts, Actual365Fixed()));*
>
> where dates and discounts are vector of type Date and DiscountFactors
> respectively.
>
> Thank you,
> Teejayu
>
>
>
> --
> View this message in context:
http://quantlib.10058.n7.nabble.com/Passing-on-a-discount-curve-without-interpolating-tp16956.html> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> _______________________________________________
> QuantLib-users mailing list
>
[hidden email]
>
https://lists.sourceforge.net/lists/listinfo/quantlib-users------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users