Example #1
0
        public void Subscribe(string symbol)
        {
            bool createNew = true;

            if (BooksForSymbols.ContainsKey(symbol))
            {
                if (BooksForSymbols[symbol].OrderBookState != RealtimeOrderBookState.OutOfSync)
                {
                    //already have one operational
                    createNew = false;
                }
            }
            if (createNew)
            {
                BooksForSymbols[symbol] = new RealTimeOrderbook(symbol);
                _websocketClient.DiffDepth.Subscribe(symbol);
                var currentBook = _httpClient.GetDepth(symbol, Enums.QueryLimit.thousand);
                //Intentionally not awaited, no need for result here
                BooksForSymbols[symbol].InitAsync(currentBook.Bids, currentBook.Asks);
            }
        }