Esempio n. 1
0
        /// <summary>
        /// 从dat中解析出行情数据 - MA数据加载 个股 - 数据
        /// </summary>
        /// <param name="valueInfosDic"></param>
        private void LoadDatData(Dictionary <string, string> valueInfosDic)
        {
            foreach (KeyValuePair <string, string> kv in valueInfosDic)
            {
                string geguStr  = kv.Key;
                string geguPath = kv.Value;

                //获取该key下的path数据
                List <MarketData> marketData = WenHuaDataHandle.GetHQDatData(geguPath);
                m_wenhuaShuJuDic.Add(geguStr, marketData);
            }

            //上图表
            GraphPane mPane = zedGraphControl1.GraphPane;//获取索引到GraphPane面板上

            foreach (KeyValuePair <string, List <MarketData> > kp in m_wenhuaShuJuDic)
            {
                List <MarketData> marketDataList = kp.Value;

                if (kp.Value == null || kp.Value.Count <= 0)
                {
                    continue;
                }

                MarketData.CalMaDiff(marketDataList);

                PointPairList dataList = new PointPairList();

                for (int j = 0; j < marketDataList.Count; j++)
                {
                    PointPair pairData = new PointPair();

                    double   x   = 0.00;
                    DateTime tM  = marketDataList[j].DateTimeNum;
                    string   daT = tM.ToString("yyyy-MM-dd").Replace("-", "");

                    double.TryParse(daT, out x);//时间double 20200617

                    double y = marketDataList[j].MADiff;

                    if (y == 0)
                    {
                        continue;
                    }

                    pairData.X = x;
                    pairData.Y = y;

                    dataList.Add(pairData);
                }

                LineItem mCure = mPane.AddCurve(kp.Key, dataList, Common.GetRandomColor(), SymbolType.None);
                m_LineItemList.Add(mCure);
                zedGraphControl1.AxisChange();//画到zedGraphControl1控件中,此句必加
            }
        }
        private void Level2_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                //选中显示个股
                this.richTextBox_Data.Clear();

                if (this.listBox_Level1.SelectedItem == null ||
                    this.listBox_Level1.SelectedItem.ToString() == "" ||
                    this.listBox_Level2.SelectedItem == null ||
                    this.listBox_Level2.SelectedItem.ToString() == "")
                {
                    return;
                }

                Level2Info infos = this.listBox_Level2.SelectedItem as Level2Info;

                string fileInfos = this.textBox_path.Text.Replace("\r\n", "") + this.listBox_Level1.SelectedItem.ToString()
                                   + "\\" + "day\\" + infos.DataCodeStr + ".dat";

                //获取数据
                if (!File.Exists(fileInfos))
                {
                    MessageBox.Show("该行情文件不存在,请刷新文华相关合约的日线数据!");
                }
                else
                {
                    List <MarketData> wDList = WenHuaDataHandle.GetHQDatData(fileInfos);
                    //因为数据可能很多,所以只展示100条
                    for (int i = wDList.Count - 1; i >= wDList.Count - 50; i--)
                    {
                        this.richTextBox_Data.AppendText(wDList[i].DateTimeNum + "|" + wDList[i].Close + "\n");
                    }
                }
            }
        }