|
From: Luigi B. <lui...@gm...> - 2010-08-31 15:21:43
|
On Tue, 2010-08-31 at 17:47 +0530, animesh saxena wrote: > I located the error in the code. I think this is probably due to > design. > Generally people would like to price options using different > processes. For example Himalayan Option is priced using BlackScholes > process in the example. When I change it to another process like > Merton76Process (which also is Stochastic1D - as per the guidelines), > I should be able to price it. Yes, in principle. But while the path generation does work with a generic process, the McHimalaya path pricer calls a method from the BlackScholes interface, namely, riskFreeRate(). The method is not in the Stochastic1D interface, so we need to cast. > The cast is throwing the error. It should. > If I change it to "STATIC CAST", the error is gone! > boost::shared_ptr<GeneralizedBlackScholesProcess> process = > > boost::static_pointer_cast<GeneralizedBlackScholesProcess>( > > processes_->process(0)); Honestly, I have no idea why this works. The process you're passing is not a GeneralizedBlackScholesProcess, so the cast you're forcing should not succeed. It might just so happen that the bits align right, but that's not guaranteed to be portable. As for a better solution, I'm not sure I have it. It could be that instead of an array of Black-Scholes processes, the Himalaya engine takes a generic process and a discount curve (so it doesn't have to retrieve the risk-free curve.) Luigi -- Just remember what ol' Jack Burton does when the earth quakes, the poison arrows fall from the sky, and the pillars of Heaven shake. Yeah, Jack Burton just looks that big old storm right in the eye and says, "Give me your best shot. I can take it." -- Jack Burton, "Big trouble in Little China" |