Posted by
gbogaert on
Nov 17, 2009; 11:24am
URL: http://quantlib.414.s1.nabble.com/Heston-model-Monte-Carlo-simulation-tp8160p8162.html
Hello Luigi,
Thank you for your advice. Could you give more detailed on the used of the MultiPath Generator? Is it not used for multiple assets?
In my case I have one asset. Based on the test-suite, I tried the PathGenerator class. From what I understood, a path is generated each time that generator.next() is called, isn't it? I called it several times (50,000x) and took the last value of the sample with sample.value.back() for each generation. I am then surprised that after relaunching my program several times I always get the same values and average.
typedef PseudoRandom::rsg_type rsg_type;
typedef PathGenerator<rsg_type>::sample_type sample_type;
BigNatural seed = 42;
Time length = 10;
Size timeSteps = 12;
bool brownianBridge = true;
Handle<Quote> x0(boost::shared_ptr<Quote>(new SimpleQuote(100.0)));
Handle<YieldTermStructure> r(flatRate(0.05, Actual360()));
Handle<YieldTermStructure> q(flatRate(0.02, Actual360()));
Handle<BlackVolTermStructure> sigma(flatVol(0.20, Actual360()));
boost::shared_ptr<StochasticProcess1D> process (new BlackScholesMertonProcess(x0,q,r,sigma));
rsg_type rsg = PseudoRandom::make_sequence_generator(timeSteps, seed);
PathGenerator<rsg_type> generator(process, length, timeSteps,rsg, brownianBridge);
for (Size i = 0; i <= 50000; i++){
sample_type sample1 = generator.next();
std::cout << sample1.value.at(j) << "\n";
}
Thank you in advance for your help and time.
For any information, please ask.
Regards,
Gilles
Luigi Ballabio wrote
On Fri, 2009-11-06 at 18:19 +0100, Bogaert, Gilles wrote:
> I would like to evaluate the Heston model using a Monte Carlo
> simulation and get the values of the paths back, a kind of array [t,
> St], or better to get the average of the paths at certain dates. I
> went through the sources but I don’t see how to use the pricing engine
> for my purpose.
Gilles,
you can use a MultiPathGenerator with a Heston process. The class is
in <ql/methods/montecarlo/multipathgenerator.hpp>.
For an example, look at <test-suite/pathgenerator.cpp> (even though it
doesn't use Heston.) Let me know if you need additional help.
Luigi
--
Prediction is very difficult, especially if it's about the future.
-- Niels Bohr
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.
http://p.sf.net/sfu/bobj-july_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users