Esempio n. 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);
        }
        public OrderBook GetOrderBook(string exchange, string market, string symbol)
        {
            OrderBook ob = null;

            switch (exchange)
            {
            case "Cryptopia":
                ob = _cryptopiaService.GetMarketOrdersAsync(string.Format(@"{0}_{1}", symbol, market)).Result;
                var i = _cryptopiaService.GetMarketAsync(string.Format(@"{0}_{1}", symbol, market)).Result;
                //ob.MarketResult = new MarketResult { Volume = i.Volume, Last = i.LastPrice };
                break;

            case "Binance":
                //ob = _binanceService.GetMarketOrders(string.Format(@"{0}{1}", symbol.ToUpper(), market.ToUpper()));
                var ii = _binanceService.Get24hrAsync(string.Format(@"{0}{1}", symbol.ToUpper(), market.ToUpper())).Result;
                //ob.MarketResult = new MarketResult { Volume = ii.volume, Last = ii.lastPrice };
                break;

            case "Bittrex":
                //var bob = _bittrexService.GetOrderBook(string.Format(@"{0}-{1}", market.ToUpper(), symbol.ToUpper())).Result;
                // ob = new OrderBook
                // {
                //     Buy = bob.buy.Select(c => new Order { Price = c.Rate, Volume = c.Quantity }),
                //     Sell = bob.sell.Select(c => new Order { Price = c.Rate, Volume = c.Quantity }),
                // };
                //var iii = _bittrexService.GetMarketSummary(string.Format(@"{0}-{1}", market.ToUpper(), symbol.ToUpper())).Result;
                //ob.MarketResult = new MarketResult { Volume = iii.Volume, Last = iii.Last };
                break;

            default:
                break;
            }
            return(ob);
        }