Commit Latest

This commit is contained in:
2025-06-25 21:05:14 -04:00
parent bf6d6ee6d7
commit 27881870f6
4 changed files with 115 additions and 93 deletions

View File

@@ -20,53 +20,51 @@ namespace PortfolioManager.ViewModels
{
public partial class ScottPlotViewModel : PlotterWorkspaceViewModel
{
// private AvaPlot plotter = default;
private List<String> watchListNames;
private String selectedWatchList;
private ObservableCollection<String> symbols = new ObservableCollection<String>();
private List<Int32> dayCounts = new int[] { 60, 90, 180, 360, 720, 1440, 3600 }.ToList<int>();
private int selectedDayCount = 90;
private bool isBusy = false;
private String selectedSymbol = default;
private String companyName = default;
BollingerBandRenderer bollingerBandRenderer = default;
private List<String> watchListNames;
private String selectedWatchList;
private ObservableCollection<String> symbols = new ObservableCollection<String>();
private List<Int32> dayCounts = new int[] { 60, 90, 180, 360, 720, 1440, 3600 }.ToList<int>();
private int selectedDayCount = 90;
private bool isBusy = false;
private String selectedSymbol = default;
private String companyName = default;
private BollingerBandRenderer bollingerBandRenderer = default;
private bool showInsiderTransactions = true;
public ScottPlotViewModel()
{
DisplayName = "Bollinger";
// Plotter = new AvaPlot();
// base.OnPropertyChanged("Plotter");
OnPlotterLoadedEventHandler += PlotterLoadedEvent;
PropertyChanged += OnViewModelPropertyChanged;
Initialize();
}
public ScottPlotViewModel()
{
DisplayName = "Bollinger";
OnPlotterLoadedEventHandler += PlotterLoadedEvent;
PropertyChanged += OnViewModelPropertyChanged;
Initialize();
}
protected override void OnDispose()
{
MDTrace.WriteLine(LogLevel.DEBUG, $"Dispose BollingerBandViewModel");
base.OnDispose();
}
protected override void OnDispose()
{
MDTrace.WriteLine(LogLevel.DEBUG, $"Dispose BollingerBandViewModel");
base.OnDispose();
}
private void Initialize(bool executePropertyChanged = true)
{
Task workerTask = Task.Factory.StartNew(() =>
{
MDTrace.WriteLine(LogLevel.DEBUG, $"BollingerBandViewModel::Initialize()");
watchListNames = WatchListDA.GetWatchLists();
watchListNames.Insert(0, UIConstants.CONST_ALL);
selectedWatchList = watchListNames.Find(x => x.Equals("Valuations"));
symbols.AddRange(WatchListDA.GetWatchList(selectedWatchList));
});
workerTask.ContinueWith((continuation) =>
{
if (executePropertyChanged)
{
base.OnPropertyChanged("Symbols");
base.OnPropertyChanged("WatchListNames");
base.OnPropertyChanged("SelectedWatchList");
}
});
}
private void Initialize(bool executePropertyChanged = true)
{
Task workerTask = Task.Factory.StartNew(() =>
{
MDTrace.WriteLine(LogLevel.DEBUG, $"BollingerBandViewModel::Initialize()");
watchListNames = WatchListDA.GetWatchLists();
watchListNames.Insert(0, UIConstants.CONST_ALL);
selectedWatchList = watchListNames.Find(x => x.Equals("Valuations"));
symbols.AddRange(WatchListDA.GetWatchList(selectedWatchList));
});
workerTask.ContinueWith((continuation) =>
{
if (executePropertyChanged)
{
base.OnPropertyChanged("Symbols");
base.OnPropertyChanged("WatchListNames");
base.OnPropertyChanged("SelectedWatchList");
}
});
}
// *******************************************************************************************************************************************
@@ -78,7 +76,7 @@ namespace PortfolioManager.ViewModels
public void PlotterLoadedEvent(object sender, PlotterLoadedEventArgs e)
{
base.OnPropertyChanged("Plotter");
}
}
private void OnViewModelPropertyChanged(object sender, PropertyChangedEventArgs eventArgs)
{
@@ -88,6 +86,7 @@ namespace PortfolioManager.ViewModels
eventArgs.PropertyName.Equals("SelectedSymbol") ||
eventArgs.PropertyName.Equals("ShowRiskFree") ||
eventArgs.PropertyName.Equals("LeastSquaresFit") ||
eventArgs.PropertyName.Equals("CheckBoxShowInsiderTransactions") ||
eventArgs.PropertyName.Equals("SelectedDayCount"))
&& !String.IsNullOrEmpty(selectedSymbol)
&& default != Plotter)
@@ -97,6 +96,7 @@ namespace PortfolioManager.ViewModels
{
companyName = PricingDA.GetNameForSymbol(selectedSymbol);
bollingerBandRenderer = new BollingerBandRenderer(Plotter);
bollingerBandRenderer.ShowInsiderTransactions=showInsiderTransactions;
bollingerBandRenderer.SetData(selectedSymbol, selectedDayCount);
bollingerBandRenderer.Render();
});
@@ -276,12 +276,12 @@ namespace PortfolioManager.ViewModels
{
get
{
if (null == bollingerBandRenderer) return false;
return bollingerBandRenderer.ShowInsiderTransactions;
return showInsiderTransactions;
}
set
{
bollingerBandRenderer.ShowInsiderTransactions = value;
showInsiderTransactions = value;
base.OnPropertyChanged("CheckBoxShowInsiderTransactions");
}
}