Beispiel #1
0
        protected override void ProcessResponse(string response)
        {
            var responseJSON = JObject.Parse(response)["pairs"].Value <JObject>();

            Console.Write("[INFO] YobitMarket is loading:  ");
            int count = 0;

            foreach (var pair in responseJSON)
            {
                ExchangePair exPair = new ExchangePair();
                exPair.Pair = pair.Key.ToUpper().Replace('_', '-');
                var pairInfo = JObject.Parse(LoadPairsInfo(pair.Key));
                exPair.PurchasePrice       = (decimal)pairInfo[pair.Key]["sell"] * (1 + _feeTaker);
                exPair.SellPrice           = (decimal)pairInfo[pair.Key]["buy"] * (1 - _feeMaker);
                exPair.StockExchangeSeller = "Yobit";

                _pairs.Add(exPair);
                CheckAddUsdtPair(exPair);

                count++;
                if (count % 10 == 0)
                {
                    Console.Write('>');
                }
            }
            CreateCrossRates();
            Console.Write('\n');
            Console.WriteLine("[INFO] YobitMarket is ready");
        }
Beispiel #2
0
        private ExchangePair AnalysePairs(ExchangePair thatMarketPair, BasicCryptoMarket[] marketsArray, int i, string keyWord = "")
        {
            ExchangePair maxSellPricePair     = thatMarketPair;
            ExchangePair minPurchasePricePair = thatMarketPair;
            ExchangePair actualPair           = new ExchangePair();

            for (int j = i; j < marketsArray.Length; j++)
            {
                string       name = thatMarketPair.Pair;
                ExchangePair anotherMarketPair = marketsArray[j].GetPairByName(name);
                if (anotherMarketPair == null)
                {
                    anotherMarketPair = marketsArray[j].GetPairByName(name.Substring(name.IndexOf('-') + 1) + '-'
                                                                      + name.Substring(0, name.IndexOf('-'))) ?? thatMarketPair;
                    if (anotherMarketPair != thatMarketPair)
                    {
                        anotherMarketPair.SellPrice     = 1 / anotherMarketPair.SellPrice;
                        anotherMarketPair.PurchasePrice = 1 / anotherMarketPair.PurchasePrice;
                    }
                }

                if (maxSellPricePair.SellPrice < anotherMarketPair.SellPrice)
                {
                    maxSellPricePair = anotherMarketPair;
                }
                if (minPurchasePricePair.PurchasePrice > anotherMarketPair.PurchasePrice)
                {
                    minPurchasePricePair = anotherMarketPair;
                }

                if (anotherMarketPair != thatMarketPair)
                {
                    marketsArray[j].DeletePairByName(anotherMarketPair.Pair);
                }
            }

            if (minPurchasePricePair.PurchasePrice < maxSellPricePair.SellPrice)
            {
                decimal diff = (maxSellPricePair.SellPrice - minPurchasePricePair.PurchasePrice) / maxSellPricePair.SellPrice;

                actualPair.Pair                = diff > (decimal)0.1 ? "[WARN] " + keyWord + minPurchasePricePair.Pair : keyWord + minPurchasePricePair.Pair;
                actualPair.PurchasePrice       = minPurchasePricePair.PurchasePrice;
                actualPair.SellPrice           = maxSellPricePair.SellPrice;
                actualPair.StockExchangeBuyer  = maxSellPricePair.StockExchangeSeller;
                actualPair.StockExchangeSeller = minPurchasePricePair.StockExchangeSeller;

                return(actualPair);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        protected override void ProcessResponse(string response)
        {
            var responseJSON = JObject.Parse(response);

            foreach (var pair in responseJSON)
            {
                ExchangePair exPair = new ExchangePair();
                exPair.Pair                = (string)pair.Key.Replace('_', '-');
                exPair.PurchasePrice       = (decimal)pair.Value["lowestAsk"] * (1 + _feeTaker);
                exPair.SellPrice           = (decimal)pair.Value["highestBid"] * (1 - _feeMaker);
                exPair.StockExchangeSeller = "Poloniex";

                _pairs.Add(exPair);
                CheckAddUsdtPair(exPair);
            }

            CreateCrossRates();
            Console.WriteLine("[INFO] PoloniexMarket is ready");
        }
Beispiel #4
0
        protected override void ProcessResponse(string response)
        {
            var responseJSON = JObject.Parse(response)["result"];

            foreach (JObject pair in responseJSON)
            {
                ExchangePair exPair = new ExchangePair();
                exPair.Pair                = (string)pair["MarketName"];
                exPair.PurchasePrice       = (decimal)pair["Ask"] * (1 + _feeTaker);
                exPair.SellPrice           = (decimal)pair["Bid"] * (1 - _feeMaker);
                exPair.StockExchangeSeller = "Bittrex";

                _pairs.Add(exPair);
                CheckAddUsdtPair(exPair);
            }

            CreateCrossRates();
            Console.WriteLine("[INFO] BittrexMarket is ready");
        }
Beispiel #5
0
        protected override void ProcessResponse(string response)
        {
            var responseJSON = JObject.Parse(response);

            foreach (var pair in responseJSON)
            {
                ExchangePair exPair      = new ExchangePair();
                char[]       signsSplit  = { '_' };
                string[]     splitedPair = pair.Key.Split(signsSplit);
                exPair.Pair = splitedPair[1] + '-' + splitedPair[0];

                exPair.PurchasePrice       = ((decimal)pair.Value["sell_price"]) * (1 + _feeTaker);
                exPair.SellPrice           = ((decimal)pair.Value["buy_price"]) * (1 - _feeMaker);
                exPair.StockExchangeSeller = "Exmo";

                _pairs.Add(exPair);
                CheckAddUsdtPair(exPair);
            }

            CreateCrossRates();
            Console.WriteLine("[INFO] ExmoMarket is ready");
        }
Beispiel #6
0
        public void FindActualPairsAndCrossRates(BasicCryptoMarket[] marketsArray)
        {
            for (int i = 0; i < marketsArray.Length - 1; i++)
            {
                foreach (ExchangePair thatMarketPair in marketsArray[i].Pairs)
                {
                    ExchangePair crossRate = AnalysePairs(thatMarketPair, marketsArray, i);
                    if (crossRate != null)
                    {
                        _actualPairs.Add(crossRate);
                    }
                }

                foreach (ExchangePair thatMarketPair in marketsArray[i].СrossRates)
                {
                    ExchangePair crossRate = AnalysePairs(thatMarketPair, marketsArray, i, "[CROSS] ");
                    if (crossRate != null)
                    {
                        _crossRates.Add(crossRate);
                    }
                }
            }
        }