예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }