Example #1
0
        private static void GetMiningProfitability(GPUOld gpuOld)
        {
            WriteLine($"Getting Mining Profitability From What to mine based on {gpuOld.CoinToStudyName} For GPU {gpuOld.Name}");

            //https://whattomine.com/coins?utf8=%E2%9C%93&adapt_q_280x=0&adapt_q_380=0&adapt_q_fury=0&adapt_q_470=0&adapt_q_480=3&adapt_q_570=1&adapt_570=true&adapt_q_580=0&adapt_q_vega56=0&adapt_q_vega64=0&adapt_q_750Ti=0&adapt_q_1050Ti=0&adapt_q_10606=0&adapt_q_1070=0&adapt_q_1070Ti=0&adapt_q_1080=0&adapt_q_1080Ti=0&eth=true&factor%5Beth_hr%5D=27.9&factor%5Beth_p%5D=120.0&factor%5Bgro_hr%5D=15.5&factor%5Bgro_p%5D=110.0&factor%5Bx11g_hr%5D=5.6&factor%5Bx11g_p%5D=110.0&factor%5Bcn_hr%5D=700.0&factor%5Bcn_p%5D=110.0&factor%5Beq_hr%5D=260.0&factor%5Beq_p%5D=110.0&factor%5Blrev2_hr%5D=5500.0&factor%5Blrev2_p%5D=110.0&factor%5Bns_hr%5D=630.0&factor%5Bns_p%5D=140.0&factor%5Blbry_hr%5D=115.0&factor%5Blbry_p%5D=115.0&factor%5Bbk2b_hr%5D=840.0&factor%5Bbk2b_p%5D=115.0&factor%5Bbk14_hr%5D=1140.0&factor%5Bbk14_p%5D=115.0&factor%5Bpas_hr%5D=580.0&factor%5Bpas_p%5D=135.0&factor%5Bskh_hr%5D=16.3&factor%5Bskh_p%5D=110.0&factor%5Bn5_hr%5D=18.0&factor%5Bn5_p%5D=110.0&factor%5Bl2z_hr%5D=420.0&factor%5Bl2z_p%5D=300.0&factor%5Bcost%5D=0.1&sort=Profitability24&volume=0&revenue=24h&factor%5Bexchanges%5D%5B%5D=&factor%5Bexchanges%5D%5B%5D=abucoins&factor%5Bexchanges%5D%5B%5D=bitfinex&factor%5Bexchanges%5D%5B%5D=bittrex&factor%5Bexchanges%5D%5B%5D=binance&factor%5Bexchanges%5D%5B%5D=cryptopia&factor%5Bexchanges%5D%5B%5D=hitbtc&factor%5Bexchanges%5D%5B%5D=poloniex&factor%5Bexchanges%5D%5B%5D=yobit&dataset=&commit=Calculate
            string response = GetHttpResponseText(gpuOld.WhatToMineUrl);
            // get the table

            // get the first row
            // first column
            // crypto name
            string cryptoName = GetTextFromHtmlStringByCssSelector(response, "body table tbody tr:first td:first div:nth-child(2)");

            //algo
            string cryptoAlgo = GetTextFromHtmlStringByCssSelector(response, "body table tbody tr:first td:first div:nth-child(3)");
            //8th column second line, profitability
            //$('').text()
            string profitability = GetTextFromHtmlStringByCssSelector(response, "body table tbody tr:first td:nth-child(8) strong");

            gpuOld.MiningProfitability.CryptoName = cryptoName;
            gpuOld.MiningProfitability.CryptoAlgo = cryptoAlgo;
            string profitabilityText = profitability;

            if (profitabilityText.IndexOf("$") > -1)
            {
                profitabilityText = profitabilityText.Remove(profitabilityText.IndexOf("$"), 1);
            }
            gpuOld.MiningProfitability.Profitability24Hours = double.Parse(profitabilityText);
        }
