Exemplo n.º 1
0
        public void ProcessBuyLimit_PickBidOrder_PartialFilled()
        {
            // Arrange
            var price = 100;
            var partialFilledAmount = 0.4;
            var fullAmount          = 1;
            var askOrder            = new Order(OrderSide.Sell, price, partialFilledAmount);
            var orderbook           = new OrderBook();

            orderbook.AddAskOrder(askOrder);
            var bidOrder = new Order(OrderSide.Buy, price, fullAmount);

            // Act
            var processor = new Processor();
            var trades    = processor.ProcessBuyLimit(bidOrder, orderbook);

            // Assert
            Assert.AreEqual(trades.Count, 1);
            Assert.AreEqual(trades[0].Price, bidOrder.Price);
            Assert.AreEqual(trades[0].Amount, partialFilledAmount);
            Assert.AreEqual(trades[0].TakerOrderId, bidOrder.Id);
            Assert.AreEqual(trades[0].MakerOrderId, askOrder.Id);

            Assert.AreEqual(orderbook.BidOrders.Count, 1);
            Assert.AreEqual(orderbook.BidOrders[0].Id, bidOrder.Id);
            Assert.AreEqual(orderbook.BidOrders[0].Price, bidOrder.Price);
            Assert.AreEqual(orderbook.BidOrders[0].Amount, fullAmount - partialFilledAmount);
            Assert.AreEqual(orderbook.BidOrders[0].Side, bidOrder.Side);
        }