コード例 #1
0
        public void Init()
        {
            m_Instrument = 1;
            m_BuyOrders = new BuyOrders(m_Instrument);

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

            for (int i = 0, j = 10; i < 10; ++i, ++j)
            {
                m_BuyOrders.Insert(new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled,
                                                   Order.BuyOrSell.Buy, 5, (ulong)j));
            }
        }
コード例 #2
0
        public void Init()
        {
            m_Instrument = 1;
            m_BuyOrders  = new BuyOrders(m_Instrument);

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

            for (int i = 0, j = 10; i < 10; ++i, ++j)
            {
                m_BuyOrders.Insert(new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled,
                                                   Order.BuyOrSell.Buy, 5, (ulong)j));
            }
        }
コード例 #3
0
        private void Add()
        {
            var newOrder = new BuyOrders
            {
                BuyComment   = BuyComment,
                BuyDate      = DateTimeOffset.Now,
                BuyPrice     = BuyPrice,
                NumbersToBuy = NumbersToBuy
            };

            newOrder.Insert();
        }
コード例 #4
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;
 }
コード例 #5
0
        public void BigSellMatchesMultipleBuysTest()
        {
            var secondBuyOrder = new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled,
                                                 Order.BuyOrSell.Buy, 90, 100);

            m_BuyOrders.Insert(secondBuyOrder);
            m_SellOrder.Quantity = 150;
            Assert.True(OrderProcessor.TryMatchOrder(m_SellOrder, m_BuyOrders, m_Trades));

            Assert.That(m_TradeProcessor.Trades.Count, Is.EqualTo(2));
            Assert.That(m_BuyOrder.Quantity == 0);
            Assert.That(secondBuyOrder.Quantity == 50);
            Assert.That(m_BuyOrders[0] == secondBuyOrder && m_BuyOrders.Count() == 1);
        }
コード例 #6
0
 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();
            }
        }
コード例 #8
0
        public void WrongOrderTypeThrowsException()
        {
            var order = new EquityOrder(m_Instrument, Order.OrderTypes.GoodUntilCancelled, Order.BuyOrSell.Sell, 5, 10ul);

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