示例#1
0
 private void regressWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Result == null)
     {
         regressingRe_ = null;
         return;
     }
     else
     {
         App.regressList_.Add(regressingRe_);
         RegressSelectForm selectform = (RegressSelectForm)createTabPage(regressingRe_.SelectFormName, new RegressSelectForm());
         RegressBuyForm    buyform    = (RegressBuyForm)createTabPage(regressingRe_.BuyFormName, new RegressBuyForm());
         if (regressingRe_.strategyList_.Count > 1)
         {
             createTabPage(regressingRe_.StatisStrategyDataFormName, new RegressStatisticsForm(regressingRe_, WantDataType.WD_StrategyData));
         }
         if (regressingRe_.runMode_ == RunMode.RM_Asset)
         {
             createTabPage(regressingRe_.StatisBonusFormName, new RegressStatisticsForm(regressingRe_, WantDataType.WD_BonusData));
         }
         else
         {
             createTabPage(regressingRe_.StatisBonusFormName, new RegressStatisticsForm(regressingRe_, WantDataType.WD_BonusData));
             createTabPage(regressingRe_.StatisRateItemFormName, new RegressStatisticsForm(regressingRe_, WantDataType.WD_RateItemData));
         }
         createTabPage(regressingRe_.StatisHistoryFormName, new RegressStatisticsForm(regressingRe_, WantDataType.WD_HistoryData));
         selectform.re_ = buyform.re_ = regressingRe_;
         LUtils.FillListViewData(selectform.selectItemListView(), regressingRe_.selItems_);
         LUtils.FillListViewData(buyform.buyItemListView(), regressingRe_.buyItems_);
         regressingRe_ = null;
     }
 }
        public RegressStatisticsForm(RegressResult re, WantDataType wd)
        {
            InitializeComponent();
            re_ = re;
            wd_ = wd;

            menuStrip1.Visible = false;
            writeAssetToolStripMenuItem.Visible      = false;
            writeAsOptimizeToolStripMenuItem.Visible = false;
            chart_.Titles.Add("Title");
            string sMode = re.runMode_ == RunMode.RM_Asset ? "Asset mode" : "Raw mode";

            chart_.Titles[0].Text = String.Format("{0} {1}", re.solutionName_, sMode);
            switch (wd_)
            {
            case WantDataType.WD_BonusData:
                fillBonusChart();
                break;

            case WantDataType.WD_StrategyData:
                fillStrategyDataChart();
                break;

            case WantDataType.WD_RateItemData:
                fillRateItemChart();
                menuStrip1.Visible = true;
                writeAssetToolStripMenuItem.Visible = true;
                break;

            case WantDataType.WD_HistoryData:
                fillHistoryDataChart();
                menuStrip1.Visible = true;
                writeAsOptimizeToolStripMenuItem.Visible = true;
                if (re_.reHistory_ == null)
                {
                    break;
                }
                historyView.Columns.Add("solution", 80);
                LUtils.InitListView(historyView, HistoryData.ShowColumnInfos);
                historyView.Items.Add(re_.reHistory_.toListViewItem(historyView, re_.solutionName_));

                addSolutionBestDataToHistoryView(re_.solutionName_, "best");
                break;

            default:
                throw new ArgumentException("Unknown data type!");
            }
        }
示例#3
0
        private void regressToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!bIsSucStart_)
            {
                return;
            }
            if (isBusy_)
            {
                MessageBox.Show(MainForm.Me, "正忙,请稍微。", "Selector");
                return;
            }
            NewRegressForm form = new NewRegressForm();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            regressingRe_ = form.re_;

            regressWorker.RunWorkerAsync();
        }
