Пример #1
0
        public void Compare_With_Trade_softWare()
        {
            // 000012 -截至到2011-1-10前60个交易日收盘价,包含1-10号
            sampleData = new double[] { 15.51, 15.86, 15.81, 16.05, 15.88, 17.02, 17.74, 16.9, 18.59, 18.87, 19.55
                , 19.18, 18.16, 19.98, 21.34, 21.35, 22.9, 22.43, 21.86
                , 20.31, 22.34, 21.19, 19.2, 20.62, 22.68, 23.02, 23.9, 23.98
                , 23.57, 23.32, 23.21, 22.1, 21.71, 21.6, 22.55, 21.77, 22.41, 22.47
                , 22.47, 22.29, 23.3, 23.14, 22.56, 22.36, 22.46, 21.94, 21.75, 22.52
                , 21.52, 21.29, 19.93, 18.66, 19.36, 19.05, 19.75
                , 20.03, 19.76, 19.34, 19.01, 18.25 };

            expectedSampleDataMA = 20.63;
            MA target = new MA(60); // TODO: Initialize to an appropriate value
            target.AddRange(sampleData);
            Assert.AreEqual(expectedSampleDataMA, Math.Round(target.Value,2));

            target.AddSample(5);
            Assert.AreEqual(20.45, Math.Round(target.Value, 2));
            target.AddSample(3);
            Assert.AreEqual(20.24, Math.Round(target.Value, 2));
            var s = "";
            foreach (var v in target.Samples)
            {
                s += v.ToString() + ",";
            }
        }
Пример #2
0
        public void ClearSamplesTest()
        {
            int numSamples = 20; // TODO: Initialize to an appropriate value
            MA target = new MA(numSamples); // TODO: Initialize to an appropriate value
            target.AddSample(3.2);
            target.AddSample(1.5);
            target.ClearSamples();

            Assert.AreEqual(target.Samples.Count, 0);
        }
Пример #3
0
 public void Verify_AddSample_Add_New_One()
 {
     int numSamples = 20; // TODO: Initialize to an appropriate value
     MA target = new MA(numSamples); // TODO: Initialize to an appropriate value
     target.AddRange(samples);
     target.AddSample(3.2);
     Assert.AreEqual(4.29, target.Value);
 }