Example #2
0
        //private static string GeRevenueAndProfit(string response, string CssSelector, string targetCurrency)
        //{
        //    CQ dom = response;
        //    CQ rows = dom[CssSelector];
        //    foreach (var row in rows)
        //    {
        //        var firstColumn = row.ChildElements.FirstOrDefault();
        //        CQ anchor = ((CQ)firstColumn.InnerHTML)["div:nth-child(2) a"];
        //        string cryptoname = anchor.Text();
        //        if (cryptoname != targetCurrency) continue;
        //        var seventhColumn = row.ChildElements.ElementAt(7);
        //        string revenueText = seventhColumn.InnerText;
        //        //second element bcoz of the <br />
        //        string profitText = seventhColumn.ChildElements.ElementAt(1).InnerText;

        //    }
        //    //string nodeName = textElement.FirstElement().NodeName.ToLower();
        //    //string result = textElement.Text(); ;

        //    //if (nodeName == "input")
        //    //    result = textElement.Val();
        //    return "";
        //}
        private static string GeRevenueAndProfit(GPUOld gpuOld, string CssSelector)
        {
            WriteLine($"Getting Revenu and profit From What to mine For GPU {gpuOld.Name}");
            string response = GetHttpResponseText(gpuOld.WhatToMineUrl);
            CQ     dom      = response;
            CQ     rows     = dom[CssSelector];

            foreach (var row in rows)
            {
                var    firstColumn = row.ChildElements.FirstOrDefault();
                CQ     anchor      = ((CQ)firstColumn.InnerHTML)["div:nth-child(2) a"];
                string cryptoname  = anchor.Text();
                if (cryptoname != gpuOld.CoinToStudyName)
                {
                    continue;
                }
                var    seventhColumn = row.ChildElements.ElementAt(7);
                string revenueText   = seventhColumn.InnerText;
                //second element bcoz of the <br />
                string profitText = seventhColumn.ChildElements.ElementAt(1).InnerText;
                gpuOld.RevenuePerDayUsd = double.Parse(revenueText.Replace("$", ""));
                gpuOld.ProfitPerDayUsd  = double.Parse(profitText.Replace("$", ""));
            }
            //string nodeName = textElement.FirstElement().NodeName.ToLower();
            //string result = textElement.Text(); ;

            //if (nodeName == "input")
            //    result = textElement.Val();
            return("");
        }
Example #3
0
        public static List <PriceSourceItemOld> GetPrice(GPUOld gpuOld, PriceSourceOld priceSource)
        {
            List <PriceSourceItemOld> priceSourceItems = new List <PriceSourceItemOld>();

            WriteLine($"Getting Price From {priceSource.Name} For GPU {gpuOld.Name}");
            //is it an api or something, else we are going to scrape the shit out of it...
            if (priceSource.PriceSourceAction != null)
            {
                List <PriceSourceItemOld> result = priceSource.PriceSourceAction.Invoke(priceSource.PriceSourceItemIdentifier);
                priceSourceItems.AddRange(result);
            }
            else
            {
                string response  = GetHttpResponseTextWithJavascript(priceSource.URL);
                string PriceText = GetTextFromHtmlStringByCssSelector(response, priceSource.Selector);

                string nameText = GetTextFromHtmlStringByCssSelector(response, priceSource.ItemNameSelector);
                if (string.IsNullOrEmpty(PriceText))
                {
                    return(priceSourceItems);
                }

                string currency = "USD";
                string imageUrl = null;
                if (!string.IsNullOrWhiteSpace(priceSource.ImageUrlSelector))
                {
                    imageUrl = GetTextFromHtmlStringByCssSelector(response, priceSource.ImageUrlSelector);
                }

                if (PriceText.IndexOf("$") > -1)
                {
                    PriceText = PriceText.Remove(PriceText.IndexOf("$"), 1);
                    currency  = "USD";
                }
                if (PriceText.IndexOf("SR") > -1)
                {
                    PriceText = PriceText.Remove(PriceText.IndexOf("SR"), 2);
                    currency  = "SAR";
                }

                PriceSourceItemOld priceSourceItem = new PriceSourceItemOld()
                {
                    Name          = nameText,
                    Price         = double.Parse(PriceText),
                    Selector      = priceSource.Selector,
                    PriceCurrency = currency
                };
                if (!string.IsNullOrWhiteSpace(imageUrl))
                {
                    priceSourceItem.ImageUrl = imageUrl;
                }

                priceSourceItems.Add(priceSourceItem);
            }

            return(priceSourceItems);
        }
