コード例 #1
0
        private static DataTable GetResults(int symbolId, string methodName)
        {
            var paramCollection = new List <KeyValuePair <string, string> >();

            paramCollection.Add(new KeyValuePair <string, string>(Common.SymbolIdColumn, symbolId.ToString()));
            paramCollection.Add(new KeyValuePair <string, string>(Common.MethodNameColumn, methodName));

            var dt = AnalysisCommon.MakeAnalysisResultsTable();

            SqlExecutor.ExecuteQueryFillDataTable(selectStatisticSqlScript, paramCollection, dt);
            return(dt);
        }
コード例 #2
0
        private static async Task <bool> CalculateStatistic(int symbolId, string methodName)
        {
            int TotalQualified, TotalValid, Last1YearQualified, Last1YearValid,
                Last3YearQualified, Last3YearValid, Last6YearQualified, Last6YearValid,
                Last10YearQualified, Last10YearValid;

            TotalQualified              = TotalValid = Last1YearQualified = Last1YearValid =
                Last3YearQualified      = Last3YearValid = Last6YearQualified = Last6YearValid =
                    Last10YearQualified = Last10YearValid = 0;
            //var statisticTable = AnalysisCommon.MakeAnalysisStatisticTable();

            var resultTable = GetResults(symbolId, methodName);

            if (resultTable.Rows.Count == 0)
            {
                return(false);
            }

            Console.WriteLine("Calculate Statistic for Symbol {0} and Method {1}", symbolId, methodName);
            int count = resultTable.Rows.Count;

            for (int i = 0; i < count; i++)
            {
                bool isValid     = false;
                bool isQualified = false;

                if (Convert.ToBoolean(resultTable.Rows[i][Common.ValidColumn]))
                {
                    isValid = true;
                    TotalValid++;
                }

                if (Convert.ToBoolean(resultTable.Rows[i][Common.QualifiedColumn]))
                {
                    isQualified = true;
                    TotalQualified++;
                }

                AnalysisCommon.CheckValidPeriod(isValid, isQualified, Convert.ToDateTime(resultTable.Rows[i][Common.DateColumn]),
                                                ref Last1YearQualified, ref Last1YearValid,
                                                ref Last3YearQualified, ref Last3YearValid,
                                                ref Last6YearQualified, ref Last6YearValid,
                                                ref Last10YearQualified, ref Last10YearValid);
            }

            var parames = new List <KeyValuePair <string, string> >();

            parames.Add(new KeyValuePair <string, string>(Common.MethodNameColumn, methodName));
            parames.Add(new KeyValuePair <string, string>(Common.SymbolIdColumn, symbolId.ToString()));
            parames.Add(new KeyValuePair <string, string>(Common.TotalValidColumn, TotalValid.ToString()));
            parames.Add(new KeyValuePair <string, string>(Common.TotalQualifiedColumn, TotalQualified.ToString()));
            parames.Add(new KeyValuePair <string, string>(Common.Last1YearValidColumn, Last1YearValid.ToString()));
            parames.Add(new KeyValuePair <string, string>(Common.Last1YearQualifiedColumn, Last1YearQualified.ToString()));
            parames.Add(new KeyValuePair <string, string>(Common.Last3YearValidColumn, Last3YearValid.ToString()));
            parames.Add(new KeyValuePair <string, string>(Common.Last3YearQualifiedColumn, Last3YearQualified.ToString()));
            parames.Add(new KeyValuePair <string, string>(Common.Last6YearValidColumn, Last6YearValid.ToString()));
            parames.Add(new KeyValuePair <string, string>(Common.Last6YearQualifiedColumn, Last6YearQualified.ToString()));
            parames.Add(new KeyValuePair <string, string>(Common.Last10YearQualifiedColumn, Last10YearQualified.ToString()));
            parames.Add(new KeyValuePair <string, string>(Common.Last10YearValidColumn, Last10YearValid.ToString()));

            SqlExecutor.ExecuteQuery(insertAnalysisStatisticSqlScript, parames);

            return(true);
        }