Beispiel #1
0
        private void DrawResult(string strategyname)
        {
            chart1.Series.Add(strategyname);

            chart1.Series[strategyname].ChartArea     = "Result"; // 设置Series绘制区域
            chart1.Series[strategyname].ChartType     = SeriesChartType.Point;
            chart1.Series[strategyname].XValueType    = ChartValueType.DateTime;
            chart1.Series[strategyname]["PointWidth"] = "1.5";

            IStockValues values = StrategyResults_.GetResult(strategyname);

            if (values == null)
            {
                return;
            }

            ICollection <DateTime> dates = values.GetAllDate();

            foreach (DateTime dt in dates)
            {
                double val = values.GetTotalValue(dt);
                Debug.Assert(val > 0);

                int curPos = chart1.Series[strategyname].Points.AddXY(dt, val);

                if (values.GetOperationSignal(dt) == OperType.Buy)
                {
                    chart1.Series[strategyname].Points[curPos].MarkerImage = ApplicationHelper.GetAppPath() + "\\image\\buysignal.bmp";
                }
                else if (values.GetOperationSignal(dt) == OperType.Sell)
                {
                    chart1.Series[strategyname].Points[curPos].MarkerImage = ApplicationHelper.GetAppPath() + "\\image\\sellsignal.bmp";
                }
            }
        }
Beispiel #2
0
        public void Judge(IStrategyResults res)
        {
            ICollection <string> allStrategies = res.AllStrategyNames;

            IStockValues    holderValues = res.GetResult("Hold");
            List <DateTime> dates        = holderValues.GetAllDate().ToList <DateTime>();

            dates.Sort();
            DateTime minDate = dates.First <DateTime>();
            DateTime maxDate = dates.Last <DateTime>();

            Debug.Assert(minDate < maxDate);

            DateTime curDate = minDate;

            while (curDate < maxDate)
            {
                foreach (string name in allStrategies)
                {
                    IStockValues values = res.GetResult(name);

                    double holderTotalValue = holderValues.GetTotalValue(curDate);

                    double strategyTotalValue = values.GetTotalValue(curDate);

                    Scores_.AddScore(name, CalcSimpleScore(holderTotalValue, strategyTotalValue));
                }

                curDate = DateFunc.GetNextWorkday(curDate);
            }
        }