public void CachesValueAndReturnsSameReference()
 {
     var provider = new LocalDiskFactorFileProvider();
     var factorFile1 = provider.Get(Symbols.SPY);
     var factorFile2 = provider.Get(Symbols.SPY);
     Assert.IsTrue(ReferenceEquals(factorFile1, factorFile2));
 }
        public void TestsFileSystemDataFeedSpeed()
        {
            var job = new BacktestNodePacket();
            var resultHandler = new BacktestingResultHandler();
            var mapFileProvider = new LocalDiskMapFileProvider();
            var factorFileProvider = new LocalDiskFactorFileProvider(mapFileProvider);
            var dataFileProvider = new DefaultDataFileProvider();

            var algorithm = new BenchmarkTest();
            var feed = new FileSystemDataFeed();

            feed.Initialize(algorithm, job, resultHandler, mapFileProvider, factorFileProvider, dataFileProvider);
            algorithm.Initialize();

            var feedThreadStarted = new ManualResetEvent(false);
            Task.Factory.StartNew(() =>
            {
                feedThreadStarted.Set();
                feed.Run();
            });
            feedThreadStarted.WaitOne();

            var stopwatch = Stopwatch.StartNew();
            var lastMonth = -1;
            var count = 0;
            foreach (var timeSlice in feed)
            {
                if (timeSlice.Time.Month != lastMonth)
                {
                    Console.WriteLine(DateTime.Now + " - Time: " + timeSlice.Time);
                    lastMonth = timeSlice.Time.Month;
                }
                count++;
            }
            Console.WriteLine("Count: " + count);

            stopwatch.Stop();
            Console.WriteLine("Elapsed time: " + stopwatch.Elapsed);
        }
 public void ReturnsNullForNotFound()
 {
     var provider = new LocalDiskFactorFileProvider();
     var factorFile = provider.Get(Symbol.Create("not - a - ticker", SecurityType.Equity, QuantConnect.Market.USA));
     Assert.IsNull(factorFile);
 }
 public void RetrievesFromDisk()
 {
     var provider = new LocalDiskFactorFileProvider();
     var factorFile = provider.Get(Symbols.SPY);
     Assert.IsNotNull(factorFile);
 }