예제 #1
0
        public void TestInsertBidLevelsPast5()
        {
            var depth = new Depth();
            var cc    = new ChangedChecker(depth);

            depth.AddOrder(1234, 800, true);
            Assert.True(cc.VerifyBidChanged(true, false, false, false, false));
            cc.Reset();

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

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

            depth.AddOrder(1231, 700, true);
            Assert.True(cc.VerifyBidChanged(false, false, false, true, false));
            cc.Reset();

            depth.AddOrder(1234, 900, true);
            Assert.True(cc.VerifyBidChanged(false, true, false, false, false));
            cc.Reset();

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

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

            depth.AddOrder(1231, 500, true);
            Assert.True(cc.VerifyBidChanged(false, false, false, false, true));
            cc.Reset();

            depth.AddOrder(1230, 200, true);

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

            Assert.True(cc.VerifyBidChanged(false, false, false, false, false));
            cc.Reset();

            var bid0 = depth.Bids.ElementAt(0).Value;
            var bid1 = depth.Bids.ElementAt(1).Value;
            var bid2 = depth.Bids.ElementAt(2).Value;
            var bid3 = depth.Bids.ElementAt(3).Value;
            var bid4 = depth.Bids.ElementAt(4).Value;

            Assert.True(VerifyLevel(bid0, 1236, 1, 300));
            Assert.True(VerifyLevel(bid1, 1235, 2, 600));
            Assert.True(VerifyLevel(bid2, 1234, 2, 1700));
            Assert.True(VerifyLevel(bid3, 1232, 1, 100));
            Assert.True(VerifyLevel(bid4, 1231, 2, 1200));
            Assert.Equal(5, depth.Bids.Count);
        }
예제 #2
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();
        }
예제 #3
0
        public void TestIncreaseDecreaseBid()
        {
            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();

            depth.ChangeOrderQuantity(1236, 37, true);
            Assert.True(cc.VerifyBidChanged(true, false, false, false, false));
            cc.Reset();

            depth.ChangeOrderQuantity(1235, -41, true);
            Assert.True(cc.VerifyBidChanged(false, true, false, false, false));
            cc.Reset();

            depth.ChangeOrderQuantity(1232, 60, true);
            Assert.True(cc.VerifyBidChanged(false, false, true, false, false));
            cc.Reset();

            depth.ChangeOrderQuantity(1236, -41, true);
            Assert.True(cc.VerifyBidChanged(true, false, false, false, false));
            cc.Reset();

            depth.ChangeOrderQuantity(1236, 210, true);
            Assert.True(cc.VerifyBidChanged(true, false, false, false, false));
            cc.Reset();

            var bid0 = depth.Bids.ElementAt(0).Value;
            var bid1 = depth.Bids.ElementAt(1).Value;
            var bid2 = depth.Bids.ElementAt(2).Value;

            Assert.True(VerifyLevel(bid0, 1236, 1, 506));
            Assert.True(VerifyLevel(bid1, 1235, 2, 559));
            Assert.True(VerifyLevel(bid2, 1232, 1, 160));
            Assert.Equal(3, depth.Bids.Count);
        }
예제 #4
0
        public void TestAddBid()
        {
            var depth = new Depth();
            var cc    = new ChangedChecker(depth);

            depth.AddOrder(1234, 100, true);
            var firstBid = depth.Bids.First().Value;

            Assert.True(VerifyLevel(firstBid, 1234, 1, 100));
            Assert.True(cc.VerifyBidChanged(true, false, false, false, false));
            Assert.Equal(1, depth.Bids.Count);
        }
예제 #5
0
        public void TestCloseBid()
        {
            var depth = new Depth();
            var cc    = new ChangedChecker(depth);

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

            depth.AddOrder(1234, 500, true);
            Assert.True(cc.VerifyBidChanged(true, false, false, false, false));
            cc.Reset();

            Assert.True(!depth.CloseOrder(1234, 300, true)); // Does not erase
            Assert.True(cc.VerifyBidChanged(true, false, false, false, false));

            var firstBid = depth.Bids.First().Value;

            Assert.True(VerifyLevel(firstBid, 1234, 1, 500));
            Assert.Equal(1, depth.Bids.Count);
        }
