Пример #1
0
        private void Handle(MarketTradeDetailUpdateMessage msg)
        {
            for (var i = 0; i < msg.Tick?.Data.Length; ++i)
            {
                var item = msg.Tick.Data[i];

                _logger.LogInformation(
                    $"Market trade detail update {msg.ParseSymbolFromTopic()}, id={msg.Tick.Id}, ts={msg.Tick.Timestamp} | [item {i}: amount={item.Amount} ts={item.Timestamp} id={item.Id} tradeId={item.TradeId} price={item.Price} direction={item.Direction}]");
            }
        }
Пример #2
0
        public void ParseSymbolFromTopic_InvalidTopic_ThrowsException(string topic)
        {
            // Arrange
            var updateMessage = new MarketTradeDetailUpdateMessage(
                topic,
                DateTimeOffset.UtcNow,
                new MarketTradeDetailTick(1, DateTimeOffset.UtcNow, Array.Empty <MarketTradeDetailTickDataItem>()));

            // Act & Assert
            Assert.Throws <HuobiWebsocketClientException>(() => updateMessage.ParseSymbolFromTopic());
        }
        private void HandleTrade(MarketTradeDetailUpdateMessage response)
        {
            var converted = response
                            .Tick
                            .Data
                            .Select(
                trade => ConvertTrade(
                    response.ParseSymbolFromTopic(),
                    trade,
                    response.Timestamp.UtcDateTime))
                            .ToArray();

            TradesSubject.OnNext(converted);
        }