What is the meaning of time variable in GBM sample paths

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

What is the meaning of time variable in GBM sample paths

nick.snels
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;

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: What is the meaning of time variable in GBM sample paths

Luigi Ballabio
It's the length of the paths as a fraction of year, so 100/255.0 should work.  I haven't checked for extreme values, but when I try your code, extract 10000 sample paths and collect the end points, I get a standard deviation between 5.4 and 5.5 for 255 time steps and length = 1, and a std dev around 2.9 for 100 time steps and length = 100/255.0.

Luigi


On Mon, Jun 27, 2016 at 2:31 PM <[hidden email]> wrote:
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;
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users