Exemple #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() + ",";
            }
        }
Exemple #2
0
 public BOLL(MA ma,double lamda)
 {
     var sd = new SD(ma);
     this.lamda = lamda;
     this.mb = ma.Value;
     this.up = this.mb + lamda * sd.Value;
     this.dn = this.mb - lamda *  sd.Value;
 }
Exemple #3
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);
 }
Exemple #4
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);
        }
Exemple #5
0
 ///                 MA(n1)+ MA(n2) +MA(n3)+ MA(n4)     
 ///       BBI =   ----------------------------------
 ///                                     4
 public BBI(int n1,int n2,int n3, int n4)
 {
     this.n1 = n1;
     this.n2 = n2;
     this.n3 = n3;
     this.n4 = n4;
     this.n1MovingAverage = new MA(n1);
     this.n2MovingAverage = new MA(n2);
     this.n3MovingAverage = new MA(n3);
     this.n4MovingAverage = new MA(n4);
 }
Exemple #6
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;
 }
Exemple #7
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);
        }
Exemple #8
0
        public void Verify_Error_Throw_When_Init_Count_Not_Equal_Sample_Count()
        {
            int numSamples = 40; // TODO: Initialize to an appropriate value
            MA target = new MA(numSamples); // TODO: Initialize to an appropriate value

            double value =  target.Value;
        }
Exemple #9
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);
 }