Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 823
Mark Rhodes Avatar asked Dec 21 '11 23:12

Mark Rhodes


People also ask

How do you make stock predictions?

This method of predicting future price of a stock is based on a basic formula. The formula is shown above (P/E x EPS = Price). According to this formula, if we can accurately predict a stock's future P/E and EPS, we will know its accurate future price.


1 Answers

A simple algorithm is to use a simple volatility number that restricts how much the stock can change within a given period (say, a single day). The higher the number, the more volatile. So each day you can compute the new price by:

rnd = Random_Float(); // generate number, 0 <= x < 1.0 change_percent = 2 * volatility * rnd; if (change_percent > volatility)     change_percent -= (2 * volatility); change_amount = old_price * change_percent; new_price = old_price + change_amount; 

A stable stock would have a volatility number of perhaps 2%. A volatility of 10% would show some pretty large swings.

Not perfect, but it could look pretty realistic.

Samples

enter image description here

like image 187
Jim Mischel Avatar answered Oct 27 '22 18:10

Jim Mischel