Commit Latest

This commit is contained in:
2025-06-15 22:17:20 -04:00
parent be64273eeb
commit a46d507c7a
3 changed files with 15 additions and 3 deletions

View File

@@ -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 // The least squares might be in the wrong order if the Bollinger band was already sorted by date
public static CompositeDataSource LeastSquares(BollingerBands bollingerBands) 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(); LeastSquaresResult leastSquaresResult = bollingerBands.LeastSquaresFitClose();
SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter();
List<BollingerBandElement> sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); List<BollingerBandElement> sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList();

View File

@@ -10,17 +10,28 @@ namespace PortfolioManager.Models
{ {
public class PortfolioTradeModel public class PortfolioTradeModel
{ {
private PortfolioTradeModel() private PortfolioTradeModel()
{ {
} }
public static CompositeDataSource Empty()
{
CompositeDataSource compositeDataSource = new CompositeDataSource()
{
DataAdapter = new SortedDateTimeDataAdapter()
};
return compositeDataSource;
}
public static CompositeDataSource PortfolioTrades(PortfolioTrades portfolioTrades) public static CompositeDataSource PortfolioTrades(PortfolioTrades portfolioTrades)
{ {
if (null == portfolioTrades || 0 == portfolioTrades.Count) return null; if (null == portfolioTrades || 0 == portfolioTrades.Count) return Empty();
List<PortfolioTrade> sortedPortfolioTrades = portfolioTrades.OrderBy(x => x.TradeDate).ToList(); List<PortfolioTrade> sortedPortfolioTrades = portfolioTrades.OrderBy(x => x.TradeDate).ToList();
SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter();
foreach (PortfolioTrade portfolioTrade in sortedPortfolioTrades) foreach (PortfolioTrade portfolioTrade in sortedPortfolioTrades)
{ {
sortedDateTimeDataAdapter.Add(portfolioTrade.TradeDate, portfolioTrade.Price); sortedDateTimeDataAdapter.Add(portfolioTrade.TradeDate, portfolioTrade.Price);
} }
CompositeDataSource compositeDataSource = new CompositeDataSource() CompositeDataSource compositeDataSource = new CompositeDataSource()

View File

@@ -91,6 +91,7 @@ namespace PortfolioManager.ViewModels
{ {
Task workerTask = Task.Factory.StartNew(() => Task workerTask = Task.Factory.StartNew(() =>
{ {
MDTrace.WriteLine(LogLevel.DEBUG, $"WatchListDA.GetWatchLists()");
watchListNames = WatchListDA.GetWatchLists(); watchListNames = WatchListDA.GetWatchLists();
watchListNames.Insert(0, UIConstants.CONST_ALL); watchListNames.Insert(0, UIConstants.CONST_ALL);
selectedWatchList = watchListNames.Find(x => x.Equals("Valuations")); selectedWatchList = watchListNames.Find(x => x.Equals("Valuations"));