Ejemplo n.º 1
0
        public void testEvaluateTrendsCharacteristics()
        {
            double[] data = new double[3793];
            int segmentsNumber;
            SegmentType[] timeSeriesTrends;
            TimeSeriesTrends instance = new TimeSeriesTrends();

            using (System.IO.StreamReader sr = new System.IO.StreamReader("TimeSeriesData.dat"))
            {
                System.Globalization.NumberFormatInfo provider = new System.Globalization.NumberFormatInfo();

                provider.NumberDecimalSeparator = ".";

                string dataLine;
                int i = 0;
                while ((dataLine = sr.ReadLine()) != null)
                {
                    data[i++] = Convert.ToDouble(dataLine, provider);
                }
            }

            segmentsNumber = 20;
            timeSeriesTrends = instance.makeTrendsAlghoritm(data, segmentsNumber);

            TrendsCharacteristics instanceTrends = new TrendsCharacteristics();
            TrendDataType[] result = instanceTrends.evaluateTrendsCharacteristics(timeSeriesTrends, data);
        }
Ejemplo n.º 2
0
        private void FindTrendsButton_Click(object sender, EventArgs e)
        {
            TimeSeriesTrends trends = new TimeSeriesTrends();
            double[] data = (from d in fxData select d.close).ToArray();
            SegmentType[] segments = trends.makeTrendsAlghoritm(data, Convert.ToInt32(NrSegmentsTextBox.Text));

            GraphPane myPane = zedGraphControl1.GraphPane;
            myPane.Title.Text = fxData[0].ticker + " " + fxData[0].datetime + " - " + fxData.Last().datetime + " [" + fxData.Count + "]";
            myPane.XAxis.Title.Text = "Points";
            myPane.YAxis.Title.Text = "Value";

            PointPairList realData = new PointPairList();
            PointPairList trendsData = new PointPairList();

            for(int i = 0; i < fxData.Count; i++)
            {
                realData.Add(i, fxData[i].close);
            }

            for (int i = 0; i < segments.Length; i++)
            {
                trendsData.Add(segments[i].lx, segments[i].ly);
                trendsData.Add(segments[i].rx, segments[i].ry);
            }

            LineItem myCurve1 = myPane.AddCurve(fxData[0].ticker, realData, Color.Blue, SymbolType.None);
            LineItem myCurve2 = myPane.AddCurve("Trends", trendsData, Color.Red, SymbolType.None);

            zedGraphControl1.AxisChange();

            TrendsCharacteristics trendsCharacteristics = new TrendsCharacteristics();
            TrendDataType[] trendData = trendsCharacteristics.evaluateTrendsCharacteristics(segments, data);
            for (int i = 0; i < trendData.Length; i++)
            {
                TrendsOutputTextBox.Text += String.Format("Trend {1}:{0}\tDuration: {2}{0}\tDynamicsOfChange: {3}{0}\tVariability: {4}{0}",
                    Environment.NewLine, i, trendData[i].duration, trendData[i].dynamicsOfChange, trendData[i].variability);
            }
        }
Ejemplo n.º 3
0
        public void testMakeTrendsAlghoritm()
        {
            double[] data = new double[3793];
            int segmentsNumber;
            SegmentType[] actualResult;
            TimeSeriesTrends instance = new TimeSeriesTrends();

            using (System.IO.StreamReader sr = new System.IO.StreamReader("TimeSeriesData.dat"))
            {
                System.Globalization.NumberFormatInfo provider = new System.Globalization.NumberFormatInfo( );

                provider.NumberDecimalSeparator = ".";

                string dataLine;
                int i = 0;
                while ((dataLine = sr.ReadLine()) != null)
                {
                    data[i++] = Convert.ToDouble(dataLine, provider);
                }
            }

            segmentsNumber = 20;
            actualResult = instance.makeTrendsAlghoritm(data, segmentsNumber);

            SegmentType[] expResult = new SegmentType[20];
            for (int i = 0; i < 20; i++)
            {
                expResult[i] = new SegmentType();
            }

            expResult[0].lx = 1;
            expResult[1].lx = 211;
            expResult[2].lx = 429;
            expResult[3].lx = 675;
            expResult[4].lx = 851;
            expResult[5].lx = 939;
            expResult[6].lx = 1101;
            expResult[7].lx = 1363;
            expResult[8].lx = 1441;
            expResult[9].lx = 1825;
            expResult[10].lx = 1893;
            expResult[11].lx = 2223;
            expResult[12].lx = 2481;
            expResult[13].lx = 2739;
            expResult[14].lx = 2987;
            expResult[15].lx = 3013;
            expResult[16].lx = 3289;
            expResult[17].lx = 3407;
            expResult[18].lx = 3589;
            expResult[19].lx = 3681;

            expResult[0].rx = 210;
            expResult[1].rx = 428;
            expResult[2].rx = 674;
            expResult[3].rx = 850;
            expResult[4].rx = 938;
            expResult[5].rx = 1100;
            expResult[6].rx = 1362;
            expResult[7].rx = 1440;
            expResult[8].rx = 1824;
            expResult[9].rx = 1892;
            expResult[10].rx = 2222;
            expResult[11].rx = 2480;
            expResult[12].rx = 2738;
            expResult[13].rx = 2986;
            expResult[14].rx = 3012;
            expResult[15].rx = 3288;
            expResult[16].rx = 3406;
            expResult[17].rx = 3588;
            expResult[18].rx = 3680;
            expResult[19].rx = 3793;

            expResult[0].ly = 1137.9;
            expResult[1].ly = 759.6;
            expResult[2].ly = 1194.6;
            expResult[3].ly = 1652.8;
            expResult[4].ly = 1363.9;
            expResult[5].ly = 1987.8;
            expResult[6].ly = 1234.6;
            expResult[7].ly = 1444.1;
            expResult[8].ly = 2224.2;
            expResult[9].ly = 1082.3;
            expResult[10].ly = 1371.5;
            expResult[11].ly = 1210.7;
            expResult[12].ly = 1642.3;
            expResult[13].ly = 1909.4;
            expResult[14].ly = 3197.0;
            expResult[15].ly = 2824.5;
            expResult[16].ly = 3692.4;
            expResult[17].ly = 3101.6;
            expResult[18].ly = 1945.2;
            expResult[19].ly = 1436.9;

            expResult[0].ry = 551.6;
            expResult[1].ry = 946.5;
            expResult[2].ry = 1594.6;
            expResult[3].ry = 1650.4;
            expResult[4].ry = 1682.7;
            expResult[5].ry = 1119.6;
            expResult[6].ry = 1601.1;
            expResult[7].ry = 2410.1;
            expResult[8].ry = 1097.1;
            expResult[9].ry = 1302.4;
            expResult[10].ry = 1054.8;
            expResult[11].ry = 1849.3;
            expResult[12].ry = 2010.5;
            expResult[13].ry = 3116.6;
            expResult[14].ry = 2581.5;
            expResult[15].ry = 3788.0;
            expResult[16].ry = 3543.1;
            expResult[17].ry = 2455.1;
            expResult[18].ry = 1547.9;
            expResult[19].ry = 2063.5;

            orginalDataTrendsEquals(expResult, actualResult, 1.1, 3);
        }
Ejemplo n.º 4
0
 public TrendsGenerator()
 {
     trends = new TimeSeriesTrends();
     trendsCharacteristics = new TrendsCharacteristics();
 }