Re: History construction
Posted by
Luigi Ballabio-2 on
URL: http://quantlib.414.s1.nabble.com/History-construction-tp2517p2519.html
At 03:07 PM 5/8/03 +0100, Alex McGuire wrote:
>Andre Louw wrote:
>>While looking at History I notice that feeding the History(dates,value)
>>constructor with lists with missing dates/values causes it to fill these
>>blanks with Null<double> values. Any objection to me propagating the last
>>known value into these slots (in my example the Friday's rate will then be
>>used as the last known rate)? I could always pass a flag to specify whether
>>this must be done or not?
>I wouldn't recommend that.
>
>There are several ways the missing rates could be filled (last good value,
>next good value, interpolation ...), so implementing this in the
>constructor would need more than just a flag, complicating things somewhat.
Good point.
>Supposing you really do need rates for every day, I think it would be
>better to add a method to History to either
> a) fill it's own gaps
> b) return a copy with the gaps filled in
>in either case taking some parameter that determines the rule used to fill
>the gaps. I'd choose b) as I'm an immutability nut, but whatever.
I'd second that, and being a polymorphism nut, I'd dump the method and
write a few history processors---each of them taking a History and
returning a copy with gaps filled in according to its one rule.
Bye,
Luigi