Login  Register

Re: A few questions about PiecewiseFlatForward

Posted by Luigi Ballabio-2 on Sep 27, 2002; 1:36am
URL: http://quantlib.414.s1.nabble.com/A-few-questions-about-PiecewiseFlatForward-tp2215p2218.html

Ciao Michele,

At 12:16 AM 9/27/02 +0200, Michele Ravani wrote:
>I was reading through the code of PiecewiseFlatForward and I have a few
>questions:
>
>* Wouldn't it be slightly more efficient to check the condition 'same
>maturity date' in the RateHelperSorter?

Maybe. Which actually means "I don't know." We would save a loop, but we
would add a specific check for equality into RateHelperSorter besides the
present less-than comparison. During the sort, the added check would be
executed N*log(N) times, as opposed to the N times in the present loop.
Really, I don't know. Also, I'm inclined to think that the time saved would
be just a small fraction of the time spent in the bootstrapping proper. Of
course I might be wrong, but as for me, this is the kind of optimizations
that I usually perform only after seeing the output of a profiler...


>* The class takes a reference to a vector of RateHelper handles
>owned by another part of the program.
>
>One can change a rate value (obvious), but also one of the vector
>items, i.e. substitute an element for another or add another one.
>After receiving the notification of a change PiecewiseFlatForward would
>bootstrap at the first chance, but at this point there is not guarantee
>that the instruments vector is still sorted or doesn't contain instruments
>with the same date. Am I missing something?

Yes. The constructor takes a const ref to the vector and _copies_ it. If
one adds/removes/replaces an element in the original vector, this won't
affect the term structure.

Bye for now,
                 Luigi