public void ShouldReturnCorrectHalfMonthBucket()
        {
            var startDate = new DateTime(2010,1,1);
            var today = new DateTime(2015,12,08);
            var productWrapper = new ProductWrapper { InputText = "UST1_2", ParserType = ParserType.CMT_Yield };
            var dataRetriever = new DailyDataRetriever(new List<ProductWrapper>() { productWrapper });
            var data = dataRetriever.getData(startDate, false, false, productWrapper.ToString());
            var ret = data.Item2.ToDifferences().GetValuesBetweenDates(startDate, today);
            var bucketgen = new BucketGenerator(null);
            bucketgen.SetupHalfMonthBucket();
            var buckets = bucketgen.SplitIntoBuckets(ret);

            Assert.That(buckets.Count, Is.EqualTo(143));
            Assert.That(buckets.First().Key, Is.EqualTo("2010_1_1"));

            bucketgen.SetupHalfMonthBucketForYears();
            var yearlyBuckets = bucketgen.SplitIntoBuckets(ret);
            Assert.That(yearlyBuckets.Count, Is.EqualTo(24));
        }
 // Retreive basket data from Bloomberg 
 // Note: need to write a parser if basket needs to support other data source
 public static Tuple<CustomBasket, DatedDataCollectionGen<double>>[] RetreiveDataForBasket(CustomBasket[] baskets, DateTime earliestDate)
 {
     try
     {
     
         return baskets.Select(b =>  new {basket = b, w =  new ProductWrapper
                                     {
                                         InputText = b.InstrumentName,
                                         Multiplier = b.Weight,
                                         ParserType = MultiProductInputParser.ParserForType(b.InstrumentName),
                                     }})
                                     .Select(x =>
                                     {
                                         var dataRetriever = new DailyDataRetriever(new []{x.w}.ToList());
                                         var data = dataRetriever.getData(earliestDate).Item2;
                                         return new  Tuple<CustomBasket, DatedDataCollectionGen<double>>(x.basket, data);                                                
                                     }).ToArray();
   
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
    protected override Tuple<string, DatedDataCollectionGen<double>> getData(DateTime earliestDate_, bool insertNan_ = true, bool displayAnyError_=true)
    {     
        var dataRetriever = new DailyDataRetriever(m_wrappers);
        try
        {
            var data = dataRetriever.getData(earliestDate_, insertNan_, displayAnyError_);
            return data;
        }
        catch (Exception e)
        {
            displayMessage("Parsing Error", e.Message, MessageBoxIcon.Error);
        }

        return null;
    }
        public void DateAroundEventModelTest()
        {
            var inputs =

                new InstrumentInputItem { Ticker = "UST1_1", Type = ParserType.CMT_Yield }
            ;
            var events1 = new[]
            {
                new DateTime(2016,02,04), 
                new DateTime(2016,01,07), 
                new DateTime(2015,12,10), 
                new DateTime(2015,11,15), 
                new DateTime(2015,10,08), 
                new DateTime(2015,09,10), 
            };
            var events2 = new[]
            {
                new DateTime(2016,02,08), 
                new DateTime(2016,01,10), 
                new DateTime(2015,12,15), 
                new DateTime(2015,11,21), 
                new DateTime(2015,10,19), 
                new DateTime(2015,09,11), 
            };
            var productWrapper = new ProductWrapper { InputText = inputs.Ticker, ParserType = inputs.Type };
            var dataRetriever = new DailyDataRetriever(new List<ProductWrapper>() { productWrapper });
            var data = dataRetriever.getData(new DateTime(2012, 1, 1), false, false, productWrapper.ToString());

            var list = new List<DataAroundEvent>();
            var offset = -5;
            var numberofPoints = 10;
            foreach (var v in events1)
            {
                list.Add(new DataAroundEvent(v.Date.Date, data.Item1, data.Item2, numberofPoints, "event1", offset));// { PivotIndex = numberofPoints - offset });
            }
            //foreach (var v in events2)
            //{
            //    list.Add(new DataAroundEvent(v.Date.Date, data.Item1, data.Item2, 10, "event2"));
            //}

            foreach (var dataAroundEvent in list)
            {
                Console.WriteLine(@" ");
                Console.WriteLine(@" ");
                Console.WriteLine(@"-------------------------------------------");
                Console.WriteLine(@"Event {0}", dataAroundEvent.EventDate);
                foreach (var p in dataAroundEvent.FilledDataAroundEvent_Level.Data)
                {
                    Console.WriteLine(@"{0},{1}", p.Index, p.Value);
                }
            }
        }
        public void ShouldCreateDataAroundEventsBucket()
        {
            var inputs = 
            
                new InstrumentInputItem {Ticker = "UST1_1", Type = ParserType.CMT_Yield}
            ;
            var events = new[]
            {
                new DateTime(2016,02,04), 
                new DateTime(2016,01,07), 
                new DateTime(2015,12,10), 
                new DateTime(2015,11,15), 
                new DateTime(2015,10,08), 
                new DateTime(2015,09,10), 
            };
            var productWrapper = new ProductWrapper { InputText = inputs.Ticker, ParserType = inputs.Type };
            var dataRetriever = new DailyDataRetriever(new List<ProductWrapper>() { productWrapper });
            var data = dataRetriever.getData(new DateTime(2012, 1, 1), false, false, productWrapper.ToString()).Item2;
            var instData = MultiInstrumentsSignalGenerator.DataAroundEventsBucket(inputs, data, events, 2012, 5,  DataAroundEventField.Filled_Diff);

            Assert.That(instData.Count, Is.EqualTo(11));            

        }