Posted by
Venkatesh, P.C. on
URL: http://quantlib.414.s1.nabble.com/Heston-process-simulation-values-tp5793.html
Hi, i tried to adapt \test-suite\hestonmodel.cpp to print out path
values of the process. Specifically, within one of the test sections of
hestonmodel, i inserted a snippet of code from
\test-suite\pathgenerator.cpp to print out path values. The key
elements then looks as follows:
boost::shared_ptr<HestonProcess> process(new HestonProcess(
riskFreeTS, dividendTS, s0, 0.3, 1.16, 0.2, 0.8,
0.8));
....
typedef PseudoRandom::rsg_type rsg_type;
typedef MultiPathGenerator<rsg_type>::sample_type sample_type;
BigNatural seed = 42; Time length = 10; Size timeSteps = 12;
Size assets = process->size();
rsg_type rsg =
PseudoRandom::make_sequence_generator(timeSteps*assets,
seed);
MultiPathGenerator<rsg_type> generator(process,
TimeGrid(length, timeSteps),
rsg, false);
Size i;
for (i=0; i<100; i++){
sample_type sample = generator.next();
wtfil << " i= " << i << " value[0]= "<< sample.value[0].back() <<
" value[1]= "<< sample.value[1].back() << std::endl;
} // end i loop
This produces [first 11 values]:
i= 0 value[0]= 8.38959 value[1]= -0.527286
i= 1 value[0]= 7.17443 value[1]= -0.0744848
i= 2 value[0]= 31.5997 value[1]= 0.669117
i= 3 value[0]= 3.29738 value[1]= 0.0869779
i= 4 value[0]= 7.42287 value[1]= 0.220784
i= 5 value[0]= 1.56449 value[1]= -0.0911644
i= 6 value[0]= 4.15224 value[1]= -0.0711199
i= 7 value[0]= 14.0519 value[1]= -0.16052
i= 8 value[0]= 7.14489 value[1]= 0.216222
i= 9 value[0]= 9.32183 value[1]= 0.155854
i= 10 value[0]= 3.46721 value[1]= -0.333396
I thought value[0] and value[1] would be the the asset value and the
variance, respectively [or their changes] at each time step i. But
value[0] seems to jump a lot (e.g., from sstep 1 to step 2] and value[1]
is often negative. Am I doing something wrong, or do these values
represent something else? How would I recover the stock value and
variance at each time step? [I tried different parameter sets----some
fixed the negative variance issue, but value[0] still bounces around a
lot.]
thanks
--------------------------------------------
P.C. Venkatesh
Office of Prudential Supervision & Risk Analysis
Division of Trading and Markets, SEC
Station Place, 100 F Street, N.E., Washington, D.C. 20549
e-mail:
[hidden email]
vox: 202 551 5549
fax: 202 772-9273 .
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users