当前位置: 首页>>代码示例>>C#>>正文


C# StockSerie.Initialise方法代码示例

本文整理汇总了C#中StockSerie.Initialise方法的典型用法代码示例。如果您正苦于以下问题:C# StockSerie.Initialise方法的具体用法?C# StockSerie.Initialise怎么用?C# StockSerie.Initialise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StockSerie的用法示例。


在下文中一共展示了StockSerie.Initialise方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateInitialisedFrom

        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;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:27,代码来源:StockViewableItemsManager.cs

示例2: DownloadIntradayData

        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;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:14,代码来源:BreadthDataProvider.cs

示例3: ToSerie

        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
                        {
//.........这里部分代码省略.........
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:101,代码来源:StockPortofolio.cs

示例4: DownloadDailyData

        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;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:65,代码来源:RydexDataProvider.cs

示例5: DownloadDailyData

        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;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:53,代码来源:CBOEDataProvider.cs

示例6: DownloadIntradayData

        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;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:35,代码来源:YahooDataProvider.cs

示例7: GenerateSimulation

        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;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:66,代码来源:BatchStrategySimulatorDlg.cs

示例8: StockAnalyzerForm_StockSerieChanged

        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;
            }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:89,代码来源:MainFrame.cs

示例9: GenerateVixPremium

        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);
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:38,代码来源:MainFrame.cs

示例10: DownloadIntradayData

        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;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:55,代码来源:ABCDataProvider.cs

示例11: DownloadDailyData

        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))
//.........这里部分代码省略.........
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:101,代码来源:ABCDataProvider.cs


注:本文中的StockSerie.Initialise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。