public void HandleAddLimitOrder(ILimitOrder limitOrder)
        {
            string symbol = limitOrder.Symbol;

            if (!OrderBooks.ContainsKey(symbol))
            {
                var bookMatchingLimitAlgo = new LimitOrderMatchingAlgorithm(dateService);
                bookMatchingLimitAlgo.AddExecutionsHandler(outgoingQueue.EnqueueClientExecution);

                var bookMatchingMarketAlgo = new MarketOrderMatchingAlgorithm(dateService);
                bookMatchingMarketAlgo.AddExecutionsHandler(outgoingQueue.EnqueueClientExecution);

                var level1 = new OrderBookBestBidAsk(symbol);
                level1.RegisterUpdateHandler(outgoingQueue.EnqueueLevel1Update);

                var book = new OrderBook(symbol, bookMatchingLimitAlgo, bookMatchingMarketAlgo, level1);
                OrderBooks.Add(symbol, book);
            }

            outgoingQueue.EnqueueAddedLimitOrder(limitOrder);
            limitOrder.RegisterDeleteNotificationHandler(OrderBooks[symbol].RemoveLimitOrder);
            limitOrder.RegisterFilledNotification(OrderBooks[symbol].RemoveLimitOrder);
            limitOrder.RegisterModifyNotificationHandler(OrderBooks[symbol].HandleLimitOrderModify);

            OrderBooks[symbol].AddLimitOrder(limitOrder);
        }
        public void HandleAddLimitOrder(ILimitOrder limitOrder)
        {
            string symbol = limitOrder.Symbol;
            if (!OrderBooks.ContainsKey(symbol))
            {
                var bookMatchingLimitAlgo = new LimitOrderMatchingAlgorithm(dateService);
                bookMatchingLimitAlgo.AddExecutionsHandler(outgoingQueue.EnqueueClientExecution);

                var bookMatchingMarketAlgo = new MarketOrderMatchingAlgorithm(dateService);
                bookMatchingMarketAlgo.AddExecutionsHandler(outgoingQueue.EnqueueClientExecution);

                var level1 = new OrderBookBestBidAsk(symbol);
                level1.RegisterUpdateHandler(outgoingQueue.EnqueueLevel1Update);

                var book = new OrderBook(symbol, bookMatchingLimitAlgo, bookMatchingMarketAlgo, level1);
                OrderBooks.Add(symbol, book);
            }

            outgoingQueue.EnqueueAddedLimitOrder(limitOrder);
            limitOrder.RegisterDeleteNotificationHandler(OrderBooks[symbol].RemoveLimitOrder);
            limitOrder.RegisterFilledNotification(OrderBooks[symbol].RemoveLimitOrder);
            limitOrder.RegisterModifyNotificationHandler(OrderBooks[symbol].HandleLimitOrderModify);

            OrderBooks[symbol].AddLimitOrder(limitOrder);
        }
        public void AddOrder(ILimitOrder order)
        {
            if (order.Price != Price)
                return;

            switch (order.Way)
            {
                case WayEnum.Buy:
                    BuyOrders.Add(order);
                    break;

                case WayEnum.Sell:
                    SellOrders.Add(order);
                    break;
            }

            order.RegisterDeleteNotificationHandler(HandleDeleteOrFilled);
            order.RegisterFilledNotification(HandleDeleteOrFilled);
        }
Exemple #4
0
        public void AddOrder(ILimitOrder order)
        {
            if (order.Price != Price)
            {
                return;
            }

            switch (order.Way)
            {
            case WayEnum.Buy:
                BuyOrders.Add(order);
                break;

            case WayEnum.Sell:
                SellOrders.Add(order);
                break;
            }

            order.RegisterDeleteNotificationHandler(HandleDeleteOrFilled);
            order.RegisterFilledNotification(HandleDeleteOrFilled);
        }