public void Init()
        {
            m_Instrument = new Instrument("MSFT");
            m_SellOrders = new SellOrders(m_Instrument);

            for (int i = 0, j = 10; i < 10; ++i, ++j)
            {
                Thread.Sleep(2);
                m_SellOrders.Insert(new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled,
                                                    Order.BuyOrSell.Sell, 5, (ulong)j));
            }

            for (int i = 0, j = 10; i < 10; ++i, ++j)
            {
                m_SellOrders.Insert(new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled,
                                                    Order.BuyOrSell.Sell, 5, (ulong)j));
            }
        }
        public void Init()
        {
            m_Instrument = 1;
            m_SellOrders = new SellOrders(m_Instrument);

            for (int i = 0, j = 10; i < 10; ++i, ++j)
            {
                Thread.Sleep(2);
                m_SellOrders.Insert(new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled,
                                                    Order.BuyOrSell.Sell, 5, (ulong)j));
            }

            for (int i = 0, j = 10; i < 10; ++i, ++j)
            {
                m_SellOrders.Insert(new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled,
                                                    Order.BuyOrSell.Sell, 5, (ulong)j));
            }
        }
Пример #3
0
        public void OneBuyLotsOfPotentialSellsOrderTest()
        {
            ulong buyQuantity = m_BuyOrder.Quantity;

            m_SellOrders.Insert(new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled, Order.BuyOrSell.Sell, 95, 100));
            m_SellOrders.Insert(new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled, Order.BuyOrSell.Sell, 95, 100));

            Assert.True(OrderProcessor.TryMatchOrder(m_BuyOrder, m_SellOrders, m_Trades));
            Trade trade = m_TradeProcessor.Trades[0];

            Assert.That(m_TradeProcessor.Trades.Count, Is.EqualTo(1));

            Assert.That(trade.Instrument, Is.EqualTo(m_Instrument));
            Assert.That(trade.Price, Is.EqualTo(m_SellOrder.Price));
            Assert.That(trade.Quantity, Is.EqualTo(buyQuantity));

            Assert.That(m_SellOrders.Count() == 2);
            Assert.That(!m_SellOrders.Contains(m_SellOrder));
        }
Пример #4
0
        private void Add()
        {
            var newOrder = new SellOrders
            {
                SellComment   = SellComment,
                SellDate      = DateTimeOffset.Now,
                SellPrice     = SellPrice,
                NumbersToSell = NumbersToSell
            };

            newOrder.Insert();
        }
Пример #5
0
 public void Init()
 {
     m_Instrument = new Instrument("GOOG");
     m_BuyOrder   = new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled, Order.BuyOrSell.Buy, 100M,
                                    100ul);
     m_SellOrder = new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled, Order.BuyOrSell.Sell, 90,
                                   100ul);
     m_SellOrders = new SellOrders(m_Instrument);
     m_BuyOrders  = new BuyOrders(m_Instrument);
     m_SellOrders.Insert(m_SellOrder);
     m_BuyOrders.Insert(m_BuyOrder);
     m_Trades         = new Trades(m_Instrument);
     m_TradeProcessor = m_Trades.TradeProcessingStrategy as Trades.InMemoryTradeProcessor;
 }
 public void Init()
 {
     m_Instrument = 1;
     m_BuyOrder = new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled, Order.BuyOrSell.Buy, 100,
                                  100ul);
     m_SellOrder = new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled, Order.BuyOrSell.Sell, 90,
                                   100ul);
     m_SellOrders = new SellOrders(m_Instrument);
     m_BuyOrders = new BuyOrders(m_Instrument);
     m_SellOrders.Insert(m_SellOrder);
     m_BuyOrders.Insert(m_BuyOrder);
     m_Trades = new Trades(m_Instrument);
     m_TradeProcessor = m_Trades.TradeProcessingStrategy as Trades.InMemoryTradeProcessor;
 }
Пример #7
0
        protected void ProcessOrder(Order order)
        {
            switch (order.BuySell)
            {
            case Order.BuyOrSell.Buy:
                TryMatchBuyOrder(order, m_SellOrders, m_Trades);
                if (order.Quantity > 0)
                {
                    m_BuyOrders.Insert(order);
                }
                break;

            case Order.BuyOrSell.Sell:
                TryMatchSellOrder(order, m_BuyOrders, m_Trades);
                if (order.Quantity > 0)
                {
                    m_SellOrders.Insert(order);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void WrongOrderTypeThrowsException()
        {
            var order = new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled, Order.BuyOrSell.Buy, 10, 10ul);

            Assert.Throws <ArgumentException>(() => m_SellOrders.Insert(order));
        }