|
From: Fabrice L. <fab...@qu...> - 2017-11-21 03:45:39
|
Hi all, I've run into an "inheritance issue" for which I'm uncertain of the way forward. Note that I'm using QuantLib in C# through SWIG. I'm building a set of yield curves (PiecewiseYieldCurve) of various flavors: some are inheriting InterpolatedDiscountCurve, some from InterpolatedZeroCurve, etc. In order to use those curves as exogenous discounting curves for other calibration instruments (SwapRateHelper for instance) and to be able to store them all in a single place, I store them in a Dictionary<string, YieldTermStructureHandle>. I also want to be able to display them using dates, not times, as the pillar points. While I can call discounts() on YieldTermStructureHandle, the dates() accessor is unavailable, because it is not defined in YieldTermStructure. It doesn't seem that I can dereference the handle (I'm in C#) and downcast the YieldTermStructure to a PiecewiseYieldCurve that I could query for dates. Furthermore, in C++ the dates() accessor is never defined as a virtual function of a base class, despite being present in all the classes inheriting from InterpolatedCurve<Interpolator>. I realize this would not solve my issue, but maybe a DateInterpolatedCurve class, between InterpolatedCurve and say InterpolatedDiscountCurve, which would hold mutable std::vector<Date> dates_ and const std::vector<Date>& dates() const; would make sense. What's the best way forward in order for me to be able to retrieve the pillar dates of those curves while retaining the capacity to store them all under one base class handle type regardless of their "flavor"? Regards, Fabrice Lecuyer |