示例#4
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (slnComboBox_.SelectedIndex == -1)
            {
                MessageBox.Show("Must select Solution!", "Selector");
                this.DialogResult = DialogResult.None;
                return;
            }
            if (dateRangeComboBox_.SelectedIndex == -1)
            {
                MessageBox.Show("Must select DateRange!", "Selector");
                this.DialogResult = DialogResult.None;
                return;
            }
            name_.Text = name_.Text.Trim();
            if (String.IsNullOrEmpty(name_.Text))
            {
                MessageBox.Show("name must be provided!");
                this.DialogResult = DialogResult.None;
                return;
            }
            foreach (var re in App.regressList_)
            {
                if (String.Equals(re.name_, name_.Text, StringComparison.CurrentCultureIgnoreCase))
                {
//                if (DialogResult.Yes == MessageBox.Show("Same name regress already exists, remove it and regress?", "Selector", MessageBoxButtons.YesNo))
                    {
                        foreach (var formName in re.AllFormNames)
                        {
                            MainForm.Me.removeForm(formName);
                        }
                        App.RemoveRegress(re);
                        break;
                    }
//                else
//                {
//                    this.DialogResult = DialogResult.None;
//                    return;
//                }
                }
            }
            List <IStrategy> strategyList = App.Solution(slnComboBox_.SelectedItem.ToString()).straList_;
            String           sMode        = radioAsset.Checked ? "Asset" : "Raw";

            if (sMode == "Asset")
            {
                foreach (var stra in strategyList)
                {
                    if (App.asset_.straData(stra.name()) == null)
                    {
                        MessageBox.Show(String.Format("Strategy: {0} has no asset, can't run in asset mode!", stra.name()), "Selector");
                        this.DialogResult = DialogResult.None;
                        return;
                    }
                }
            }
            else
            {
                if (strategyList.Count != 1)
                {
                    MessageBox.Show("Raw mode only support single strategy solution!", "Selector");
                    this.DialogResult = DialogResult.None;
                    return;
                }
            }

            re_                = new RegressResult();
            re_.runMode_       = sMode == "Asset" ? RunMode.RM_Asset : RunMode.RM_Raw;
            re_.name_          = name_.Text;
            re_.solutionName_  = slnComboBox_.SelectedItem.ToString();
            re_.dateRangeName_ = dateRangeComboBox_.SelectedItem.ToString();
            re_.dateRangeList_ = App.DateRange(re_.dateRangeName_).rangeList_;
            re_.strategyList_  = App.Solution(re_.solutionName_).straList_;
            Utils.SetSysInfo(DB.Global(), "NewRegressForm.solution", slnComboBox_.SelectedItem.ToString());
            Utils.SetSysInfo(DB.Global(), "NewRegressForm.daterange", dateRangeComboBox_.SelectedItem.ToString());
            Utils.SetSysInfo(DB.Global(), "NewRegressForm.Mode", sMode);
            this.DialogResult = DialogResult.OK;
            Close();
        }
        public void selItemsHistoryDataToChart(Chart chart, List <SelectItem> selItems, List <DateRange> dateRangeList, RunMode runMode, out ChartXUnit xUnit)
        {
            List <HistoryData>    dataList = new List <HistoryData>();
            List <DateSelectItem> items    = RegressResult.ToDaySelectItemList(selItems, dateRangeList);

            xUnit = SUtils.DetermineXUnit(items.Count);
            if (items.Count == 0)
            {
                return;
            }
            if (xUnit == ChartXUnit.CXU_Year)
            {
                items.Reverse();
                int startDate        = items[0].date_;
                int endDate          = items[items.Count - 1].date_;
                int startYear        = Utils.Year(startDate);
                int endYear          = Utils.Year(endDate);
                int iSearchStartHint = 0;
                for (int iYear = startYear; iYear <= endYear; iYear++)
                {
                    int iStartIndex = -1;
                    int nDaySpan    = 0;
                    for (int i = iSearchStartHint; i < items.Count; i++)
                    {
                        if (iStartIndex == -1 && Utils.Year(items[i].date_) == iYear)
                        {
                            iStartIndex = i;
                        }
                        if (iStartIndex != -1)
                        {
                            if (Utils.Year(items[i].date_) == iYear)
                            {
                                nDaySpan++;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    iSearchStartHint = iStartIndex + nDaySpan;
                    HistoryData data = StrategyAsset.GetHistoryData(items, iStartIndex, nDaySpan, runMode);
                    dataList.Add(data);
                }
            }
            else
            {
                int nDaySpan    = SUtils.ToDayCount(xUnit);
                int iStartIndex = 0;
                do
                {
                    if (iStartIndex + nDaySpan - 1 > items.Count)
                    {
                        break;
                    }
                    HistoryData data = StrategyAsset.GetHistoryData(items, iStartIndex, nDaySpan, runMode);
                    dataList.Add(data);
                    iStartIndex += nDaySpan;
                } while (iStartIndex < items.Count);
                dataList.Reverse();
            }

            List <String> xDescList = new List <string>();

            foreach (var item in dataList)
            {
                xDescList.Add(SUtils.ToXDesc(xUnit, item.startDate_, item.endDate_));
            }
            SUtils.FillHistoryDataToChart(chart, dataList, xDescList);
            re_.reHistory_ = StrategyAsset.GetHistoryData(items, 0, items.Count, re_.runMode_);
        }