Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string         filepath1 = @"data/000001.csv";
            string         filepath2 = @"data/600519.csv";
            classCSVHelper csh       = new classCSVHelper();

            filepath1 = Server.MapPath(filepath1);
            filepath2 = Server.MapPath(filepath2);
            DataTable dt1 = csh.readCsvSql(filepath1);
            DataTable dt2 = csh.readCsvSql(filepath2);

            double[] closingPrice1 = new double[25];
            for (int i = 0; i < 25; i++)
            {
                closingPrice1[i] = double.Parse(dt1.Rows[i][3].ToString());
                Response.Write(string.Format("{0},{1}</br>", i, closingPrice1[i]));
            }
            double[] closingPrice2 = new double[25];
            for (int i = 0; i < 25; i++)
            {
                closingPrice2[i] = double.Parse(dt2.Rows[i][3].ToString());
                Response.Write(string.Format("{0},{1}</br>", i, closingPrice2[i]));
            }
            double ppcc = calCov(closingPrice1, closingPrice2) / (Caldevar(closingPrice1) * Caldevar(closingPrice2));

            Response.Write("相关系数为" + ppcc);
        }
Пример #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string         filepath = txtFilePath.Text;
            classCSVHelper csh      = new classCSVHelper();

            filepath = Server.MapPath(filepath);

            DataTable dt1 = csh.readCsvSql(filepath);
            DataTable dt  = csh.readCsvTxt(filepath, Encoding.Default);
            int       i   = 0;

            double[] closingPrice = new double[dt1.Rows.Count];
            foreach (DataRow dr in dt1.Rows)
            {
                closingPrice[i++] = double.Parse(dr[3].ToString());
            }
        }