On 03/24/2006 05:00:51 PM, davide ricci wrote:
> I'm trying to use a Monte Carlo to price an European option and I'm
> using as reference the esemple EuropeanOption.cpp. It seems to me
> that in this example, only one Monte Carlo simulation is performed on
> random path.
This is correct.
> Instead I'd like to perform several simulations to price the
> option. Therefore I think I've to write a code like this :
>
> for (int i = 0 ; i < M ; i++)
> {
> boost::shared_ptr<PricingEngine> mcengine1;
> mcengine1=MakeMCEuropeanEngine<PseudoRandom>().withSteps(timeSteps).withTolerance(0.02).withSeed(mcSeed);
> option.setPricingEngine(mcengine1);
> value = option.NPV();
> }
>
> where M is the number of simulations. For every simulation I've also
> to generate a new seed.
> Is this correct ?
Yes, I think so.
> What kind of method I can use to generate the seed ?
A quick hack could be to use the current time;
seed = (unsigned long)(std::time(0));
would give you a random seed at each iteration. However, I suspect that
a bit of googling would give you better references on how to choose
seeds for this purpose.
Ciao,
Luigi
----------------------------------------
Discontent is the first necessity of progress.
-- Thomas A. Edison