internal void Bind(ProductWrapper wrapper_)
    {
      if (cmbProductType.Items.Count == 0)
        cmbProductType.AddItems(typeof (ParserType));

      Wrapper = wrapper_;

      tbMult.Bind(wrapper_, "Multiplier", new Validators.DoubleValidator(null));
      cmbProductType.Bind(wrapper_, "ParserType", new Validators.EnumDescValidator(ParserType.Bbg_PX_Last));
      tbInputString.Bind(wrapper_, "InputText");
    }
    private void addWrapper()
    {
      var wrapper = new ProductWrapper();
      var disp = new ProductWrapperDisplay();
      disp.Bind(wrapper);
      m_wrappers.Add(wrapper);
      SI.Controls.LookFeel.ProcessControl(disp);

      flowLayoutPanel1.Controls.Add(disp);

      sortOutPositioning();

      subscribeToControlEvents(disp);
    }
        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));
        }
        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));            

        }