示例#1
0
        private void ToolStripMenuItem_AddStrategySeries_Click(object sender, EventArgs e)
        {
            try
            {
                AddStrategyTextPathForm f = new AddStrategyTextPathForm();
                f.ShowDialog();

                //添加一条Item到treeView中
                ListViewItem lvi = new ListViewItem();
                lvi.Text = f.IResult;
                this.listView1.Items.Add(lvi);

                //搜出最原始的MC数据
                string        path      = f.IResult;
                List <string> mcStrList = RedTxt(path);

                //清空两个表-Series-邦定Series数据源
                m_MCEditTradeList.Clear();
                m_HandleTimeSeriesTradeList.Clear();
                this.chart1.Series["时间序列资金曲线"].Points.Clear();
                List <DateTime> xBind = new List <DateTime>();
                List <double>   yBind = new List <double>();

                //添加到两个表
                List <TradeInfo> mcStandardTradeList = HandleMCTradeInfoList(mcStrList);
                foreach (TradeInfo info in mcStandardTradeList)
                {
                    m_MCEditTradeList.Add(info);
                }

                List <TradeInfo> timeSeriesTradeList = HandleTimeSeriesTradeInfoList(mcStandardTradeList);

                foreach (TradeInfo info in timeSeriesTradeList)
                {
                    m_HandleTimeSeriesTradeList.Add(info);

                    xBind.Add(info.DateInfo);
                    yBind.Add(info.Quality);
                }

                this.chart1.Series[0].Points.DataBindXY(xBind, yBind);

                //保存Strategy-PathName -- List<>的Dic用于切换和组合叠加
                m_StategyNameTradeDic.Add(path, timeSeriesTradeList);
                m_StategyNameOrgionTradeDic.Add(path, mcStandardTradeList);
            }
            catch (Exception ex)
            {
                MessageBox.Show("添加失败:" + ex.Message + "请重新添加...");
            }
        }
        /// <summary>
        /// 添加策略
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolStripMenuItem_AddStrategy_Click(object sender, EventArgs e)
        {
            try
            {
                AddStrategyTextPathForm f = new AddStrategyTextPathForm();
                f.ShowDialog();

                //添加一条Item到treeView中
                this.listView_Strategy.Items.Add(f.IResult);

                string path = f.IResult;
                HoldSingleStrategyDataAndSet(path);
            }
            catch (Exception ex)
            {
                MessageBox.Show("发生异常信息,请检查后重试:" + ex.Message);
            }
        }
示例#3
0
        /// <summary>
        /// 添加策略
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolStripMenuItem_AddStrategy_Click(object sender, EventArgs e)
        {
            try
            {
                AddStrategyTextPathForm f = new AddStrategyTextPathForm();
                f.ShowDialog();

                //上面现在给的是一个文件夹的路径@"X:\xxx\xxx",搜索文件夹下路径的所有.txt文件导入-策略文件
                string filePath = f.IResult;

                m_Folder = filePath;

                string[] files = Directory.GetFiles(filePath, "*.txt");

                this.backgroundWorker1.RunWorkerAsync(files);
            }
            catch (Exception ex)
            {
                MessageBox.Show("添加策略外部数据错误,请检查后重试:" + ex.Message);
            }
        }
        private void ToolStripMenuItem_AddStrategySeries_Click(object sender, EventArgs e)
        {
            try
            {
                AddStrategyTextPathForm f = new AddStrategyTextPathForm();
                f.ShowDialog();

                //上面现在给的是一个文件夹的路径@"X:\xxx\xxx",搜索文件夹下路径的所有.txt文件导入-策略文件
                string        filePath = f.IResult;
                List <string> files    = Directory.GetFiles(filePath, "*.txt").ToList();

                if (files.Count <= 0)
                {
                    MessageBox.Show("请确认输入的文件夹下有数据文本...");
                    return;
                }

                foreach (string file in files)
                {
                    //添加一条Item到treeView中
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = file;
                    this.listView1.Items.Add(lvi);

                    this.chart1.Series.Clear();
                    this.chart1.Legends.Clear();
                    //因为没有必要参数和曲线每个再去填了,只是直接选第一个txt展示即可。后面的切换再填
                    //搜出最原始的MC数据
                    List <string> mcStrList = RedTxt(file);

                    //清空两个表-Series-邦定Series数据源
                    m_MCEditTradeList.Clear();
                    m_HandleTimeSeriesTradeList.Clear();
                    //this.chart1.Series["时间序列资金曲线"].Points.Clear();
                    List <DateTime> xBind = new List <DateTime>();
                    List <double>   yBind = new List <double>();

                    //添加到两个表
                    List <TradeInfo> mcStandardTradeList = HandleMCTradeInfoList(mcStrList);
                    foreach (TradeInfo info in mcStandardTradeList)
                    {
                        m_MCEditTradeList.Add(info);
                    }

                    List <TradeInfo> timeSeriesTradeList = HandleTimeSeriesTradeInfoList(mcStandardTradeList);

                    foreach (TradeInfo info in timeSeriesTradeList)
                    {
                        m_HandleTimeSeriesTradeList.Add(info);

                        xBind.Add(info.DateInfo);
                        yBind.Add(info.Quality);
                    }

                    System.Windows.Forms.DataVisualization.Charting.Series seriesStrategy = new System.Windows.Forms.DataVisualization.Charting.Series();
                    seriesStrategy.ChartArea  = "ChartArea1";
                    seriesStrategy.ChartType  = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                    seriesStrategy.Legend     = Path.GetFileNameWithoutExtension(file);
                    seriesStrategy.LegendText = Path.GetFileNameWithoutExtension(file);
                    seriesStrategy.ResetIsVisibleInLegend();
                    seriesStrategy.Name = file;
                    seriesStrategy.IsVisibleInLegend = true;
                    this.chart1.Legends.Add(seriesStrategy.LegendText);

                    this.chart1.Series.Add(seriesStrategy);

                    this.chart1.Series[0].Points.DataBindXY(xBind, yBind);

                    //保存Strategy-PathName -- List<>的Dic用于切换和组合叠加
                    m_StategyNameTradeDic.Add(file, timeSeriesTradeList);
                    m_StategyNameOrgionTradeDic.Add(file, mcStandardTradeList);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("添加失败:" + ex.Message + "请重新添加...");
            }
        }