Пример #1
0
        public TLValues getKoineksData()
        {
            HttpWebRequest request2 = (HttpWebRequest)WebRequest.Create("https://koineks.com/ticker");

            request2.Headers.Add("ContentType", "application/xml");
            request2.Method            = WebRequestMethods.Http.Get;
            request2.AllowAutoRedirect = true;
            request2.Proxy             = null;
            HttpWebResponse response2     = (HttpWebResponse)request2.GetResponse();
            Stream          stream2       = response2.GetResponseStream();
            StreamReader    streamreader2 = new StreamReader(stream2);
            string          jsonResponse2 = streamreader2.ReadToEnd();
            TLValues        mm2           = JsonConvert.DeserializeObject <TLValues>(jsonResponse2);
            decimal         usd2Tl        = Convert.ToDecimal(ForexService.getForex(), new CultureInfo("en-US"));

            mm2.BTC.bidUSD  = (Convert.ToDecimal(mm2.BTC.bid, new CultureInfo("en-US")) / usd2Tl).ToString();
            mm2.ETH.bidUSD  = (Convert.ToDecimal(mm2.ETH.bid, new CultureInfo("en-US")) / usd2Tl).ToString();
            mm2.DASH.bidUSD = (Convert.ToDecimal(mm2.DASH.bid, new CultureInfo("en-US")) / usd2Tl).ToString();

            return(mm2);


            //switch (coin)
            //{
            //    case "btc":
            //        usdValue=Convert.ToDecimal(mm2.BTC.bid, new CultureInfo("en-US")) / Convert.ToDecimal(usd2tl, new CultureInfo("en-US"));
            //        break;
            //    case "eth":
            //        usdValue = Convert.ToDecimal(mm2.ETH.bid, new CultureInfo("en-US")) / Convert.ToDecimal(usd2tl, new CultureInfo("en-US"));
            //        break;
            //    case "dash":
            //        usdValue = Convert.ToDecimal(mm2.DASH.bid, new CultureInfo("en-US")) / Convert.ToDecimal(usd2tl, new CultureInfo("en-US"));
            //        break;
            //}
        }
Пример #2
0
        public IActionResult Index()
        {
            GetterCex gc=new GetterCex();
            GetterKoineks gk=new GetterKoineks();
            USDInfo a=gc.getCoinUSD();
            var b=gk.getKoineksData();
            decimal usd2Tl = Convert.ToDecimal(ForexService.getForex(), new CultureInfo("en-US"));
            List<PriceComparison> comparisons = new List<PriceComparison>();
            foreach (Currency currency in a.data)
            {
                if(currency.symbol1=="ZEC" || currency.symbol1 == "BCH") continue;
                PriceComparison comparison = new PriceComparison
                {
                    Currency = currency.symbol1,
                    Ask = Convert.ToDecimal(currency.lprice, new CultureInfo("en-US")),
                    Exchange = "CEX"
                };
                comparisons.Add(comparison);
            }

            comparisons.Add(new PriceComparison
            {
                Currency = b.BTC.short_code,
                Ask = Convert.ToDecimal(b.BTC.ask, new CultureInfo("en-US")) / usd2Tl,
                Bid = Convert.ToDecimal(b.BTC.bid, new CultureInfo("en-US")) / usd2Tl,
                Disparity = decimal.Parse(b.BTC.bidUSD, new NumberFormatInfo() { NumberDecimalSeparator = "," })  - Convert.ToDecimal(a.data.Where(x => x.symbol1 == "BTC").Select(x => x.lprice).FirstOrDefault(), new CultureInfo("en-US")),
                Exchange = "Koineks"
            });

            comparisons.Add(new PriceComparison
            {
                Currency = b.ETH.short_code,
                Ask = Convert.ToDecimal(b.ETH.ask, new CultureInfo("en-US")) / usd2Tl,
                Bid = Convert.ToDecimal(b.ETH.bid, new CultureInfo("en-US")) / usd2Tl,
                Disparity = decimal.Parse(b.ETH.bidUSD, new NumberFormatInfo() { NumberDecimalSeparator = "," }) - Convert.ToDecimal(a.data.Where(x => x.symbol1 == "ETH").Select(x => x.lprice).FirstOrDefault(), new CultureInfo("en-US")),
                Exchange = "Koineks"
            });

            comparisons.Add(new PriceComparison
            {
                Currency = b.DASH.short_code,
                Ask = Convert.ToDecimal(b.DASH.ask, new CultureInfo("en-US"))/ usd2Tl,
                Bid = Convert.ToDecimal(b.DASH.bid, new CultureInfo("en-US"))/ usd2Tl,
                Disparity = decimal.Parse(b.DASH.bidUSD, new NumberFormatInfo() { NumberDecimalSeparator = "," }) - Convert.ToDecimal(a.data.Where(x => x.symbol1 == "DASH").Select(x => x.lprice).FirstOrDefault(), new CultureInfo("en-US")),
                Exchange = "Koineks"
            });


            return View(comparisons);
        }