예제 #1
0
        private async Task <IEnumerable <KeyValuePair <string, ExchangeOrderBook> > > GetOrderBooks(
            string[] marketSymbols,
            IExchangeAPI api
            )
        {
            IEnumerable <KeyValuePair <string, ExchangeOrderBook> > orderBooks;

            if (marketSymbols.Length == 0)
            {
                orderBooks = await api.GetOrderBooksAsync(Max);
            }
            else
            {
                var orderBooksList = await Task.WhenAll(
                    marketSymbols.Select(async ms =>
                {
                    var orderBook = await api.GetOrderBookAsync(ms, Max);

                    orderBook.MarketSymbol ??= ms;

                    return(orderBook);
                })
                    );

                orderBooks = orderBooksList.ToDictionary(k => k.MarketSymbol, v => v);
            }

            return(orderBooks);
        }