示例#1
0
        public CryptoGatorForm()
        {
            bool   success;
            string message;

            /*var li = BittrexMarket.GetList(out success, out message);
             * var marketNames = new List<string>();
             * foreach (var m in li)
             *  marketNames.Add(m.MarketName);*/

            //var trades = BittrexMarketHistoryTrade.GetList("BTC-DOGE", out success, out message);

            InitializeComponent();

            OrderBookGridPanel gridPanel;

            //string result = Bitfinex.Instance.Authenticate().Result;
            //return;

            gridPanel = new OrderBookGridPanel(GetPanel(0), "GATOR", ColorPalette(1, 0));
            gridPanel.Initialize();
            m_gridPanels.Add(gridPanel);


            // GDAX: WORKS!!!
            GDAX.Instance.StartWebSocket();
            string[] args = { @"""type"":""subscribe""", @"""product_ids"":[""btc-usd""]", @"""channels"":[""level2""]" };
            GDAX.Instance.SubscribeWebSocket(args);
            gridPanel = new OrderBookGridPanel(GetPanel(1), "GDAX", ColorPalette(1, 1));
            gridPanel.Initialize();
            GDAX.Instance.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
            m_gridPanels.Add(gridPanel);

            // BitMEX: WORKS!!!
            BitMEX.Instance.StartWebSocket();
            BitMEX.Instance.SubscribeWebSocket();
            gridPanel = new OrderBookGridPanel(GetPanel(2), "BitMEX", ColorPalette(1, 2));
            gridPanel.Initialize();
            BitMEX.Instance.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
            m_gridPanels.Add(gridPanel);

            // HitBTC: WORKS!!!
            HitBTC.Instance.StartWebSocket();
            HitBTC.Instance.SubscribeWebSocket();
            gridPanel = new OrderBookGridPanel(GetPanel(3), "HitBTC", ColorPalette(1, 3));
            gridPanel.Initialize();
            HitBTC.Instance.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
            m_gridPanels.Add(gridPanel);

            // Bitfinex: WORKS!!!
            Bitfinex.Instance.StartWebSocket();
            Bitfinex.Instance.SubscribeWebSocket();
            gridPanel = new OrderBookGridPanel(GetPanel(4), "Bitfinex", ColorPalette(1, 4));
            gridPanel.Initialize();
            Bitfinex.Instance.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
            m_gridPanels.Add(gridPanel);

            // Gemini: WORKS!!!
            Gemini.Instance.StartWebSocket(new string[] { "BTCUSD" });
            Gemini.Instance.SubscribeWebSocket();
            gridPanel = new OrderBookGridPanel(GetPanel(5), "Gemini", ColorPalette(1, 5));
            gridPanel.Initialize();
            Gemini.Instance.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
            m_gridPanels.Add(gridPanel);

            // Cex: WORKS!!! ... uh, cannot connect to socket?!?

            /*Cex.Instance.StartWebSocket();
             * Cex.Instance.SubscribeWebSocket();
             * gridPanel = new OrderBookGridPanel(GetPanel(6), "Cex", ColorPalette(1, 6));
             * gridPanel.Initialize();
             * Cex.Instance.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
             * m_gridPanels.Add(gridPanel);*/



            //var markets_list = new List<string> { "BTC-LTC", "BTC-USD", "BTC-DASH", "BTC-ETH", "BTC-XMY", "BTC-GLD", "ETH-ANT", "ETH-LTC" };



            m_aggregateTimer.Elapsed += aggregateTimer_Elapsed;
            m_aggregateTimer.Interval = 1000;
            m_aggregateTimer.Enabled  = true;


            /*gridPanel = new TraderMarketGridPanel(panelCrypto2, markets_list[1], Color.DodgerBlue, 20000);
             * gridPanel.Initialize();
             * gridPanel.InitializeColumns(BittrexTraderMarket.Columns, Color.White);
             * //gridPanel.UpdateListFunction = UpdateBitstampTicker;
             * m_gridPanels.Add(gridPanel);*/

            /*
             * gridPanel = new SmallGridPanel(panelCrypto2, "BlockchainInfoTicker", Color.Green, 3000);
             * gridPanel.Initialize();
             * gridPanel.InitializeColumns(BlockchainInfoTicker.Columns, Color.White);
             * gridPanel.UpdateDictionaryFunction = UpdateBlockchainInfoTicker;
             * m_gridPanels.Add(gridPanel);
             *
             * gridPanel = new SmallGridPanel(panelCrypto3, "CoinMarketCapTicker", Color.DodgerBlue, 15000);
             * gridPanel.Initialize();
             * gridPanel.InitializeColumns(CoinMarketCapTicker.Columns, Color.White);
             * gridPanel.UpdateListFunction = UpdateCoinMarketCapTicker;
             * m_gridPanels.Add(gridPanel);
             *
             * gridPanel = new SmallGridPanel(panelCrypto4, "BitCoinChartsWeightedPrices", Color.Red, 5000);
             * gridPanel.Initialize();
             * gridPanel.InitializeColumns(BitcoinChartsWeightedPrices.Columns, Color.White);
             * gridPanel.UpdateDictionaryFunction = UpdateBitcoinChartsWeightedPrices;
             * m_gridPanels.Add(gridPanel);*/

            //m_gridPanels[0].EnableUpdates(true);
            //m_gridPanels[1].EnableUpdates(true);
            //m_gridPanels[2].EnableUpdates(true);
            //m_gridPanels[3].EnableUpdates(true);
        }
        public CryptoGatorForm()
        {
            bool   success;
            string message;

            /*var li = BittrexMarket.GetList(out success, out message);
             * var marketNames = new List<string>();
             * foreach (var m in li)
             *  marketNames.Add(m.MarketName);*/

            //var trades = BittrexMarketHistoryTrade.GetList("BTC-DOGE", out success, out message);

            InitializeComponent();

            Crypto.InitializeExchanges();

            OrderBookGridPanel gridPanel;

            //string result = Bitfinex.Instance.Authenticate().Result;
            //return;

            gridPanel = new OrderBookGridPanel(GetPanel(0), "GATOR", ColorPalette(1, 0));
            gridPanel.Initialize();
            m_gridPanels.Add(gridPanel);

            var gdax     = Crypto.Exchanges[CryptoExch.GDAX] as GDAX;
            var bitfinex = Crypto.Exchanges[CryptoExch.BITFINEX] as Bitfinex;
            var hitbtc   = Crypto.Exchanges[CryptoExch.HITBTC] as HitBTC;
            var bitflyer = Crypto.bitflyer;
            var poloniex = Crypto.poloniex;

            /*var binance = Crypto.Exchanges[CryptoExch.BINANCE] as Binance;
             * var kraken = Crypto.Exchanges[CryptoExch.KRAKEN] as Kraken;
             * var bithumb = Crypto.Exchanges[CryptoExch.BITHUMB] as Bithumb;
             * var itbit = Crypto.Exchanges[CryptoExch.ITBIT] as ItBit;
             * var bittrex = Crypto.Exchanges[CryptoExch.BITTREX] as Bittrex;
             * var btcc = Crypto.Exchanges[CryptoExch.BTCC] as BTCC;
             * var okcoin = Crypto.Exchanges[CryptoExch.OKCOIN] as OkCoin;
             * var poloniex = Crypto.Exchanges[CryptoExch.POLONIEX] as Poloniex;
             * var bitstamp = Crypto.Exchanges[CryptoExch.BITSTAMP] as Bitstamp;*/



            // GDAX: WORKS!!!
            gdax.StartWebSocket(null);
            string[] args = { @"""type"":""subscribe""", @"""product_ids"":[""btc-usd""]", @"""channels"":[""level2""]" };
            gdax.SubscribeWebSocket(args);
            gridPanel = new OrderBookGridPanel(GetPanel(1), "GDAX", ColorPalette(1, 1));
            gridPanel.Initialize();
            gdax.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
            m_gridPanels.Add(gridPanel);

            // BitMEX: WORKS!!!

            /*BitMEX.Instance.StartWebSocket();
             * BitMEX.Instance.SubscribeWebSocket();
             * gridPanel = new OrderBookGridPanel(GetPanel(2), "BitMEX", ColorPalette(1, 2));
             * gridPanel.Initialize();
             * BitMEX.Instance.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
             * m_gridPanels.Add(gridPanel);*/

            // HitBTC: WORKS!!!
            hitbtc.StartWebSocket();
            hitbtc.SubscribeWebSocket();
            gridPanel = new OrderBookGridPanel(GetPanel(2), "HitBTC", ColorPalette(1, 3));
            gridPanel.Initialize();
            hitbtc.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
            m_gridPanels.Add(gridPanel);

            // Bitfinex: WORKS!!!
            bitfinex.StartWebSocket();
            bitfinex.SubscribeWebSocket();
            gridPanel = new OrderBookGridPanel(GetPanel(3), "Bitfinex", ColorPalette(1, 4));
            gridPanel.Initialize();
            bitfinex.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
            m_gridPanels.Add(gridPanel);

            // Gemini: WORKS!!!
            Gemini.Instance.StartWebSocket(new string[] { "BTCUSD" });
            Gemini.Instance.SubscribeWebSocket();
            gridPanel = new OrderBookGridPanel(GetPanel(4), "Gemini", ColorPalette(1, 5));
            gridPanel.Initialize();
            Gemini.Instance.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
            m_gridPanels.Add(gridPanel);

            // BitFlyer: WORKS!!!
            bitflyer.StartWebSocket(new string[] { "BTC_USD" });
            bitflyer.SubscribeWebSocket();
            gridPanel = new OrderBookGridPanel(GetPanel(5), "BitFlyer", ColorPalette(1, 6));
            gridPanel.Initialize();
            bitflyer.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
            m_gridPanels.Add(gridPanel);

            // Poloniex: WORKS!!!
            poloniex.StartWebSocket(new string[] { "BTC_USD" });
            poloniex.SubscribeWebSocket();
            gridPanel = new OrderBookGridPanel(GetPanel(6), "Poloniex", ColorPalette(1, 7));
            gridPanel.Initialize();
            poloniex.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
            m_gridPanels.Add(gridPanel);

            // Cex: WORKS!!! ... uh, cannot connect to socket?!?

            /*Cex.Instance.StartWebSocket();
             * Cex.Instance.SubscribeWebSocket();
             * gridPanel = new OrderBookGridPanel(GetPanel(6), "Cex", ColorPalette(1, 6));
             * gridPanel.Initialize();
             * Cex.Instance.UpdateOrderBookEvent += gridPanel.Handle_UpdateOrderBook;
             * m_gridPanels.Add(gridPanel);*/



            //var markets_list = new List<string> { "BTC-LTC", "BTC-USD", "BTC-DASH", "BTC-ETH", "BTC-XMY", "BTC-GLD", "ETH-ANT", "ETH-LTC" };



            m_aggregateTimer.Elapsed += aggregateTimer_Elapsed;
            m_aggregateTimer.Interval = 1000;
            m_aggregateTimer.Enabled  = true;


            /*gridPanel = new TraderMarketGridPanel(panelCrypto2, markets_list[1], Color.DodgerBlue, 20000);
             * gridPanel.Initialize();
             * gridPanel.InitializeColumns(BittrexTraderMarket.Columns, Color.White);
             * //gridPanel.UpdateListFunction = UpdateBitstampTicker;
             * m_gridPanels.Add(gridPanel);*/

            /*
             * gridPanel = new SmallGridPanel(panelCrypto2, "BlockchainInfoTicker", Color.Green, 3000);
             * gridPanel.Initialize();
             * gridPanel.InitializeColumns(BlockchainInfoTicker.Columns, Color.White);
             * gridPanel.UpdateDictionaryFunction = UpdateBlockchainInfoTicker;
             * m_gridPanels.Add(gridPanel);
             *
             * gridPanel = new SmallGridPanel(panelCrypto3, "CoinMarketCapTicker", Color.DodgerBlue, 15000);
             * gridPanel.Initialize();
             * gridPanel.InitializeColumns(CoinMarketCapTicker.Columns, Color.White);
             * gridPanel.UpdateListFunction = UpdateCoinMarketCapTicker;
             * m_gridPanels.Add(gridPanel);
             *
             * gridPanel = new SmallGridPanel(panelCrypto4, "BitCoinChartsWeightedPrices", Color.Red, 5000);
             * gridPanel.Initialize();
             * gridPanel.InitializeColumns(BitcoinChartsWeightedPrices.Columns, Color.White);
             * gridPanel.UpdateDictionaryFunction = UpdateBitcoinChartsWeightedPrices;
             * m_gridPanels.Add(gridPanel);*/

            //m_gridPanels[0].EnableUpdates(true);
            //m_gridPanels[1].EnableUpdates(true);
            //m_gridPanels[2].EnableUpdates(true);
            //m_gridPanels[3].EnableUpdates(true);
        }