I use the code (taken from
https://mhittesdorf.wordpress.com/2013/12/29/introducing-quantlib-modeling-asset-prices-with-geometric-brownian-motion/)
below to generate GBM sample paths. The code is for a sample path of one year. I
would however like to make sample paths for 100 trading days. So I adjusted
time_steps to 100, but I don’t know what to do with the length variable. When I
set it to 100/255, the extreme values of the sample paths are much bigger and
more frequent then when I just leave it at 1 (which to me seems
counterintuative). So what is the meaning of the length variable and to which
value should I set it? Thank you.
Real starting_price = 20.16; //closing price for INTC on 12/7/2012
Real mu = .2312; //INTC one year historical annual return
Volatility hv = 0.2116; //INTC one year historical volatility
Size time_steps = 255; //trading days in a year (U.S.)
Time length = 1; //one year
//instantiate Geometric Brownian Motion (GBM) stochastic process
const boost::shared_ptr<StochasticProcess>& gbm =
boost::shared_ptr<StochasticProcess> (new
GeometricBrownianMotionProcess(starting_price, mu, hv));
//generate a sequence of normally distributed random numbers from a
//uniform distribution using Box-Muller transformation
BigInteger seed = SeedGenerator::instance().get();
MersenneTwisterUniformRng mersenneRng(seed);
BoxMullerGaussianRng<MersenneTwisterUniformRng>
boxMullerRng(mersenneRng);
RandomSequenceGenerator<BoxMullerGaussianRng<MersenneTwisterUniformRng>>
gsg(time_steps, boxMullerRng);
//generate simulated path of stock price using GBM stochastic process
PathGenerator<RandomSequenceGenerator<BoxMullerGaussianRng<MersenneTwisterUniformRng>>
> gbmPathGenerator(gbm, length, time_steps, gsg, false);
const Path& samplePath =
gbmPathGenerator.next().value;