|
From: Wei Li <ttl...@gm...> - 2024-01-17 03:27:07
|
Hello Luigi, Thank you for your reply. I actually discovered the ZeroSpreadedTermStructure after my original post, and I think it can solve half of my problem. The other half is for the volatility surfaces. We have our derived class from BlackVolatilityTermStructure to store the smile sections, as well as a constant spread handle. And it is this class that we are caching (in the cache the spread value now is 0). And now we need to assign different spreads to different trades. So is there an equivalent class for spreaded BlackVolatilityTermStructure? If not , I guess I can modify our derived class . Cheers, Wei On Tue, Jan 16, 2024 at 6:31 PM Luigi Ballabio <lui...@gm...> wrote: > Hello, > shallow copy is the C++ default, and I'm afraid we never bothered with > deep copy since most of the time ters structures are passed around by > shared_ptr anyway. > If BASE_TS is your derived class, you can implement a copy constructor. > Otherwise, do you really need a copy to add a spread? As an alternative, > you might pass around your original base term structure and add a constant > spread by means of a class like ZeroSpreadedTermStructure (see > https://github.com/lballabio/QuantLib/blob/master/ql/termstructures/yield/zerospreadedtermstructure.hpp > ). > > Hope this helps, > Luigi > > > On Tue, Jan 2, 2024 at 6:55 AM Wei Li <ttl...@gm...> wrote: > >> Dear all, >> >> Happy new year to all! >> >> In our c++ project we are caching our term structures / vol surfaces >> calibrated from real time market data. And during the calculation we need >> to assign different spread values for different trades. For example, for >> TRADE_A, the risk free term structure would be BASE_TS with a constant 0.01 >> spread, and for TRADE_B, it would be the same BASE_TS with a constant 0.02 >> spread. And we are caching BASE_TS since it makes only sense to us (we have >> our derived classes of YieldTermStructure and VolTermStructure to add the >> spreads, in case you were wondering). >> >> But how can I make a deep copy of BASE_TS and use this copy with >> arbitrary spread values to the calculation? I tried the (default) copy >> constructors of the classes and they are apparently shallow-copied. So how >> can I achieve this? It doesn't need to be the deep copy of the bases, it >> can also be the deep copy of the shared_ptr / handle, as long as it does >> the trick. >> >> Thank you very much! >> >> Cheers, >> Wei >> _______________________________________________ >> QuantLib-users mailing list >> Qua...@li... >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > |