Example #1
0
 public ComputedPaths(double percentProfit, string unitProfit, Track track, OffersIndicator indicator)
 {
     PercentageProfit = percentProfit;
     UnitProfit       = unitProfit;
     Track            = track;
     Indicator        = indicator;
 }
Example #2
0
 public ComputedPaths(double percentProfit, string unitProfit, Track track, OffersIndicator indicator)
 {
     PercentageProfit = percentProfit;
     UnitProfit = unitProfit;
     Track = track;
     Indicator = indicator;
 }
Example #3
0
        public void ComputeSinglePath(OffersIndicator Indicator, Track track, List <ComputedPaths> computedPaths)
        {
            #region VARIABLES
            double fee;
            double min_doge_double = 0, min_ltc_double = 0, min_btc_double = 0;
            double price1 = 0, price2 = 0, price3 = 0;
            double amountBTC = 0;
            double min_ltc_minus_fee = 0, min_btc_minus_fee = 0, min_doge_minus_fee = 0, tmp = 0;

            double btc_common = 0, ltc_common = 0, doge_common = 0, btc_common_final = 0;
            #endregion

            #region STEP 1
            for (int i = 0; i < Indicator.one; i++)
            {
                //zbierz oferty
                if (track.path[0] == track.jsons[0][email protected] &&
                    track.path[1] == track.jsons[0][email protected])
                {
                    min_btc_double    = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    price1            = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    price1            = Math.Round(price1, 10, MidpointRounding.AwayFromZero);
                    min_ltc_double    = min_btc_double * price1;
                    fee               = FeeTransaction(track.path, 0);
                    min_ltc_minus_fee = (min_ltc_double) * (1 - fee);
                    min_ltc_minus_fee = Math.Round(min_ltc_minus_fee, 10, MidpointRounding.AwayFromZero);
                }
                else
                {
                    min_ltc_double    = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    price1            = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    price1            = Math.Round(price1, 10, MidpointRounding.AwayFromZero);
                    min_btc_double    = min_ltc_double / price1;
                    min_btc_double    = Math.Round(min_btc_double, 10, MidpointRounding.AwayFromZero);
                    fee               = FeeTransaction(track.path, 0);
                    min_ltc_minus_fee = min_ltc_double * (1 - fee);
                    min_ltc_minus_fee = Math.Round(min_ltc_minus_fee, 10, MidpointRounding.AwayFromZero);
                }

                btc_common += min_btc_double;
                ltc_common += min_ltc_minus_fee;
            }
            #endregion

            #region ETAP 2
            double[] temp_LTC    = new double[Indicator.two];
            double[] temp_price2 = new double[Indicator.two];
            for (int j = 0; j < Indicator.two; j++)
            {
                //zbierz oferty DOGE
                if (track.path[1] == track.jsons[1][email protected] && track.path[2] == track.jsons[1][email protected])
                {
                    temp_price2[j]  = Convert.ToDouble(track.jsons[1][email protected][j].price.Replace('.', ','));
                    min_doge_double = Convert.ToDouble(track.jsons[1][email protected][j].quantity.Replace('.', ','));
                    temp_LTC[j]     = Convert.ToDouble(track.jsons[1][email protected][j].total.Replace('.', ','));
                }
                else
                {
                    temp_price2[j]  = Convert.ToDouble(track.jsons[1][email protected][j].price.Replace('.', ','));
                    min_doge_double = Convert.ToDouble(track.jsons[1][email protected][j].quantity.Replace('.', ','));
                    temp_LTC[j]     = Convert.ToDouble(track.jsons[1][email protected][j].total.Replace('.', ','));
                }
                //odlicz opłaty (fee) za transakcje
                fee = FeeTransaction(track.path, 1);
                min_doge_minus_fee = (min_doge_double * (1 - fee));
                min_doge_minus_fee = Math.Round(min_doge_minus_fee, 10, MidpointRounding.AwayFromZero);

                doge_common += min_doge_minus_fee;
            }

            //jesli za mało ltc to trudno KONIEC będą inne ścieżki krotsze na ktore wystarczy
            if (ltc_common < temp_LTC.Sum())
            {
                return;
            }

            //jeśli wystarczyło to przelicz tak zeby nic nie zostało - sie nie zmarnowało
            var    tempLtcSum   = temp_LTC.Sum();
            double tmpMinLtcSum = 0;
            double tmpMinBtcSum = 0;
            double tmpPrice1    = 0;
            for (int i = 0; i < Indicator.one; i++)
            {
                double tmpMinBtcDouble   = 0;
                double tmpMinLtcDouble   = 0;
                double tmpMinLtcMinusFee = 0;
                if (track.path[0] == track.jsons[0][email protected] &&
                    track.path[1] == track.jsons[0][email protected])
                {
                    tmpMinBtcDouble = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    tmpPrice1       = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    tmpPrice1       = Math.Round(tmpPrice1, 10, MidpointRounding.AwayFromZero);
                    tmpMinLtcDouble = tmpMinBtcDouble * tmpPrice1;
                }
                else
                {
                    tmpMinLtcDouble = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    tmpPrice1       = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    tmpPrice1       = Math.Round(tmpPrice1, 10, MidpointRounding.AwayFromZero);
                    tmpMinBtcDouble = tmpMinLtcDouble / tmpPrice1;
                }
                fee = FeeTransaction(track.path, 0);
                tmpMinLtcMinusFee = (tmpMinLtcDouble) * (1 - fee);
                tmpMinLtcSum     += Math.Round(tmpMinLtcMinusFee, 10, MidpointRounding.AwayFromZero);
                if (tempLtcSum >= tmpMinLtcSum)
                {
                    tmpMinBtcSum += tmpMinBtcDouble;
                    continue;
                }
                else if (tempLtcSum < tmpMinLtcSum)
                {
                    tmpMinLtcSum = tmpMinLtcSum - tmpMinLtcMinusFee;
                    var difference = tempLtcSum - tmpMinLtcSum;
                    tmpMinLtcSum = tmpMinLtcSum + difference;
                    var howMuchWeNeedToBuy = difference / (1 - fee);
                    var amountOfBtc        = howMuchWeNeedToBuy / tmpPrice1;
                    tmpMinBtcSum += amountOfBtc;
                    break;
                }
            }
            btc_common = tmpMinBtcSum;
            ltc_common = tmpMinLtcSum;
            #endregion

            #region ETAP 3
            double[] temp_DOGE           = new double[Indicator.three];
            double[] temp_price3         = new double[Indicator.three];
            double   final_btc           = 0.0;
            double   final_btc_minus_fee = 0.0;
            for (int k = 0; k < Indicator.three; k++)
            {
                //zbierz oferty btc
                if (track.path[2] == track.jsons[2][email protected] &&
                    track.path[3] == track.jsons[2][email protected])
                {
                    temp_price3[k] = Convert.ToDouble(track.jsons[2][email protected][k].price.Replace('.', ','));
                    final_btc      = Convert.ToDouble(track.jsons[2][email protected][k].quantity.Replace('.', ','));
                    temp_DOGE[k]   = Convert.ToDouble(track.jsons[2][email protected][k].total.Replace('.', ','));
                }
                else
                {
                    temp_price3[k] = Convert.ToDouble(track.jsons[2][email protected][k].price.Replace('.', ','));
                    final_btc      = Convert.ToDouble(track.jsons[2][email protected][k].quantity.Replace('.', ','));
                    temp_DOGE[k]   = Convert.ToDouble(track.jsons[2][email protected][k].total.Replace('.', ','));
                }

                //odlicz opłaty (fee) za transakcje
                fee = FeeTransaction(track.path, 2);
                final_btc_minus_fee = (final_btc * (1 - fee));
                final_btc_minus_fee = Math.Round(final_btc_minus_fee, 10, MidpointRounding.AwayFromZero);

                btc_common_final += final_btc_minus_fee;
            }
            double tmpPrice3 = temp_price3.Last();

            //jesli za mało doge to trudno KONIEC będą inne ścieżki
            if (doge_common < temp_DOGE.Sum())
            {
                return;
            }

            //jeśli wystarczyło to przelicz tak zeby nic nie zostało - sie nie zmarnowało
            //przelicz DOGE - LTC
            var    tempDogeSum    = temp_DOGE.Sum();
            double _tmpMinDogeSum = 0;
            double _tmpMinLtcSum  = 0;
            double _tmpMinBtcSum  = 0;
            double tmpPrice2      = 0.0;
            for (int i = 0; i < Indicator.two; i++)
            {
                double tmpMinDogeDouble   = 0.0;
                double tmpMinLtcDouble    = 0.0;
                double tmpMinDogeMinusFee = 0.0;

                if (track.path[1] == track.jsons[1][email protected] &&
                    track.path[2] == track.jsons[1][email protected])
                {
                    //przelicz od poczatku
                    tmpMinLtcDouble  = Convert.ToDouble(track.jsons[1][email protected][i].total.Replace('.', ','));
                    tmpPrice2        = Convert.ToDouble(track.jsons[1][email protected][i].price.Replace('.', ','));
                    tmpPrice2        = Math.Round(tmpPrice2, 10, MidpointRounding.AwayFromZero);
                    tmpMinDogeDouble = tmpMinLtcDouble * tmpPrice2;
                }
                else
                {
                    //przelicz od poczatku
                    tmpMinLtcDouble  = Convert.ToDouble(track.jsons[1][email protected][i].total.Replace('.', ','));
                    tmpPrice2        = Convert.ToDouble(track.jsons[1][email protected][i].price.Replace('.', ','));
                    tmpPrice2        = Math.Round(tmpPrice2, 10, MidpointRounding.AwayFromZero);
                    tmpMinDogeDouble = tmpMinLtcDouble / tmpPrice2;
                }

                fee = FeeTransaction(track.path, 1);
                tmpMinDogeMinusFee = (tmpMinDogeDouble) * (1 - fee);
                _tmpMinDogeSum    += Math.Round(tmpMinDogeMinusFee, 10, MidpointRounding.AwayFromZero);

                if (tempDogeSum >= _tmpMinDogeSum)
                {
                    _tmpMinLtcSum += tmpMinLtcDouble;
                    continue;
                }
                else if (tempDogeSum < _tmpMinDogeSum)
                {
                    _tmpMinDogeSum = _tmpMinDogeSum - tmpMinDogeMinusFee;
                    var difference = tempDogeSum - _tmpMinDogeSum;
                    _tmpMinDogeSum = difference + _tmpMinDogeSum;
                    var howMuchWeNeedToBuy = difference / (1 - fee);
                    var amountOfLtc        = howMuchWeNeedToBuy / tmpPrice2;
                    _tmpMinLtcSum += amountOfLtc;
                    break;
                }
            }
            doge_common = _tmpMinDogeSum;
            ltc_common  = _tmpMinLtcSum;

            //przelicz LTC-BTC idąc wstecz tak zeby nic sie nie zmarnowało..
            //jeśli wystarczyło to przelicz tak zeby nic nie zostało - sie nie zmarnowało
            tempLtcSum   = ltc_common;
            tmpMinLtcSum = 0;
            tmpMinBtcSum = 0;
            for (int i = 0; i < Indicator.one; i++)
            {
                double tmpMinBtcDouble   = 0;
                double tmpMinLtcDouble   = 0;
                double tmpMinLtcMinusFee = 0;
                if (track.path[0] == track.jsons[0][email protected] &&
                    track.path[1] == track.jsons[0][email protected])
                {
                    tmpMinBtcDouble = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    tmpPrice1       = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    tmpPrice1       = Math.Round(tmpPrice1, 10, MidpointRounding.AwayFromZero);
                    tmpMinLtcDouble = tmpMinBtcDouble * tmpPrice1;
                }
                else
                {
                    tmpMinLtcDouble = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    tmpPrice1       = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    tmpPrice1       = Math.Round(tmpPrice1, 10, MidpointRounding.AwayFromZero);
                    tmpMinBtcDouble = tmpMinLtcDouble / tmpPrice1;
                }
                fee = FeeTransaction(track.path, 0);
                tmpMinLtcMinusFee = (tmpMinLtcDouble) * (1 - fee);
                tmpMinLtcSum     += Math.Round(tmpMinLtcMinusFee, 10, MidpointRounding.AwayFromZero);
                if (tempLtcSum >= tmpMinLtcSum)
                {
                    tmpMinBtcSum += tmpMinBtcDouble;
                    continue;
                }
                else if (tempLtcSum < tmpMinLtcSum)
                {
                    tmpMinLtcSum = tmpMinLtcSum - tmpMinLtcMinusFee;
                    var difference = tempLtcSum - tmpMinLtcSum;
                    tmpMinLtcSum = tmpMinLtcSum + difference;
                    var howMuchWeNeedToBuy = difference / (1 - fee);
                    var amountOfBtc        = howMuchWeNeedToBuy / tmpPrice1;
                    tmpMinBtcSum += amountOfBtc;
                    break;
                }
            }
            btc_common = tmpMinBtcSum;
            ltc_common = tmpMinLtcSum;
            #endregion

            #region Add to list and compute profit
            //
            //FINAL STAGE - COMPUTE PROFIT
            //

            double finalDiff = btc_common_final - btc_common;

            //this.val = difference;

            if (finalDiff > 0.0)
            {
                //var BRAWO = "BRAWO JEST OKAZJA DO ARBITRAZU";
                ArbitrageItem arbitrageItem = new ArbitrageItem();
                //if (min_btc_double < 0.000001 || min_ltc_double < 0.000000001 || min_doge_double < 0.0000000001)
                //    return;



                arbitrageItem.Fill(track.path, String.Format("{0:F10}", btc_common),
                                   String.Format("{0:F10}", ltc_common),
                                   String.Format("{0:F10}", doge_common),
                                   String.Format("{0:F10}", btc_common_final),
                                   String.Format("{0:F10}", tmpPrice1),
                                   String.Format("{0:F10}", tmpPrice2),
                                   String.Format("{0:F10}", tmpPrice3));
                arbitrageItem.Profit         = String.Format("{0:F10}", finalDiff);
                arbitrageItem.PercentBenefit = Convert.ToDouble(String.Format("{0:F10}", finalDiff)) * 100 / btc_common;

                computedPaths.Add(new ComputedPaths(arbitrageItem.PercentBenefit, arbitrageItem.Profit, track, Indicator));
                if (Options.Instance.displayAllPaths == false)
                {
                    if (arbitrageItem.PercentBenefit > Options.Instance.minPercentBenefit)
                    {
                        arbitrageList.Add(arbitrageItem);
                    }
                }
                else
                {
                    arbitrageList.Add(arbitrageItem);
                }
            }
            #endregion
        }
Example #4
0
        public void ComputeSinglePath(OffersIndicator Indicator, Track track,List<ComputedPaths> computedPaths)
        {
            #region VARIABLES
            double fee;
            double min_doge_double = 0, min_ltc_double = 0, min_btc_double = 0;
            double price1 = 0, price2 = 0, price3 = 0;
            double amountBTC = 0;
            double min_ltc_minus_fee = 0, min_btc_minus_fee = 0, min_doge_minus_fee = 0, tmp = 0;

            double btc_common = 0, ltc_common = 0, doge_common = 0, btc_common_final = 0;
            #endregion

            #region STEP 1
            for (int i = 0; i < Indicator.one; i++)
            {
                //zbierz oferty
                if (track.path[0] == track.jsons[0][email protected] &&
                    track.path[1] == track.jsons[0][email protected])
                {
                    min_btc_double = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    price1 = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    price1 = Math.Round(price1, 10, MidpointRounding.AwayFromZero);
                    min_ltc_double = min_btc_double * price1;
                    fee = FeeTransaction(track.path, 0);
                    min_ltc_minus_fee = (min_ltc_double) * (1 - fee);
                    min_ltc_minus_fee = Math.Round(min_ltc_minus_fee, 10, MidpointRounding.AwayFromZero);
                }
                else
                {
                    min_ltc_double = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    price1 = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    price1 = Math.Round(price1, 10, MidpointRounding.AwayFromZero);
                    min_btc_double = min_ltc_double / price1;
                    min_btc_double = Math.Round(min_btc_double, 10, MidpointRounding.AwayFromZero);
                    fee = FeeTransaction(track.path, 0);
                    min_ltc_minus_fee = min_ltc_double * (1 - fee);
                    min_ltc_minus_fee = Math.Round(min_ltc_minus_fee, 10, MidpointRounding.AwayFromZero);
                }

                btc_common += min_btc_double;
                ltc_common += min_ltc_minus_fee;
            }
            #endregion

            #region ETAP 2
            double[] temp_LTC = new double[Indicator.two];
            double[] temp_price2 = new double[Indicator.two];
            for (int j = 0; j < Indicator.two; j++)
            {
                //zbierz oferty DOGE
                if (track.path[1] == track.jsons[1][email protected] && track.path[2] == track.jsons[1][email protected])
                {
                    temp_price2[j] = Convert.ToDouble(track.jsons[1][email protected][j].price.Replace('.', ','));
                    min_doge_double = Convert.ToDouble(track.jsons[1][email protected][j].quantity.Replace('.', ','));
                    temp_LTC[j] = Convert.ToDouble(track.jsons[1][email protected][j].total.Replace('.', ','));
                }
                else
                {
                    temp_price2[j] = Convert.ToDouble(track.jsons[1][email protected][j].price.Replace('.', ','));
                    min_doge_double = Convert.ToDouble(track.jsons[1][email protected][j].quantity.Replace('.', ','));
                    temp_LTC[j] = Convert.ToDouble(track.jsons[1][email protected][j].total.Replace('.', ','));
                }
                //odlicz opłaty (fee) za transakcje
                fee = FeeTransaction(track.path, 1);
                min_doge_minus_fee = (min_doge_double * (1 - fee));
                min_doge_minus_fee = Math.Round(min_doge_minus_fee, 10, MidpointRounding.AwayFromZero);

                doge_common += min_doge_minus_fee;
            }

            //jesli za mało ltc to trudno KONIEC będą inne ścieżki krotsze na ktore wystarczy
            if (ltc_common < temp_LTC.Sum())
                return;

            //jeśli wystarczyło to przelicz tak zeby nic nie zostało - sie nie zmarnowało
            var tempLtcSum = temp_LTC.Sum();
            double tmpMinLtcSum = 0;
            double tmpMinBtcSum = 0;
            double tmpPrice1 = 0;
            for (int i = 0; i < Indicator.one; i++)
            {
                double tmpMinBtcDouble = 0;
                double tmpMinLtcDouble = 0;
                double tmpMinLtcMinusFee = 0;
                if (track.path[0] == track.jsons[0][email protected] &&
                    track.path[1] == track.jsons[0][email protected])
                {
                    tmpMinBtcDouble = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    tmpPrice1 = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    tmpPrice1 = Math.Round(tmpPrice1, 10, MidpointRounding.AwayFromZero);
                    tmpMinLtcDouble = tmpMinBtcDouble * tmpPrice1;
                }
                else
                {
                    tmpMinLtcDouble = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    tmpPrice1 = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    tmpPrice1 = Math.Round(tmpPrice1, 10, MidpointRounding.AwayFromZero);
                    tmpMinBtcDouble = tmpMinLtcDouble / tmpPrice1;

                }
                fee = FeeTransaction(track.path, 0);
                tmpMinLtcMinusFee = (tmpMinLtcDouble) * (1 - fee);
                tmpMinLtcSum += Math.Round(tmpMinLtcMinusFee, 10, MidpointRounding.AwayFromZero);
                if (tempLtcSum >= tmpMinLtcSum)
                {
                    tmpMinBtcSum += tmpMinBtcDouble;
                    continue;
                }
                else if (tempLtcSum < tmpMinLtcSum)
                {
                    tmpMinLtcSum = tmpMinLtcSum - tmpMinLtcMinusFee;
                    var difference = tempLtcSum - tmpMinLtcSum;
                    tmpMinLtcSum = tmpMinLtcSum + difference;
                    var howMuchWeNeedToBuy = difference / (1 - fee);
                    var amountOfBtc = howMuchWeNeedToBuy / tmpPrice1;
                    tmpMinBtcSum += amountOfBtc;
                    break;
                }
            }
            btc_common = tmpMinBtcSum;
            ltc_common = tmpMinLtcSum;
            #endregion

            #region ETAP 3
            double[] temp_DOGE = new double[Indicator.three];
            double[] temp_price3 = new double[Indicator.three];
            double final_btc = 0.0;
            double final_btc_minus_fee = 0.0;
            for (int k = 0; k < Indicator.three; k++)
            {
                //zbierz oferty btc
                if (track.path[2] == track.jsons[2][email protected] &&
                    track.path[3] == track.jsons[2][email protected])
                {
                    temp_price3[k] = Convert.ToDouble(track.jsons[2][email protected][k].price.Replace('.', ','));
                    final_btc = Convert.ToDouble(track.jsons[2][email protected][k].quantity.Replace('.', ','));
                    temp_DOGE[k] = Convert.ToDouble(track.jsons[2][email protected][k].total.Replace('.', ','));
                }
                else
                {
                    temp_price3[k] = Convert.ToDouble(track.jsons[2][email protected][k].price.Replace('.', ','));
                    final_btc = Convert.ToDouble(track.jsons[2][email protected][k].quantity.Replace('.', ','));
                    temp_DOGE[k] = Convert.ToDouble(track.jsons[2][email protected][k].total.Replace('.', ','));
                }

                //odlicz opłaty (fee) za transakcje
                fee = FeeTransaction(track.path, 2);
                final_btc_minus_fee = (final_btc * (1 - fee));
                final_btc_minus_fee = Math.Round(final_btc_minus_fee, 10, MidpointRounding.AwayFromZero);

                btc_common_final += final_btc_minus_fee;
            }
            double tmpPrice3 = temp_price3.Last();

            //jesli za mało doge to trudno KONIEC będą inne ścieżki
            if (doge_common < temp_DOGE.Sum())
                return;

            //jeśli wystarczyło to przelicz tak zeby nic nie zostało - sie nie zmarnowało
            //przelicz DOGE - LTC
            var tempDogeSum = temp_DOGE.Sum();
            double _tmpMinDogeSum = 0;
            double _tmpMinLtcSum = 0;
            double _tmpMinBtcSum = 0;
            double tmpPrice2 = 0.0;
            for (int i = 0; i < Indicator.two; i++)
            {
                double tmpMinDogeDouble = 0.0;
                double tmpMinLtcDouble = 0.0;
                double tmpMinDogeMinusFee = 0.0;

                if (track.path[1] == track.jsons[1][email protected] &&
                    track.path[2] == track.jsons[1][email protected])
                {
                    //przelicz od poczatku
                    tmpMinLtcDouble = Convert.ToDouble(track.jsons[1][email protected][i].total.Replace('.', ','));
                    tmpPrice2 = Convert.ToDouble(track.jsons[1][email protected][i].price.Replace('.', ','));
                    tmpPrice2 = Math.Round(tmpPrice2, 10, MidpointRounding.AwayFromZero);
                    tmpMinDogeDouble = tmpMinLtcDouble*tmpPrice2;
                }
                else
                {
                    //przelicz od poczatku
                    tmpMinLtcDouble = Convert.ToDouble(track.jsons[1][email protected][i].total.Replace('.', ','));
                    tmpPrice2 = Convert.ToDouble(track.jsons[1][email protected][i].price.Replace('.', ','));
                    tmpPrice2 = Math.Round(tmpPrice2, 10, MidpointRounding.AwayFromZero);
                    tmpMinDogeDouble = tmpMinLtcDouble / tmpPrice2;
                }

                fee = FeeTransaction(track.path, 1);
                tmpMinDogeMinusFee = (tmpMinDogeDouble) * (1 - fee);
                _tmpMinDogeSum += Math.Round(tmpMinDogeMinusFee, 10, MidpointRounding.AwayFromZero);

                if (tempDogeSum >= _tmpMinDogeSum)
                {
                    _tmpMinLtcSum += tmpMinLtcDouble;
                    continue;
                }
                else if (tempDogeSum < _tmpMinDogeSum)
                {
                    _tmpMinDogeSum = _tmpMinDogeSum - tmpMinDogeMinusFee;
                    var difference = tempDogeSum - _tmpMinDogeSum;
                    _tmpMinDogeSum = difference + _tmpMinDogeSum;
                    var howMuchWeNeedToBuy = difference / (1 - fee);
                    var amountOfLtc = howMuchWeNeedToBuy / tmpPrice2;
                    _tmpMinLtcSum += amountOfLtc;
                    break;
                }
            }
            doge_common = _tmpMinDogeSum;
            ltc_common = _tmpMinLtcSum;

            //przelicz LTC-BTC idąc wstecz tak zeby nic sie nie zmarnowało..
            //jeśli wystarczyło to przelicz tak zeby nic nie zostało - sie nie zmarnowało
            tempLtcSum = ltc_common;
            tmpMinLtcSum = 0;
            tmpMinBtcSum = 0;
            for (int i = 0; i < Indicator.one; i++)
            {
                double tmpMinBtcDouble = 0;
                double tmpMinLtcDouble = 0;
                double tmpMinLtcMinusFee = 0;
                if (track.path[0] == track.jsons[0][email protected] &&
                    track.path[1] == track.jsons[0][email protected])
                {
                    tmpMinBtcDouble = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    tmpPrice1 = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    tmpPrice1 = Math.Round(tmpPrice1, 10, MidpointRounding.AwayFromZero);
                    tmpMinLtcDouble = tmpMinBtcDouble * tmpPrice1;
                }
                else
                {
                    tmpMinLtcDouble = Convert.ToDouble(track.jsons[0][email protected][i].total.Replace('.', ','));
                    tmpPrice1 = Convert.ToDouble(track.jsons[0][email protected][i].price.Replace('.', ','));
                    tmpPrice1 = Math.Round(tmpPrice1, 10, MidpointRounding.AwayFromZero);
                    tmpMinBtcDouble = tmpMinLtcDouble / tmpPrice1;

                }
                fee = FeeTransaction(track.path, 0);
                tmpMinLtcMinusFee = (tmpMinLtcDouble) * (1 - fee);
                tmpMinLtcSum += Math.Round(tmpMinLtcMinusFee, 10, MidpointRounding.AwayFromZero);
                if (tempLtcSum >= tmpMinLtcSum)
                {
                    tmpMinBtcSum += tmpMinBtcDouble;
                    continue;
                }
                else if (tempLtcSum < tmpMinLtcSum)
                {
                    tmpMinLtcSum = tmpMinLtcSum - tmpMinLtcMinusFee;
                    var difference = tempLtcSum - tmpMinLtcSum;
                    tmpMinLtcSum = tmpMinLtcSum + difference;
                    var howMuchWeNeedToBuy = difference / (1 - fee);
                    var amountOfBtc = howMuchWeNeedToBuy / tmpPrice1;
                    tmpMinBtcSum += amountOfBtc;
                    break;
                }
            }
            btc_common = tmpMinBtcSum;
            ltc_common = tmpMinLtcSum;
            #endregion

            #region Add to list and compute profit
            //
            //FINAL STAGE - COMPUTE PROFIT
            //

            double finalDiff = btc_common_final - btc_common;

            //this.val = difference;

            if (finalDiff > 0.0)
            {
                //var BRAWO = "BRAWO JEST OKAZJA DO ARBITRAZU";
                ArbitrageItem arbitrageItem = new ArbitrageItem();
                //if (min_btc_double < 0.000001 || min_ltc_double < 0.000000001 || min_doge_double < 0.0000000001)
                //    return;

                arbitrageItem.Fill(track.path, String.Format("{0:F10}", btc_common),
                    String.Format("{0:F10}", ltc_common),
                    String.Format("{0:F10}", doge_common),
                    String.Format("{0:F10}", btc_common_final),
                    String.Format("{0:F10}", tmpPrice1),
                    String.Format("{0:F10}", tmpPrice2),
                    String.Format("{0:F10}", tmpPrice3));
                arbitrageItem.Profit = String.Format("{0:F10}", finalDiff);
                arbitrageItem.PercentBenefit = Convert.ToDouble(String.Format("{0:F10}", finalDiff)) * 100 / btc_common;

                computedPaths.Add(new ComputedPaths(arbitrageItem.PercentBenefit,arbitrageItem.Profit,track, Indicator));
                if (Options.Instance.displayAllPaths == false)
                {
                    if (arbitrageItem.PercentBenefit > Options.Instance.minPercentBenefit)
                        arbitrageList.Add(arbitrageItem);
                }
                else
                {
                    arbitrageList.Add(arbitrageItem);
                }
            }
            #endregion
        }