void UpdateArbitrageInfo(TickerCollection info, ITickerCollectionUpdateListener listener)
        {
            info.ObtainDataSuccessCount = 0;
            info.ObtainDataCount        = 0;
            info.NextOverdueMs          = 6000;
            info.StartUpdateMs          = timer.ElapsedMilliseconds;
            info.ObtainingData          = true;
            info.UpdateTimeMs           = 0;

            for (int i = 0; i < info.Count; i++)
            {
                info.Tickers[i].Exchange.UpdateOrderBookAsync(info.Tickers[i], 10, (e) => {
                    if (e.Result)
                    {
                        e.Ticker.OrderBook.UpdateHistory();
                    }
                    if (e.Result)
                    {
                        info.ObtainDataSuccessCount++;
                    }
                    info.ObtainDataCount++;

                    if (info.ObtainDataCount == info.Count)
                    {
                        info.IsActual      = info.ObtainDataSuccessCount == info.Count;
                        info.IsUpdating    = true;
                        info.ObtainingData = false;
                        info.UpdateTimeMs  = (int)(timer.ElapsedMilliseconds - info.StartUpdateMs);
                        if (listener != null)
                        {
                            listener.OnUpdateTickerCollection(info, true);
                        }
                    }
                });
            }
            //Task task = Task.Factory.StartNew(() => {
            //    for(int i = 0; i < info.Count; i++) {
            //        if(info.Tickers[i].UpdateOrderBook(OrderBook.Depth)) {
            //            //if(info.Tickers[i].UpdateTrades() && info.Tickers[i].TradeStatistic.Count > 0)
            //            //    info.Tickers[i].OrderBook.TradeInfo = info.Tickers[i].TradeStatistic.Last();
            //            //info.Tickers[i].OrderBook.CalcStatistics();
            //            info.Tickers[i].OrderBook.UpdateHistory();
            //            info.ObtainDataSuccessCount++;
            //        }
            //        info.ObtainDataCount++;
            //    }
            //});

            //await task;

            info.LastUpdate = DateTime.UtcNow;
        }
        async void UpdateArbitrageInfo(TickerCollection info, ITickerCollectionUpdateListener listener)
        {
            info.ObtainDataSuccessCount = 0;
            info.ObtainDataCount        = 0;
            info.NextOverdueMs          = 6000;
            info.StartUpdateMs          = timer.ElapsedMilliseconds;
            info.ObtainingData          = true;

            Task task = Task.Factory.StartNew(() => {
                for (int i = 0; i < info.Count; i++)
                {
                    if (info.Tickers[i].UpdateArbitrageOrderBook())
                    {
                        //if(info.Tickers[i].UpdateTrades() && info.Tickers[i].TradeStatistic.Count > 0)
                        //    info.Tickers[i].OrderBook.TradeInfo = info.Tickers[i].TradeStatistic.Last();
                        //info.Tickers[i].OrderBook.CalcStatistics();
                        info.Tickers[i].OrderBook.UpdateHistory();
                        info.ObtainDataSuccessCount++;
                    }
                    info.ObtainDataCount++;
                }
            });

            await task;

            Interlocked.Decrement(ref concurrentTickersCount); //todo
            if (info.ObtainDataCount == info.Count)
            {
                info.IsActual      = info.ObtainDataSuccessCount == info.Count;
                info.IsUpdating    = true;
                info.ObtainingData = false;
                info.UpdateTimeMs  = (int)(timer.ElapsedMilliseconds - info.StartUpdateMs);
                //Debug.WriteLine(string.Format("{0} = {1}", info.Name, info.UpdateTimeMs));
                if (listener != null)
                {
                    listener.OnUpdateTickerCollection(info, true);
                }
            }
            info.LastUpdate = DateTime.UtcNow;
        }
 public void Update(TickerCollection collection, ITickerCollectionUpdateListener listener)
 {
     Interlocked.Increment(ref concurrentTickersCount);
     UpdateArbitrageInfo(collection, listener);
 }
 public void Update(TickerCollection collection, ITickerCollectionUpdateListener listener)
 {
     UpdateArbitrageInfo(collection, listener);
 }