public void calculateScoreData() { display = ""; DateTime latestDate = DateTime.MinValue; if (scoreData.Count > 0) { latestDate = scoreData.Last().date; } var analyzedDataToCalculate = from q in analyzedData where q.date > latestDate select q; display += $"latest date = {latestDate}, to calculate = {analyzedDataToCalculate.Count()}\r\n"; foreach (var currentAnalyzedData in analyzedDataToCalculate) { bool hasInvalidData = currentAnalyzedData.parameters.Contains(null); if (hasInvalidData) { continue; } var currentData = currentAnalyzedData.date; int totalParameterCount = AnalyzedDataInformation.parameterIndexForScore.Count(); var newScoreData = new ScoreDataInformation(); newScoreData.date = currentData; decimal[] valueScore = new decimal[ScoreDataInformation.SCORE_DAY_RANGE_DEFINITION.Length]; decimal[] rankScore = new decimal[ScoreDataInformation.SCORE_DAY_RANGE_DEFINITION.Length]; foreach (var parameterName in AnalyzedDataInformation.parameterIndexForScore.Keys) { var lookUpTable = parameterFuturePriceDictionary[parameterName]; var index = AnalyzedDataInformation.parameterIndexForScore[parameterName]; var parameterValue = currentAnalyzedData.parameters[index].GetValueOrDefault(); decimal?[] logArray = lookUpLogFromParameter(parameterValue, lookUpTable); decimal?[] rankArray = lookUpRankFromParameter(parameterValue, lookUpTable); valueScore = valueScore.addUpDecimalArray(getScoreFromArray(logArray)); rankScore = rankScore.addUpDecimalArray(getScoreFromArray(rankArray)); } newScoreData.valueScore = valueScore.divideElementBy(AnalyzedDataInformation.parameterIndexForScore.Keys.Count).exp().round(2); newScoreData.rankScore = rankScore.divideElementBy(AnalyzedDataInformation.parameterIndexForScore.Keys.Count).round(2); scoreData.Add(newScoreData); } }
public DailyChartInformation(string stockID, AnalyzedDataInformation analyzedData, ScoreDataInformation scoreData) { this.stockID = stockID; this.volume = analyzedData.volume; this.open = analyzedData.open; this.high = analyzedData.high; this.low = analyzedData.low; this.close = analyzedData.close; this.change = analyzedData.change; this.avg = analyzedData.avg; this.divide = analyzedData.divide; this.recentEmpty = analyzedData.recentEmpty; this.recentMinVolume = analyzedData.recentMinVolume; this.isLowVolume = recentMinVolume < DataAnalyzer.MIN_VOLUME_THRESHOLD; this.N_avg = analyzedData.N_avg; this.N_open = analyzedData.N_open; this.N_high = analyzedData.N_high; this.N_low = analyzedData.N_low; this.N_close = analyzedData.N_close; for (int i = 0; i < valueScore.Length; i++) { this.valueScore[i] = scoreData.valueScore[i]; } for (int i = 0; i < rankScore.Length; i++) { this.rankScore[i] = scoreData.rankScore[i]; } }