示例#1
0
        public void TestGetSetPrice()
        {
            var codec = new PbTickCodec();
            codec.Config.SetTickSize(0.2);

            PbTick tick = new PbTick();

            Assert.AreEqual(0, codec.GetBidPrice(tick, 1));
            Assert.AreEqual(0, codec.GetBidPrice(tick, 4));
            Assert.AreEqual(0, codec.GetBidPrice(tick, 10));

            codec.SetBidPrice(tick, 1, 1.0);
            codec.SetBidPrice(tick, 4, 2.4);
            codec.SetBidPrice(tick, 10, 5.8);

            Assert.AreEqual(1, codec.GetBidPrice(tick, 1));
            Assert.AreEqual(2.4, codec.GetBidPrice(tick, 4));
            Assert.AreEqual(5.8, codec.GetBidPrice(tick, 10));



            Assert.AreEqual(0, codec.GetAskPrice(tick, 1));
            Assert.AreEqual(0, codec.GetAskPrice(tick, 4));
            Assert.AreEqual(0, codec.GetAskPrice(tick, 10));

            codec.SetAskPrice(tick, 1, -1.0);
            codec.SetAskPrice(tick, 4, 2.4);
            codec.SetAskPrice(tick, 10, -5.8);

            Assert.AreEqual(-1.0, codec.GetAskPrice(tick, 1));
            Assert.AreEqual(2.4, codec.GetAskPrice(tick, 4));
            Assert.AreEqual(-5.8, codec.GetAskPrice(tick, 10));

            codec.SetAskCount(tick, 1, 4);
            codec.SetAskCount(tick, 4, 5);
            codec.SetAskCount(tick, 10, -9);

            Assert.AreEqual<double>(4, codec.GetAskCount(tick, 1));
            Assert.AreEqual<double>(5, codec.GetAskCount(tick, 4));
            Assert.AreEqual<double>(-9, codec.GetAskCount(tick, 10));

            codec.SetSettlementPrice(tick, 1234.56);
            Assert.AreEqual(1234.56, codec.GetSettlementPrice(tick), "SettlementPrice");

            codec.SetTurnover(tick, 4567.8);
            Assert.AreEqual(4567.8, codec.GetTurnover(tick), "Turnover");
        }