From a46d507c7a44d5212e9fde178e51d14aee92f001 Mon Sep 17 00:00:00 2001 From: "Sean Kessler (Europa)" Date: Sun, 15 Jun 2025 22:17:20 -0400 Subject: [PATCH] Commit Latest --- PortfolioManager/Models/BollingerBandModel.cs | 2 +- PortfolioManager/Models/PortfolioTradeModel.cs | 15 +++++++++++++-- .../ViewModels/BollingerBandViewModel.cs | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/PortfolioManager/Models/BollingerBandModel.cs b/PortfolioManager/Models/BollingerBandModel.cs index 2148875..d1cae63 100644 --- a/PortfolioManager/Models/BollingerBandModel.cs +++ b/PortfolioManager/Models/BollingerBandModel.cs @@ -169,7 +169,7 @@ namespace PortfolioManager.Models // The least squares might be in the wrong order if the Bollinger band was already sorted by date public static CompositeDataSource LeastSquares(BollingerBands bollingerBands) { - if (null == bollingerBands || 0 == bollingerBands.Count) return null; + if (null == bollingerBands || 0 == bollingerBands.Count) return Empty(); LeastSquaresResult leastSquaresResult = bollingerBands.LeastSquaresFitClose(); SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); List sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); diff --git a/PortfolioManager/Models/PortfolioTradeModel.cs b/PortfolioManager/Models/PortfolioTradeModel.cs index 90c5bee..f07d449 100644 --- a/PortfolioManager/Models/PortfolioTradeModel.cs +++ b/PortfolioManager/Models/PortfolioTradeModel.cs @@ -10,17 +10,28 @@ namespace PortfolioManager.Models { public class PortfolioTradeModel { + private PortfolioTradeModel() { } + + public static CompositeDataSource Empty() + { + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = new SortedDateTimeDataAdapter() + }; + return compositeDataSource; + } + public static CompositeDataSource PortfolioTrades(PortfolioTrades portfolioTrades) { - if (null == portfolioTrades || 0 == portfolioTrades.Count) return null; + if (null == portfolioTrades || 0 == portfolioTrades.Count) return Empty(); List sortedPortfolioTrades = portfolioTrades.OrderBy(x => x.TradeDate).ToList(); SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); foreach (PortfolioTrade portfolioTrade in sortedPortfolioTrades) { - sortedDateTimeDataAdapter.Add(portfolioTrade.TradeDate, portfolioTrade.Price); + sortedDateTimeDataAdapter.Add(portfolioTrade.TradeDate, portfolioTrade.Price); } CompositeDataSource compositeDataSource = new CompositeDataSource() diff --git a/PortfolioManager/ViewModels/BollingerBandViewModel.cs b/PortfolioManager/ViewModels/BollingerBandViewModel.cs index 4094aba..8bf3d50 100644 --- a/PortfolioManager/ViewModels/BollingerBandViewModel.cs +++ b/PortfolioManager/ViewModels/BollingerBandViewModel.cs @@ -91,6 +91,7 @@ namespace PortfolioManager.ViewModels { Task workerTask = Task.Factory.StartNew(() => { + MDTrace.WriteLine(LogLevel.DEBUG, $"WatchListDA.GetWatchLists()"); watchListNames = WatchListDA.GetWatchLists(); watchListNames.Insert(0, UIConstants.CONST_ALL); selectedWatchList = watchListNames.Find(x => x.Equals("Valuations"));