public static IStockViewableSeries CreateInitialisedFrom(IStockViewableSeries aViewableSerie, StockSerie stockSerie) { if (!stockSerie.Initialise()) return null; IStockViewableSeries viewableSerie = null; switch (aViewableSerie.Type) { case ViewableItemType.Indicator: viewableSerie = stockSerie.GetIndicator(aViewableSerie.Name); break; case ViewableItemType.Decorator: viewableSerie = stockSerie.GetDecorator(aViewableSerie.Name, ((IStockDecorator)aViewableSerie).DecoratedItem); break; case ViewableItemType.PaintBar: viewableSerie = stockSerie.GetPaintBar(aViewableSerie.Name); break; case ViewableItemType.TrailStop: viewableSerie = stockSerie.GetTrailStop(aViewableSerie.Name); break; case ViewableItemType.Trail: viewableSerie = stockSerie.GetTrail(aViewableSerie.Name, ((IStockTrail)aViewableSerie).TrailedItem); break; default: break; } return viewableSerie; }
public override bool DownloadIntradayData(string rootFolder, StockSerie stockSerie) { if (stockSerie.StockName.Contains("CAC40") || stockSerie.StockName.Contains("SBF120")) { StockDataProviderBase.DownloadSerieData(rootFolder, stockDictionary["CAC40"]); StockDataProviderBase.DownloadSerieData(rootFolder, stockDictionary["ACCOR"]); stockSerie.IsInitialised = false; stockSerie.ClearBarDurationCache(); return stockSerie.Initialise(); } return true; }
internal void ToSerie(StockSerie stockSerie, StockSerie referenceSerie = null) { float open = 0.0f; float high = 0.0f; float low = 0.0f; float close = 0.0f; int volume = 1; float cash = TotalDeposit; Dictionary<string, PositionValues> stockPositionDico = new Dictionary<string, PositionValues>(); // Statistics int nbTrades = 0; int nbWinTrades = 0; float maxDrawdown = float.MaxValue; float maxGain = float.MinValue; float maxLoss = float.MinValue; if (referenceSerie == null) { referenceSerie = StockDictionary.StockDictionarySingleton["CAC40"]; } referenceSerie.Initialise(); foreach (DateTime date in referenceSerie.GetValues(StockSerie.StockBarDuration.Daily).Where(d => d.DATE.Year > 2014).Select(v => v.DATE.Date)) { // Calculate open value // Retrieve orders for this date/time var orderList = this.OrderList.FindAll(order => order.ExecutionDate.Date == date).OrderBy(o => o.ID); // Manage new orders foreach (StockOrder stockOrder in orderList) { int numberOfShare = stockOrder.IsShortOrder ? -stockOrder.Number : stockOrder.Number; if (stockOrder.IsBuyOrder()) // Buy position { cash -= stockOrder.TotalCost; if (stockPositionDico.ContainsKey(stockOrder.StockName)) { stockPositionDico[stockOrder.StockName].Position += numberOfShare; stockPositionDico[stockOrder.StockName].OpenValue = (stockPositionDico[stockOrder.StockName].Position * stockPositionDico[stockOrder.StockName].OpenValue + numberOfShare * stockOrder.Value) / (stockPositionDico[stockOrder.StockName].Position + numberOfShare); } else { if (stockDictionary.ContainsKey(stockOrder.StockName) && stockDictionary[stockOrder.StockName].Initialise()) { stockPositionDico.Add(stockOrder.StockName, new PositionValues(numberOfShare, stockOrder.Value, stockDictionary[stockOrder.StockName].GetValues(StockSerie.StockBarDuration.Daily))); } else { StockLog.Write("Initialisation failed: " + stockOrder.StockName); stockPositionDico.Add(stockOrder.StockName, new PositionValues(numberOfShare, stockOrder.Value, null)); } } } else // Closing Position { if (stockPositionDico.ContainsKey(stockOrder.StockName)) { cash += stockOrder.TotalCost; PositionValues position = stockPositionDico[stockOrder.StockName]; if (position.Position == numberOfShare) { maxDrawdown = Math.Min(maxDrawdown, position.MaxDrawdown); stockPositionDico.Remove(stockOrder.StockName); nbTrades++; } else { position.Position -= numberOfShare; } if (stockOrder.IsShortOrder) { if (position.OpenValue > stockOrder.Value) { nbWinTrades++; maxGain = Math.Max(maxGain, (position.OpenValue - stockOrder.Value) / position.OpenValue); } else { maxLoss = Math.Max(maxLoss, -(position.OpenValue - stockOrder.Value) / position.OpenValue); } } else { if (position.OpenValue < stockOrder.Value) { nbWinTrades++; maxGain = Math.Max(maxGain, -(position.OpenValue - stockOrder.Value) / position.OpenValue); } else { maxLoss = Math.Max(maxLoss, (position.OpenValue - stockOrder.Value) / position.OpenValue); } } } else { // Open short position cash += stockOrder.TotalCost; if (stockDictionary.ContainsKey(stockOrder.StockName) && stockDictionary[stockOrder.StockName].Initialise()) { stockPositionDico.Add(stockOrder.StockName, new PositionValues(-numberOfShare, stockOrder.Value, stockDictionary[stockOrder.StockName].GetValues(StockSerie.StockBarDuration.Daily))); } else { StockLog.Write("Initialisation failed: " + stockOrder.StockName); stockPositionDico.Add(stockOrder.StockName, new PositionValues(-numberOfShare, stockOrder.Value, null)); } //throw new System.Exception("Sell order found on non bought stock " + stockOrder.StockName + " in " + this.Name); // @@@@ Need to have proper error manegement otherwise the applications crashes. //return referenceSerie; } } } // Calculate new value after taking into account the orders. low = cash; high = cash; close = cash; open = cash; if (stockPositionDico.Count != 0) { foreach (PositionValues position in stockPositionDico.Values) { StockDailyValue currentValue = position.AtDate(date); if (currentValue == null) { // Position on stock not in dico if (position.Position > 0) { close += position.OpenValue * position.Position; open += position.OpenValue * position.Position; low += position.OpenValue * position.Position; high += position.OpenValue * position.Position; } } else { // Position on stock in dico close += currentValue.CLOSE * position.Position; open += currentValue.OPEN * position.Position; if (position.Position > 0) { position.MaxValue = Math.Max(position.MaxValue, currentValue.HIGH); position.MinValue = Math.Min(position.MinValue, currentValue.LOW); low += currentValue.LOW * position.Position; high += currentValue.HIGH * position.Position; } else { // We are facing a short order, everything is reversed low += currentValue.HIGH * position.Position; high += currentValue.LOW * position.Position; position.MaxValue = Math.Max(position.MaxValue, currentValue.LOW); position.MinValue = Math.Min(position.MinValue, currentValue.HIGH); } } } } StockDailyValue dailyValue = new StockDailyValue(stockSerie.StockName, open, high, low, close, volume, date); stockSerie.Add(date, dailyValue); dailyValue.Serie = stockSerie; } StockLog.Write("Statistics for " + stockSerie.StockName); StockLog.Write("NbTrades: " + nbTrades); StockLog.Write("Win %: " + ((float)nbWinTrades / (float)nbTrades).ToString("P2")); StockLog.Write("MaxDrowdown: " + maxDrawdown.ToString("P2")); StockLog.Write("MaxGain: " + maxGain.ToString("P2")); StockLog.Write("MaxLoss: " + maxLoss.ToString("P2")); }
public override bool DownloadDailyData(string rootFolder, StockSerie stockSerie) { if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { bool isUpTodate = false; stockSerie.Initialise(); if (stockSerie.Count > 0) { // This serie already exist, download just the missing data. DateTime lastDate = stockSerie.Keys.Last(); isUpTodate = (lastDate >= DateTime.Today) || (lastDate.DayOfWeek == DayOfWeek.Friday && (DateTime.Now - lastDate).Days <= 3 && DateTime.UtcNow.Hour < 23) || (lastDate >= DateTime.Today.AddDays(-1) && DateTime.UtcNow.Hour < 23); NotifyProgress("Downloading " + stockSerie.StockGroup.ToString() + " - " + stockSerie.StockName); if (!isUpTodate) { NotifyProgress("Downloading " + stockSerie.StockGroup.ToString() + " - " + stockSerie.StockName); for (int year = lastDate.Year; year < DateTime.Today.Year; year++) { // Happy new year !!! it's time to archive old data... if (!File.Exists(rootFolder + ARCHIVE_FOLDER + "\\" + stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + "_" + year.ToString() + ".csv")) { this.DownloadFileFromRydex(rootFolder + ARCHIVE_FOLDER, stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + "_" + year.ToString() + ".csv", new DateTime(year, 1, 1), new DateTime(year, 12, 31), stockSerie.ShortName); } } DateTime startDate = new DateTime(DateTime.Today.Year, 01, 01); string fileName = stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + ".csv"; this.DownloadFileFromRydex(rootFolder + FOLDER, fileName, startDate, DateTime.Today, stockSerie.ShortName); if (stockSerie.StockName == "URSA") // Check if something new has been downloaded using URSA as the reference for all downloads { this.ParseRydexData(stockSerie, rootFolder + FOLDER + "\\" + fileName); if (lastDate == stockSerie.Keys.Last()) { this.needDownload = false; } } } else { if (stockSerie.StockName == "URSA") { this.needDownload = false; } } stockSerie.IsInitialised = isUpTodate; } else { NotifyProgress("Creating archive for " + stockSerie.StockName + " - " + stockSerie.StockGroup.ToString()); DateTime lastDate = new DateTime(DateTime.Today.Year, 01, 01); for (int i = lastDate.Year - 1; i > ARCHIVE_START_YEAR; i--) { if (!this.DownloadFileFromRydex(rootFolder + ARCHIVE_FOLDER, stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + "_" + i.ToString() + ".csv", new DateTime(i, 1, 1), new DateTime(i, 12, 31), stockSerie.ShortName)) { break; } } this.DownloadFileFromRydex(rootFolder + FOLDER, stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + ".csv", lastDate, DateTime.Today, stockSerie.ShortName); } } return true; }
public override bool DownloadDailyData(string rootFolder, StockSerie stockSerie) { if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { bool isUpTodate = false; stockSerie.Initialise(); DateTime lastDate; if (stockSerie.Count > 0) { // This serie already exist, download just the missing data. lastDate = stockSerie.Keys.Last(); } else { lastDate = DateTime.MinValue; } isUpTodate = (lastDate >= DateTime.Today) || (lastDate.DayOfWeek == DayOfWeek.Friday && (DateTime.Now - lastDate).Days <= 3 && DateTime.UtcNow.Hour < 23) || (lastDate == DateTime.Today.AddDays(-1) && DateTime.UtcNow.Hour < 23); if (!isUpTodate) { NotifyProgress("Downloading " + stockSerie.StockGroup.ToString() + " - " + stockSerie.StockName); string fileName = stockSerie.StockName + "_" + stockSerie.StockGroup + ".csv"; if (stockSerie.StockName.StartsWith("PCR.")) { this.DownloadCBOEPutCallRatioData(rootFolder + FOLDER, fileName); } else { this.DownloadFileFromCBOE(rootFolder + FOLDER, fileName, stockSerie.StockName); } if (stockSerie.StockName == "PCR.EQUITY") // Check if something new has been downloaded using PCR.EQUITY as the reference for all downloads { this.ParsePCRatioCSV(stockSerie, rootFolder + FOLDER + "\\" + fileName); if (lastDate == stockSerie.Keys.Last()) { this.needDownload = false; } } } else { if (stockSerie.StockName == "PCR.EQUITY") // Check if something new has been downloaded using PCR.EQUITY as the reference for all downloads { this.needDownload = false; } } stockSerie.IsInitialised = isUpTodate; } return true; }
public override bool DownloadIntradayData(string rootFolder, StockSerie stockSerie) { if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { NotifyProgress("Downloading intraday for " + stockSerie.StockName); if (!stockSerie.Initialise()) { return false; } if (DateTime.Today.DayOfWeek == DayOfWeek.Saturday || DateTime.Today.DayOfWeek == DayOfWeek.Sunday || stockSerie.Keys.Last() == DateTime.Today) { return false; } string folder = rootFolder + INTRADAY_FOLDER; string fileName = stockSerie.ShortName + ".csv"; if (File.Exists(folder + "\\" + fileName)) { if (File.GetLastWriteTime(folder + "\\" + fileName) > DateTime.Now.AddMinutes(-5)) return false; } using (WebClient wc = new WebClient()) { wc.Proxy.Credentials = CredentialCache.DefaultCredentials; string url = "http://download.finance.yahoo.com/d/quotes.csv?s=" + stockSerie.ShortName + "&f=d1t1oml1v&e=.csv"; wc.DownloadFile(url, folder + "\\" + fileName); stockSerie.IsInitialised = false; } } return true; }
private StockPortofolio GenerateSimulation(StockSerie stockSerie) { stockSerie.Initialise(); // Manage selected Stock and portofolio StockPortofolio portofolio = new StockPortofolio(stockSerie.StockName + "_P"); portofolio.TotalDeposit = this.simulationParameterControl.amount; stockPortofolioList.Add(portofolio); this.SelectedStrategy = StrategyManager.CreateStrategy(this.simulationParameterControl.SelectedStrategyName, stockSerie, null, simulationParameterControl.supportShortSelling); // intialise the serie stockSerie.Initialise(); StockOrder lastOrder = stockSerie.GenerateSimulation(SelectedStrategy, this.simulationParameterControl.StartDate, this.simulationParameterControl.EndDate.AddHours(18), this.simulationParameterControl.amount, this.simulationParameterControl.reinvest, this.simulationParameterControl.amendOrders, this.simulationParameterControl.supportShortSelling, this.simulationParameterControl.takeProfit, this.simulationParameterControl.profitRate, this.simulationParameterControl.stopLoss, this.simulationParameterControl.stopLossRate, this.simulationParameterControl.fixedFee, this.simulationParameterControl.taxRate, portofolio); // Do a bit of cleanup if (lastOrder != null && this.simulationParameterControl.removePendingOrders) { if (lastOrder.IsBuyOrder()) { lastOrder = null; } else { if (lastOrder.State != StockOrder.OrderStatus.Executed) { portofolio.OrderList.Remove(portofolio.OrderList.Last()); lastOrder = null; } } } // Display pending order if (this.simulationParameterControl.displayPendingOrders && lastOrder != null && lastOrder.State == StockOrder.OrderStatus.Pending) { if (SelectedStockChanged != null) { SelectedStockChanged(lastOrder.StockName, true); } OrderEditionDlg orderEditionDlg = new OrderEditionDlg(lastOrder); orderEditionDlg.StartPosition = FormStartPosition.Manual; orderEditionDlg.Location = new Point(0, 0); orderEditionDlg.ShowDialog(); } // Create Portofoglio serie portofolio.Initialize(stockDictionary); if (stockDictionary.Keys.Contains(portofolio.Name)) { stockDictionary.Remove(portofolio.Name); } stockDictionary.Add(portofolio.Name, portofolio.GeneratePortfolioStockSerie(portofolio.Name, stockSerie, stockSerie.StockGroup)); // Generate report if (this.generateReportCheckBox.Checked) { this.simulationParameterControl.GenerateReportLine("BatchReport_" + SelectedStrategy + ".csv", stockSerie, portofolio); } return portofolio; }
private void StockAnalyzerForm_StockSerieChanged(StockSerie newSerie, bool ignoreLinkedTheme) { // if (newSerie == null) { DeactivateGraphControls("No data to display"); this.Text = "Ultimate Chartist - " + "No stock selected"; return; } if (!newSerie.IsInitialised) { this.statusLabel.Text = ("Loading data..."); this.Refresh(); this.Cursor = Cursors.WaitCursor; } this.currentStockSerie = newSerie; if (!newSerie.Initialise()) { DeactivateGraphControls("No data to display"); this.Text = "Ultimate Chartist - " + "Failure Loading data selected"; return; } // TODO Manage COT Series if (this.currentStockSerie.StockName.EndsWith("_COT")) { this.ForceBarDuration(StockSerie.StockBarDuration.Weekly, false); } else { this.currentStockSerie.BarDuration = (StockSerie.StockBarDuration)this.barDurationComboBox.SelectedItem; } if (!ignoreLinkedTheme && newSerie.StockAnalysis != null && !string.IsNullOrEmpty(newSerie.StockAnalysis.Theme) && this.themeComboBox.SelectedText != newSerie.StockAnalysis.Theme && this.themeComboBox.Items.Contains(newSerie.StockAnalysis.Theme)) { if (this.themeComboBox.SelectedItem.ToString() == newSerie.StockAnalysis.Theme) { ApplyTheme(); } else { this.themeComboBox.SelectedItem = newSerie.StockAnalysis.Theme; } } else { ApplyTheme(); } string id; if (CurrentStockSerie.ShortName == CurrentStockSerie.StockName) { id = CurrentStockSerie.StockGroup + "-" + CurrentStockSerie.ShortName; } else { id = CurrentStockSerie.StockGroup + "-" + CurrentStockSerie.ShortName + " - " + CurrentStockSerie.StockName; } if (!string.IsNullOrWhiteSpace(this.CurrentStockSerie.ISIN)) { id += " - " + this.CurrentStockSerie.ISIN; } this.Text = "Ultimate Chartist - " + Settings.Default.AnalysisFile.Split('\\').Last() + " - " + id; // Set the Check Box UpDownState this.followUpCheckBox.CheckBox.Checked = CurrentStockSerie.StockAnalysis.FollowUp; // Set the comment button color if (CurrentStockSerie.StockAnalysis.Comments.Count == 0) { this.commentBtn.BackColor = System.Drawing.SystemColors.Control; } else { this.commentBtn.BackColor = System.Drawing.SystemColors.GradientInactiveCaption; } // Set the default theme checkstate if (this.currentStockSerie.StockAnalysis != null && this.currentStockSerie.StockAnalysis.Theme == currentTheme) { this.defaultThemeStripButton.CheckState = CheckState.Checked; } else { this.defaultThemeStripButton.CheckState = CheckState.Unchecked; } }
private void GenerateVixPremium() { if (!this.StockDictionary.ContainsKey("VIX")) { return; } StockSerie vixSerie = this.StockDictionary["VIX"]; if (!vixSerie.Initialise()) { return; } StockSerie spSerie = this.StockDictionary["SP500"]; if (!spSerie.Initialise()) { return; } StockSerie vixPremium = new StockSerie("VIX_PREMIUM", "VIX_PREMIUM", StockSerie.Groups.INDICATOR, StockDataProvider.Generated); // Generate the VIX Premium FloatSerie spVolatilitySerie = spSerie.GetSerie(StockIndicatorType.VOLATILITY_STDEV); float spVolatility = 0; int index = 0; foreach (StockDailyValue vixValue in vixSerie.Values) { index = spSerie.IndexOf(vixValue.DATE); if (index != -1) { spVolatility = spVolatilitySerie[index]; StockDailyValue dailyValue = new StockDailyValue(vixPremium.StockName, vixValue.OPEN / spVolatility, vixValue.HIGH / spVolatility, vixValue.LOW / spVolatility, vixValue.CLOSE / spVolatility, 0, vixValue.DATE); vixPremium.Add(dailyValue.DATE, dailyValue); dailyValue.Serie = vixPremium; } } vixPremium.Initialise(); this.StockDictionary.Add(vixPremium.StockName, vixPremium); }
public override bool DownloadIntradayData(string rootFolder, StockSerie stockSerie) { StockLog.Write("DownloadIntradayData Group: " + stockSerie.StockGroup + " - " + stockSerie.StockName); if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { NotifyProgress("Downloading intraday for" + stockSerie.StockGroup.ToString()); if (!stockSerie.Initialise()) { return false; } if (DateTime.Today.DayOfWeek == DayOfWeek.Saturday || DateTime.Today.DayOfWeek == DayOfWeek.Sunday || stockSerie.Keys.Last() == DateTime.Today) { return false; } string folder = rootFolder + ABC_INTRADAY_FOLDER; string fileName; string item; if (stockSerie.BelongsToGroup(StockSerie.Groups.SRD)) { fileName = DateTime.Today.ToString("yyMMdd_") + "SRD.csv"; item = "complet"; } else { fileName = DateTime.Today.ToString("yyMMdd_") + "IndicesFr.csv"; item = "indicesfrp"; } if (File.Exists(folder + "\\" + fileName)) { if (File.GetLastWriteTime(folder + "\\" + fileName) > DateTime.Now.AddMinutes(-4)) return false; } // TODO Check the time of the day to avoid useless download if (this.DownloadIntradayFileFromABC(folder, fileName, item)) { // Deinitialise all the SBF120 stock foreach (StockSerie serie in stockDictionary.Values.Where(s => s.BelongsToGroup(stockSerie.StockGroup))) { serie.IsInitialised = false; } loadedGroups.Clear(); //foreach (StockSerie serie in stockDictionary.Values.Where(s => s.DataProvider == StockDataProvider.Breadth && s.StockName.Contains("SBF120") || s.StockName.Contains("CAC40"))) //{ // serie.IsInitialised = false; //} } } return true; }
public override bool DownloadDailyData(string rootFolder, StockSerie stockSerie) { StockLog.Write("DownloadDailyData Group: " + stockSerie.StockGroup + " - " + stockSerie.StockName); if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { bool isUpTodate = false; stockSerie.Initialise(); if (stockSerie.Count > 0) { DateTime lastDate = stockSerie.Keys.Last(); if (lastDate.TimeOfDay != TimeSpan.Zero) { stockSerie.Remove(lastDate); lastDate = stockSerie.Keys.Last(); } isUpTodate = (lastDate >= DateTime.Today) || (lastDate.DayOfWeek == DayOfWeek.Friday && (DateTime.Now - lastDate).Days <= 3 && (DateTime.Today.DayOfWeek == DayOfWeek.Monday && DateTime.Now.Hour < 18)) || (lastDate == DateTime.Today.AddDays(-1) && DateTime.Now.Hour < 18); if (!isUpTodate) { NotifyProgress("Downloading " + stockSerie.StockGroup.ToString() + " - " + stockSerie.StockName); // Happy new year !!! it's time to archive old data... for (int year = lastDate.Year; year < DateTime.Today.Year; year++) { if ( !File.Exists(rootFolder + ARCHIVE_FOLDER + "\\" + stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + "_" + year.ToString() + ".csv")) { this.DownloadFileFromProvider(rootFolder + ARCHIVE_FOLDER, stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + "_" + year.ToString() + ".csv", new DateTime(year, 1, 1), new DateTime(year, 12, 31), stockSerie.ShortName); } } DateTime startDate = new DateTime(DateTime.Today.Year, 01, 01); string fileName = stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + ".csv"; this.DownloadFileFromProvider(rootFolder + ABC_DAILY_FOLDER, fileName, startDate, DateTime.Today, stockSerie.ISIN); if (stockSerie.StockName == "CAC40") // Check if something new has been downloaded using CAC40 as the reference for all downloads { this.ParseCSVFile(stockSerie, rootFolder + ABC_DAILY_FOLDER + "\\" + fileName); if (lastDate == stockSerie.Keys.Last()) { this.needDownload = false; } else { DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "eurolistap"); DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "eurolistbp"); DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "eurolistcp"); DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "alterp"); //DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "srdp"); DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "sp500u"); DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "indicessecp"); } } } else { if (stockSerie.StockName == "CAC40") // Check if something new has been downloaded using CAC40 as the reference for all downloads { this.needDownload = false; } } stockSerie.IsInitialised = isUpTodate; // && !needReloadIntraday; Why need reload intraday ??? } else { NotifyProgress("Creating archive for " + stockSerie.StockName + " - " + stockSerie.StockGroup.ToString()); DateTime lastDate = new DateTime(DateTime.Today.Year, 01, 01); if (stockSerie.StockName == "CAC40") { for (int m = DateTime.Today.Month - 1; m >= 1; m--) { DateTime month = new DateTime(lastDate.Year, m, 1); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "eurolistap"); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "eurolistbp"); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "eurolistcp"); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "alterp"); //DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "srdp"); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "sp500u"); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "indicessecp"); } } for (int i = lastDate.Year - 1; i > ARCHIVE_START_YEAR; i--) { if ( !this.DownloadFileFromProvider(rootFolder + ARCHIVE_FOLDER, stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + "_" + i.ToString() + ".csv", new DateTime(i, 1, 1), new DateTime(i, 12, 31), stockSerie.ISIN)) { break; } if (stockSerie.StockName == "CAC40") { for (int m = 12; m >= 1; m--) { DateTime month = new DateTime(i, m, 1); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "eurolistap"); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "eurolistbp"); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "eurolistcp"); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "alterp"); //DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "srdp"); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "sp500u"); DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "indicessecp"); } } } this.DownloadFileFromProvider(rootFolder + ABC_DAILY_FOLDER, stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + ".csv", lastDate, DateTime.Today, stockSerie.ISIN); } } return true; }