예제 #1
0
        private bool TryUpdateStockPrice(StockModel stock)
        {
            var r = _updateOrNotRandom.NextDouble();

            if (r > 0.1)
            {
                return(false);
            }

            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);
        }
예제 #2
0
 private void BroadcastStockPrice(StockModel stock)
 {
     Clients.All.updateStockPrice(stock);
 }