Esempio n. 1
0
        public static bool UpdateMMTest(Microsoft.AnalysisServices.MiningModel mm, string strStockCode, DateTime dtTo)
        {
            mm.AlgorithmParameters.Clear();
            // Default:10; 10:5 -> from 0 to (n-10)/5
            //mm.AlgorithmParameters.Add("MINIMUM_SUPPORT", 10);

            // 0.1:0.05 -> from 0 to (1-0.1)/0.05=18
            mm.AlgorithmParameters.Add("COMPLEXITY_PENALTY", COMPLEXITY_PENALTY);

            // {5,20,60}, 0:0.1 -> from 0 to (1-0.1)/0.05=18
            mm.AlgorithmParameters.Add("PERIODICITY_HINT", "{5,20,60}");
            mm.AlgorithmParameters.Add("AUTO_DETECT_PERIODICITY", AUTO_DETECT_PERIODICITY);

            // Defeult: 1, 10
            mm.AlgorithmParameters.Add("HISTORIC_MODEL_COUNT", HISTORIC_MODEL_COUNT);
            mm.AlgorithmParameters.Add("HISTORIC_MODEL_GAP", HISTORIC_MODEL_GAP);

            // Max, Min Time Series
            mm.AlgorithmParameters.Add("MAXIMUM_SERIES_VALUE", MAXIMUM_SERIES_VALUE);
            mm.AlgorithmParameters.Add("MINIMUM_SERIES_VALUE", MINIMUM_SERIES_VALUE);

            mm.Update();
            mm.Process(ProcessType.ProcessFull);
            return(ADOMDLib.CheckResultTest(strStockCode, dtTo));
        }
Esempio n. 2
0
        private void btnUpdateAll_Click(object sender, EventArgs e)
        {
            txtProgress.Text = "Đang xử lý ...";
            odlgHisFile.ShowDialog();
            string sFile = odlgHisFile.FileName;

            ADOMDLib.IncAllProcess(cboStock.Text, sFile);
            txtProgress.Text = "Xử lý xong!";
        }
Esempio n. 3
0
 private void btnResetMulti_Click(object sender, EventArgs e)
 {
     if (cboStock.SelectedIndex == -1)
     {
         MessageBox.Show("Bạn cần chọn mô hình của chứng khoán cần xử lý");
     }
     else
     {
         txtProgress.Text = "Đang xóa dữ liệu dự báo cũ ...";
         txtProgress.Refresh();
         ADOMDLib.ResetMulti(cboStock.Text, true);
         txtProgress.Text = "Hoàn tất việc xóa dữ liệu dự báo cũ ...";
     }
 }
Esempio n. 4
0
 private void btnUpdateAll_Click(object sender, EventArgs e)
 {
     txtProgress.Text = "Đang xử lý ...";
     if (odlgHisFile.ShowDialog() == DialogResult.OK)
     {
         string sFile = odlgHisFile.FileName;
         ADOMDLib.IncAllProcess(cboStock.Text, sFile, chkContinue.Checked);
         txtProgress.Text = "Xử lý xong!";
     }
     else
     {
         txtProgress.Text = "Thoát!";
     }
 }
Esempio n. 5
0
 private void btnForcast_Click(object sender, EventArgs e)
 {
     if (cboStock.SelectedIndex == -1)
     {
         MessageBox.Show("Bạn cần chọn mô hình của chứng khoán cần xử lý");
     }
     else
     {
         txtProgress.Text = "Đang dự báo ...";
         int iMulti = Convert.ToInt16(txtNumber.Text);
         if (cboStock.SelectedIndex > -1)
         {
             ADOMDLib.ForecastTest(txtProgress, cboStock.Text, iMulti, chkAnalysis.Checked, chkServey.Checked, chkOver.Checked);
         }
     }
 }
Esempio n. 6
0
 private void btnExport_Click(object sender, EventArgs e)
 {
     if (txtStockCode.Text != "")
     {
         fdlgBrowse.SelectedPath = System.IO.Directory.GetCurrentDirectory();
         DialogResult result = fdlgBrowse.ShowDialog();
         if (result == DialogResult.OK)
         {
             ADOMDLib.ExportCSV(txtStockCode.Text, fdlgBrowse.SelectedPath);
         }
     }
     else
     {
         MessageBox.Show("Nhập mã stock vào TextBox!");
     }
 }
Esempio n. 7
0
        private void btnUpdateTrain_Click(object sender, EventArgs e)
        {
            txtProgress.Text = "Đang cập nhật ...";
            txtProgress.Refresh();

            if (!(txtStockCode.Text == null))
            {
                ADOMDLib.ResetMulti(txtStockCode.Text, false);
                ADOLib.UpdateTrainDB(svr, txtStockCode.Text, chkAll.Checked, dtpFrom.Value, dtpTo.Value, chkMulti.Checked);
            }
            else
            {
                MessageBox.Show("Bạn cần nhập mã chứng khoán!");
            }
            txtProgress.Text = "Cập nhật xong!";
        }
Esempio n. 8
0
 private void btnExportBoth_Click(object sender, EventArgs e)
 {
     if (cboStockCode.Text != "")
     {
         fdlgBrowse.SelectedPath = System.IO.Directory.GetCurrentDirectory();
         DialogResult result = fdlgBrowse.ShowDialog();
         if (result == DialogResult.OK)
         {
             //ADOMDLib.Export2CSV(cboStockCode.Text, fdlgBrowse.SelectedPath);
             ADOMDLib.ExportMulti2CSV(cboStockCode.Text, fdlgBrowse.SelectedPath);
         }
     }
     else
     {
         MessageBox.Show("Chọn mã stock trong ComboBox!");
     }
 }
