예제 #1
0
 public void Process()
 {
     try
     {
         SymbolDownloader symbolDownloader = new SymbolDownloader(_reportDate);
         symbolDownloader.OnLoadDataComplete += new SymbolDownloader.LoadDataCompleted(symbolDownloader_OnLoadDataComplete);
         SymbolDownloaderQueue symbolDownloaderQueue = SymbolDownloaderQueue.Instance(1000);
         symbolDownloaderQueue.Enqueue(symbolDownloader);
     }
     catch (Exception ex)
     {
         LogOps.LogException(ex);
     }
 }
예제 #2
0
        void symbolDownloader_OnLoadDataComplete(SymbolDownloader symbolDownloader, List<Symbol> symbolList)
        {
            try
            {
                IEnumerable<string> symbolNameEnumerable = from symbol in symbolList select symbol.SymbolName;

                // Consider only those symbols that are in major market indexes
                IEnumerable<Symbol> symbolEnumerable = _entities.SymbolSet.Where(symbol => symbolNameEnumerable.Contains(symbol.SymbolName));

                // Set the next report date
                foreach (Symbol symbol in symbolEnumerable)
                {
                    symbol.ReportDate = _reportDate;
                }

                _entities.SaveChanges();

                // Keep track of progress on the list of symbols
                _symbolNameList = (from s in symbolEnumerable select s.SymbolName).ToList<string>();
                _symbolNameListReport = (from s in symbolEnumerable select s.SymbolName).ToList<string>();
                _symbolNameListDayPrice = (from s in symbolEnumerable select s.SymbolName).ToList<string>();

                // Load the price history for the market indexes
                dayPriceDownloader_Enqueue("^DJI",3000);
                dayPriceDownloader_Enqueue("^IXIC",3000);
                dayPriceDownloader_Enqueue("^GSPC",3000);
                System.Threading.Thread.Sleep(10000);

                // Retrieve the report history
                foreach (String symbolName in _symbolNameList)
                {
                    ReportDownloader reportDownloader = new ReportDownloader(symbolName);
                    reportDownloader.OnLoadDataComplete += new ReportDownloader.LoadDataCompleted(reportDownloader_OnLoadDataComplete);
                    ReportDownloaderQueue reportDownloaderQueue = ReportDownloaderQueue.Instance(5000);
                    reportDownloaderQueue.Enqueue(reportDownloader);
                }

                if (_symbolNameList.Count() == 0)
                {
                    if (OnCompleted != null) OnCompleted();
                    this.Dispose();
                }
            }
            catch (Exception ex)
            {
                LogOps.LogException(ex);
            }
        }