Exemplo 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);
        }
Exemplo 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);
            }
        }