algorithmstockstochastic-process

Are there known techniques to generate realistic looking fake stock data?


I recently wrote some Javascript code to generate random fake stock data as I wanted to show a chart that at first glanced looked like real stock data - but all I came up with was pretty noddy. I was just wondering if there are some resources that explain how this might be done "properly" i.e. so you get realistic looking data that has the same patterns that you see in real stock data?


Solution

  • I had a book Fractal Market Analysis (just got rid of it recently) that talked about the statistical properties of stock prices. Not very useful for investing, but it might have been able to help you.

    You'll need something that models a random process with desired statistical properties. Two examples of random processes are Gaussian white noise and a Wiener process (the latter which models Brownian motion and is also the limit of a random walk with small steps).

    If I remember right from the Fractal Market Analysis book, there was an assertion that the logarithm of stock prices had characteristics similar to so-called "1/f noise" or "pink noise", so you could try looking for articles on pink noise generation in software. (and then take the results and plug them into e^x) (edit: oops, I misremembered. Looks like it's more like fractional Brownian motion)

    (Here's a nice readable essay that talks about the history behind the study of fractal random processes -- and how the flooding of the Nile relates to the stock market -- unfortunately it doesn't get into technical data, but maybe there are search terms like Hurst exponent that can get you started.)

    The problem becomes more difficult if you need multiple series of stock data. (in which case there is some correlation between stocks that depends on various common factors e.g. national economy, industry type, etc.) I'm not sure how you could go about that, but start with one random process first.