private bool TryUpdateStockPrice(WatchListItemViewModel stock) { // Randomly choose whether to udpate this stock or not var r = updateOrNotRandom.NextDouble(); if (r > 0.1) { return false; } // Update the stock price by a random factor of the range percent var random = new Random((int)Math.Floor(stock.Price)); var percentChange = random.NextDouble()*RangePercent; var pos = random.NextDouble() > 0.51; var change = Math.Round(stock.Price*(decimal)percentChange, 2); change = pos ? change : -change; stock.Price += change; return true; }
private bool TryUpdateStockPrice(WatchListItemViewModel stock) { // Randomly choose whether to udpate this stock or not var r = updateOrNotRandom.NextDouble(); if (r > 0.1) { return(false); } // Update the stock price by a random factor of the range percent var random = new Random((int)Math.Floor(stock.Price)); var percentChange = random.NextDouble() * RangePercent; var pos = random.NextDouble() > 0.51; var change = Math.Round(stock.Price * (decimal)percentChange, 2); change = pos ? change : -change; stock.Price += change; return(true); }