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)); } }
private void Add() { var newOrder = new BuyOrders { BuyComment = BuyComment, BuyDate = DateTimeOffset.Now, BuyPrice = BuyPrice, NumbersToBuy = NumbersToBuy }; newOrder.Insert(); }
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 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); }
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; }
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.Sell, 5, 10ul); Assert.Throws <ArgumentException>(() => m_BuyOrders.Insert(order)); }