/// <summary>
        /// Bitstamp websocket client.
        /// Use method `Send()` to subscribe to channels.
        /// And `Streams` to handle messages.
        /// </summary>
        /// <param name="communicator">Live or backtest communicator</param>
        public BitstampWebsocketClient(IBitstampCommunicator communicator)
        {
            BitstampValidations.ValidateInput(communicator, nameof(communicator));

            _communicator = communicator;
            _messageReceivedSubscription = _communicator.MessageReceived.Subscribe(HandleMessage);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Stream snapshot manually via communicator
        /// </summary>
        public static void StreamFakeSnapshot(OrderBookSnapshotResponse snapshot, IBitstampCommunicator communicator)
        {
            var symbolSafe = (snapshot?.Symbol ?? string.Empty).ToLower().Replace("-", "").Replace("_", "");
            var response   = snapshot;

            if (response != null)
            {
                response.Symbol = $"{symbolSafe}";

                var serialized = JsonConvert.SerializeObject(response, BitstampJsonSerializer.Settings);
                communicator.StreamFakeMessage(ResponseMessage.TextMessage(serialized));
            }
        }