NewLimitOrder() public method

public NewLimitOrder ( IStopLimitOrder stopLimitOrder ) : ILimitOrder
stopLimitOrder IStopLimitOrder
return ILimitOrder
        public void ShouldCreateNewOrderBookItMatchItAndRemoveIt()
        {
            var repo = new OrderRepository();
            var limitAlgo = new LimitOrderMatchingAlgorithm(new DateService());
            var marketAlgo = new MarketOrderMatchingAlgorithm(new DateService());
            var level1 = new OrderBookBestBidAsk("ABC");
            var book = new OrderBook("ABC", limitAlgo, marketAlgo, level1);

            var sellOrder1 = repo.NewLimitOrder("ABC", 9, 88.2d, 100, WayEnum.Sell);
            book.AddLimitOrder(sellOrder1);

            var buyOrder1 = repo.NewLimitOrder("ABC", 9, 88.0d, 50, WayEnum.Buy);
            book.AddLimitOrder(buyOrder1);

            Assert.AreEqual(88.2d, level1.BestAskPrice);
            Assert.AreEqual(88.0d, level1.BestBidPrice);

            buyOrder1.Modify(50, 88.2d);

            Assert.AreEqual(88.2d, level1.BestAskPrice);
            Assert.IsNull(level1.BestBidPrice);

            var retrievedBuyOrder = repo.TryGetLimitOrder(buyOrder1.ExchangeOrderId);
            Assert.IsNull(retrievedBuyOrder);
        }
        public void RepositoryShouldIncrementOrderNumber()
        {
            var repo = new OrderRepository();

            var firstOrder = repo.NewLimitOrder("ABC", 12, 200, 90, WayEnum.Buy);
            var secondOrder = repo.NewLimitOrder("ABC", 12, 200, 90, WayEnum.Buy);
            Assert.AreEqual(1, firstOrder.ExchangeOrderId);
            Assert.AreEqual(2, secondOrder.ExchangeOrderId);
        }
 public void RepositoryShouldReturnNullOnNonExistingOrderId()
 {
     var repo = new OrderRepository();
     var order = repo.NewLimitOrder("ABC", 12, 200.45d, 90, WayEnum.Buy);
     var retrievedOrder = repo.TryGetLimitOrder(666);
     Assert.IsNull(retrievedOrder);
 }
 public void NewOrderShouldBeRetrievableThroughOrderId()
 {
     var repo = new OrderRepository();
     var order = repo.NewLimitOrder("ABC", 12, 200.45d, 90, WayEnum.Buy);
     var retrievedOrder = repo.TryGetLimitOrder(order.ExchangeOrderId);
     Assert.AreEqual(order, retrievedOrder);
 }
        public void RepositoryShouldRemoveOrderFromRepositoryWhenOrderIsDeleted()
        {
            var repo = new OrderRepository();
            var order = repo.NewLimitOrder("ABC", 12, 200.45d, 90, WayEnum.Buy);
            order.Delete();

            var retrievedOrder = repo.TryGetLimitOrder(order.ExchangeOrderId);
            Assert.IsNull(retrievedOrder);
        }
        public void RepositoryShouldReturnOrderWithCorrectData()
        {
            var repo = new OrderRepository();

            var order = repo.NewLimitOrder("ABC", 12, 200.45d, 90, WayEnum.Buy);
            Assert.AreEqual("ABC", order.Symbol);
            Assert.AreEqual(12, order.ClientId);
            Assert.AreEqual(200.45d, order.Price);
            Assert.AreEqual(90, order.Quantity);
            Assert.AreEqual(WayEnum.Buy, order.Way);
        }
        public void ShouldReturnAllClientOrders()
        {
            var repo = new OrderRepository();

            var order1 = repo.NewLimitOrder("ABC", 12, 200.45d, 90, WayEnum.Buy);
            var order2 = repo.NewLimitOrder("ABC", 12, 200.45d, 90, WayEnum.Buy);
            var order3 = repo.NewLimitOrder("ABC", 13, 200.45d, 90, WayEnum.Buy);
            var order4 = repo.NewLimitOrder("ABC", 14, 200.45d, 90, WayEnum.Buy);

            var client12 = repo.GetClientLimitOrders(12);
            var client13 = repo.GetClientLimitOrders(13);
            var client14 = repo.GetClientLimitOrders(14);

            Assert.AreEqual(2, client12.Count);
            Assert.AreEqual(1, client13.Count);
            Assert.AreEqual(1, client14.Count);

            Assert.AreEqual(order1, client12[0]);
            Assert.AreEqual(order2, client12[1]);
            Assert.AreEqual(order3, client13[0]);
            Assert.AreEqual(order4, client14[0]);
        }