public override bool LoadData(string rootFolder, StockSerie stockSerie) { string archiveFileName = rootFolder + ARCHIVE_FOLDER + "\\" + stockSerie.ShortName.Replace(':', '_') + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + ".txt"; if (File.Exists(archiveFileName)) { stockSerie.ReadFromCSVFile(archiveFileName); } string fileName = rootFolder + INTRADAY_FOLDER + "\\" + stockSerie.ShortName.Replace(':', '_') + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + ".txt"; if (File.Exists(fileName)) { if (ParseIntradayData(stockSerie, fileName)) { stockSerie.Values.Last().IsComplete = false; var lastDate = stockSerie.Keys.Last(); DateTime firstArchiveDate = lastDate.AddMonths(-2).AddDays(-lastDate.Day + 1).Date; stockSerie.SaveToCSVFromDateToDate(archiveFileName, firstArchiveDate, lastDate.AddDays(-5).Date); // Archive other time frames string durationFileName; StockSerie.StockBarDuration previousDuration = stockSerie.BarDuration; foreach (StockSerie.StockBarDuration duration in cacheDurations) { durationFileName = rootFolder + ARCHIVE_FOLDER + "\\" + duration + "\\" + stockSerie.ShortName.Replace(':', '_') + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + ".txt"; if (File.Exists(durationFileName) && File.GetLastWriteTime(durationFileName).Date == DateTime.Today.Date) break; // Only cache once a day. stockSerie.BarDuration = duration; stockSerie.SaveToCSVFromDateToDate(durationFileName, stockSerie.Keys.First(), lastDate.AddDays(-1).Date); } // Set back to previous duration. if (previousDuration != stockSerie.BarDuration) { stockSerie.BarDuration = previousDuration; } } else { return false; } } return true; }