예제 #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 ValueTest()
 {
     MA ma = new MA(20); // TODO: Initialize to an appropriate value
     ma.AddRange(samples);
     SD target = new SD(ma); // TODO: Initialize to an appropriate value
     double actual;
     actual = Math.Round(target.Value,4);
     Assert.AreEqual(expected, actual);
 }
예제 #3
0
 public static void MyClassInitialize(TestContext testContext)
 {
     // 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 };
     ma = new MA(60);
     ma.AddRange(sampleData);
     var s = ma.Value;
 }
예제 #4
0
        public void CountTest()
        {
            int numSamples = 20; // TODO: Initialize to an appropriate value
            MA target = new MA(numSamples); // TODO: Initialize to an appropriate value

            target.ClearSamples();
            target.AddRange(samples);

            var actual = target.Value;
            Assert.AreEqual(expected, actual);
        }
예제 #5
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);
 }