コード例 #1
0
        // constructor
        public Client(List <string> cryptocurrencies)
        {
            // builds the pricelist using a list of cryprocurrency market strings
            foreach (string cryptocurrency in cryptocurrencies)
            {
                CryptocurrencyData newCryptocurrencyData = new CryptocurrencyData(cryptocurrency);
                priceList.Add(newCryptocurrencyData);
            }

            // add the ticker channel to the channel list
            theChanelTypes = new List <ChannelType>()
            {
                ChannelType.Ticker
            };

            theProductTypes = parseProducts(cryptocurrencies);

            theCoinBaseProClient = new CoinbasePro.CoinbaseProClient();

            theWebSocket = theCoinBaseProClient.WebSocket;


            theWebSocket.Start(theProductTypes, theChanelTypes);

            // event handler for ticker received
            theWebSocket.OnTickerReceived += WebSocket_OnTickerReceived;
        }
コード例 #2
0
        public void UpdateCryptocurrencyList(List <string> cryptocurrencies)
        {
            // empties the pricelist before adding the new data to it
            priceList.Clear();

            // builds the pricelist using a list of cryprocurrency market strings
            foreach (string cryptocurrency in cryptocurrencies)
            {
                CryptocurrencyData newCryptocurrencyData = new CryptocurrencyData(cryptocurrency);
                priceList.Add(newCryptocurrencyData);
            }

            // update the product types from the newly updated cryptocurrency list
            theProductTypes = parseProducts(cryptocurrencies);

            // restarts the websocket with the new list of currencies to listen for
            theWebSocket.Stop();
            theWebSocket.Start(theProductTypes, theChanelTypes);
        }