shared pointers and deep copies

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

shared pointers and deep copies

Eduardo Alonso
Dear all.

I've been thinking about adapting the Monte Carlo engine to calculate the Greeks as well, but I encountered a fundamental problem. It seems to me that the easiest way would be creating several path generators, with shifted yield term structures, shifted implied volatility surfaces, shifted spots and so on. Then I would calculate the payoffs for shifted and non-shifted paths, and compute the Greeks by finite differences. However, since Quantlib uses shared pointers, I see it impossible to clone the stochastic processes and shift everything, since it performs only shallow copies. Did any of you give a thought to this? I even tried replacing all the smart pointers by copy_ptr from http://code.axter.com/copy_ptr.h to no avail -- wouldn't compile. I don't know if it's the particular implementation of the copy_ptr what fails -- since it is not a standard class. Any ideas about how copy_ptr implementations other than the one I mentioned? It is clear that it failed also because some incompatibilities with boost::dynamic_pointer_cast and even maybe the STL.

Thanks a lot in advance and a nice weekend to everyone.

Ed

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: shared pointers and deep copies

Luigi Ballabio
Hi Eduardo,
        apologies for the delay.

On Fri, 2008-02-22 at 18:48 +0100, Eduardo Alonso wrote:

> I've been thinking about adapting the Monte Carlo engine to calculate
> the Greeks as well, but I encountered a fundamental problem. It seems
> to me that the easiest way would be creating several path generators,
> with shifted yield term structures, shifted implied volatility
> surfaces, shifted spots and so on. Then I would calculate the payoffs
> for shifted and non-shifted paths, and compute the Greeks by finite
> differences. However, since Quantlib uses shared pointers, I see it
> impossible to clone the stochastic processes and shift everything,

True. However, you could still clone the process manually. What kind of
code were you trying to write? Do you have any sample snippet of code
you can post here?

Luigi


--

Ninety percent of everything is crap.
--- Theodore Sturgeon



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: shared pointers and deep copies

Eduardo Alonso
Thanks for your answer, Luigi. I will work something ou and send it to the list.

Regards

Eduardo

On Thu, Mar 13, 2008 at 11:31 AM, Luigi Ballabio <[hidden email]> wrote:
Hi Eduardo,
       apologies for the delay.

On Fri, 2008-02-22 at 18:48 +0100, Eduardo Alonso wrote:

> I've been thinking about adapting the Monte Carlo engine to calculate
> the Greeks as well, but I encountered a fundamental problem. It seems
> to me that the easiest way would be creating several path generators,
> with shifted yield term structures, shifted implied volatility
> surfaces, shifted spots and so on. Then I would calculate the payoffs
> for shifted and non-shifted paths, and compute the Greeks by finite
> differences. However, since Quantlib uses shared pointers, I see it
> impossible to clone the stochastic processes and shift everything,

True. However, you could still clone the process manually. What kind of
code were you trying to write? Do you have any sample snippet of code
you can post here?

Luigi


--

Ninety percent of everything is crap.
--- Theodore Sturgeon




-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users