Example #1
0
        private async Task Ticker(IExchangeAPI api, string exchange, string global_symbol)
        {
            try
            {
                var symbol = api.GlobalSymbolToExchangeSymbol(global_symbol);
                var ticker = await api.GetTickerAsync(symbol);

                //var ticker = api.GetTicker(symbol);
                Console.WriteLine("[{0,-10} {1,9}]      b:{2:0.00000000}      a:{3:0.00000000}", exchange, symbol, ticker.Bid, ticker.Ask);
            }
            catch (Exception ex)
            {
                //Console.WriteLine("***[{0} {1}] ERROR: {2}***", exchange, global_symbol, ""); //ex.Message);
            }
        }
Example #2
0
        private async Task TestTicker(IExchangeAPI api, string marketSymbol)
        {
            if (FunctionRegex == null || Regex.IsMatch("ticker", FunctionRegex, RegexOptions.IgnoreCase))
            {
                try
                {
                    Console.Write("Test {0} GetTickerAsync... ", api.Name);
                    var ticker = await api.GetTickerAsync(marketSymbol);

                    Assert(ticker != null && ticker.Ask > 0m && ticker.Bid > 0m && ticker.Last > 0m &&
                           ticker.Volume != null && ticker.Volume.QuoteCurrencyVolume > 0m &&
                           ticker.Volume.BaseCurrencyVolume > 0m);
                    Console.WriteLine($"OK (ask: {ticker.Ask}, bid: {ticker.Bid}, last: {ticker.Last})");
                }
                catch
                {
                    Console.WriteLine("Data invalid or empty");
                }
            }
        }
Example #3
0
        public override async Task RunCommand()
        {
            var marketSymbol  = "BTC-USD";
            var marketSymbol2 = "XXBTZUSD";

            IExchangeAPI
                apiCoinbase = ExchangeAPI.GetExchangeAPI(ExchangeName.Coinbase),
                apiGemini   = ExchangeAPI.GetExchangeAPI(ExchangeName.Gemini),
                apiKraken   = ExchangeAPI.GetExchangeAPI(ExchangeName.Kraken),
                apiBitfinex = ExchangeAPI.GetExchangeAPI(ExchangeName.Bitfinex);

            //TODO: Make this multi-threaded and add parameters
            Console.WriteLine("Use CTRL-C to stop.");

            while (true)
            {
                var ticker = await apiCoinbase.GetTickerAsync(marketSymbol);

                var orders = await apiCoinbase.GetOrderBookAsync(marketSymbol);

                var askAmountSum = orders.Asks.Values.Sum(o => o.Amount);
                var askPriceSum  = orders.Asks.Values.Sum(o => o.Price);
                var bidAmountSum = orders.Bids.Values.Sum(o => o.Amount);
                var bidPriceSum  = orders.Bids.Values.Sum(o => o.Price);

                var ticker2 = await apiGemini.GetTickerAsync(marketSymbol);

                var orders2 = await apiGemini.GetOrderBookAsync(marketSymbol);

                var askAmountSum2 = orders2.Asks.Values.Sum(o => o.Amount);
                var askPriceSum2  = orders2.Asks.Values.Sum(o => o.Price);
                var bidAmountSum2 = orders2.Bids.Values.Sum(o => o.Amount);
                var bidPriceSum2  = orders2.Bids.Values.Sum(o => o.Price);

                var ticker3 = await apiKraken.GetTickerAsync(marketSymbol2);

                var orders3 = await apiKraken.GetOrderBookAsync(marketSymbol2);

                var askAmountSum3 = orders3.Asks.Values.Sum(o => o.Amount);
                var askPriceSum3  = orders3.Asks.Values.Sum(o => o.Price);
                var bidAmountSum3 = orders3.Bids.Values.Sum(o => o.Amount);
                var bidPriceSum3  = orders3.Bids.Values.Sum(o => o.Price);

                var ticker4 = await apiBitfinex.GetTickerAsync(marketSymbol);

                var orders4 = await apiBitfinex.GetOrderBookAsync(marketSymbol);

                var askAmountSum4 = orders4.Asks.Values.Sum(o => o.Amount);
                var askPriceSum4  = orders4.Asks.Values.Sum(o => o.Price);
                var bidAmountSum4 = orders4.Bids.Values.Sum(o => o.Amount);
                var bidPriceSum4  = orders4.Bids.Values.Sum(o => o.Price);

                Console.Clear();
                Console.WriteLine("GDAX: {0,13:N}, {1,15:N}, {2,8:N}, {3,13:N}, {4,8:N}, {5,13:N}", ticker.Last,
                                  ticker.Volume.QuoteCurrencyVolume, askAmountSum, askPriceSum, bidAmountSum, bidPriceSum);
                Console.WriteLine("GEMI: {0,13:N}, {1,15:N}, {2,8:N}, {3,13:N}, {4,8:N}, {5,13:N}", ticker2.Last,
                                  ticker2.Volume.QuoteCurrencyVolume, askAmountSum2, askPriceSum2, bidAmountSum2, bidPriceSum2);
                Console.WriteLine("KRAK: {0,13:N}, {1,15:N}, {2,8:N}, {3,13:N}, {4,8:N}, {5,13:N}", ticker3.Last,
                                  ticker3.Volume.QuoteCurrencyVolume, askAmountSum3, askPriceSum3, bidAmountSum3, bidPriceSum3);
                Console.WriteLine("BITF: {0,13:N}, {1,15:N}, {2,8:N}, {3,13:N}, {4,8:N}, {5,13:N}", ticker4.Last,
                                  ticker4.Volume.QuoteCurrencyVolume, askAmountSum4, askPriceSum4, bidAmountSum4, bidPriceSum4);
                Thread.Sleep(IntervalMs);
            }
        }