Пример #1
0
        private void OnTick(MarketTick ticks)
        {
            _lastTicks.Add(ticks);
            if (_lastTicks.Count == 20)
            {
                _lastTicks.RemoveAt(0);
            }

            var start = DateTime.Now;
            var spreads = _lastTicks.Select(x => 100 * (x.Mid - x.Bid) / x.Bid);
            Console.WriteLine("Time (computing spreads): " + (DateTime.Now - start).TotalMilliseconds + " ms");

            var averageSpread = spreads.Average();
            Console.WriteLine("Time (total): " + (DateTime.Now - start).TotalMilliseconds + " ms");

            IndicatorUpdated(averageSpread);
        }
Пример #2
0
        private void OnTick(MarketTick ticks)
        {
            _lastTicks.Add(ticks);
            if (_lastTicks.Count == 20)
            {
                _lastTicks.RemoveAt(0);
            }

            var start   = DateTime.Now;
            var spreads = _lastTicks.Select(x => 100 * (x.Mid - x.Bid) / x.Bid);

            Console.WriteLine("Time (computing spreads): " + (DateTime.Now - start).TotalMilliseconds + " ms");

            var averageSpread = spreads.Average();

            Console.WriteLine("Time (total): " + (DateTime.Now - start).TotalMilliseconds + " ms");

            IndicatorUpdated(averageSpread);
        }