Beispiel #1
0
        public async Task <IEnumerable <IOrderBook> > GetAllAsync()
        {
            var assetPairs = await _assetsHelper.GetAllAssetPairsAsync();

            var orderBooks = new List <IOrderBook>();

            foreach (var pair in assetPairs)
            {
                var buyBookJson  = _distributedCache.GetStringAsync(_cacheSettings.GetOrderBookKey(pair.Id, true));
                var sellBookJson = _distributedCache.GetStringAsync(_cacheSettings.GetOrderBookKey(pair.Id, false));

                var buyBook = (await buyBookJson)?.DeserializeJson <OrderBook>();
                if (buyBook != null)
                {
                    orderBooks.Add(buyBook);
                }

                var sellBook = (await sellBookJson)?.DeserializeJson <OrderBook>();
                if (sellBook != null)
                {
                    orderBooks.Add(sellBook);
                }
            }

            return(orderBooks);
        }