示例#1
0
        public async Task <MarketPrice> GetPriceAsync(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "BtcAlpha", CoinShortName = shortName
            };

            try
            {
                var root = await HttpHelper.GetAsync <BtcAlphaRootObject[]>($"https://btc-alpha.com/api/v1/exchanges/?pair={shortName}_BTC&price=");

                if (root.Length > 0)
                {
                    var amount    = root.Sum(r => r.amount);
                    var fullPrice = root.Sum(r => r.amount * r.price);
                    marketPrice.Price      = fullPrice / amount;
                    marketPrice.Volume     = amount;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
        public async Task <MarketPrice> GetPriceAsync(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "CryptoBridge", CoinShortName = shortName
            };

            try
            {
                if (root == null)
                {
                    root = await HttpHelper.GetAsync <CryptoBridgeRoot[]>($"https://api.crypto-bridge.org/api/v1/ticker");
                }
                var find = root.FirstOrDefault(f => f.id.Equals($"{shortName.ToUpper()}_BTC"));
                if (find != null)
                {
                    marketPrice.Price      = find.bid;
                    marketPrice.Volume     = find.volume / find.bid;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
        public async Task <MarketPrice> GetPriceAsync(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "Southxchange", CoinShortName = shortName
            };

            try
            {
                var root = await HttpHelper.GetAsync <SouthxchangeRootObject>($"https://www.southxchange.com/api/price/{shortName}/BTC");

                //var root = JsonConvert.DeserializeObject<SouthxchangeRootObject>(result);
                if (root != null)
                {
                    marketPrice.Price      = root.Bid;
                    marketPrice.Volume     = root.Volume24Hr;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
        public async Task <MarketPrice> GetPriceAsync(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "Coinexchangeio", CoinShortName = shortName
            };

            try
            {
                if (root == null)
                {
                    root = await HttpHelper.GetAsync <CoinexchangeioMarketRoot>($"https://www.coinexchange.io/api/v1/getmarkets");
                }
                if (root.success == "1")
                {
                    var findMarket = root.result.FirstOrDefault(f => f.MarketAssetCode.Equals($"{shortName.ToUpper()}") && f.BaseCurrencyCode == "BTC");
                    if (findMarket != null)
                    {
                        var find = await HttpHelper.GetAsync <CoinexchangeioMarketSummaryRoot>($"https://www.coinexchange.io/api/v1/getmarketsummary?market_id={findMarket.MarketID}");

                        if (find != null && find.success == "1" && find.result != null)
                        {
                            marketPrice.Price      = find.result.BidPrice;
                            marketPrice.Volume     = find.result.Volume;
                            marketPrice.IsGetPrice = true;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
示例#5
0
        public MarketPrice GetPrice(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "BtcAlpha", CoinShortName = shortName
            };

            try
            {
                var result = HttpHelper.Get($"https://btc-alpha.com/api/v1/exchanges/?pair={shortName}_BTC&price=");
                var root   = JsonConvert.DeserializeObject <BtcAlphaRootObject[]>(result);
                if (root.Length > 0)
                {
                    var amount    = root.Sum(r => r.amount);
                    var fullPrice = root.Sum(r => r.amount * r.price);
                    marketPrice.Price      = fullPrice / amount;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
示例#6
0
        public MarketPrice GetPrice(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "Cryptopia", CoinShortName = shortName
            };

            try
            {
                var result = HttpHelper.Get($"https://www.cryptopia.co.nz/api/GetMarket/{shortName}_BTC");
                var root   = JsonConvert.DeserializeObject <CryptopiaRoot>(result);
                //var root = HttpHelper.Get<CryptopiaRoot>($"https://www.cryptopia.co.nz/api/GetMarket/{shortName}_BTC");
                if (root != null && root.Success && root.Error == null && root.Data != null)
                {
                    marketPrice.Price      = root.Data.BidPrice;
                    marketPrice.Volume     = root.Data.Volume;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
        public async Task <MarketPrice> GetPriceAsync(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "StocksExchange", CoinShortName = shortName
            };

            try
            {
                if (root == null)
                {
                    root = await HttpHelper.GetAsync <StocksExchangeRoot[]>($"https://stocks.exchange/api2/ticker");
                }

                var find = root.FirstOrDefault(f => f.market_name.Equals($"{shortName}_BTC"));
                if (find != null)
                {
                    marketPrice.Price      = find.bid;
                    marketPrice.Volume     = find.vol;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
示例#8
0
        public async Task <MarketPrice> GetPriceAsync(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "Bittrex", CoinShortName = shortName
            };

            try
            {
                var root = await HttpHelper.GetAsync <BittrexRoot>($"https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-{shortName.ToLower()}");

                if (root != null && root.success && root.result != null && root.result.FirstOrDefault() != null)
                {
                    var result = root.result.FirstOrDefault();
                    marketPrice.Price      = result.Bid;
                    marketPrice.Volume     = result.Volume;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
示例#9
0
        public async Task <MarketPrice> GetPriceAsync(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "Cryptohub", CoinShortName = shortName
            };

            try
            {
                var response = await HttpHelper.GetAsync($"https://cryptohub.online/api/market/ticker/{shortName.ToUpper()}/");

                var obj = JsonConvert.DeserializeObject(response) as Newtonsoft.Json.Linq.JObject;
                if (obj.HasValues)
                {
                    var first = obj.Children().OfType <Newtonsoft.Json.Linq.JProperty>().FirstOrDefault(c => c.Name == $"BTC_{shortName.ToUpper()}");
                    if (first != null && first.FirstOrDefault() != null)
                    {
                        var childs = first.FirstOrDefault().Children().OfType <Newtonsoft.Json.Linq.JProperty>();
                        var last   = childs.FirstOrDefault(c => c.Name == "last");
                        marketPrice.Price      = Convert.ToDouble((last.Value as Newtonsoft.Json.Linq.JValue).Value);
                        marketPrice.Volume     = 1;
                        marketPrice.IsGetPrice = true;
                    }
                }
                //var values = root2.Values<CryptohubValue>();
                //var root = await HttpHelper.GetAsync<YobitRoot>($"https://cryptohub.online/api/market/ticker/{shortName.ToUpper()}/");
                //if (root != null && root.ticker != null)
                //{
                //    marketPrice.Price = root.ticker.buy;
                //    marketPrice.Volume = root.ticker.vol_cur;
                //    marketPrice.IsGetPrice = true;
                //}
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
示例#10
0
        public MarketPrice GetPrice(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "CryptoBridge", CoinShortName = shortName
            };

            try
            {
                var result = HttpHelper.Get($"https://api.crypto-bridge.org/api/v1/ticker");
                var root   = JsonConvert.DeserializeObject <CryptoBridgeRoot[]>(result);
                var find   = root.FirstOrDefault(f => f.id.Equals($"{shortName}_BTC"));
                if (find != null)
                {
                    marketPrice.Price      = find.bid;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
示例#11
0
        public async Task <MarketPrice> GetPriceAsync(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "Cryptopia", CoinShortName = shortName
            };

            try
            {
                var root = await HttpHelper.GetAsync <CryptopiaRoot>($"https://www.cryptopia.co.nz/api/GetMarket/{shortName}_BTC");

                if (root != null && root.Success && root.Error == null && root.Data != null)
                {
                    marketPrice.Price      = root.Data.BidPrice;
                    marketPrice.Volume     = root.Data.Volume;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
示例#12
0
        public async Task <MarketPrice> GetPriceAsync(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "Yobit", CoinShortName = shortName
            };

            try
            {
                var root = await HttpHelper.GetAsync <YobitRoot>($"https://yobit.net/api/2/{shortName.ToLower()}_btc/ticker");

                if (root != null && root.ticker != null)
                {
                    marketPrice.Price      = root.ticker.buy;
                    marketPrice.Volume     = root.ticker.vol_cur;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
示例#13
0
        public async Task <MarketPrice> GetPriceAsync(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "Kucoin", CoinShortName = shortName
            };

            try
            {
                var root = await HttpHelper.GetAsync <KucoinRoot>($"https://api.kucoin.com/v1/open/tick?symbol={shortName.ToUpper()}-BTC");

                if (root != null && root.success && root.data != null)
                {
                    marketPrice.Price      = root.data.buy;
                    marketPrice.Volume     = root.data.vol;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }
示例#14
0
        public async Task <MarketPrice> GetPriceAsync(string shortName)
        {
            var marketPrice = new MarketPrice()
            {
                MarketName = "Graviex", CoinShortName = shortName
            };

            try
            {
                var root = await HttpHelper.GetAsync <GraviexRootObject>($"https://graviex.net:443//api/v2/tickers/{shortName.ToLower()}btc.json");

                if (root != null && root.ticker != null)
                {
                    marketPrice.Price      = root.ticker.buy;
                    marketPrice.Volume     = root.ticker.vol;
                    marketPrice.IsGetPrice = true;
                }
            }
            catch (Exception e)
            {
                marketPrice.IsGetPrice = false;
            }
            return(marketPrice);
        }