private bool TryUpdateStockPrice(Stock stock) { var r = updateOrNotRandom.NextDouble(); if (r > .1) { return false; } var random = new Random((int)Math.Floor(stock.Price)); var percentChange = random.NextDouble() * rangePercent; var pos = random.NextDouble() > .51; var change = Math.Round(stock.Price * (decimal)percentChange, 2); change = pos ? change : -change; stock.Price += change; return true; }
private void BroadcastStockPrice(Stock stock) { Clients.All.updateStockPrice(stock); }