Ejemplo n.º 1
0
        /// <summary>
        /// Get the ticker.
        /// </summary>
        /// <returns></returns>
        private async Task <KrakenTicker> GetTicker(KrakenPair pair)
        {
            using (HttpResponseMessage response = await this._httpClient.GetAsync(new Uri($"Ticker?pair={pair.PairId}", UriKind.Relative)))
            {
                string json = await response.Content.ReadAsStringAsync();

                JObject      jObject = JObject.Parse(json);
                KrakenTicker ticker  = JsonConvert.DeserializeObject <KrakenTicker>(jObject["result"][pair.PairId].ToString(), this._serializerSettings);
                ticker.BaseCurrency  = pair.BaseCurrency;
                ticker.QuoteCurrency = pair.QuoteCurrency;
                return(ticker);
            }
        }
Ejemplo n.º 2
0
        private MarketSummaryDto?CreateMarketSummaryDto(IReadOnlyList <KrakenAsset> assets, KrakenTicker ticker, ICoinBuilder builder)
        {
            if (ticker.Last == null || ticker.Volume == null)
            {
                return(null);
            }

            string?baseCurrencySymbol = FindCurrency(assets: assets, search: ticker.BaseCurrency);

            if (baseCurrencySymbol == null)
            {
                return(null);
            }

            string?marketCurrencySymbol = FindCurrency(assets: assets, search: ticker.QuoteCurrency);

            if (marketCurrencySymbol == null)
            {
                return(null);
            }

            // always look at the quoted currency first as if that does not exist, then no point creating doing any more
            Currency?marketCurrency = builder.Get(marketCurrencySymbol);

            if (marketCurrency == null)
            {
                return(null);
            }

            Currency?baseCurrency = builder.Get(baseCurrencySymbol);

            if (baseCurrency == null)
            {
                return(null);
            }

            return(new MarketSummaryDto(market: this.Name,
                                        baseCurrency: baseCurrency,
                                        marketCurrency: marketCurrency,
                                        volume: ticker.Volume[1],
                                        last: ticker.Last[0],
                                        lastUpdated: null));
        }