Beispiel #1
0
        public async Task <MarketPrices> GetPricesAsync(PublicPricesContext context)
        {
            var r = await ApiProvider.GetTickersAsync().ConfigureAwait(false);

            if (r == null || r.Length == 0)
            {
                throw new ApiResponseException("No tickers returned", this);
            }

            var prices = new MarketPrices();

            var rPairsDict     = r.ToDictionary(x => x.Symbol.ToAssetPair(this, 3), x => x);
            var pairsQueryable = context.IsRequestAll ? rPairsDict.Keys.ToList() : context.Pairs;

            foreach (var pair in pairsQueryable)
            {
                rPairsDict.TryGetValue(pair, out var currentTicker);

                if (currentTicker == null)
                {
                    prices.MissedPairs.Add(pair);
                }
                else
                {
                    prices.Add(new MarketPrice(Network, pair, currentTicker.LastBuyPrice)
                    {
                        PriceStatistics = new PriceStatistics(Network, pair.Asset2, r[0].BestAsk, r[0].BestBid),
                        Volume          = new NetworkPairVolume(Network, pair, r[0].DailyTradedTotalVolume)
                    });
                }
            }

            return(prices);
        }
Beispiel #2
0
        public async Task <AssetPairs> GetAssetPairsAsync(NetworkProviderContext context)
        {
            var r = await ApiProvider.GetTickersAsync().ConfigureAwait(false);

            if (r == null || r.Length == 0)
            {
                throw new ApiResponseException("No asset pairs returned", this);
            }

            var pairs = new AssetPairs();

            foreach (var rCurrentTicker in r)
            {
                pairs.Add(rCurrentTicker.Symbol.ToAssetPair(this, 3));
            }

            return(pairs);
        }
Beispiel #3
0
        public async Task <bool> TestPublicApiAsync(NetworkProviderContext context)
        {
            var r = await ApiProvider.GetTickersAsync().ConfigureAwait(false);

            return(r?.Length > 0);
        }