public StaticViewModel(IEnumerable <ButtonDefinition> defs, GenericViewModel <Type> types, IObservable <TimeValueSeriesViewModel> timeValueSeriesViewModelService, IObservable <PredictionsViewModel> predictionsViewModelService,
                               IObservable <IFilterWrapperViewModel> fwvms)

        {
            SignalButtonsVM = new CollectionViewModel <ButtonDefinition>(defs);


            //odefs.Subscribe(a =>
            //{
            //    this.AlgoButtonsVM = new CollectionViewModel<ButtonDefinition>(a);
            //    NotifyChanged(nameof(AlgoButtonsVM));
            //});
            TypesVM = types;


            fwvms.Subscribe(a =>
            {
                this.AlgoVM = (a);
                NotifyChanged(nameof(AlgoVM));
            });
            predictionsViewModelService.Subscribe(a =>
            {
                this.PredictionsVM = a;
                NotifyChanged(nameof(PredictionsVM));
            });

            timeValueSeriesViewModelService.Subscribe(a =>
            {
                this.SeriesVM = a;
                NotifyChanged(nameof(SeriesVM));
            });

            //var defs = ButtonDefinitionFactory.Build<PredictionsViewModel>((a) =>
            //{
            //    this.PredictionsVM = a;
            //    NotifyChanged(nameof(PredictionsVM));
            //}, typeof(Filter.ViewModel.VMStaticFactory));
        }
        //public static IObservable<StaticViewModel> BuildStaticService(IObservable<IEnumerable<KeyValuePair<DateTime, double>>> observable,IScheduler uischeduler)
        //{
        //    return observable.Select(s =>
        //    {
        //       return BuildStatic(s, uischeduler);

        //    });
        //}



        public static StaticViewModel BuildStatic(/*IObservable<IEnumerable<KeyValuePair<DateTime, double>>> s,*/ IScheduler uischeduler)
        {
            var s = new Filter.Model.Observable <IEnumerable <KeyValuePair <DateTime, double> > >();

            var ts = s.Select(_ => new TimeValueSeriesViewModel(_));


            Action <IEnumerable <KeyValuePair <DateTime, double> > > avi = (a) => s.Publish(a);

            var bds = ButtonDefinitionFactory.Build(avi, typeof(Filter.Service.SignalGenerator));



            var types = Helper.GetInheritingTypes(typeof(Filter.Model.IFilterWrapper));

            var vm = new GenericViewModel <Type>(types.ToObservable(), null, uischeduler);

            var bdds = vm.GetSelectedObjectSteam().Where(a => a != null).Select(_ =>
                                                                                ViewModelSelector(_));

            var dfs = bdds.Select(_ => _.Output).Select(v => v.WithLatestFrom(s, (a, b) => new { a, b }).Select(l => new PredictionsViewModel(l.a.BatchRun(l.b)))).SelectMany(l => l);


            //var xs = new Filter.Model.Observable<Type>();

            //Action<Type> at = (a) => xs.Publish(a);

            //var bds = ButtonDefinitionFactory.Build(avi, typeof(Filter.Service.SignalGenerator));


            //var x = new Filter.Model.Observable<PredictionsViewModel>();

            //Action<IEnumerable<KeyValuePair<DateTime, Tuple<double, double>[]>>> av = (a) => x.Publish(new PredictionsViewModel(a));

            //var defs = s.Select(_ => ButtonDefinitionFactory.Build(av, typeof(Filter.Service.StaticPredictionService), _));

            return(new StaticViewModel(bds, vm, ts, dfs, bdds));
        }