Example #1
0
            private void DoStart()
            {
                for (int i = 0; i < 10; ++i)
                {
                    var prices = new Prices();
                    double mid = _randGenerator.NextDouble() * 100;

                    prices.BidPx = Math.Max(0, mid - TickSize);
                    prices.AskPx = Math.Max(0, mid + TickSize);
                    prices.BidQty = (uint)_randGenerator.Next(1, 10) * 10;
                    prices.AskQty = (uint)_randGenerator.Next(1, 10) * 10;
                    prices.Volume = 0;

                    _prices[i] = prices;
                }

                DispatchPrices();
                _timer.Start();
            }
        private void DoStart()
        {
            for (int i = 0; i < 10; ++i)
            {
                var    prices = new Prices();
                double mid    = _randGenerator.NextDouble() * 100;

                prices.BidPx  = Math.Max(0, mid - TickSize);
                prices.AskPx  = Math.Max(0, mid + TickSize);
                prices.BidQty = (uint)_randGenerator.Next(1, 10) * 10;
                prices.AskQty = (uint)_randGenerator.Next(1, 10) * 10;
                prices.Volume = 0;

                _prices[i] = prices;
            }

            DispatchPrices();
            _timer.Start();
        }
        private void UpdatePrices()
        {
            for (int i = 0; i < 10; ++i)
            {
                if (_randGenerator.Next(0, 2) != ShouldUpdatePrices)
                {
                    continue;
                }

                Prices prices = _prices[i];
                bool   walkUp = Convert.ToBoolean(_randGenerator.Next(0, 2));

                double tickToUse = walkUp ? TickSize : -1 * TickSize;

                prices.BidPx += tickToUse;
                prices.AskPx += tickToUse;

                prices.BidQty  = (uint)_randGenerator.Next(1, 10) * 10;
                prices.AskQty  = (uint)_randGenerator.Next(1, 10) * 10;
                prices.Volume += (uint)_randGenerator.Next(1, 10) * 10;

                NewPricesArrived?.Invoke(this, (uint)i, prices);
            }
        }