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


C# StockSerie.BelongsToGroup方法代码示例

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


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

示例1: LoadData


//.........这里部分代码省略.........
                    if (!loadedGroups.Contains(abcGroup))
                    {
                        if (loadingGroup == null)
                        {
                            loadingGroup = abcGroup;
                        }
                        else
                        {
                            StockLog.Write("Already busy loading group: " + stockSerie.StockGroup);
                            if (loadingGroup == abcGroup)
                            {
                                do
                                {
                                    Thread.Sleep(100);
                                } while (loadingGroup == abcGroup);
                                return stockSerie.Count != 0;
                            }
                            else
                            {
                                do
                                {
                                    Thread.Sleep(100);
                                } while (loadingGroup == abcGroup);
                            }
                        }

                        //
                        StockLog.Write("Sync OK Group: " + stockSerie.StockGroup + " - " + stockSerie.StockName);
                        fileName = abcGroup + "_*.csv";
                        var groupFiles =
                           System.IO.Directory.GetFiles(rootFolder + ARCHIVE_FOLDER, fileName).OrderByDescending(s => s);
                        foreach (string archiveFileName in groupFiles)
                        {
                            NotifyProgress("Loading data for " + Path.GetFileNameWithoutExtension(archiveFileName));
                            if (!ParseABCGroupCSVFile(archiveFileName, stockSerie.StockGroup)) break;
                            else
                            {
                                res = true;
                            }
                        }
                        groupFiles =
                           System.IO.Directory.GetFiles(rootFolder + ABC_DAILY_FOLDER, fileName).OrderByDescending(s => s);
                        foreach (string currentFileName in groupFiles)
                        {
                            res = ParseABCGroupCSVFile(currentFileName, stockSerie.StockGroup);
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    StockLog.Write(ex);
                }
                finally
                {
                    loadingGroup = null;
                    loadedGroups.Add(abcGroup);
                }
                // @@@@ stockSerie.ClearBarDurationCache(); Removed as I don't know why it's here.
            }

            if (stockSerie.Count == 0)
            {
                // Read archive first
                fileName = stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() +
                           "_*.csv";
                files = System.IO.Directory.GetFiles(rootFolder + ARCHIVE_FOLDER, fileName);
                foreach (string archiveFileName in files)
                {
                    res |= ParseCSVFile(stockSerie, archiveFileName);
                }

                // Read daily value
                fileName = rootFolder + ABC_DAILY_FOLDER + "\\" + stockSerie.ShortName + "_" + stockSerie.StockName + "_" +
                           stockSerie.StockGroup.ToString() + ".csv";
                res |= ParseCSVFile(stockSerie, fileName);
            }
            // Read intraday
            if (res && stockSerie.Keys.Last() != DateTime.Today)
            {
                if (stockSerie.BelongsToGroup(StockSerie.Groups.SRD))
                {
                    fileName = rootFolder + ABC_INTRADAY_FOLDER + "\\" + DateTime.Today.ToString("yyMMdd_") + "SRD.csv";
                    ParseABCGroupCSVFile(fileName, StockSerie.Groups.SRD, true);
                    return true;
                }
                else if (stockSerie.BelongsToGroup(StockSerie.Groups.SP500))
                {
                    fileName = rootFolder + ABC_INTRADAY_FOLDER + "\\" + DateTime.Today.ToString("yyMMdd_") + "SP500.csv";
                    ParseABCGroupCSVFile(fileName, StockSerie.Groups.SP500, true);
                    return true;
                }
                else if (stockSerie.BelongsToGroup(StockSerie.Groups.INDICES))
                {
                    fileName = rootFolder + ABC_INTRADAY_FOLDER + "\\" + DateTime.Today.ToString("yyMMdd_") + "IndicesFR.csv";
                    ParseABCIntradayFile(stockSerie, fileName);
                    return true;
                }
            }
            return res;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:101,代码来源:ABCDataProvider.cs

示例2: DownloadDailyData

        public override bool DownloadDailyData(string rootFolder, StockSerie stockSerie)
        {
            if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
             {
            string shortName = stockSerie.ShortName;
            if (stockSerie.BelongsToGroup(StockSerie.Groups.FTSE100))
            {
               shortName = "LON:" + shortName;
            }
            else if (stockSerie.BelongsToGroup(StockSerie.Groups.DAX30))
            {
               shortName = "ETR:" + shortName;
            }

            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 <= 2 && (DateTime.Today.DayOfWeek == DayOfWeek.Monday && DateTime.UtcNow.Hour < 20)) ||
                   (lastDate >= DateTime.Today.AddDays(-1) && DateTime.UtcNow.Hour < 20);

               NotifyProgress("Downloading " + stockSerie.StockGroup.ToString() + " - " + stockSerie.StockName);
               if (!isUpTodate)
               {
                  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.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 + FOLDER, fileName, startDate, DateTime.Today, shortName);

                  if (stockSerie.StockName == "ADIDAS") // Check if something new has been downloaded using ANGLO AMERICAN as the reference for all downloads
                  {
                     this.ParseCSVFile(stockSerie, rootFolder + FOLDER + "\\" + fileName);
                     if (lastDate == stockSerie.Keys.Last())
                     {
                        this.needDownload = false;
                     }
                  }
               }
               else
               {
                  if (stockSerie.StockName == "ADIDAS")
                  {
                     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.DownloadFileFromProvider(rootFolder + ARCHIVE_FOLDER, stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + "_" + i.ToString() + ".csv", new DateTime(i, 1, 1), new DateTime(i, 12, 31), shortName))
                  {
                     break;
                  }
               }
               this.DownloadFileFromProvider(rootFolder + FOLDER, stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + ".csv", lastDate, DateTime.Today, shortName);
            }
             }
             return true;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:80,代码来源:GoogleDataProvider.cs

示例3: 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


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