A quick internet search tells me that a Wiener process is like a random walk or Brownian motion type simulation, so that helps me understand what is going on inside of the loop.
I modified the code to this:
I called the UDF from the spreadsheet with the following inputs:
C is "C"
S is a random double from 0 to 1000
x is a random double from 0 to 1
T is ROUNDUP(n/250,0) (so T will actually be an integer that never includes a fractional portion)
z is a random double from 0 to 1
r is a random double from 0 to 0.1
q is a random double from 0 to 1
n is a random double from 200 to 700 (seems like it maybe should be an integer because we are not really considering fractional trading days).
nlter =1 because I feel like I need to get one random walk to work correctly before I worry about getting 1000 random walks to work correctly.
As noted previously, it seems that a lot of the problem is when there is more than 1 year (when n is greater than 250), and several runs through seem to confirm. Whenever n<250, I get an error free run and some kind of price output (I did not check to see if it was the correct price). Whenever n>250, I get an error 9 subscript out of range. I'm still not sure how the author of this code was intending to keep track of trading years inside of SimVar(), but it seems that something is not quite correct. The way SimVar() is dimensioned, it looks like he/she was intending each "row" (first dimension) would represent a single random walk, and each "column" (second dimension) would represent a trading day. However, inside of the loop, it is almost like the programmer was thinking that each "row" represents a trading year and each "column" represents a trading day. I don't know how he/she intended to represent a random walk (maybe thinking there should be a third dimension to SimVar()??). That seems to me to be where the problem lies. How are you wanting to use SimVar()?
Bookmarks