Exemple #1
0
        public async Task StartAsync()
        {
            var orderBooks = await _matchingEngineClient.OrderBooks.GetAllAsync();

            foreach (var orderBook in orderBooks)
            {
                var type = orderBook.IsBuy
                    ? LimitOrderType.Buy
                    : LimitOrderType.Sell;

                var limitOrders = orderBook.Levels
                                  .Select(level => new LimitOrder
                {
                    Id       = level.OrderId,
                    Price    = level.Price,
                    Volume   = Math.Abs(level.Volume),
                    WalletId = level.WalletId,
                    Type     = type
                })
                                  .ToList();

                if (orderBook.IsBuy)
                {
                    _orderBooksHandler.HandleBuy(orderBook.AssetPairId, orderBook.Timestamp, limitOrders);
                }
                else
                {
                    _orderBooksHandler.HandleSell(orderBook.AssetPairId, orderBook.Timestamp, limitOrders);
                }
            }

            _orderBooksSubscriber.Start();
        }
Exemple #2
0
        public async Task StartAsync()
        {
            var orderBooks = await _matchingEngineClient.OrderBooks.GetAllAsync();

            foreach (var orderBook in orderBooks)
            {
                var type = orderBook.IsBuy
                    ? MyNoSql.OrderBookData.LimitOrderType.Buy
                    : MyNoSql.OrderBookData.LimitOrderType.Sell;

                var limitOrders = orderBook.Levels
                                  .Select(level => new MyNoSql.OrderBookData.LimitOrder
                {
                    Id       = Guid.Parse(level.OrderId),
                    Price    = decimal.Parse(level.Price),
                    Volume   = Math.Abs(decimal.Parse(level.Volume)),
                    WalletId = level.WalletId,
                    Type     = type
                })
                                  .ToList();

                _orderBooksHandler.Handle(orderBook.BrokerId, orderBook.Asset, orderBook.IsBuy, orderBook.Timestamp.ToDateTime(), limitOrders);
            }

            _orderBooksSubscriber.Start();
        }
        public async Task StartAsync()
        {
            await _candlesCache.InitializeAsync();

            _orderBooksSubscriber.Start();
        }