Esempio n. 1
0
        public void TestWebsocketsGdax()
        {
            // create a web socket connection to the exchange. Note you can Dispose the socket anytime to shut it down.
            // the web socket will handle disconnects and attempt to re-connect automatically.
            IExchangeAPI b = new ExchangeGdaxAPI();

            using (var socket = b.GetTickersWebSocket((tickers) =>
            {
                Console.WriteLine("{0} tickers, first: {1}", tickers.Count, tickers.First());
            }))
            {
                Console.WriteLine("Press ENTER to shutdown.");
                Console.ReadLine();
            }
        }
        public IDisposable TestWebsocketsGdax(bool display = false)
        {
            IExchangeAPI a      = new ExchangeGdaxAPI();
            var          socket = a.GetTickersWebSocket((tickers) =>
            {
                if (display)
                {
                    Console.WriteLine("GDAX     {0,4} tickers, first: {1}", tickers.Count, tickers.First());
                }
                //await Task.Run(async () => HandleTickerUpdate( a, tickers));
                //HandleTickerUpdate(a, tickers);
                m_outputQ.Enqueue(new TickerOutput("GDAX", tickers));
            });

            return(socket);
        }
Esempio n. 3
0
        public IDisposable StartWebsocketsGdax(bool display = false)
        {
            IExchangeAPI a      = new ExchangeGdaxAPI();
            var          socket = a.GetTickersWebSocket((tickers) =>
            {
                if (display)
                {
                    Console.WriteLine("GDAX     {0,4} tickers, first: {1}", tickers.Count, tickers.First());
                }
                HandleTickerUpdate("GDAX", tickers);
                //m_outputQ.Enqueue(new TickerOutput("GDAX", tickers));
                if (tickers.Select(s => s.Key).Contains("BTC-USD"))
                {
                    //Console.WriteLine("GDAX");
                    if (TickersExistForAllExchanges)
                    {
                        DisplaySpreads("GDAX");
                    }
                }
            });

            return(socket);
        }