Example #1
0
        private void dataGrid_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView;
                if (resultDataGrid == null)
                {
                    return;
                }
                string stockCode = resultTab.SelectedTab.Name;

                if (resultDataGrid.CurrentRow == null)
                {
                    return;
                }
                AppTypes.TimeRanges      timeRange    = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[e.ColumnIndex].DataPropertyName);
                data.baseDS.stockCodeRow stockCodeRow = application.dataLibs.FindAndCache(myDataSet.stockCode, stockCode);
                if (stockCodeRow == null)
                {
                    return;
                }

                string strategyCode = resultDataGrid.CurrentRow.Cells[0].Value.ToString();
                ShowTradeTransactions(stockCodeRow, strategyCode, timeRange, cbTimeScale.myValue);
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
Example #2
0
        private void dataGrid_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView;
                if (resultDataGrid == null)
                {
                    return;
                }
                string stockCode = resultTab.SelectedTab.Name;

                if (resultDataGrid.CurrentRow == null)
                {
                    return;
                }
                AppTypes.TimeRanges          timeRange    = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[e.ColumnIndex].DataPropertyName);
                databases.tmpDS.stockCodeRow stockCodeRow = DataAccess.Libs.myStockCodeTbl.FindBycode(stockCode);
                if (stockCodeRow == null)
                {
                    return;
                }

                string     strategyCode = resultDataGrid.CurrentRow.Cells[0].Value.ToString();
                DataParams dataParam    = new DataParams(timeScaleCb.myValue.Code, timeRange, 0);
                ShowTradeTransactions(stockCodeRow, strategyCode, dataParam);
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
Example #3
0
        private void openMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView;
                if (resultDataGrid == null)
                {
                    return;
                }

                string stockCode = resultTab.SelectedTab.Name;
                data.baseDS.stockCodeRow stockCodeRow = application.dataLibs.FindAndCache(myDataSet.stockCode, stockCode);
                if (stockCodeRow != null)
                {
                    return;
                }

                AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[resultDataGrid.ColumnCount - 1].Name);
                ShowStock(stockCodeRow, timeRange, cbTimeScale.myValue);
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
        private void profitDetailMenu_Click(object sender, EventArgs e)
        {
            try
            {
                common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView;
                if (resultDataGrid == null || resultDataGrid.CurrentRow == null || resultDataGrid.CurrentCell == null)
                {
                    return;
                }
                if (resultDataGrid.CurrentCell.ColumnIndex <= 0)
                {
                    return;
                }

                string stockCode = resultTab.SelectedTab.Name;
                data.tmpDS.stockCodeRow stockCodeRow = DataAccess.Libs.myStockCodeTbl.FindBycode(stockCode);
                if (stockCodeRow == null)
                {
                    return;
                }
                application.Strategy.Meta meta = application.Strategy.Libs.FindMetaByName(resultDataGrid.CurrentRow.Cells[0].Value.ToString());

                int colId = resultDataGrid.CurrentCell.ColumnIndex;
                AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[colId].DataPropertyName);
                ShowTradeTransactions(stockCodeRow, meta.Code, timeRange, timeScaleCb.myValue);
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
        private void DoRankingDB()
        {
            this.myValueType = ValueTypes.Amount;
            this.Amount2PercentDenominator = Settings.sysStockTotalCapAmt;

            resultTab.TabPages.Clear();
            StringCollection stockCodeList = codeListLb.myValues;
            StringCollection timeRangeList = timeRangeLb.myCheckedValues;

            string[] strategyList = common.system.Collection2List(strategyClb.myCheckedValues);
            progressBar.Value = 0; progressBar.Minimum = 0; progressBar.Maximum = stockCodeList.Count * timeRangeList.Count;

            EstimateOptions estimateOption = new EstimateOptions();

            for (int stockCodeId = 0; stockCodeId < stockCodeList.Count; stockCodeId++)
            {
                string    stockCode      = stockCodeList[stockCodeId].ToString();
                DataTable testRetsultTbl = CreateDataTable(timeRangeList, strategyList);
                common.controls.baseDataGridView resultGrid = CreateResultGrid(stockCode, testRetsultTbl);

                for (int colId = 0; colId < timeRangeList.Count; colId++)
                {
                    try
                    {
                        progressBar.Value++;
                        Application.DoEvents();
                        this.ShowReccount(progressBar.Value.ToString() + "/" + progressBar.Maximum.ToString());

                        AppTypes.TimeRanges      timeRange    = AppTypes.TimeRangeFromCode(timeRangeList[colId]);
                        application.AnalysisData analysisData = new application.AnalysisData(timeRange, timeScaleCb.myValue, stockCode,
                                                                                             commonClass.DataAccessMode.WebService);
                        for (int rowId = 0; rowId < strategyList.Length; rowId++)
                        {
                            testRetsultTbl.Rows[rowId][colId + 1] = 0;
                            //Analysis cached data so we MUST clear cache to ensure the system run correctly
                            application.Strategy.Data.ClearCache();
                            application.Strategy.Data.TradePoints advices = application.Strategy.Libs.Analysis(analysisData, strategyList[rowId]);
                            if (advices != null)
                            {
                                testRetsultTbl.Rows[rowId][colId + 1] =
                                    application.Strategy.Libs.EstimateTrading_Profit(analysisData, application.Strategy.Libs.ToTradePointInfo(advices), estimateOption);
                            }
                        }
                    }
                    catch (Exception er)
                    {
                        this.WriteError(stockCodeList[stockCodeId] + " : " + timeRangeList[colId] + " : " + strategyList[colId], er.Message);
                        //this.ShowError(er);
                    }
                }
            }
        }
        private void allProfitDetailMenu_Click(object sender, EventArgs e)
        {
            try
            {
                using (new DataAccess.PleaseWait())
                {
                    common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView;
                    if (resultDataGrid == null)
                    {
                        return;
                    }

                    string stockCode = resultTab.SelectedTab.Name;
                    data.tmpDS.stockCodeRow stockCodeRow = DataAccess.Libs.myStockCodeTbl.FindBycode(stockCode);
                    if (stockCodeRow == null)
                    {
                        return;
                    }

                    if (resultDataGrid.SelectedRows.Count > 0)
                    {
                        for (int rowId = 0; rowId < resultDataGrid.SelectedRows.Count; rowId++)
                        {
                            application.Strategy.Meta meta = application.Strategy.Libs.FindMetaByName(resultDataGrid.SelectedRows[rowId].Cells[0].Value.ToString());
                            for (int idx = 1; idx < resultDataGrid.ColumnCount; idx++)
                            {
                                AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[idx].DataPropertyName);
                                ShowTradeTransactions(stockCodeRow, meta.Code, timeRange, timeScaleCb.myValue);
                            }
                        }
                    }
                    else
                    {
                        if (resultDataGrid.CurrentRow != null)
                        {
                            application.Strategy.Meta meta = application.Strategy.Libs.FindMetaByName(resultDataGrid.CurrentRow.Cells[0].Value.ToString());
                            for (int idx = 1; idx < resultDataGrid.ColumnCount; idx++)
                            {
                                AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[idx].DataPropertyName);
                                ShowTradeTransactions(stockCodeRow, meta.Code, timeRange, timeScaleCb.myValue);
                            }
                        }
                    }
                }
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
Example #7
0
        private void profitEstimateMenu_Click(object sender, EventArgs e)
        {
            try
            {
                common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView;
                if (resultDataGrid == null)
                {
                    return;
                }

                string stockCode    = resultTab.SelectedTab.Name;
                string strategyCode = "";
                data.baseDS.stockCodeRow stockCodeRow = application.dataLibs.FindAndCache(myDataSet.stockCode, stockCode);
                if (stockCodeRow == null)
                {
                    return;
                }

                if (resultDataGrid.SelectedRows.Count > 0)
                {
                    for (int rowId = 0; rowId < resultDataGrid.SelectedRows.Count; rowId++)
                    {
                        strategyCode = resultDataGrid.SelectedRows[rowId].Cells[0].Value.ToString();
                        for (int idx = 1; idx < resultDataGrid.ColumnCount; idx++)
                        {
                            AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[idx].DataPropertyName);
                            ShowTradeTransactions(stockCodeRow, strategyCode, timeRange, cbTimeScale.myValue);
                        }
                    }
                }
                else
                {
                    if (resultDataGrid.CurrentRow != null)
                    {
                        strategyCode = resultDataGrid.CurrentRow.Cells[0].Value.ToString();
                        for (int idx = 1; idx < resultDataGrid.ColumnCount; idx++)
                        {
                            AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[idx].DataPropertyName);
                            ShowTradeTransactions(stockCodeRow, strategyCode, timeRange, cbTimeScale.myValue);
                        }
                    }
                }
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
Example #8
0
        private void DoRanking()
        {
            this.myValueType = ValueTypes.Amount;
            this.Amount2PercentDenominator = application.Settings.sysStockTotalCapAmt;

            resultTab.TabPages.Clear();
            StringCollection stockCodeList = stockCodeSelectLb.myValues;
            StringCollection strategyList  = strategyClb.myCheckedValues;
            StringCollection timeRangeList = timeRangeLb.myCheckedValues;

            progressBar.Value = 0; progressBar.Minimum = 0; progressBar.Maximum = stockCodeList.Count * timeRangeList.Count;
            for (int stockCodeId = 0; stockCodeId < stockCodeList.Count; stockCodeId++)
            {
                string    stockCode      = stockCodeList[stockCodeId].ToString();
                DataTable testRetsultTbl = CreateDataTable(timeRangeList, strategyList);
                common.controls.baseDataGridView resultGrid = CreateResultGrid(stockCode, testRetsultTbl);

                for (int colId = 0; colId < timeRangeList.Count; colId++)
                {
                    AppTypes.TimeRanges timeRange = AppTypes.TimeRangeFromCode(timeRangeList[colId]);
                    decimal             profit    = 0;

                    application.Data analysisData = new application.Data(timeRange, cbTimeScale.myValue, stockCode);
                    for (int rowId = 0; rowId < strategyList.Count; rowId++)
                    {
                        profit = 0;
                        //Analysis cached data so we MUST clear cache to ensure the system run correctly
                        Strategy.Data.ClearCache();
                        Strategy.TradePoints advices = Strategy.Libs.Analysis(analysisData, strategyList[rowId]);
                        if (advices != null)
                        {
                            myTmpDS.tradeEstimate.Clear();
                            Strategy.Libs.EstimateTrading(analysisData, advices, new Strategy.Libs.EstimateOptions(), myTmpDS.tradeEstimate);
                            profit = (myTmpDS.tradeEstimate.Count == 0 ? 0 : profit = myTmpDS.tradeEstimate[myTmpDS.tradeEstimate.Count - 1].profit);
                        }
                        testRetsultTbl.Rows[rowId][colId + 1] = profit;
                    }
                    progressBar.Value++;
                    Application.DoEvents();
                }
            }
            FormResize();
        }
Example #9
0
        private static DataTable CreateDataTable(StringCollection timeRangeList, StringCollection strategyList)
        {
            // Define the new datatable
            DataTable tbl = new DataTable();

            // Define columns
            DataColumn col = new DataColumn("item");

            tbl.Columns.Add(col);
            for (int idx = 0; idx < timeRangeList.Count; idx++)
            {
                string colName = timeRangeList[idx];
                col         = new DataColumn(colName, typeof(Decimal));
                col.Caption = AppTypes.Type2Text(AppTypes.TimeRangeFromCode(timeRangeList[idx]));
                tbl.Columns.Add(col);
            }
            for (int rowId = 0; rowId < strategyList.Count; rowId++)
            {
                tbl.Rows.Add(strategyList[rowId]);
            }
            return(tbl);
        }
Example #10
0
        private void profitDetailMenu_Click(object sender, EventArgs e)
        {
            try
            {
                common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView;
                if (resultDataGrid == null || resultDataGrid.CurrentRow == null || resultDataGrid.CurrentCell == null)
                {
                    return;
                }

                //TUAN - 29 Sept 2012 fix bug profit detail and all profit details
                if (resultDataGrid.CurrentCell.ColumnIndex < 0)
                {
                    return;
                }
                //TUAN - 29 Sept 2012 fix bug profit detail and all profit details

                string stockCode = resultTab.SelectedTab.Name;
                databases.tmpDS.stockCodeRow stockCodeRow = DataAccess.Libs.myStockCodeTbl.FindBycode(stockCode);
                if (stockCodeRow == null)
                {
                    return;
                }
                application.Strategy.StrategyMeta meta = application.Strategy.StrategyLibs.FindMetaByName(resultDataGrid.CurrentRow.Cells[0].Value.ToString());

                //TUAN - 29 Sept 2012 fix bug profit detail and all profit details
                int colId = resultDataGrid.CurrentCell.ColumnIndex == 0 ? 1 : resultDataGrid.CurrentCell.ColumnIndex;
                //TUAN - 29 Sept 2012 fix bug profit detail and all profit details
                DataParams dataParam = new DataParams(timeScaleCb.myValue.Code, AppTypes.TimeRangeFromCode(resultDataGrid.Columns[colId].DataPropertyName), 0);
                ShowTradeTransactions(stockCodeRow, meta.Code, dataParam);
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
Example #11
0
        private void openMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string stockCode = resultTab.SelectedTab.Name;

                if (this.CurrentDataGridView == null)
                {
                    return;
                }
                AppTypes.TimeRanges timeRange = AppTypes.TimeRanges.All;
                common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView;
                if (resultDataGrid.CurrentCell != null && resultDataGrid.CurrentCell.ColumnIndex > 0)
                {
                    int colId = resultDataGrid.CurrentCell.ColumnIndex;
                    timeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[colId].DataPropertyName);
                }
                ShowStock(stockCode, timeRange, timeScaleCb.myValue);
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
Example #12
0
        private static DataTable CreateDataTable(StringCollection timeRangeList, string[] strategyList)
        {
            // Define the new datatable
            DataTable tbl = new DataTable();

            // Define columns
            DataColumn col = new DataColumn("item");

            tbl.Columns.Add(col);
            for (int idx = 0; idx < timeRangeList.Count; idx++)
            {
                string colName = timeRangeList[idx];
                col         = new DataColumn(colName, typeof(Decimal));
                col.Caption = AppTypes.Type2Text(AppTypes.TimeRangeFromCode(timeRangeList[idx]));
                tbl.Columns.Add(col);
            }
            application.Strategy.StrategyMeta meta;
            for (int rowId = 0; rowId < strategyList.Length; rowId++)
            {
                meta = application.Strategy.StrategyLibs.FindMetaByCode(strategyList[rowId]);
                tbl.Rows.Add(meta.Name.Trim());
            }
            return(tbl);
        }
Example #13
0
        //From database
        public static bool Load_Global_Settings(ref GlobalSettings settings)
        {
            int num;
            StringCollection aFields = new StringCollection();

            // System
            aFields.Clear();
            aFields.Add(common.system.GetName(new { settings.WriteLogAccess }));
            aFields.Add(common.system.GetName(new { settings.PasswordMinLen }));
            aFields.Add(common.system.GetName(new { settings.UseStrongPassword }));
            if (!GetConfig(ref aFields))
            {
                return(false);
            }

            if (int.TryParse(aFields[0], out num))
            {
                settings.WriteLogAccess = (AppTypes.SyslogMedia)num;
            }
            if (int.TryParse(aFields[1], out num))
            {
                settings.PasswordMinLen = (byte)num;
            }
            if (aFields[2].Trim() != "")
            {
                settings.UseStrongPassword = (aFields[2] == Boolean.TrueString);
            }

            // Data count
            aFields.Clear();
            aFields.Add(common.system.GetName(new { settings.DayScanForLastPrice }));
            aFields.Add(common.system.GetName(new { settings.AlertDataCount }));
            aFields.Add(common.system.GetName(new { settings.ChartMaxLoadCount_FIRST }));
            aFields.Add(common.system.GetName(new { settings.ChartMaxLoadCount_MORE }));
            if (!GetConfig(ref aFields))
            {
                return(false);
            }

            if (aFields[0].Trim() != "" & int.TryParse(aFields[0], out num))
            {
                settings.DayScanForLastPrice = (short)num;
            }
            if (aFields[1].Trim() != "" & int.TryParse(aFields[1], out num))
            {
                settings.AlertDataCount = (short)num;
            }
            if (aFields[2].Trim() != "" & int.TryParse(aFields[2], out num))
            {
                settings.ChartMaxLoadCount_FIRST = (short)num;
            }
            if (aFields[3].Trim() != "" & int.TryParse(aFields[3], out num))
            {
                settings.ChartMaxLoadCount_MORE = (short)num;
            }


            //Auto key
            aFields.Clear();
            aFields.Add(common.system.GetName(new { settings.DataKeyPrefix }));
            aFields.Add(common.system.GetName(new { settings.DataKeySize }));
            aFields.Add(common.system.GetName(new { settings.AutoEditKeySize }));
            aFields.Add(common.system.GetName(new { settings.TimeOut_AutoKey }));
            if (!GetConfig(ref aFields))
            {
                return(false);
            }
            if (aFields[0].Trim() != "")
            {
                settings.DataKeyPrefix = aFields[0].Trim();
            }
            if (int.TryParse(aFields[1], out num))
            {
                settings.DataKeySize = num;
            }
            if (int.TryParse(aFields[2], out num))
            {
                settings.AutoEditKeySize = num;
            }
            if (int.TryParse(aFields[3], out num))
            {
                settings.TimeOut_AutoKey = num;
            }

            //Email
            aFields.Clear();
            aFields.Add(common.system.GetName(new { settings.smtpAddress }));
            aFields.Add(common.system.GetName(new { settings.smtpPort }));
            aFields.Add(common.system.GetName(new { settings.smtpAuthAccount }));
            aFields.Add(common.system.GetName(new { settings.smtpAuthPassword }));
            aFields.Add(common.system.GetName(new { settings.smtpSSL }));
            if (!GetConfig(ref aFields))
            {
                return(false);
            }

            if (aFields[0].Trim() != "")
            {
                settings.smtpAddress = aFields[0];
            }
            if (aFields[1].Trim() != "" & int.TryParse(aFields[1], out num))
            {
                settings.smtpPort = num;
            }
            settings.smtpAuthAccount  = aFields[2].Trim();
            settings.smtpAuthPassword = aFields[3].Trim();
            settings.smtpSSL          = (aFields[4].Trim() == Boolean.TrueString);

            //Default
            aFields.Clear();
            aFields.Add(common.system.GetName(new { settings.DefautLanguage }));
            aFields.Add(common.system.GetName(new { settings.DefaultTimeRange }));
            aFields.Add(common.system.GetName(new { settings.DefaultTimeScaleCode }));
            aFields.Add(common.system.GetName(new { settings.ScreeningTimeScaleCode }));

            aFields.Add(common.system.GetName(new { settings.AlertDataCount }));
            aFields.Add(common.system.GetName(new { settings.ScreeningDataCount }));

            if (!GetConfig(ref aFields))
            {
                return(false);
            }

            if (aFields[0].Trim() != "")
            {
                settings.DefautLanguage = AppTypes.Code2Language(aFields[0].Trim());
            }
            if (aFields[1].Trim() != "")
            {
                settings.DefaultTimeRange = AppTypes.TimeRangeFromCode(aFields[1]);
            }
            if (aFields[2].Trim() != "")
            {
                settings.DefaultTimeScaleCode = aFields[2];
            }
            if (aFields[3].Trim() != "")
            {
                settings.ScreeningTimeScaleCode = aFields[3];
            }

            if (aFields[4].Trim() != "" & int.TryParse(aFields[4], out num))
            {
                settings.AlertDataCount = (short)num;
            }
            if (aFields[5].Trim() != "" & int.TryParse(aFields[5], out num))
            {
                settings.ScreeningDataCount = (short)num;
            }

            //Timming
            aFields.Clear();
            aFields.Add(common.system.GetName(new { settings.TimerIntervalInSecs }));
            aFields.Add(common.system.GetName(new { settings.RefreshDataInSecs }));
            aFields.Add(common.system.GetName(new { settings.CheckAlertInSeconds }));
            aFields.Add(common.system.GetName(new { settings.AutoCheckInSeconds }));
            if (!GetConfig(ref aFields))
            {
                return(false);
            }

            if (aFields[0].Trim() != "" & int.TryParse(aFields[0], out num))
            {
                settings.TimerIntervalInSecs = (short)num;
            }
            if (aFields[1].Trim() != "" & int.TryParse(aFields[1], out num))
            {
                settings.RefreshDataInSecs = (short)num;
            }
            if (aFields[2].Trim() != "" & int.TryParse(aFields[2], out num))
            {
                settings.CheckAlertInSeconds = (short)num;
            }
            if (aFields[3].Trim() != "" & int.TryParse(aFields[3], out num))
            {
                settings.AutoCheckInSeconds = (short)num;
            }
            return(true);
        }
Example #14
0
        private void allProfitDetailMenu_Click(object sender, EventArgs e)
        {
            try
            {
                using (new DataAccess.PleaseWait())
                {
                    common.controls.baseDataGridView resultDataGrid = this.CurrentDataGridView;
                    if (resultDataGrid == null)
                    {
                        return;
                    }

                    string stockCode = resultTab.SelectedTab.Name;
                    databases.tmpDS.stockCodeRow stockCodeRow = DataAccess.Libs.myStockCodeTbl.FindBycode(stockCode);
                    if (stockCodeRow == null)
                    {
                        return;
                    }

                    DataParams dataParam = new DataParams(timeScaleCb.myValue.Code, AppTypes.TimeRanges.None, 0);
                    //TUAN - 29 Sept 2012 fix bug profit detail and all profit details
                    int min = int.MaxValue;
                    int max = -1;
                    for (int i = 0; i < resultDataGrid.SelectedCells.Count; i++)
                    {
                        if (resultDataGrid.SelectedCells[i].RowIndex > max)
                        {
                            max = resultDataGrid.SelectedCells[i].RowIndex;
                        }
                        if (resultDataGrid.SelectedCells[i].RowIndex < min)
                        {
                            min = resultDataGrid.SelectedCells[i].RowIndex;
                        }
                    }
                    //if (resultDataGrid.SelectedRows.Count > 0)
                    if (min < max)
                    {
                        for (int rowId = min; rowId <= max; rowId++)
                        {
                            application.Strategy.StrategyMeta meta = application.Strategy.StrategyLibs.FindMetaByName(resultDataGrid.Rows[rowId].Cells[0].Value.ToString());
                            for (int idx = 1; idx < resultDataGrid.ColumnCount; idx++)
                            {
                                dataParam.TimeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[idx].DataPropertyName);
                                ShowTradeTransactions(stockCodeRow, meta.Code, dataParam);
                            }
                        }
                        //for (int rowId = 0; rowId < resultDataGrid.SelectedRows.Count; rowId++)
                        //{
                        //    application.Strategy.StrategyMeta meta = application.Strategy.StrategyLibs.FindMetaByName(resultDataGrid.SelectedRows[rowId].Cells[0].Value.ToString());
                        //    for (int idx = 1; idx < resultDataGrid.ColumnCount; idx++)
                        //    {
                        //        dataParam.TimeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[idx].DataPropertyName);
                        //        ShowTradeTransactions(stockCodeRow, meta.Code, dataParam);
                        //    }
                        //}
                    }
                    //TUAN - 29 Sept 2012 fix bug profit detail and all profit details
                    else
                    {
                        if (resultDataGrid.CurrentRow != null)
                        {
                            application.Strategy.StrategyMeta meta = application.Strategy.StrategyLibs.FindMetaByName(resultDataGrid.CurrentRow.Cells[0].Value.ToString());
                            for (int idx = 1; idx < resultDataGrid.ColumnCount; idx++)
                            {
                                dataParam.TimeRange = AppTypes.TimeRangeFromCode(resultDataGrid.Columns[idx].DataPropertyName);
                                ShowTradeTransactions(stockCodeRow, meta.Code, dataParam);
                            }
                        }
                    }
                }
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
Example #15
0
        /// <summary>
        /// Thuc hien viec sap xep chien luoc
        /// </summary>
        private void DoRanking()
        {
            this.ShowReccount("");

            this.myValueType = ValueTypes.Amount;
            this.Amount2PercentDenominator = Settings.sysStockTotalCapAmt;

            resultTab.TabPages.Clear();
            StringCollection stockCodeList = codeListLb.myValues;
            StringCollection timeRangeList = timeRangeLb.myCheckedValues;

            string[] strategyList = common.system.Collection2List(strategyClb.myCheckedValues);
            progressBar.Value = 0; progressBar.Minimum = 0; progressBar.Maximum = stockCodeList.Count;

            string          timeScaleCode  = timeScaleCb.myValue.Code;
            EstimateOptions estimateOption = new EstimateOptions();

            DataAccess.Libs.ClearCache();

            ArrayList resulTblList = new ArrayList();

            this.ShowReccount(progressBar.Value.ToString() + "/" + progressBar.Maximum.ToString());
            int codeStartIdx = 0, codeEndIdx = 0;

            while (codeStartIdx < stockCodeList.Count)
            {
                codeEndIdx += Settings.sysNumberOfItemsInBatchProcess;
                if (codeEndIdx >= stockCodeList.Count)
                {
                    codeEndIdx = stockCodeList.Count - 1;
                }

                //Create Tab and grid for each code
                resulTblList.Clear();
                string[] processCodeList = new string[codeEndIdx - codeStartIdx + 1];
                for (int idx1 = codeStartIdx, idx2 = 0; idx1 <= codeEndIdx; idx1++, idx2++)
                {
                    resulTblList.Add(CreateDataTable(timeRangeList, strategyList));
                    CreateResultGrid(stockCodeList[idx1], resulTblList[idx2] as DataTable);
                    processCodeList[idx2] = stockCodeList[idx1];
                }

                for (int colId = 0; colId < timeRangeList.Count; colId++)
                {
                    AppTypes.TimeRanges timeRange  = AppTypes.TimeRangeFromCode(timeRangeList[colId]);
                    decimal[][]         profitList = DataAccess.Libs.Estimate_Matrix_Profit(timeRange, timeScaleCode, processCodeList, strategyList, estimateOption);
                    for (int idx1 = 0; idx1 < profitList.Length; idx1++)
                    {
                        DataTable tbl = resulTblList[idx1] as DataTable;
                        for (int idx2 = 0; idx2 < profitList[idx1].Length; idx2++)
                        {
                            tbl.Rows[idx2][colId + 1] = profitList[idx1][idx2];
                        }
                    }
                    Application.DoEvents();
                }
                progressBar.Value = codeEndIdx + 1;
                this.ShowReccount(progressBar.Value.ToString() + "/" + progressBar.Maximum.ToString());
                codeStartIdx = codeEndIdx + 1;
            }
        }