コード例 #1
0
ファイル: PoloniexClient.cs プロジェクト: th12eat/CoinBot
        /// <summary>
        /// Get the market summaries.
        /// </summary>
        /// <returns></returns>
        private async Task <List <PoloniexTicker> > GetTickers()
        {
            using (HttpResponseMessage response = await this._httpClient.GetAsync(new Uri("public?command=returnTicker", UriKind.Relative)))
            {
                string json = await response.Content.ReadAsStringAsync();

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

                return(tickers);
            }
        }
コード例 #2
0
ファイル: PoloniexClient.cs プロジェクト: EatMyMC/CoinBot
        private MarketSummaryDto?CreateMarketSummaryDto(PoloniexTicker ticker, ICoinBuilder builder)
        {
            Currency?baseCurrency = builder.Get(ticker.Pair.Substring(startIndex: 0, ticker.Pair.IndexOf(value: '_')));

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

            Currency?marketCurrency = builder.Get(ticker.Pair.Substring(ticker.Pair.IndexOf(value: '_') + 1));

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

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