public static void RunShowExchangeStats(Dictionary <string, string> dict)
        {
            string       symbol      = "BTC-USD";
            string       symbol2     = "XXBTZUSD";
            IExchangeAPI apiGDAX     = new ExchangeGdaxAPI();
            IExchangeAPI apiGemini   = new ExchangeGeminiAPI();
            IExchangeAPI apiKraken   = new ExchangeKrakenAPI();
            IExchangeAPI apiBitfinex = new ExchangeBitfinexAPI();

            while (true)
            {
                ExchangeTicker    ticker       = apiGDAX.GetTicker(symbol);
                ExchangeOrderBook orders       = apiGDAX.GetOrderBook(symbol);
                decimal           askAmountSum = orders.Asks.Sum(o => o.Amount);
                decimal           askPriceSum  = orders.Asks.Sum(o => o.Price);
                decimal           bidAmountSum = orders.Bids.Sum(o => o.Amount);
                decimal           bidPriceSum  = orders.Bids.Sum(o => o.Price);

                ExchangeTicker    ticker2       = apiGemini.GetTicker(symbol);
                ExchangeOrderBook orders2       = apiGemini.GetOrderBook(symbol);
                decimal           askAmountSum2 = orders2.Asks.Sum(o => o.Amount);
                decimal           askPriceSum2  = orders2.Asks.Sum(o => o.Price);
                decimal           bidAmountSum2 = orders2.Bids.Sum(o => o.Amount);
                decimal           bidPriceSum2  = orders2.Bids.Sum(o => o.Price);

                ExchangeTicker    ticker3       = apiKraken.GetTicker(symbol2);
                ExchangeOrderBook orders3       = apiKraken.GetOrderBook(symbol2);
                decimal           askAmountSum3 = orders3.Asks.Sum(o => o.Amount);
                decimal           askPriceSum3  = orders3.Asks.Sum(o => o.Price);
                decimal           bidAmountSum3 = orders3.Bids.Sum(o => o.Amount);
                decimal           bidPriceSum3  = orders3.Bids.Sum(o => o.Price);

                ExchangeTicker    ticker4       = apiBitfinex.GetTicker(symbol);
                ExchangeOrderBook orders4       = apiBitfinex.GetOrderBook(symbol);
                decimal           askAmountSum4 = orders4.Asks.Sum(o => o.Amount);
                decimal           askPriceSum4  = orders4.Asks.Sum(o => o.Price);
                decimal           bidAmountSum4 = orders4.Bids.Sum(o => o.Amount);
                decimal           bidPriceSum4  = orders4.Bids.Sum(o => o.Price);

                Console.Clear();
                Console.WriteLine("GDAX: {0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}, {4:0.00}, {5:0.00}", ticker.Last, ticker.Volume.PriceAmount, askAmountSum, askPriceSum, bidAmountSum, bidPriceSum);
                Console.WriteLine("GEMI: {0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}, {4:0.00}, {5:0.00}", ticker2.Last, ticker2.Volume.PriceAmount, askAmountSum2, askPriceSum2, bidAmountSum2, bidPriceSum2);
                Console.WriteLine("KRAK: {0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}, {4:0.00}, {5:0.00}", ticker3.Last, ticker3.Volume.PriceAmount, askAmountSum3, askPriceSum3, bidAmountSum3, bidPriceSum3);
                Console.WriteLine("BITF: {0:0.00}, {1:0.00}, {2:0.00}, {3:0.00}, {4:0.00}, {5:0.00}", ticker4.Last, ticker4.Volume.PriceAmount, askAmountSum4, askPriceSum4, bidAmountSum4, bidPriceSum4);
                Thread.Sleep(5000);
            }
        }
예제 #2
0
 static ExchangeTicker GetTicker(ConcurrentDictionary <string, ExchangeTicker> tickerDict, ExchangeGeminiAPI api, string marketSymbol)
 {
     return(tickerDict.GetOrAdd(marketSymbol, (_marketSymbol) =>
     {
         (string baseCurrency, string quoteCurrency) = api.ExchangeMarketSymbolToCurrenciesAsync(_marketSymbol).Sync();
         return new ExchangeTicker
         {
             MarketSymbol = _marketSymbol,
             Volume = new ExchangeVolume
             {
                 BaseCurrency = baseCurrency,
                 QuoteCurrency = quoteCurrency
             }
         };
     }));
 }