public void CanGetByTimeSpan()
 {
     OHLCVIntervalRepository repository = new OHLCVIntervalRepository();
       var intervals =  repository.GetByTimeSpan("FakeExchange","OHLCIntervalRepositoryTests", DateTime.Now.AddDays(-9) , DateTime.Now);
        var intevalList = intervals.ToList<OHLCVInterval>();
        Assert.That(intevalList.Count > 0);
 }
        public void CanSaveOHLCInterval()
        {
            OHLCVInterval newOHLCVInterval = new OHLCVInterval();

            newOHLCVInterval.DateTime = DateTime.Now;
            newOHLCVInterval.Open = 1234f;
            newOHLCVInterval.High =1235f;
            newOHLCVInterval.Low = 1233f;
            newOHLCVInterval.Close = 1234.5f;
            newOHLCVInterval.Volume = 1234567890;
            newOHLCVInterval.Index = 0;
            //newOHLCVInterval.DataSource = "EODData";
            newOHLCVInterval.Instrument ="OHLCIntervalRepositoryTests";
            newOHLCVInterval.Exchange = "FakeExchange";
              //  newOHLCVInterval.Id = Guid.NewGuid();// newOHLCVInterval.Instrument + newOHLCVInterval.DateTime.Ticks.ToString();

            OHLCVIntervalRepository repository = new OHLCVIntervalRepository();
            repository.Save(newOHLCVInterval);
        }
        private int EnumerateExtractedDataForYear(string targetFolder, string exchange)
        {
            //  Stopwatch stopwatch = new Stopwatch();
               int fileCount = 0;
               foreach (var extractedFile in new DirectoryInfo(targetFolder).EnumerateFiles())
               {
               fileCount++;
               //stopwatch.Reset();
               // stopwatch.Start();
               //Parse & Save OHLCVIntervals
               OHLCVIntervalReader reader = new OHLCVIntervalReader(
                   extractedFile.OpenText(),
                   new EODDataOHLVCIntervalParser(exchange),
                   false);

               OHLCVIntervalRepository repository = new OHLCVIntervalRepository();
               int lineCount = 0;
               try
               {
                   foreach (var interval in reader)
                   {
                       lineCount++;
                       repository.Save(interval);
                   }
               }
               catch (Exception e)
               {
                   logger.ErrorFormat("Parser Error in file: {0}, @line: {1}, exception: {2}", extractedFile.Name, lineCount, e.Message);
               }
               logger.InfoFormat("Parsed file: {0}, sucessfully parsed  {1} lines", extractedFile.Name, lineCount);

               // stopwatch.Stop();
               // Console.WriteLine("Finished parsing file: {0} in: {1} seconds.", extractedFile.Name,stopwatch.ElapsedMilliseconds/1000);
               }
               return fileCount;
        }