From 8d0f7359f5be2033ab35236b708088985e8b7ebe Mon Sep 17 00:00:00 2001 From: "Sean Kessler (Europa)" Date: Mon, 16 Jun 2025 20:59:41 -0400 Subject: [PATCH] Add BollingerBand to menus --- .../ViewModels/CMMomentumViewModel.cs | 21 ++++++++++++++++++ .../ViewModels/CMTrendViewModel.cs | 22 ++++++++++++++++++- .../ViewModels/MomentumViewModel.cs | 19 ++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/PortfolioManager/ViewModels/CMMomentumViewModel.cs b/PortfolioManager/ViewModels/CMMomentumViewModel.cs index 140d6af..959393f 100644 --- a/PortfolioManager/ViewModels/CMMomentumViewModel.cs +++ b/PortfolioManager/ViewModels/CMMomentumViewModel.cs @@ -155,6 +155,7 @@ namespace PortfolioManager.ViewModels get { ObservableCollection collection = new ObservableCollection(); + collection.Add(new MenuItem() { Header = "Bollinger Bands...", Command = BollingerBandsCommand, StaysOpenOnClick = false }); collection.Add(new MenuItem() { Header = "Close Position...", Command = CloseCommand, StaysOpenOnClick = false }); collection.Add(new MenuItem() { Header = "Edit Position...", Command = EditCommand, StaysOpenOnClick = false }); collection.Add(new MenuItem() { Header = "Add To WatchList", Command = AddToWatchListCommand, StaysOpenOnClick = false }); @@ -288,6 +289,18 @@ namespace PortfolioManager.ViewModels // *********************************************************** R E L A Y *************************************************************** + [RelayCommand(CanExecute = nameof(CanExecuteBollingerBands))] + public async Task BollingerBands() + { + await ExecuteBollingerBands(); + } + + public bool CanExecuteBollingerBands() + { + if (null == selectedPosition || null == selectedPosition.Symbol) return false; + return true; + } + [RelayCommand] public async Task LoadFile() { @@ -336,6 +349,14 @@ namespace PortfolioManager.ViewModels // *************************************************************************************************************************************** + public async Task ExecuteBollingerBands() + { + SaveParameters saveParams = SaveParameters.Parse("Type,PortfolioManager.ViewModels.BollingerBandViewModel,SelectedSymbol," + selectedPosition.Symbol + ",SelectedWatchList,{All},SelectedDayCount,360"); + saveParams.Referer=this; + WorkspaceInstantiator.Invoke(saveParams); + await Task.FromResult(true); + } + public async Task OpenCloseDialog() { IPurePosition clonedPosition = Position.Clone(selectedPosition.Position); diff --git a/PortfolioManager/ViewModels/CMTrendViewModel.cs b/PortfolioManager/ViewModels/CMTrendViewModel.cs index 75de2b6..207330f 100644 --- a/PortfolioManager/ViewModels/CMTrendViewModel.cs +++ b/PortfolioManager/ViewModels/CMTrendViewModel.cs @@ -238,6 +238,7 @@ namespace PortfolioManager.ViewModels get { ObservableCollection collection = new ObservableCollection(); + collection.Add(new MenuItem() { Header = "Bollinger Bands...", Command = BollingerBandsCommand, StaysOpenOnClick = false }); collection.Add(new MenuItem() { Header = "Close Position...", Command = CloseCommand, StaysOpenOnClick = false }); collection.Add(new MenuItem() { Header = "Edit Position...", Command = EditCommand, StaysOpenOnClick = false }); collection.Add(new MenuItem() { Header = "Add To WatchList", Command = AddToWatchListCommand, StaysOpenOnClick = false }); @@ -246,8 +247,18 @@ namespace PortfolioManager.ViewModels } } - // ********************************************************************* R E L A Y S ***************************************************************** + [RelayCommand(CanExecute = nameof(CanExecuteBollingerBands))] + public async Task BollingerBands() + { + await ExecuteBollingerBands(); + } + + public bool CanExecuteBollingerBands() + { + if (null == selectedPosition || null == selectedPosition.Symbol) return false; + return true; + } [RelayCommand(CanExecute = nameof(CanClosePosition))] public async Task Close() @@ -335,6 +346,15 @@ namespace PortfolioManager.ViewModels return true; } + // ********************************************************************************************************************************* + public async Task ExecuteBollingerBands() + { + SaveParameters saveParams = SaveParameters.Parse("Type,PortfolioManager.ViewModels.BollingerBandViewModel,SelectedSymbol," + selectedPosition.Symbol + ",SelectedWatchList,{All},SelectedDayCount,360"); + saveParams.Referer=this; + WorkspaceInstantiator.Invoke(saveParams); + await Task.FromResult(true); + } + private void HandleToggleReturnOrPercent() { showAsGainLoss = !showAsGainLoss; diff --git a/PortfolioManager/ViewModels/MomentumViewModel.cs b/PortfolioManager/ViewModels/MomentumViewModel.cs index 5696548..e02f70b 100644 --- a/PortfolioManager/ViewModels/MomentumViewModel.cs +++ b/PortfolioManager/ViewModels/MomentumViewModel.cs @@ -154,6 +154,7 @@ namespace PortfolioManager.ViewModels get { ObservableCollection collection = new ObservableCollection(); + collection.Add(new MenuItem() { Header = "Bollinger Bands...", Command = BollingerBandsCommand, StaysOpenOnClick = false }); collection.Add(new MenuItem() { Header = "Close Position...", Command = CloseCommand, StaysOpenOnClick = false }); collection.Add(new MenuItem() { Header = "Edit Position...", Command = EditCommand, StaysOpenOnClick = false }); collection.Add(new MenuItem() { Header = "Add To WatchList", Command = AddToWatchListCommand, StaysOpenOnClick = false }); @@ -286,6 +287,17 @@ namespace PortfolioManager.ViewModels } // *********************************************************** R E L A Y *************************************************************** + [RelayCommand(CanExecute = nameof(CanExecuteBollingerBands))] + public async Task BollingerBands() + { + await ExecuteBollingerBands(); + } + + public bool CanExecuteBollingerBands() + { + if (null == selectedPosition || null == selectedPosition.Symbol) return false; + return true; + } [RelayCommand] public async Task LoadFile() @@ -334,6 +346,13 @@ namespace PortfolioManager.ViewModels } // **************************************************************************************************************************************** + public async Task ExecuteBollingerBands() + { + SaveParameters saveParams = SaveParameters.Parse("Type,PortfolioManager.ViewModels.BollingerBandViewModel,SelectedSymbol," + selectedPosition.Symbol + ",SelectedWatchList,{All},SelectedDayCount,360"); + saveParams.Referer=this; + WorkspaceInstantiator.Invoke(saveParams); + await Task.FromResult(true); + } public async Task OpenCloseDialog() {