I am trying to model the stock's price process. Let's assume volatility and risk-free rate is given. I've come up with the code below to try and model the price process with the geometrical Brownian motion. This should take into account risk-free rate and dividend yield q.
$$S_t = S_0 \exp\left(\left[r-q-\frac 12\sigma^2\right]t + \sigma W_t\right)$$
% initial price, time, risk-free rate, dividend yield pct, volatility % p = simPrice(66, 365, 0.0088, 0.0236, 0.2); function [path] = simPrice(initialPrice, days, r, q, sigma) path = zeros(1, days+1); path(1) = initialPrice; for t=1:length(path)-1 path(t+1) = nextSt(path(t), (1/days), r, q, sigma); end end function [ expected ] = nextSt(initial, t, r, q, sigma) n = randn(); expected = initial * exp( (r - q -(0.5 * (sigma^2)))*t + sigma*sqrt(t)*n); end
However, as I am quite new to this, I'd like some reassurance that this is indeed correct. I feel like the price process is a bit jumpy? I am particularly worried that I am doing something wrong in the nextSt(..) function. This could be either in the formula inside the function itself (am I implementing the $W_t$ part of the formula correctly?) or the parameters I pass to it. For example, I am not sure if I am doing the time parameters right here.
Note that I am using annualised volatility, dividend yield and risk-free rate. The next St is always computed over one day. So shouldn't I have to convert those parameters to daily values by dividing by $sqrt(252)$?
This is the result when I do so:
The results on the first graph seem more plausible, but the parameters I used there make no sense?