예제 #1
0
파일: MainForm.cs 프로젝트: weiqk/FinData
        private void 分析家数据读取器FToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Form fxjReader = new FinData.Tools.FxjReaderForm();
            //fxjReader.ShowDialog();

            FinData.FxjData fxjReader = new FinData.FxjData();
            fxjReader.ShowFxjReader();
        }
예제 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     FinData.FxjData fxj = new  FinData.FxjData();
     if (dataType.Text.Trim() == "")
     {
         MessageBox.Show("��ѡ����������!", "��Ϣ");
         return;
     }
     try
     {
         string callText;
         string dt = dataType.Text.Split('-')[0];
         if (newFileName.Text == "")
         {
             dataArray = fxj.GetData(dt, code.Text,Convert.ToInt32(cboRecordCount.Text.Trim()));
             callText = "fxjdata.GetData(\"" + dt + "\",\"" + code.Text.Trim() + "\",\""+cboRecordCount.Text.Trim()+"\")";
         }
         else
         {
             dataArray = fxj.GetData(dt, code.Text, newFileName.Text,Convert.ToInt32(cboRecordCount.Text.Trim()));
             callText = "fxjdata.GetData(\"" + dt + "\",\"" + code.Text.Trim() + "\",\"" + newFileName.Text.Trim() + "\",\"" + cboRecordCount.Text.Trim() + "\")";
         }
         //statusStrip1.Text = fxj.Msg;
         if (fxj.Error == 0 && dataArray.GetLength(0) > 0)
         {
             string[,] colname = fxj.GetFields(dt);
             dataGridView.DataSource = new ArrayDataView(dataArray);
             for (int i = 0; i < dataGridView.Rows.Count; i++)
             {
                 dataGridView.Rows[i].HeaderCell.Value = (i+1).ToString().Trim();
             }
             if (colname.GetLength(0) == dataGridView.Columns.Count)
             {
                 for (int i = 0; i < colname.GetLength(0); i++)
                 {
                     dataGridView.Columns[i].HeaderText = colname[i, 0] + "(" + colname[i, 1] + ")";
                 }
             }
             methodText.Text = callText;
         }
         else
         {
             methodText.Text = "";
             MessageBox.Show("û�����ݻ�������" + fxj.Msg);
         }
     }
     catch (Exception ex)
     {
         methodText.Text = "";
         MessageBox.Show(ex.Message);
     }
 }
예제 #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     FinData.FxjData fxj = new  FinData.FxjData();
     if (dataType.Text.Trim() == "")
     {
         MessageBox.Show("请选择数据类型!", "信息");
         return;
     }
     try
     {
         string callText;
         string dt = dataType.Text.Split('-')[0];
         if (newFileName.Text == "")
         {
             dataArray = fxj.GetData(dt, code.Text, Convert.ToInt32(cboRecordCount.Text.Trim()));
             callText  = "fxjdata.GetData(\"" + dt + "\",\"" + code.Text.Trim() + "\",\"" + cboRecordCount.Text.Trim() + "\")";
         }
         else
         {
             dataArray = fxj.GetData(dt, code.Text, newFileName.Text, Convert.ToInt32(cboRecordCount.Text.Trim()));
             callText  = "fxjdata.GetData(\"" + dt + "\",\"" + code.Text.Trim() + "\",\"" + newFileName.Text.Trim() + "\",\"" + cboRecordCount.Text.Trim() + "\")";
         }
         //statusStrip1.Text = fxj.Msg;
         if (fxj.Error == 0 && dataArray.GetLength(0) > 0)
         {
             string[,] colname       = fxj.GetFields(dt);
             dataGridView.DataSource = new ArrayDataView(dataArray);
             for (int i = 0; i < dataGridView.Rows.Count; i++)
             {
                 dataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString().Trim();
             }
             if (colname.GetLength(0) == dataGridView.Columns.Count)
             {
                 for (int i = 0; i < colname.GetLength(0); i++)
                 {
                     dataGridView.Columns[i].HeaderText = colname[i, 0] + "(" + colname[i, 1] + ")";
                 }
             }
             methodText.Text = callText;
         }
         else
         {
             methodText.Text = "";
             MessageBox.Show("没有数据或发生错误。" + fxj.Msg);
         }
     }
     catch (Exception ex)
     {
         methodText.Text = "";
         MessageBox.Show(ex.Message);
     }
 }
