Exemplo n.º 1
0
        /// <summary>
        /// Sunscribes the ticker symbol to the current connection.
        /// </summary>
        /// <param name="tickersymbol">The tickersymbol.</param>
        private void UnSubscribeTickerSymbol(string tickersymbol)
        {
            //Check if we are subscribed
            if (!_connectedTickers.Contains(tickersymbol))
            {
                return;
            }

            //Create request
            var socketmethod = new SocketRequestModel
            {
                Action        = "unsubscribe",
                Type          = "book",
                TradingPairId = tickersymbol
            };

            //Send for orderbook
            SendRequest(socketmethod);

            //Send for trades
            socketmethod.Type = "trade";
            SendRequest(socketmethod);

            //Send for ticker
            socketmethod.Type = "ticker";
            SendRequest(socketmethod);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Sends a request to the cobinhood socket connection.
 /// </summary>
 /// <param name="request">The request.</param>
 private void SendRequest(SocketRequestModel request)
 {
     try
     {
         var serialized = JSON.Serialize(request);
         _log.Trace($"Sending request to cobinhood socket: {serialized}");
         _socket.Send(serialized);
     }
     catch (Exception e)
     {
         _log.Error(e, $"Could not send request to Cobinhood socket due to exception.");
     }
 }