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]; } }
public void standarizeAnalyzeData() { display = ""; generateEmptyandRecentEmptyDateList(); DateTime lastDateInAnalyzedData = DateTime.MinValue; if (analyzedData.Count > 0) { lastDateInAnalyzedData = analyzedData.Last().date; addDisplay($"Last Date In Analyzed Data = {lastDateInAnalyzedData.ToShortDateString()}"); } else { addDisplay($"Emtpy Analyzed Data"); } addDisplay($"expected data to calculate = { basicDailyData.Count() - analyzedData.Count() }"); int startIndexInBasicDailyData = basicDailyData.FindIndex(x => x.date > lastDateInAnalyzedData); if (startIndexInBasicDailyData < 0) { addDisplay("no data to update"); return; } addDisplay($"start date In Basic Daily Data = {basicDailyData.Find(x => x.date > lastDateInAnalyzedData).date.ToShortDateString()}"); addDisplay($"start Index In Basic Daily Data = {startIndexInBasicDailyData}"); double startWeight = getStartWeight(); addDisplay($"start weight = {startWeight}"); for (int i = startIndexInBasicDailyData; i < basicDailyData.Count(); i++) { var newAnalyzedData = new AnalyzedDataInformation(basicDailyData[i]); if (stockType == "A") { newAnalyzedData.dealedStock /= 1000; newAnalyzedData.volume /= 1000; } if (i == 0) { newAnalyzedData.divideWeight = startWeight; newAnalyzedData.recentMinVolume = newAnalyzedData.volume; newAnalyzedData.recentMinVolumeDate = newAnalyzedData.date; } else { if (newAnalyzedData.close == 0) { newAnalyzedData.close = analyzedData.Last().close; newAnalyzedData.open = analyzedData.Last().open; newAnalyzedData.low = analyzedData.Last().low; newAnalyzedData.high = analyzedData.Last().high; newAnalyzedData.change = 0; } newAnalyzedData.recentMinVolume = analyzedData.Last().recentMinVolume; newAnalyzedData.recentMinVolumeDate = analyzedData.Last().recentMinVolumeDate; if (newAnalyzedData.volume < newAnalyzedData.recentMinVolume) { newAnalyzedData.recentMinVolume = newAnalyzedData.volume; newAnalyzedData.recentMinVolumeDate = newAnalyzedData.date; } else if (i - basicDailyData.FindIndex(x => x.date == newAnalyzedData.recentMinVolumeDate) >= AnalyzedDataInformation.RECENT_MIN_VOL_DAY) { int startIndex = Math.Max(0, i - AnalyzedDataInformation.RECENT_MIN_VOL_DAY); for (int j = startIndex; j < i; j++) { if (j == startIndex) { newAnalyzedData.recentMinVolume = analyzedData[j].volume; newAnalyzedData.recentMinVolumeDate = analyzedData[j].date; } if (analyzedData[j].volume < newAnalyzedData.recentMinVolume) { newAnalyzedData.recentMinVolume = analyzedData[j].volume; newAnalyzedData.recentMinVolumeDate = analyzedData[j].date; } } } decimal expectChange = newAnalyzedData.close - analyzedData.Last().close; newAnalyzedData.divide = (expectChange - newAnalyzedData.change) * -1; if (basicDailyData[i - 1].close == 0) { newAnalyzedData.divide = 0; } if (newAnalyzedData.divide == 0) { newAnalyzedData.divideWeight = analyzedData.Last().divideWeight; } else // divide { newAnalyzedData.divideWeight = analyzedData.Last().divideWeight * (1 + newAnalyzedData.divide.getDoubleFromDecimal() / newAnalyzedData.close.getDoubleFromDecimal()); } } if (newAnalyzedData.dealedOrder != 0) { newAnalyzedData.volumePerOrder = newAnalyzedData.volume / newAnalyzedData.dealedOrder; } else { newAnalyzedData.volumePerOrder = 0; } newAnalyzedData.setNprice(); if (recentEmptyDateList.Contains(newAnalyzedData.date)) { newAnalyzedData.recentEmpty = true; } analyzedData.Add(newAnalyzedData); } addDisplay($"last date = {analyzedData.Last().date.ToShortDateString()}"); }