diff --git a/ViewModels/MGSHMomentumViewModel.cs b/ViewModels/MGSHMomentumViewModel.cs index 4e4a2ca..70615cb 100644 --- a/ViewModels/MGSHMomentumViewModel.cs +++ b/ViewModels/MGSHMomentumViewModel.cs @@ -41,10 +41,6 @@ namespace TradeBlotter.ViewModels private String initialPath=null; private String pathFileName=null; -// momentum candidate section - private String selectedDate = null; - private DateTime selectableDateStart=Utility.Epoch; - private DateTime selectableDateEnd=Utility.Epoch; private ObservableCollection momentumCandidates=new ObservableCollection(); private MGSHMomentumCandidate selectedItem=null; private RelayCommand runCommand; @@ -112,11 +108,6 @@ namespace TradeBlotter.ViewModels monitorIntervals.Add("90"); monitorIntervals.Add("120"); selectedMonitorInterval=monitorIntervals[0]; - DateTime earliestPricingDate=PricingDA.GetEarliestDate(); - earliestPricingDate+=new TimeSpan(252,0,0,0); - selectableDateStart=earliestPricingDate; - selectableDateEnd=PricingDA.GetLatestDate(); - selectedDate=selectableDateEnd.ToShortDateString(); configuration=new MGSHConfiguration(); NVPCollection nvpCollection=configuration.ToNVPCollection(); nvpDictionary=nvpCollection.ToDictionary(); @@ -131,6 +122,8 @@ namespace TradeBlotter.ViewModels base.OnPropertyChanged("Parameters"); base.OnPropertyChanged("SelectedParameter"); base.OnPropertyChanged("ParameterValue"); + base.OnPropertyChanged("LastTradeDate"); + base.OnPropertyChanged("NextTradeDate"); } protected override void OnDispose() @@ -243,7 +236,6 @@ namespace TradeBlotter.ViewModels { } - // ************************************************************************************************************************************************ // ************************************************************************************************************************************************ // ************************************************************************************************************************************************ @@ -265,23 +257,14 @@ namespace TradeBlotter.ViewModels } } - public DateTime SelectableDateStart - { - get{return selectableDateStart;} - set{selectableDateStart=value;} - } - - public DateTime SelectableDateEnd - { - get{return selectableDateEnd;} - set{selectableDateEnd=value;} - } // ******************************************************************************************************************************************************************************** private void Run() { try { - if(null==selectedDate)return; + if(null==sessionParams)return; + DateGenerator dateGenerator = new DateGenerator(); + DateTime selectedDate = dateGenerator.FindPrevBusinessDay(sessionParams.TradeDate); BusyIndicator = true; BusyContent="Running Momentum..."; Task workerTask = Task.Factory.StartNew(() => @@ -289,7 +272,7 @@ namespace TradeBlotter.ViewModels MGSHConfiguration localConfiguration=new MGSHConfiguration(); localConfiguration.MaxPositions = int.Parse(nvpDictionary["MaxPositions"].Value); localConfiguration.HoldingPeriod = int.Parse(nvpDictionary["HoldingPeriod"].Value); - MGSHMomentumCandidates candidates = MGSHMomentumGenerator.GenerateMomentumWithFallback(Utility.ParseDate(selectedDate), configuration == null ? localConfiguration : configuration); + MGSHMomentumCandidates candidates = MGSHMomentumGenerator.GenerateMomentumWithFallback(selectedDate, configuration == null ? localConfiguration : configuration); momentumCandidates=new ObservableCollection(); foreach(MGSHMomentumCandidate momentumCandidate in candidates)momentumCandidates.Add(momentumCandidate); }); @@ -350,7 +333,6 @@ namespace TradeBlotter.ViewModels StringBuilder sb = new StringBuilder(); sb.Append(companyProfile.Sector).Append("/").Append(companyProfile.Industry).Append("\n").Append(companyProfile.Description); return sb.ToString(); - //return companyProfile.Description; } } // **************************************************************************************************************************************************************** @@ -376,13 +358,22 @@ namespace TradeBlotter.ViewModels set{selectedPosition=value;base.OnPropertyChanged("SelectedPosition");} } - public String SelectedDate + public String LastTradeDate { - get { return selectedDate; } - set + get + { + if(null == sessionParams)return Utility.DateTimeToStringMMSDDSYYYY(Utility.Epoch); + DateGenerator dateGenerator=new DateGenerator(); + return Utility.DateTimeToStringMMSDDSYYYY(dateGenerator.FindPrevBusinessDay(sessionParams.TradeDate)); + } + } + + public String NextTradeDate + { + get { - selectedDate = value; - base.OnPropertyChanged("SelectedDate"); + if(null == sessionParams)return Utility.DateTimeToStringMMSDDSYYYY(Utility.Epoch); + return Utility.DateTimeToStringMMSDDSYYYY(sessionParams.TradeDate); } } @@ -1388,6 +1379,8 @@ namespace TradeBlotter.ViewModels base.OnPropertyChanged("ExpectationColor"); base.OnPropertyChanged("ExpectationDescription"); base.OnPropertyChanged("ReloadEnabled"); + base.OnPropertyChanged("LastTradeDate"); + base.OnPropertyChanged("NextTradeDate"); }); return true; } diff --git a/Views/MGSHMomentumView.xaml b/Views/MGSHMomentumView.xaml index 336c9af..a48de8d 100644 --- a/Views/MGSHMomentumView.xaml +++ b/Views/MGSHMomentumView.xaml @@ -38,8 +38,15 @@ - - + + + + + + + + +