Exemplo n.º 1
0
        /// <summary>
        /// Find the best price and return algor@pool name with best price
        /// </summary>
        /// <param name="algors">List of algorithm</param>
        /// <param name="seeCurrent">Field to compare is estimate_current if specify true, otherwise use field estimate_last24h to compare.</param>
        /// <returns>algor@pool with best price</returns>
        public static (string, double) FindBestPrice(List <AlgorithmResult> algors, bool seeCurrent, MinerModel miners)
        {
            double bestPrice = 0;
            string bestName  = "";
            Dictionary <string, double> priceList = new Dictionary <string, double>();

            foreach (AlgorithmResult algor in algors)
            {
                string algorAtPool = algor.name + "@" + algor.Pool.ToString();
                if (seeCurrent)
                {
                    if (algor.estimate_current > bestPrice && !IsExclude(algorAtPool, miners.Exclude))
                    {
                        bestPrice = algor.estimate_current;
                        bestName  = algorAtPool;
                    }
                    foreach (KeyValuePair <string, string> path in miners.Path)
                    {
                        if (algorAtPool.ToLower() == path.Key.ToLower() && !priceList.ContainsKey(algorAtPool))
                        {
                            priceList.Add(algorAtPool, algor.estimate_current);
                            break;
                        }
                    }
                }
                else
                {
                    if (algor.estimate_last24h > bestPrice && !IsExclude(algorAtPool, miners.Exclude))
                    {
                        bestPrice = algor.estimate_last24h;
                        bestName  = algorAtPool;
                    }
                    foreach (KeyValuePair <string, string> path in miners.Path)
                    {
                        if (algorAtPool.ToLower() == path.Key.ToLower() && !priceList.ContainsKey(algorAtPool))
                        {
                            priceList.Add(algorAtPool, algor.estimate_last24h);
                            break;
                        }
                    }
                }
            }

            if (!IsInConfigured(bestName, miners.Path))
            {
                string bestNameInUserConfig  = "";
                double bestPriceInUserConfig = 0;
                foreach (KeyValuePair <string, double> path in priceList)
                {
                    if (path.Value > bestPriceInUserConfig)
                    {
                        bestNameInUserConfig  = path.Key;
                        bestPriceInUserConfig = path.Value;
                    }
                }
                bestName  = bestNameInUserConfig;
                bestPrice = bestPriceInUserConfig;
            }
            return(bestName, bestPrice);
        }
Exemplo n.º 2
0
        /// <summary>
        ///  Find the best price and return coin@pool name with best price
        /// </summary>
        /// <param name="coins">List of coin</param>
        /// <returns>coin@pool with best price</returns>
        public static (string, double) FindBestPrice(List <CryptoCurrencyResult> coins, MinerModel miners)
        {
            double bestPrice = 0;
            string bestName  = "";
            Dictionary <string, double> priceList = new Dictionary <string, double>();

            foreach (CryptoCurrencyResult coin in coins)
            {
                string coinAtPool = coin.symbol + "@" + coin.Pool.ToString().ToLower();

                if (coin.h24_btc > bestPrice && !IsExclude(coinAtPool, miners.Exclude))
                {
                    bestPrice = coin.h24_btc;
                    bestName  = coinAtPool;
                }
                foreach (KeyValuePair <string, string> path in miners.Path)
                {
                    if (coinAtPool.ToLower() == path.Key.ToLower() && !priceList.ContainsKey(coinAtPool))
                    {
                        priceList.Add(coinAtPool, coin.h24_btc);
                        break;
                    }
                }
            }

            if (!IsInConfigured(bestName, miners.Path))
            {
                string bestNameInUserConfig  = "";
                double bestPriceInUserConfig = 0;
                foreach (KeyValuePair <string, double> path in priceList)
                {
                    if (path.Value > bestPriceInUserConfig)
                    {
                        bestNameInUserConfig  = path.Key;
                        bestPriceInUserConfig = path.Value;
                    }
                }
                bestName  = bestNameInUserConfig;
                bestPrice = bestPriceInUserConfig;
            }

            return(bestName, bestPrice);
        }