예제 #1
0
        private ICurrencyCoin GetCoinDetails(ICurrencyCoin coin)
        {
            switch (coin.Exchange)
            {
            case "Binance":
                var r1 = _binanceService.Get24hrAsync(coin.APIFormatted).Result;
                coin.LastPrice = r1.lastPrice;
                coin.AskPrice  = r1.askPrice;
                coin.BidPrice  = r1.bidPrice;
                coin.Volume    = r1.volume;
                break;

            case "Bittrex":
                var r2 = _bittrexService.GetMarketSummaryAsync(coin.APIFormatted).Result;
                coin.LastPrice = r2.LastPrice;
                coin.AskPrice  = r2.AskPrice;
                coin.BidPrice  = r2.BidPrice;
                coin.Volume    = r2.Volume;
                break;

            case "Cryptopia":
                var r3 = _cryptopiaService.GetMarketAsync(coin.APIFormatted).Result;
                coin.LastPrice = r3.LastPrice;
                coin.AskPrice  = r3.AskPrice;
                coin.BidPrice  = r3.BidPrice;
                coin.Volume    = r3.Volume;
                break;

            default:
                break;
            }
            return(coin);
        }
        private ArbitrageResult ComparePrices(ICurrencyCoin value1, ICurrencyCoin value2)
        {
            ArbitrageResult result = null;

            if (value1.Price > value2.Price && ((1 - (value2.Price / value1.Price)) * 100) > 5)
            {
                result = new ArbitrageResult
                {
                    Market         = value1.Market,
                    Symbol         = value1.TickerSymbol,
                    Exchange1      = value1.Exchange,
                    Exchange1Logo  = value1.Logo,
                    Exchange1Price = value1.Price,
                    Exchange2      = value2.Exchange,
                    Exchange2Logo  = value2.Logo,
                    Exchange2Price = value2.Price,
                };
            }
            else if (((1 - (value1.Price / value2.Price)) * 100) > 5)
            {
                result = new ArbitrageResult
                {
                    Market         = value1.Market,
                    Symbol         = value1.TickerSymbol,
                    Exchange1      = value2.Exchange,
                    Exchange1Logo  = value2.Logo,
                    Exchange1Price = value2.Price,
                    Exchange2      = value1.Exchange,
                    Exchange2Logo  = value1.Logo,
                    Exchange2Price = value1.Price,
                };
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Takes  two coins and determines if they should be potential
        /// arbitrage candidates.  Currenly based on ARB_THRESHOLD amount
        /// </summary>
        /// <param name="c1"></param>
        /// <param name="c2"></param>
        /// <returns>Returns null if not a canidate otherwise returns a Tuple with both coins.</returns>
        private Tuple <ICurrencyCoin, ICurrencyCoin> CompareCoins(ICurrencyCoin c1, ICurrencyCoin c2)
        {
            Tuple <ICurrencyCoin, ICurrencyCoin> result = null;
            var priceDiff = ((c2.Price - c1.Price) / Math.Abs(c1.Price)) * 100;

            if (priceDiff >= ARB_THRESHOLD)
            {
                c1 = GetCoinDetails(c1);
                c2 = GetCoinDetails(c2);
                if (c1.Volume > 0 && c2.Volume > 0)
                {
                    result = Tuple.Create <ICurrencyCoin, ICurrencyCoin>(c1, c2);
                }
            }
            return(result);
        }