Esempio n. 1
0
        public async Task <List <float> > CalculateLuck(int countblock)
        {
            HashRate hashRate      = new HashRate();
            float    hrn           = float.Parse(await hashRate.Rate()) / 1000;
            Pool     pool          = new Pool();
            string   viabtc        = "ViaBTC";
            string   slushpool     = "SlushPool";
            string   viabtchash    = pool.Parse(viabtc);
            string   slushpoolhash = pool.Parse(slushpool);

            viabtchash    = viabtchash.Substring(0, viabtchash.Length - 5).Replace(",", "").Replace(".", ",");
            slushpoolhash = slushpoolhash.Substring(0, slushpoolhash.Length - 5).Replace(",", "").Replace(".", ",");
            //Console.WriteLine(viabtchash);
            float               viabtcpie    = (((float.Parse(viabtchash) * 100 / hrn)) * countblock) / 100;
            float               slushpoolpie = (((float.Parse(slushpoolhash) * 100 / hrn)) * countblock) / 100;
            EFBlockRepository   eFBlock      = new EFBlockRepository();
            IEnumerable <Block> countb       = eFBlock.Blocks.OrderByDescending(x => x.height).Take(countblock);
            int   countviabtc    = countb.Where(x => x.poolname == viabtc).Count();
            int   countslushpool = countb.Where(x => x.poolname == slushpool).Count();
            float luckviabtc     = 100 * countviabtc / viabtcpie;
            float luckslushpool  = 100 * countslushpool / slushpoolpie;

            Console.WriteLine(luckviabtc);
            Console.WriteLine(luckslushpool);
            List <float> luck = new List <float>()
            {
                luckviabtc, luckslushpool
            };

            return(luck);
        }
Esempio n. 2
0
        public async void CalculateProbability(string namepool)//Task<List<double>> CalculateProbability(string namepool,int countblock, int forecastblock)
        {
            int                countblock    = 1000;
            int                forecastblock = 100;
            HashRate           hashRate      = new HashRate();
            EFMinearRepository eFMinear      = new EFMinearRepository();
            //network hrt
            float hrn = float.Parse(await hashRate.Rate()) / 1000;

            Pool pool = new Pool();

            //pool hrt
            string hashs = pool.Parse(namepool);

            //string hashs = pool.Parse("ViaBTC");
            hashs = hashs.Substring(0, hashs.Length - 5).Replace(",", "").Replace(".", ",");
            double hash = double.Parse(hashs);

            //T
            double T = forecastblock * 10 / 60;
            //double T = 100 * 10 / 60;

            //BTC.com
            double btc     = (T / 24) * 1.6 * 1000 * double.Parse(eFMinear.Minears.OrderBy(x => x.date).Select(x => x.fpps_mining_earnings).LastOrDefault(), CultureInfo.InvariantCulture);
            int    countfb = (int)Math.Ceiling(btc / 1.6 * hash / 12.8);
            //Console.WriteLine("Необходимое количество найденных блоков для прибыли : {0} ", countfb);
            EFBlockRepository   eFBlock = new EFBlockRepository();
            IEnumerable <Block> countb  = eFBlock.Blocks.OrderByDescending(x => x.height).Take(countblock);
            int count = countb.Where(x => x.poolname == namepool).Count();
            //IEnumerable<Block> countb = eFBlock.Blocks.OrderByDescending(x => x.height).Take(1000);
            //int count = countb.Where(x => x.poolname == "ViaBTC").Count();

            //P
            double P = Calc(hrn, hash, countblock, forecastblock, countfb, count);

            //double P = Calc(hrn, hash, 1000, 100, countfb, count);
            Console.WriteLine("{3} : Вероятность {1} для {2} и более блоков за {4} блоков : {0}%", P, namepool, countfb, DateTime.Now, forecastblock);
            //Console.WriteLine("Вероятность {1} : {0}%", P, namepool);

            //Revenue
            //double revenue1 = findblock * 1.6 / viabtchash * 12.8;
            //double revenue2 = findblock * 1.6 / slushpoolhash * 12.8;
            double revenue = (countfb * 1.6 / hash * 12.8) - btc;

            //Console.WriteLine("Доход {1} : {0} BTC", revenue, "ViaBTC");
            Console.WriteLine("{3} : Доход {1} при {2} блоков : {0} BTC", revenue, namepool, countfb, DateTime.Now);
            //List<double> ret = new List<double> { P, revenue };
            //return ret;


            //laplas
            double matwait              = (hash / hrn) * 144;
            int    maxheight            = eFBlock.Blocks.OrderByDescending(x => x.height).Select(x => x.height).FirstOrDefault();
            IEnumerable <Block> countbl = eFBlock.Blocks.OrderByDescending(x => x.height).Take(countblock);
            List <int>          cntbl   = new List <int>();

            cntbl.Add(countbl.Where(x => x.height <= maxheight && x.height >= maxheight - 143 && x.poolname == namepool).Count());
            cntbl.Add(countbl.Where(x => x.height < maxheight - 143 && x.height >= maxheight - 287 && x.poolname == namepool).Count());
            cntbl.Add(countbl.Where(x => x.height < maxheight - 287 && x.height >= maxheight - 431 && x.poolname == namepool).Count());
            cntbl.Add(countbl.Where(x => x.height < maxheight - 431 && x.height >= maxheight - 575 && x.poolname == namepool).Count());
            cntbl.Add(countbl.Where(x => x.height < maxheight - 575 && x.height >= maxheight - 719 && x.poolname == namepool).Count());
            Console.WriteLine("{3} : Вероятность {1} для {2} и более блоков : {0}%", Function.Function.FuncLaplas(cntbl, matwait, countfb) * 100, namepool, countfb, DateTime.Now);
        }