function randomPrice(oldPrice, volatility) {
  const rnd = randomNumber();
  let changePercent = 2 * volatility * rnd;
  if (changePercent > volatility) {
    changePercent -= (2 * volatility);
  }
  const changeAmount = oldPrice * changePercent;
  const newPrice = oldPrice + changeAmount;
  return newPrice;
}
function randomPrice(oldPrice, volatility) {
  const rnd = randomNumber();
  let changePercent = 2 * volatility * rnd;
  if (changePercent > volatility) {
    changePercent -= (2 * volatility);
  }
  const changeAmount = oldPrice * changePercent;
  const newPrice = oldPrice + changeAmount;
  return newPrice;
}
function randomPrice ( oldPrice , volatility ) { const rnd = randomNumber ( ) ; let changePercent = 2 * volatility * rnd ; if ( changePercent > volatility ) { changePercent -= ( 2 * volatility ) ; } const changeAmount = oldPrice * changePercent ; const newPrice = oldPrice + changeAmount ; return newPrice ; }
Return a random price based on the previous price and volatility
@param {Number} oldPrice - the previous price
@param {Number} volatility - the current volatility
@return {Number} newPrice
Return a random price based on the previous price and volatility