I'm trying to implement a Monte Carlo PricingEngine that stores multidimensional statistics.
I have done the following:
- Defined a Monte Carlo Trait that among other things stores as the path_pricer_type
PathPricer<MultiPath,Array>
(my process is one dimensional but has 2 factors). let's call this struct MyMCTrait. - Implemented a class that derives from both
McSimulation<MyMCTrait,PseudoRandom,SequenceStatistics>
andVanillaOption::engine
. - Implemented a
PathPricer<MultiPath,Array>
in which the first element of the Array returned by the operator() is the price of the option.
I'm getting compiling errors because in methods value() and valueWithSamples() of class McSimulation we have the following initializations:
a. result_type(mcModel_->sampleAccumulator().mean());
b. result_type error(mcModel_->sampleAccumulator().errorEstimate());
that are trying to cast from std::vector<Real>
(returned by the SequenceStatistics methods) to Array (result_type).
I doubt that the right way to go is to implement the cast (if it's possible), could anyone point me to the right direction? Thanks.
EDIT
I got the Pricing Engine working by using a derived class from SequenceStatistics
. I just overrode the inspectors mean() and errorEstimate() and made them return an Array. To do this I used the base class methods + the Array constructor that takes begin and end iterators.
I'm still wondering though if this is the right way to proceed. Thanks for any thoughts.