Пример #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 async Task ShouldGetQuotes_WithCurrencyPairs_CHFUSD()
        {
            // Arrange
            var pairs        = new[] { "CHFUSD" };
            var forexService = new ForexService(new ForexServiceConfiguration());

            // Act
            var quotes = await forexService.GetQuotes(pairs);

            // Assert
            quotes.Should().NotBeNullOrEmpty();
        }
Пример #3
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);
        }
        public void TestInitialize()
        {
            _forexCsvRepositoryMock = new Mock <IForexCsvRepository>();
            _treeRepositoryMock     = new Mock <ITreeDataRepository <ForexTreeData> >();

            var forexRecords = ForexRecordsBuilder.BuildRecords();

            _forexCsvRepositoryMock
            .Setup(x => x.CsvLinesNormalized)
            .Returns(forexRecords);

            _service = new ForexService(
                _forexCsvRepositoryMock.Object,
                _treeRepositoryMock.Object
                );
        }
Пример #5
0
        private async void RunForex()
        {
            logger.LogInformation("RunForex starts at " + Environment.TickCount);
            DataContext dataContext = GetDataContext();

            logger.LogInformation("dataContext == null ? " + (dataContext == null));
            ForexService forexService = new ForexService(dataContext, configuration, logger);

            if (forexService != null)
            {
                ForexModel forexModel = forexService.GetHTTPForex();
                if (forexModel != null)
                {
                    Forex forex = new Models.Forex(forexModel);
                    if (forex != null)
                    {
                        bool result = await forexService.Update(forex);
                    }
                }
            }
            logger.LogInformation("RunForex stops at " + Environment.TickCount);
        }
Пример #6
0
 public ForexServiceTest() : base()
 {
     document     = new HtmlDocument();
     logger       = GetLogger(configuration, serviceProvider);
     forexService = new ForexService(context, configuration, logger);
 }