예제 #6
0
        public void TestCloseEraseBid()
        {
            var depth = new Depth();
            var cc    = new ChangedChecker(depth);

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

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

            depth.AddOrder(1234, 500, true);
            Assert.True(cc.VerifyBidChanged(false, true, false, false, false));
            cc.Reset();

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

            Assert.True(!depth.CloseOrder(1235, 300, true)); // Does not erase
            Assert.True(cc.VerifyBidChanged(true, false, false, false, false));
            cc.Reset();

            Assert.True(depth.CloseOrder(1235, 400, true)); // Erase
            Assert.True(cc.VerifyBidChanged(true, true, true, false, false));

            var bid0 = depth.Bids.ElementAt(0).Value;
            var bid1 = depth.Bids.ElementAt(1).Value;

            Assert.True(VerifyLevel(bid0, 1234, 1, 500));
            Assert.True(VerifyLevel(bid1, 1233, 1, 200));
            Assert.Equal(2, depth.Bids.Count);
        }
예제 #7
0
        public void TestAddCloseAddHigherBid()
        {
            var depth = new Depth();
            var cc    = new ChangedChecker(depth);

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

            depth.CloseOrder(1234, 300, true);
            Assert.True(cc.VerifyBidChanged(true, false, false, false, false));
            cc.Reset();

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

            var bid = depth.Bids.ElementAt(0).Value;

            Assert.True(VerifyLevel(bid, 1235, 1, 200));
            Assert.Equal(1, depth.Bids.Count);
        }
예제 #8
0
        public void TestAppendBidLevels()
        {
            var depth = new Depth();
            var cc    = new ChangedChecker(depth);

            depth.AddOrder(1236, 300, true);
            depth.AddOrder(1235, 200, true);
            depth.AddOrder(1232, 100, true);
            depth.AddOrder(1235, 400, true);

            var bid0 = depth.Bids.ElementAt(0).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.True(cc.VerifyBidChanged(true, true, true, false, false));
            Assert.Equal(3, depth.Bids.Count);
        }
예제 #9
0
        public void TestCloseBidsFreeLevels()
        {
            var depth = new Depth();
            var cc    = new ChangedChecker(depth);

            depth.AddOrder(1234, 800, true);
            Assert.True(cc.VerifyBidChanged(true, false, false, false, false));
            cc.Reset();

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

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

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

            depth.AddOrder(1234, 900, true);
            Assert.True(cc.VerifyBidChanged(false, false, true, false, false));
            cc.Reset();

            depth.AddOrder(1231, 700, true);
            Assert.True(cc.VerifyBidChanged(false, false, false, false, true));
            cc.Reset();

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

            depth.AddOrder(1231, 500, true);
            Assert.True(cc.VerifyBidChanged(false, false, false, false, true));
            cc.Reset();

            depth.CloseOrder(1234, 900, true); // No erase
            Assert.True(cc.VerifyBidChanged(false, false, true, false, false));
            cc.Reset();

            depth.CloseOrder(1232, 100, true); // Erase
            Assert.True(cc.VerifyBidChanged(false, false, false, true, true));
            cc.Reset();

            depth.CloseOrder(1236, 300, true); // Erase
            Assert.True(cc.VerifyBidChanged(true, true, true, true, false));
            cc.Reset();

            var bid0 = depth.Bids.ElementAt(0).Value;
            var bid1 = depth.Bids.ElementAt(1).Value;
            var bid2 = depth.Bids.ElementAt(2).Value;

            Assert.True(VerifyLevel(bid0, 1235, 2, 600));
            Assert.True(VerifyLevel(bid1, 1234, 1, 800));
            Assert.True(VerifyLevel(bid2, 1231, 2, 1200));
            Assert.Equal(3, depth.Bids.Count);

            depth.AddOrder(1233, 350, true); // Insert
            Assert.True(cc.VerifyBidChanged(false, false, true, true, false));
            cc.Reset();

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

            depth.AddOrder(1231, 700, true);
            Assert.True(cc.VerifyBidChanged(false, false, false, false, true));
            cc.Reset();

            bid0 = depth.Bids.ElementAt(0).Value;
            bid1 = depth.Bids.ElementAt(1).Value;
            bid2 = depth.Bids.ElementAt(2).Value;
            var bid3 = depth.Bids.ElementAt(3).Value;
            var bid4 = depth.Bids.ElementAt(4).Value;

            Assert.True(VerifyLevel(bid0, 1236, 1, 300));
            Assert.True(VerifyLevel(bid1, 1235, 2, 600));
            Assert.True(VerifyLevel(bid2, 1234, 1, 800));
            Assert.True(VerifyLevel(bid3, 1233, 1, 350));
            Assert.True(VerifyLevel(bid4, 1231, 3, 1900));
            Assert.Equal(5, depth.Bids.Count);
        }