Esempio n. 9
0
        public static void ProcessUpdateMMTest(Server svr, string strStockCode, bool bCon)
        {
            Database db = svr.Databases.GetByName("StockPredict");

            Microsoft.AnalysisServices.MiningStructure ms = db.MiningStructures.FindByName(strStockCode);

            string            strMsg, strCap;
            MessageBoxButtons buttons = MessageBoxButtons.OK;

            if (ms == null)
            {
                strMsg = "Cấu trúc dự báo cho cổ phiếu này không tồn tại!";
                strCap = "Mining Structure";
                // Displays the MessageBox.
                MessageBox.Show(strMsg, strCap, buttons, MessageBoxIcon.Error);
                return;
            }

            Microsoft.AnalysisServices.MiningModel mm = ms.MiningModels.FindByName(strStockCode);
            if (mm == null)
            {
                strMsg = "Mô hình dự báo cho cổ phiếu này không tồn tại!";
                strCap = "Mining Model";
                // Displays the MessageBox.
                MessageBox.Show(strMsg, strCap, buttons, MessageBoxIcon.Error);
                return;
            }


            // Check exist table: CR
            ADOMDLib.ExistExpandTable(strStockCode, "_CRT", bCon);

            // Initial parameters
            DefaultParam(strStockCode);

            // Get ToDate from StockForecastModel
            SqlConnection cn = new SqlConnection(str_Con_SQL);

            cn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = cn;
            cmd.CommandText = "SELECT ToDate FROM StockForecastModel WHERE StockCode='" + strStockCode + "'";
            SqlDataReader rdr = cmd.ExecuteReader();

            rdr.Read();
            DateTime dtTo = rdr.GetDateTime(0);

            rdr.Close();
            cn.Close();

            // Loop mining
            while (AUTO_DETECT_PERIODICITY < 0.95)
            {
                while (COMPLEXITY_PENALTY < 0.95)
                {
                    while (HISTORIC_MODEL_COUNT < 3)
                    {
                        while (HISTORIC_MODEL_GAP < 15)
                        {
                            if (!UpdateMMTest(mm, strStockCode, dtTo))
                            {
                                // Update parameters into StockForecastModel
                                UpdateForecastModel(strStockCode);
                                return;
                            }
                            HISTORIC_MODEL_GAP++;
                        }
                        HISTORIC_MODEL_GAP = i_Save_HMG;
                        HISTORIC_MODEL_COUNT++;
                    }
                    HISTORIC_MODEL_COUNT = 1;
                    COMPLEXITY_PENALTY  += 0.05;
                }
                COMPLEXITY_PENALTY       = 0.05;
                AUTO_DETECT_PERIODICITY += 0.05;
            }

            // Get the best parameters
            UpdateMMTest(mm, strStockCode, dtTo);
            GetBestParamTest(strStockCode);
            UpdateForecastModel(strStockCode);
        }
Esempio n. 10
0
        public static void ProcessUpdateMM(Server svr, string strStockCode, bool bCon)
        {
            Database db = svr.Databases.GetByName("StockPredict");

            Microsoft.AnalysisServices.MiningStructure ms = db.MiningStructures.FindByName(strStockCode);

            string            strMsg, strCap;
            MessageBoxButtons buttons = MessageBoxButtons.OK;

            if (ms == null)
            {
                strMsg = "Cấu trúc dự báo cho cổ phiếu này không tồn tại!";
                strCap = "Mining Structure";
                // Displays the MessageBox.
                MessageBox.Show(strMsg, strCap, buttons, MessageBoxIcon.Error);
                return;
            }

            Microsoft.AnalysisServices.MiningModel mm = ms.MiningModels.FindByName(strStockCode);
            if (mm == null)
            {
                strMsg = "Mô hình dự báo cho cổ phiếu này không tồn tại!";
                strCap = "Mining Model";
                // Displays the MessageBox.
                MessageBox.Show(strMsg, strCap, buttons, MessageBoxIcon.Error);
                return;
            }


            // Check exist table: CR
            ADOMDLib.ExistExpandTable(strStockCode, "_CR", bCon);

            // Initial parameters and get count of IDs
            int iCount_ID = InitialParameters(strStockCode);

            // Loop mining
            while (AUTO_DETECT_PERIODICITY < 0.95)
            {
                while (COMPLEXITY_PENALTY < 0.95)
                {
                    while (HISTORIC_MODEL_COUNT < 3)
                    {
                        while (HISTORIC_MODEL_GAP < 15)
                        {
                            HISTORIC_MODEL_GAP++;
                            if (!UpdateMM(mm, strStockCode, false))
                            {
                                // back to previous
                                //HISTORIC_MODEL_GAP--;
                                //UpdateMM(mm, strStockCode, true);
                                // Update parameters into StockForecastModel
                                UpdateForecastModel(strStockCode);
                                return;
                            }
                        }
                        HISTORIC_MODEL_GAP = i_Save_HMG;
                        HISTORIC_MODEL_COUNT++;
                    }
                    HISTORIC_MODEL_COUNT = 1;
                    COMPLEXITY_PENALTY  += 0.05;
                }
                COMPLEXITY_PENALTY       = 0.05;
                AUTO_DETECT_PERIODICITY += 0.05;
            }
            // Get the best parameters
            // Get the best parameters
            UpdateMM(mm, strStockCode, false);
            GetBestParam(strStockCode);
            UpdateForecastModel(strStockCode);
        }