public OHLCVInterval Parse(string rawData, int index)
        {
            OHLCVInterval newOHLCVInterval = new OHLCVInterval();
            DateTime parsedDate;

            string[] fields = rawData.Split(",".ToCharArray());

            if (!DateTime.TryParse(fields[date], out parsedDate))
                if (!DateTime.TryParseExact(fields[date], "yyyyMMdd", null, System.Globalization.DateTimeStyles.None, out parsedDate))
                    throw new System.FormatException("String was not recognized as a valid DateTime.");

            newOHLCVInterval.DateTime = parsedDate.Date;
            newOHLCVInterval.Open = Single.Parse(fields[open]);
            newOHLCVInterval.High = Single.Parse(fields[high]);
            newOHLCVInterval.Low = Single.Parse(fields[low]);
            newOHLCVInterval.Close = Single.Parse(fields[close]);
            newOHLCVInterval.Volume = long.Parse(fields[vol]);
            newOHLCVInterval.Index = index;
            newOHLCVInterval.Exchange = exchange;

               // newOHLCVInterval.DataSource = "EODData";
            newOHLCVInterval.Instrument =fields[instrument];
            newOHLCVInterval.Id = String.Format("{0}{1}{2}", exchange, newOHLCVInterval.Instrument ,newOHLCVInterval.DateTime.ToShortDateString());
            return newOHLCVInterval;
        }
        public OHLCVInterval Parse(string rawData, int index)
        {
            OHLCVInterval newOHLCVInterval = new OHLCVInterval();

            string[] fields = rawData.Split(",".ToCharArray());
            newOHLCVInterval.DateTime = DateTime.Parse(fields[date]);
            newOHLCVInterval.Open = Single.Parse(fields[open]);
            newOHLCVInterval.High = Single.Parse(fields[high]);
            newOHLCVInterval.Low = Single.Parse(fields[low]);
            newOHLCVInterval.Close = Single.Parse(fields[close]);
            newOHLCVInterval.Volume = long.Parse(fields[vol]);
            newOHLCVInterval.Index = index;
            //newOHLCVInterval.DataSource = "Yahoo";
            newOHLCVInterval.Instrument = this.instrument;
            newOHLCVInterval.Id = newOHLCVInterval.Instrument + newOHLCVInterval.DateTime.ToShortDateString();

            return newOHLCVInterval;
        }
        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);
        }
        public void Save(OHLCVInterval intervalToSave)
        {
            var collection = db.GetCollection<OHLCVInterval>(collectionName); //intervalToSave.Instrument);

               collection.Insert<OHLCVInterval>(intervalToSave);
        }