예제 #4
0
        private void readFieldNames_Click(object sender, EventArgs e)
        {
            FinData.FxjData fxj = new FinData.FxjData();
            //string[,] s;
            if (dataType.Text.Trim() == "")
            {
                MessageBox.Show("请选择数据类型!", "信息");
                return;
            }
            try
            {
                string callText;
                string dt = dataType.Text.Split('-')[0];
                dataArray = fxj.GetFields(dt);
                callText  = "fxjdata.GetFields(\"" + dt + "\")";

                if (fxj.Error == 0 && dataArray.GetLength(0) > 0)
                {
                    dataGridView.DataSource = new ArrayDataView(dataArray);
                    for (int i = 0; i < dataGridView.Rows.Count; i++)
                    {
                        dataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString().Trim();
                    }
                    dataGridView.Columns[0].HeaderText = "字段名称";
                    dataGridView.Columns[1].HeaderText = "字段说明";
                    dataGridView.Columns[2].HeaderText = "字段类型";
                    methodText.Text = callText;
                }
                else
                {
                    methodText.Text = "";
                    MessageBox.Show("没有数据或发生错误 " + fxj.Msg);
                }
            }
            catch (Exception ex)
            {
                methodText.Text = "";
                MessageBox.Show(ex.Message);
            }
        }
예제 #5
0
 private void testToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FinData.FxjData fxj = new FxjData();
     string[,] x = fxj.GetData("hqfq", "SZ000001",0);
     MessageBox.Show(x[1, 1]);
 }
예제 #6
0
 private void finData����汾VToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FinData.FxjData fxj = new FxjData();
     MessageBox.Show(fxj.Version, "����汾");
 }
예제 #7
0
 private void btnCurrentDay_Click(object sender, EventArgs e)
 {
     FinData.FxjData fxj = new FinData.FxjData();
     fxj.GetStkInfo("sh");
 }
예제 #8
0
        private void readFieldNames_Click(object sender, EventArgs e)
        {
            FinData.FxjData fxj = new FinData.FxjData();
            //string[,] s;
            if (dataType.Text.Trim() == "")
            {
                MessageBox.Show("��ѡ����������!","��Ϣ");
                return;
            }
            try
            {
                string callText;
                string dt = dataType.Text.Split('-')[0];
                dataArray = fxj.GetFields(dt);
                callText = "fxjdata.GetFields(\"" + dt + "\")";

                if (fxj.Error == 0 && dataArray.GetLength(0) > 0)
                {
                    dataGridView.DataSource = new ArrayDataView(dataArray);
                    for (int i = 0; i < dataGridView.Rows.Count; i++)
                    {
                        dataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString().Trim();
                    }
                    dataGridView.Columns[0].HeaderText ="�ֶ�����";
                    dataGridView.Columns[1].HeaderText = "�ֶ�˵��";
                    dataGridView.Columns[2].HeaderText = "�ֶ�����";
                    methodText.Text = callText;
                }
                else
                {
                    methodText.Text = "";
                    MessageBox.Show("û�����ݻ������� " + fxj.Msg);
                }
            }
            catch (Exception ex)
            {
                methodText.Text = "";
                MessageBox.Show(ex.Message);
            }
        }
예제 #9
0
 private void FxjReader_Load(object sender, EventArgs e)
 {
     FxjData fxj = new FxjData();
     //string[] dataTypeNames = fxj.GetTables("");
     string[,] tableNames = fxj.GetTables();
     for (int i = 0; i < tableNames.GetLength(0); i++)
     {
         dataType.Items.Add(tableNames[i,0]+"-"+tableNames[i,1]);
     }
 }
예제 #10
0
 private void btnCurrentDay_Click(object sender, EventArgs e)
 {
     FinData.FxjData fxj = new FinData.FxjData();
     fxj.GetStkInfo("sh");
 }
