Esempio n. 1
0
        public void TestReplaceBid()
        {
            var depth = new Depth();
            var cc    = new ChangedChecker(depth);

            depth.AddOrder(1236, 300, true);
            Assert.True(cc.VerifyBidChanged(true, false, false, false, false));
            cc.Reset();

            depth.AddOrder(1235, 200, true);
            Assert.True(cc.VerifyBidChanged(false, true, false, false, false));
            cc.Reset();

            depth.AddOrder(1232, 100, true);
            Assert.True(cc.VerifyBidChanged(false, false, true, false, false));
            cc.Reset();

            depth.AddOrder(1235, 400, true);
            Assert.True(cc.VerifyBidChanged(false, true, false, false, false));
            cc.Reset();


            // Verify Levels
            var bid0 = depth.Bids.First().Value;
            var bid1 = depth.Bids.ElementAt(1).Value;
            var bid2 = depth.Bids.ElementAt(2).Value;

            Assert.True(VerifyLevel(bid0, 1236, 1, 300));
            Assert.True(VerifyLevel(bid1, 1235, 2, 600));
            Assert.True(VerifyLevel(bid2, 1232, 1, 100));
            Assert.Equal(3, depth.Bids.Count);

            // Replace bid
            depth.ReplaceOrder(1235, 1237, 200, 200, true);

            // Verify Levels
            bid0 = depth.Bids.First().Value;
            bid1 = depth.Bids.ElementAt(1).Value;
            bid2 = depth.Bids.ElementAt(2).Value;
            var bid3 = depth.Bids.ElementAt(3).Value;

            Assert.True(VerifyLevel(bid0, 1237, 1, 200));
            Assert.True(VerifyLevel(bid1, 1236, 1, 300));
            Assert.True(VerifyLevel(bid2, 1235, 1, 400));
            Assert.True(VerifyLevel(bid3, 1232, 1, 100));
            Assert.Equal(4, depth.Bids.Count);

            Assert.True(cc.VerifyBidChanged(true, true, true, true, false));
            cc.Reset();
        }
Esempio n. 2
0
        public void TestReplaceAsk()
        {
            var depth = new Depth();
            var cc    = new ChangedChecker(depth);

            depth.AddOrder(1236, 300, false);
            Assert.True(cc.VerifyAskChanged(true, false, false, false, false));
            cc.Reset();

            depth.AddOrder(1235, 200, false);
            Assert.True(cc.VerifyAskChanged(true, true, false, false, false));
            cc.Reset();

            depth.AddOrder(1232, 100, false);
            Assert.True(cc.VerifyAskChanged(true, true, true, false, false));
            cc.Reset();

            depth.AddOrder(1235, 400, false);
            Assert.True(cc.VerifyAskChanged(false, true, false, false, false));
            cc.Reset();

            // Verify Levels
            var ask0 = depth.Asks.First().Value;
            var ask1 = depth.Asks.ElementAt(1).Value;
            var ask2 = depth.Asks.ElementAt(2).Value;

            Assert.True(VerifyLevel(ask0, 1232, 1, 100));
            Assert.True(VerifyLevel(ask1, 1235, 2, 600));
            Assert.True(VerifyLevel(ask2, 1236, 1, 300));
            Assert.Equal(3, depth.Asks.Count);

            // Replace ask
            depth.ReplaceOrder(1235, 1237, 200, 200, false);

            // Verify Levels
            ask0 = depth.Asks.First().Value;
            ask1 = depth.Asks.ElementAt(1).Value;
            ask2 = depth.Asks.ElementAt(2).Value;
            var ask3 = depth.Asks.ElementAt(3).Value;

            Assert.True(VerifyLevel(ask0, 1232, 1, 100));
            Assert.True(VerifyLevel(ask1, 1235, 1, 400));
            Assert.True(VerifyLevel(ask2, 1236, 1, 300));
            Assert.True(VerifyLevel(ask3, 1237, 1, 200));
            Assert.Equal(4, depth.Asks.Count);

            Assert.True(cc.VerifyAskChanged(false, true, false, true, false));
            cc.Reset();
        }