|
From: Wei Li <ttl...@gm...> - 2024-01-02 05:52:23
|
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 |