예제 #11
0
        private string[,] GetHqfq(DataTypes dataType, string code, string newFileName, int iRecordCount)//复权价格,分红再投资,向前复权法
        {
            FxjData fxj = new FxjData();
            string[,] hq = fxj.GetData("hq", code, newFileName, iRecordCount);
            if (fxj.Error != 0 || hq.GetLength(1)<4 ) return new string[1, 1] { { null } };
            string[,] x = new string[hq.GetLength(0),9];
            string[,] cq = fxj.GetData("cq", code, newFileName, iRecordCount);
            string fmt = "_jj_qz".IndexOf(this.GetCodeType(code)) > 0 ? "F3" : "F";
            if (fxj.Error != 0 || cq.GetLength(1) < 4 || cq.GetLength(0)==0) //没有除权信息
            {
                for (int i = 0; i < hq.GetLength(0); i++)
                {
                    for (int j = 0; j < hq.GetLength(1); j++)
                    {
                        x[i, j] = hq[i, j];
                    }
                    if (i == 0)
                    {
                        x[i, hq.GetLength(1)] = "0.00000";
                    }
                    else
                    {
                        x[i, hq.GetLength(1)] = (Single.Parse(hq[i, 5]) / Single.Parse(hq[i - 1, 5]) - 1).ToString("0.00000");
                    }
                }
            }
            else  //有除权信息
            {
                DateTime[] cqdt = new DateTime[cq.GetLength(0)];
                for (int j = 0; j < cq.GetLength(0); j++) cqdt[j] = new DateTime(int.Parse(cq[j, 1].Split('-')[0]), int.Parse(cq[j, 1].Split('-')[1]), int.Parse(cq[j, 1].Split('-')[2]));
                int i0 = hq.GetLength(0) - 1;
                DateTime hqdt_1,hqdt;
                double kp_1,zg_1,zd_1,sp_1,kp,zg,zd,sp,kpx,zgx,zdx,spx,sgbl,kpsyl,zgsyl,zdsyl,spsyl, pgbl, pgjg, fh;
                for (int k = 0; k < 8; k++) x[i0, k] = hq[i0, k];  //最后一条记录
                x[0, 8] = "0.00000";
                kpx = double.Parse(x[i0, 2]);
                zgx = double.Parse(x[i0, 3]);
                zdx = double.Parse(x[i0, 4]);
                spx = double.Parse(x[i0, 5]);
                for (int i = i0; i > 0; i--)
                {
                    sgbl = 0; pgbl = 0; pgjg = 0; fh = 0;
                    hqdt_1 = new DateTime(int.Parse(hq[i - 1, 1].Split('-')[0]), int.Parse(hq[i - 1, 1].Split('-')[1]), int.Parse(hq[i - 1, 1].Split('-')[2]));
                    hqdt = new DateTime(int.Parse(hq[i, 1].Split('-')[0]), int.Parse(hq[i, 1].Split('-')[1]), int.Parse(hq[i, 1].Split('-')[2]));
                    for (int j = 0; j < cq.GetLength(0); j++)
                    {
                        if (hqdt_1 < cqdt[j] && cqdt[j] <= hqdt)
                        {
                            sgbl = double.Parse(cq[j, 2]);
                            pgbl = double.Parse(cq[j, 3]);
                            pgjg = double.Parse(cq[j, 4]);
                            fh = double.Parse(cq[j, 5]);
                        }
                    }
                    x[i-1, 0] = hq[i-1, 0];//dm
                    x[i-1, 1] = hq[i-1, 1];//rq
                    //syl=1+第t日收益率 =( t日收盘价*(1+送股比例+配股比例)+分红金额-配股价格*配股比例)/(t-1日收盘价)
                    kp = double.Parse(hq[i, 2]);
                    zg = double.Parse(hq[i, 3]);
                    zd = double.Parse(hq[i, 4]);
                    sp = double.Parse(hq[i, 5]);
                    kp_1 = double.Parse(hq[i-1, 2]);
                    zg_1 = double.Parse(hq[i-1, 3]);
                    zd_1 = double.Parse(hq[i-1, 4]);
                    sp_1 = double.Parse(hq[i-1, 5]);
                    kpsyl = (kp * (1 + sgbl + pgbl) + fh - pgjg * pgbl) / kp_1; 
                    zgsyl = (zg * (1 + sgbl + pgbl) + fh - pgjg * pgbl) / zg_1; 
                    zdsyl = (zd * (1 + sgbl + pgbl) + fh - pgjg * pgbl) / zd_1; 
                    spsyl = (sp * (1 + sgbl + pgbl) + fh - pgjg * pgbl) / sp_1;
                    kpx = kpx / kpsyl;
                    zgx = zgx / zgsyl;
                    zdx = zdx / zdsyl;
                    spx = spx / spsyl;
                    x[i - 1, 2] = kpx.ToString(fmt);
                    x[i - 1, 3] = zgx.ToString(fmt);
                    x[i - 1, 4] = zdx.ToString(fmt);
                    x[i - 1, 5] = spx.ToString(fmt);
                    x[i - 1, 6] = hq[i - 1, 6];//sl 成交量未复权
                    x[i - 1, 7] = hq[i - 1, 7];//je
                    x[i, 8] = (spsyl - 1).ToString("0.00000");//spsyl 收盘价收益率
                    
                }

            }

            return x;

        }
예제 #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "ȡ��(&C)")
            {
                if (MessageBox.Show("ȷ��Ҫ�ж�����ת����", "ȷ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    stopConverting = true;
                    outputBox.Enabled = true;
                    treeView1.Enabled = true;
                    status3.Text += DateTime.Now.ToString("HH:mm:ss") + ":�ж�ת��!\n";
                }
                return;
            }

            if (treeView1.Nodes.Count < 1)
            {
                MessageBox.Show("û���ҵ����ݣ�", "����");
                return;
            }
            if (descPath.Text.Trim() == "")
            {
                MessageBox.Show("��ѡ��Ŀ���ļ��У�", "����");
                descPath.Focus();
                return;
            }
            if(Directory.Exists(descPath.Text)==false)
            {
                MessageBox.Show("�ļ��С�" + descPath.Text +"�������ڣ�������ѡ��򴴽���", "����",MessageBoxButtons.OK);
                descPath.Focus();
                return;
            }
            if (MessageBox.Show("ת������ʱ����������ѡ���ڡ�" + descPath.Text.Trim() + "���д�������ļ���ͬ���ļ��������ǣ�\n\nȷ����ʼת����","ȷ��",MessageBoxButtons.OKCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button2)!=DialogResult.OK)
            {
                return;
            }

            //ת������
            int errorCounts = 0;
            button1.Text = "ȡ��(&C)";
            status.Text = "";
            status2.Text = "";
            status3.Text = DateTime.Now.ToString("HH:mm:ss") + ":��ʼת��...\n";
            outputBox.Enabled = false;
            treeView1.Enabled = false;
            try
            {
                FxjData fxj = new FxjData();
                string[,] x;
                string s="";
                string sepChar = seperateChar.Text;
                for (int i = 0; i < treeView1.Nodes.Count ; i++)
                {
                    if (treeView1.Nodes[i].Nodes.Count > 0)
                    {
                        string[,] codes = fxj.GetData("dm", treeView1.Nodes[i].Nodes[0].Text.Split('|')[1],0);
                        foreach (TreeNode node in treeView1.Nodes[i].Nodes)
                        {

                            if (node.Checked)
                            {
                                status.Text = node.Text.Split('|')[1] + node.Text.Split('|')[2];
                                status3.Text += DateTime.Now.ToString("HH:mm:ss") + ":��ʼת��" + status.Text + " \n";
                                Application.DoEvents();
                                switch (node.Text.Split('|')[2])
                                {
                                    case "dm":
                                        StreamWriter swdm = new StreamWriter(descPath.Text + @"\" + node.Text.Split('|')[3], false);
                                        x = fxj.GetFields("dm");
                                        for (int ii = 0; ii < x.GetLength(0); ii++)
                                        {
                                            swdm.Write(x[ii, 0] + "(" + x[ii, 1] + ")" + sepChar);

                                        }
                                        swdm.WriteLine();
                                        x = fxj.GetData("dm", node.Text.Split('|')[1],0);
                                        if (fxj.Error == 1 && errorCounts < 10) { status3.Text += DateTime.Now.ToString("HH:mm:ss") + ":" + node.Text.Split('|')[1] + "," + fxj.Msg + (errorCounts == 9 ? "\n ������������" : "") + " \n"; errorCounts++; }
                                        for (int ii = 0; ii < x.GetLength(0); ii++)
                                        {
                                            status2.Text = x[ii, 0];
                                            Application.DoEvents();
                                            if (stopConverting) { swdm.Close(); return; }
                                            for (int jj = 0; jj < x.GetLength(1); jj++)
                                            {
                                                swdm.Write(x[ii, jj] + sepChar);
                                            }
                                            swdm.WriteLine();
                                        }
                                        swdm.Close();
                                        status3.Text += DateTime.Now.ToString("HH:mm:ss") + ":����" + node.Text.Split('|')[3] + " \n";
                                        break;
                                    case "bk":
                                    case "pj":
                                        StreamWriter sw0 = new StreamWriter(descPath.Text + @"\" + node.Text.Split('|')[3], false);
                                        x = fxj.GetFields(node.Text.Split('|')[2]);
                                        for (int ii = 0; ii < x.GetLength(0); ii++)
                                        {
                                            sw0.Write(x[ii, 0] + "(" + x[ii, 1] + ")" + sepChar);

                                        }
                                        sw0.WriteLine();
                                        x = fxj.GetData(node.Text.Split('|')[2], "",0);
                                        if (fxj.Error == 1 && errorCounts < 10) { status3.Text += DateTime.Now.ToString("HH:mm:ss") + ":" + node.Text.Split('|')[2] + "," + fxj.Msg + (errorCounts == 9 ? "\n ������������" : "") + " \n"; errorCounts++; }
                                        for (int ii = 0; ii < x.GetLength(0); ii++)
                                        {
                                            status2.Text = x[ii, 0];
                                            Application.DoEvents();
                                            if (stopConverting) { sw0.Close(); return; }
                                            for (int jj = 0; jj < x.GetLength(1); jj++)
                                            {
                                                sw0.Write(x[ii, jj] + sepChar);
                                            }
                                            sw0.WriteLine();
                                        }
                                        sw0.Close();
                                        status3.Text += DateTime.Now.ToString("HH:mm:ss") + ":����" + node.Text.Split('|')[3] + " \n";
                                        break;
                                    default:
                                        StreamWriter sw = new StreamWriter(descPath.Text + @"\" + node.Text.Split('|')[3], false);
                                        x = fxj.GetFields(node.Text.Split('|')[2]);
                                        for (int ii = 0; ii < x.GetLength(0); ii++)
                                        {
                                            sw.Write(x[ii, 0] + "(" + x[ii, 1] + ")" + sepChar);

                                        }
                                        sw.WriteLine();
                                        for (int c = 0; c < codes.GetLength(0); c++)
                                        {
                                            if (fxj.GetCodeType(codes[c, 0]) != "")
                                            {
                                                status2.Text = codes[c, 0];
                                                Application.DoEvents();

                                                x = fxj.GetData(node.Text.Split('|')[2], codes[c, 0], node.Text.Split('|')[4],0);
                                                if (fxj.Error == 1 && errorCounts < 10) { status3.Text += DateTime.Now.ToString("HH:mm:ss") + ":" + codes[c, 0] + "," + fxj.Msg + (errorCounts==9?"\n ������������":"") + " \n"; errorCounts++; }
                                                for (int ii = 0; ii < x.GetLength(0); ii++)
                                                {
                                                    if (stopConverting) { sw.Close(); return; }
                                                    s = "";
                                                    for (int jj = 0; jj < x.GetLength(1); jj++)
                                                    {
                                                        s += x[ii, jj] + sepChar;
                                                    }
                                                    sw.WriteLine(s);
                                                }
                                            }

                                        }
                                        status3.Text += DateTime.Now.ToString("HH:mm:ss") + ":����" + node.Text.Split('|')[3] + " \n";
                                        sw.Close();
                                        break;
                                }
                            }

                        }

                    }

                }
            }//try
            catch (Exception ex)
            {
                status3.Text += "��������" + ex.Message+"\n";
            }
            finally
            {
                button1.Text = "ת��(&T)";
                stopConverting = false;
                outputBox.Enabled = true;
                treeView1.Enabled = true;
                status3.Text += DateTime.Now.ToString("HH:mm:ss") + ":ת������.\n";
            }
        }
예제 #13
0
        private void FxjConverter_Load(object sender, EventArgs e)
        {
            FxjData fxj = new FxjData();
            if (fxj.FxjPath == "")
            {
                fxjPath.Text = "û���ҵ������ң�";
                fxjPath.ForeColor = Color.Red;
            }
            else
            {
                this.fxjPath.Text = fxj.FxjPath;
                this.ver.Text = fxj.Version;
                if (fxj.GetMarkets().GetLength(0) > 0)
                {
                    TreeNode[] marketNode = new TreeNode[fxj.GetMarkets().GetLength(0) + 1];
                    treeView1.ExpandAll();
                    for (int i = 0; i < fxj.GetMarkets().GetLength(0); i++)
                    {
                        DirectoryInfo dir = new DirectoryInfo(fxj.FxjPath + @"\data\" + fxj.GetMarkets()[i, 0].Trim());
                        if (dir.Exists)
                        {
                            marketNode[i] = treeView1.Nodes.Add(fxj.GetMarkets()[i, 1]);
                            string[,] tables = fxj.GetTables();
                            for (int j = 0; j < tables.GetLength(0); j++)
                            {
                                if ("..SH,SZ,".IndexOf(fxj.GetMarkets()[i, 0].ToUpper()) > 0 && tables[j, 0].ToLower() != "bk")  //�
                                {
                                    if (File.Exists(fxj.FxjPath + @"data\" + fxj.GetMarkets()[i, 0] + @"\" + tables[j, 2]) ||
                                        ",,,fp,gb,gd,cw,jjjz,jjzh".IndexOf(tables[j, 0].ToLower()) > 0 && File.Exists(fxj.FxjPath + @"data\" + tables[j, 2]))
                                    {
                                        marketNode[i].Nodes.Add(tables[j, 1] + "|" + fxj.GetMarkets()[i, 0].ToLower() + "|" + tables[j, 0] + "|" + fxj.GetMarkets()[i, 0].ToLower() + tables[j, 0] + ".txt|" + tables[j, 2]);
                                    }

                                }
                                else   //�����г�
                                {
                                    if (File.Exists(fxj.FxjPath + @"data\" + fxj.GetMarkets()[i, 0] + @"\" + tables[j, 2]))
                                    {
                                        if (",,,fp,gb,gd,cw,jjjz,jjzh".IndexOf(tables[j, 0].ToLower()) <= 0 && tables[j, 0].ToLower() != "bk")
                                        {
                                            marketNode[i].Nodes.Add(tables[j, 1] + "|" + fxj.GetMarkets()[i, 0].ToLower() + "|" + tables[j, 0] + "|" + fxj.GetMarkets()[i, 0].ToLower() + tables[j, 0] + ".txt|" + tables[j, 2]);
                                        }
                                    }

                                }
                            }

                            foreach (FileInfo file in dir.GetFiles(@"*.PRP"))
                            {
                                marketNode[i].Nodes.Add("��ʷ�ֱʳɽ�|" + fxj.GetMarkets()[i, 0].ToLower() + "|hqmb|"+ fxj.GetMarkets()[i, 0].ToLower()+"hqmb" + file.Name.Substring(0, file.Name.IndexOf(".")) + ".txt|" + file.Name);
                            }
                        }
                    }
                    marketNode[fxj.GetMarkets().GetLength(0)] = treeView1.Nodes.Add("��������");
                    marketNode[fxj.GetMarkets().GetLength(0)].Nodes.Add("���|ss|bk|bk.txt|block.def");
                    marketNode[fxj.GetMarkets().GetLength(0)].Nodes.Add("����|ss|pj|pj.txt|����.str");
                }
            }
        }