Exemplo n.º 1
0
        public void TestTickMultiplier()
        {
            PbTickCodec codec = new PbTickCodec();

            codec.Config.SetTickSize(0.2);
            codec.TickSize = codec.Config.GetTickSize();
            codec.Config.ContractMultiplier = 50000;
            codec.Config.Time_ssf_Diff = 5;

            PbTick tick1 = new PbTick();
            codec.SetAveragePrice(tick1, 123.45);
            codec.SetSettlementPrice(tick1, 123.45);
            codec.SetTurnover(tick1, 1234567890123456);
            codec.SetOpenInterest(tick1, 9123456789012345678);
            codec.SetVolume(tick1, 1234567890);



            Assert.AreEqual(123.45, codec.GetAveragePrice(tick1));
            Assert.AreEqual(123.45, codec.GetSettlementPrice(tick1));
            Assert.AreEqual(1234567890120000, codec.GetTurnover(tick1));
            Assert.AreEqual(9123456789012345678, codec.GetOpenInterest(tick1));
            Assert.AreEqual(1234567890, codec.GetVolume(tick1));

            codec.Config.ContractMultiplier = 5;
            codec.SetTurnover(tick1, 1234567890123456);
            Assert.AreEqual(1234567890123456, codec.GetTurnover(tick1));

            codec.Config.ContractMultiplier = 0.1;
            codec.SetTurnover(tick1, 12345678901234.56);
            Assert.AreEqual(12345678901234.56, codec.GetTurnover(tick1));
        }