public void ShouldTriggerSellSideOnHigherBidAndEqualAskPrice() { bool triggered = false; var trigger = new BestPriceTrigger("abc", 51, WayEnum.Sell); trigger.SetTriggerAction(() => triggered = true); var bb = new OrderBookBestBidAsk("abc"); bb.Set(50, 51, 1, 1); var triggerResult = trigger.TryExecute(bb); Assert.IsTrue(triggerResult); Assert.IsTrue(triggered); }
public void ShouldTriggerBuySideOnLowerAskPrice() { bool triggered = false; var trigger = new BestPriceTrigger("abc", 10.4d, WayEnum.Sell); trigger.SetTriggerAction(() => triggered = true); var bb = new OrderBookBestBidAsk("abc"); bb.Set(null, 9.4d, 1, 1); var triggerResult = trigger.TryExecute(bb); Assert.IsTrue(triggerResult); Assert.IsTrue(triggered); }
public void ShouldNotTriggerBuySideOnLowerBidAndAskPrice() { bool triggered = false; var trigger = new BestPriceTrigger("abc", 52d, WayEnum.Buy); trigger.SetTriggerAction(() => triggered = true); var bb = new OrderBookBestBidAsk("abc"); bb.Set(50, 51, 1, 1); var triggerResult = trigger.TryExecute(bb); Assert.IsFalse(triggerResult); Assert.IsFalse(triggered); }
public void ShouldRemoveTriggerWhenTriggerIsExecuted() { var orderBookBestBidAsk = new OrderBookBestBidAsk("ABC"); var book = new OrderBook("ABC", limitOrderMatchingAlgorithmMock.Object, marketOrderMatchingAlgorithmMock.Object, orderBookBestBidAsk); var trigger = new BestPriceTrigger("ABC", 10, WayEnum.Buy); var stopOrder = new StopLimitOrder("abc", 10, 90, 90, WayEnum.Buy, 2, trigger); trigger.SetTriggerAction(() => { stopOrder.Delete(); }); book.AddStopLimitOrder(stopOrder); Assert.AreEqual(trigger, book.BuySideStopLimitOrders[0].Trigger); orderBookBestBidAsk.Set(11, 12, 100, 100); trigger.TryExecute(orderBookBestBidAsk); Assert.AreEqual(0, book.BuySideStopLimitOrders.Count); }