Example #4
0
        private static void GetHashrate(GPUOld gpuOld)
        {
            WriteLine($"Getting Hashrate From WhatToMine For GPU {gpuOld.Name}");

            string response     = GetHttpResponseText(gpuOld.WhatToMineUrl);
            string hashRateText = GetTextFromHtmlStringByCssSelector(response, "#factor_eth_hr");

            gpuOld.Hashrate = double.Parse(hashRateText);
        }
Example #5
0
        //private static string GetHttpResponseText(string url)
        //{
        //    HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;

        //    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        //    WebHeaderCollection header = response.Headers;

        //    var encoding = ASCIIEncoding.ASCII;
        //    string responseText = string.Empty;
        //    using (var reader = new System.IO.StreamReader(response.GetResponseStream(), encoding))
        //    {
        //        responseText = reader.ReadToEnd();
        //    }

        //    return responseText;
        //}

        public static void GetPrices(GPUOld gpuOld)
        {
            foreach (var priceSource in gpuOld.PriceSources)
            {
                var priceSourceItems = GetPrice(gpuOld, priceSource);
                priceSource.PriceSourceItems.AddRange(priceSourceItems);
            }
            //Calculate USD Price
            foreach (var priceSourceItem in gpuOld.PriceSources.SelectMany(s => s.PriceSourceItems))
            {
                FillUSDPrice(priceSourceItem);
            }
        }
Example #6
0
        public void TestMethod1()
        {
            string         asinNumber  = "B06Y15M48C";
            PriceSourceOld priceSource = new PriceSourceOld()
            {
                PriceSourceItemIdentifier = asinNumber,
                PriceSourceAction         = AmazonService.SearchItemLookupOperationOld
            };
            GPUOld gpuOld = new GPUOld()
            {
                PriceSources = new List <PriceSourceOld>()
                {
                    priceSource
                },
            };

            InsighterService.GetPrice(gpuOld, priceSource);
        }
Example #7
0
        private static PriceSourceItemOld FetchGpu(string asinNumber)
        {
            PriceSourceOld priceSource = new PriceSourceOld()
            {
                PriceSourceItemIdentifier = asinNumber,
                PriceSourceAction         = AmazonService.SearchItemLookupOperationOld
            };

            GPUOld gpuOld = new GPUOld()
            {
                PriceSources = new List <PriceSourceOld>()
                {
                    priceSource
                },
            };

            List <PriceSourceItemOld> priceSourceItems = InsighterService.GetPrice(gpuOld, priceSource);

            return(priceSourceItems?.FirstOrDefault());
        }
Example #8
0
        private static void FindHashCost(GPUOld gpuOld)
        {
            gpuOld.HashPricePerSourceList.Clear();

            foreach (var item in gpuOld.PriceSources)
            {
                //TODO:now using the lowest price from the results, maybe use different hash price for each source
                //price for the GPU / Hashrate
                if (item.PriceSourceItems.Any())
                {
                    double             price = item.PriceSourceItems.Min(p => p.Price);
                    HashPricePerSource hashPricePerSource = new HashPricePerSource()
                    {
                        Source    = item.Name,
                        HashPrice = price / gpuOld.Hashrate
                    };
                    gpuOld.HashPricePerSourceList.Add(hashPricePerSource);
                }
            }
        }