Exemplo n.º 1
0
        public static void Main()
        {
            IDisplayMessage console = new Console();

            console.Display(ProductNotFoundMessage.For(SomeUnknownBarcode));
            console.Display(new EmptyBarCodeMessage());
            console.Display(PriceMessage.For(Price.InCents(255)));
            System.Console.ReadKey();
        }
        public void SendToQueue(MarketDto market)
        {
            var request = new PriceMessage()
            {
                Market = market.Name
            };

            _producer.PublishMessage(request, "PriceRequestQueue");
            _logger.LogInformation($"Published to PriceRequestQueue: {request}");
        }
Exemplo n.º 3
0
        private void SendToQueue(MarketDto market)
        {
            var request = new PriceMessage()
            {
                Id     = Guid.NewGuid().ToString(),
                Market = market.Name
            };

            _producer.PublishMessage(request, "PriceRequestQueue", "5000");
            _batchLog.Update(_logId, $"Published to PriceRequestQueue");
        }
Exemplo n.º 4
0
        private OrderBook Convert(PriceMessage priceMessage)
        {
            var assetPair = _withWithoutSuffixMapping[priceMessage.Instrument];

            var bids = GetOrderBookItems(priceMessage.Levels.Sell);
            var asks = GetOrderBookItems(priceMessage.Levels.Buy);

            var result = new OrderBook(Source, assetPair, priceMessage.Timestamp, asks, bids);

            return(result);
        }
Exemplo n.º 5
0
        private static PriceMessage MockPriceResponse()
        {
            var priceResponse = new PriceMessage()
            {
                Prices = new List <PriceDto>()
                {
                    new PriceDto()
                    {
                        Market = "TestGBPUSD"
                    }
                }
            };

            return(priceResponse);
        }
Exemplo n.º 6
0
        private async Task HandleAsync(PriceMessage message)
        {
            var orderBook  = Convert(message);
            var instrument = _withWithoutSuffixMapping[message.Instrument];

            if (_orderBooksCache.TryGetValue(instrument, out var existedOrderBook))
            {
                if (orderBook.Timestamp > existedOrderBook.Timestamp)
                {
                    _orderBooksCache[instrument] = orderBook;
                    await PublishOrderBookAndTickPrice(orderBook);
                }
            }
            else
            {
                _orderBooksCache[instrument] = orderBook;
            }
        }
Exemplo n.º 7
0
 private bool Process(PriceMessage priceMessage)
 {
     return true;
 }
Exemplo n.º 8
0
 private void HandlePrice(PriceMessage message)
 {
     Console.WriteLine("Total price: {0}", OrderDetails.Sum(x => x.Price));
 }
Exemplo n.º 9
0
 private void OnPrice(PriceMessage price)
 {
     Console.WriteLine("RECEIVED: {0} = {1}", price.Ticker, price.Price);
 }