Example #1
0
        /// <summary>
        /// Get the market summaries.
        /// </summary>
        /// <returns></returns>
        private async Task <List <GateIoTicker> > GetTickers()
        {
            using (HttpResponseMessage response = await this._httpClient.GetAsync(new Uri("tickers", UriKind.Relative)))
            {
                string json = await response.Content.ReadAsStringAsync();

                JObject             jResponse = JObject.Parse(json);
                List <GateIoTicker> tickers   = new List <GateIoTicker>();

                foreach (KeyValuePair <string, JToken> jToken in jResponse)
                {
                    JObject      obj    = JObject.Parse(jToken.Value.ToString());
                    GateIoTicker ticker = JsonConvert.DeserializeObject <GateIoTicker>(obj.ToString(), this._serializerSettings);
                    ticker.Pair = jToken.Key;
                    tickers.Add(ticker);
                }

                return(tickers);
            }
        }
Example #2
0
        private MarketSummaryDto?CreateMarketSummaryDto(GateIoTicker marketSummary, ICoinBuilder builder)
        {
            // always look at the quoted currency first as if that does not exist, then no point creating doing any more
            Currency?marketCurrency = builder.Get(marketSummary.Pair.Substring(marketSummary.Pair.IndexOf(PAIR_SEPARATOR) + 1));

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

            Currency?baseCurrency = builder.Get(marketSummary.Pair.Substring(startIndex: 0, marketSummary.Pair.IndexOf(PAIR_SEPARATOR)));

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

            return(new MarketSummaryDto(market: this.Name,
                                        baseCurrency: baseCurrency,
                                        marketCurrency: marketCurrency,
                                        volume: marketSummary.BaseVolume,
                                        last: marketSummary.Last,
                                        lastUpdated: null));
        }