private Task ProcessMessageAsync(OrderBook orderBook)
        {
            // workaround for Lykke production
            var internalAssetPair = orderBook.Asset.Replace("EOS", "EOScoin");

            var sellLimitOrders = orderBook.Asks.Select(o => new Domain.LimitOrder
            {
                Price  = o.Price,
                Volume = o.Volume,
                Type   = Domain.LimitOrderType.Sell
            });

            var buyLimitOrders = orderBook.Bids.Select(o => new Domain.LimitOrder
            {
                Price  = o.Price,
                Volume = o.Volume,
                Type   = Domain.LimitOrderType.Buy
            });

            return(_b2C2OrderBookService.SetAsync(new Domain.OrderBook
            {
                AssetPairId = internalAssetPair,
                Time = orderBook.Timestamp,
                LimitOrders = sellLimitOrders.Concat(buyLimitOrders).ToArray()
            }));
        }
        private async Task ProcessMessageAsync(OrderBook orderBook)
        {
            // workaround for Lykke production
            var internalAssetPair = orderBook.Asset.Replace("EOS", "EOScoin");

            var now = DateTime.UtcNow;

            //_log.Info("B2C2 Order Book handled.", new
            //{
            //    AssetPairId = orderBook.Asset,
            //    OrderBookTimestamp = orderBook.Timestamp,
            //    Now = now,
            //    Latency = (now - orderBook.Timestamp).TotalMilliseconds
            //});

            PrometheusMetrics.B2C2OrderBookLatency.Inc((now - orderBook.Timestamp).TotalMilliseconds);

            var sellLimitOrders = orderBook.Asks.Select(o => new Domain.LimitOrder
            {
                Price  = o.Price,
                Volume = o.Volume,
                Type   = Domain.LimitOrderType.Sell
            });

            var buyLimitOrders = orderBook.Bids.Select(o => new Domain.LimitOrder
            {
                Price  = o.Price,
                Volume = o.Volume,
                Type   = Domain.LimitOrderType.Buy
            });

            var newOrderBook = new Domain.OrderBook
            {
                AssetPairId = internalAssetPair,
                Time        = orderBook.Timestamp,
                LimitOrders = sellLimitOrders.Concat(buyLimitOrders).ToArray()
            };

            await _b2C2OrderBookService.SetAsync(newOrderBook);

            await _marketMakerService.UpdateOrderBooksAsync(newOrderBook.AssetPairId);
        }
Example #3
0
        private Task ProcessMessageAsync(OrderBook orderBook)
        {
            var sellLimitOrders = orderBook.Asks.Select(o => new Domain.LimitOrder
            {
                Price  = o.Price,
                Volume = o.Volume,
                Type   = Domain.LimitOrderType.Sell
            });

            var buyLimitOrders = orderBook.Bids.Select(o => new Domain.LimitOrder
            {
                Price  = o.Price,
                Volume = o.Volume,
                Type   = Domain.LimitOrderType.Buy
            });

            return(_b2C2OrderBookService.SetAsync(new Domain.OrderBook
            {
                AssetPairId = orderBook.Asset,
                Time = orderBook.Timestamp,
                LimitOrders = sellLimitOrders.Concat(buyLimitOrders).ToArray()
            }));
        }