public virtual async Task <bool> Analyze(DataTable dtPrices, DataTable rootTable) { var rows = dtPrices.Rows; if (rows.Count == 0) { return(false); } string symbolId = rows[0][Common.SymbolIdColumn].ToString(); var table = AnalysisCommon.MakeAnalysisResultsTable(); Console.WriteLine(string.Format("Analyzing Symbol {0} with method {1}", symbolId, Name)); for (int i = 0; i < rows.Count; i++) { bool isQualified = false; bool isValid = false; StockData currentPrice = TryGetPriceValues(rows, i); StockData beforePrice = TryGetPriceValues(rows, i - 1); StockData afterPrice = TryGetPriceValues(rows, i + 1); //if current date has no volume then skip it if (currentPrice != null && currentPrice.volume != null && currentPrice.volume == 0) { continue; } if (Qualified(rows, i, currentPrice, beforePrice, afterPrice)) { isQualified = true; isValid = Valid(rows, i); var newRow = table.NewRow(); newRow[Common.SymbolIdColumn] = symbolId; newRow[Common.MethodNameColumn] = Name; newRow[Common.DateColumn] = rows[i][Common.DateColumn].ToString(); newRow[Common.QualifiedColumn] = Convert.ToInt32(isQualified).ToString(); newRow[Common.ValidColumn] = Convert.ToInt32(isValid).ToString(); table.Rows.Add(newRow); } } if (table.Rows.Count > 0) { Console.WriteLine(string.Format("Write {0} rows to DB for symbol {1} and method {2}", table.Rows.Count, symbolId, Name)); var ret = await SqlExecutor.BulkCopy(table); } //AnalysisCommon.MergeAnalysisResultTable(rootTable, table); return(true); }