Beispiel #1
0
        public void ShouldMatchMultipleSellOrdersToSameBuyOrder()
        {
            var executions    = new List <INewExecution>();
            var executionalgo = new LimitOrderMatchingAlgorithm(new DateService());

            executionalgo.AddExecutionsHandler(executions.Add);

            var priceSlot = new PriceSlot(90, executionalgo, new MarketOrderMatchingAlgorithm(new DateService()));

            var sellOrder1 = new LimitOrder("ABC", 10, 90, WayEnum.Sell, 90);
            var sellOrder2 = new LimitOrder("ABC", 40, 90, WayEnum.Sell, 90);
            var buyOrder   = new LimitOrder("ABC", 50, 90, WayEnum.Buy, 80);

            priceSlot.AddOrder(sellOrder1);
            priceSlot.AddOrder(sellOrder2);
            priceSlot.TryMatchLimitOrder(buyOrder);

            Assert.AreEqual(2, executions.Count);
            Assert.AreEqual(0, priceSlot.BuyOrders.Count);
            Assert.AreEqual(0, priceSlot.SellOrders.Count);
        }
Beispiel #2
0
        public void ShouldMatchBuyOrderCompletely()
        {
            var executions    = new List <INewExecution>();
            var executionalgo = new LimitOrderMatchingAlgorithm(new DateService());

            executionalgo.AddExecutionsHandler(executions.Add);



            var priceSlot = new PriceSlot(90, executionalgo, new MarketOrderMatchingAlgorithm(new DateService()));

            var sellOrder = new LimitOrder("ABC", 100, 90, WayEnum.Sell, 90);
            var buyOrder  = new LimitOrder("ABC", 10, 90, WayEnum.Buy, 80);

            priceSlot.AddOrder(sellOrder);
            priceSlot.TryMatchLimitOrder(buyOrder);

            Assert.AreEqual(1, executions.Count);
            Assert.AreEqual(0, priceSlot.BuyOrders.Count);
            Assert.AreEqual(1, priceSlot.SellOrders.Count);
            Assert.AreEqual(90, priceSlot.SellOrders[0].Quantity);
        }