Re: Caching the pricing engine

Posted by javit on
URL: http://quantlib.414.s1.nabble.com/Caching-the-pricing-engine-tp6574p6581.html

Robert,

The lazy object structure is built exactly for this purpose. Once you change a value at runtime, the observers notify the changes in observables. If I understand your question correctly, you don't have to worry about resetting the engines.

Thank you,
Javit

<quote author="Robert Kubrick">
Is there a way to reset the process for the AnalyticEuropeanEngine  
without creating a new engine instance every time?
I have the following code:

   Date exerciseDate(Day(exercise.day()), Month(exercise.month
().as_enum()), Year(exercise.year()));
   shared_ptr<Exercise> pExercise(new EuropeanExercise(exerciseDate));

   Handle<Quote> underlyingHndl(shared_ptr
(new SimpleQuote
(price)));
   shared_ptr<StrikedTypePayoff> pPayoff(new PlainVanillaPayoff(side  
== CALL ? Option::Call : Option::Put, strike));

   Handle<BlackVolTermStructure> flatVolTS
(shared_ptr<BlackVolTermStructure>(new BlackConstantVol(_settlement,
                                                                         
                           _calendar,
                                                                         
                           vol,
                                                                         
                           _dayCounter)));

   Handle<YieldTermStructure> _flatTermStructure
(shared_ptr<YieldTermStructure>(new FlatForward(_settlement,
                                                                         
                         _riskFreeRate,
                                                                         
                         _dayCounter)));

   shared_ptr<BlackScholesProcess> pProcess(new BlackScholesProcess
(underlyingHndl,
                                                                     
_flatTermStructure,
                                                                     
flatVolTS));
   EuropeanOption eo(pPayoff, pExercise);
   shared_ptr<PricingEngine> pPE(new AnalyticEuropeanEngine(pProcess));
   eo.setPricingEngine(pPE);

I would like to cache most of the instances here and change the  
contract conditions at runtime to calculate option chains.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users