What am I doing
I am making a chart of fictitious stock options. The price is updated every second using this function.
function stockVariation($price,$max_up,$max_down) { // Price > 1 if($price > 1) { // Calculate $ratio=(mt_rand(0,$max_up/2)-mt_rand(0,$max_down/2))/1000; $price+=$ratio; } // Price <=1 (we don't want 0 or negative price...) else $price+=mt_rand(1,$max_up)/1000; return round($price,3); }
I use the values โโmax_up and max_down (from 10 to 100) to gradually change the price and simulate some volatility.
For example, with max_up: 40 and max_down: 45, the price will gradually decline.
My question
But the problem is that the generated prices are too much volatile, even if max_up = max_down. The result is not applicable. (e.g. + 10 points in one day for a base price of 15,000).
The result of the evolution of prices per hour within 24 hours 
Is it possible that choosing a round ($ price, 4) and dividing by 10,000 instead of 1,000 would be better?
If anyone has an idea or advice to generate a โnaturalโ evolution of prices, thanks in advance.
Valky source share