RE: A few questions about PiecewiseFlatForward
Posted by Luigi Ballabio-2 on
URL: http://quantlib.414.s1.nabble.com/A-few-questions-about-PiecewiseFlatForward-tp2215p2216.html
At 10:35 AM 9/27/02 +0200, Ravani, Michele wrote:
>Yes, I completely missed the fact that the member variable instruments_ is
>an actual copy.
>This also means that the TermStructure is constant in terms of composition
>after being created.
True. However, this is somehow compensated by the fact that instruments
usually take a relinkable handle, thus allowing one to do:
RelinkableHandle<TermStructure> h;
SomeInstrument i(..., h, ...);
// here the instrument cannot be priced yet---no actual term structure
std::vector<Handle<RateHelper> > v1;
... // compose v1
h.linkTo(Handle<TermStructure>(new PiecewiseFlatForward(..., v1, ...));
// ok, now the instrument uses the piecewise flat forward we just created
std::cout << i.NPV() << std::endl;
// need to change the composition?
std::vector<Handle<RateHelper> > v2; // or reuse v1 if you want
... // compose v2 or change v1
h.linkTo(Handle<TermStructure>(new PiecewiseFlatForward(..., v2, ...));
// now the instrument will use the new term structure
std::cout << i.NPV() << std::endl;
Bye,
Luigi