Initial Commit

This commit is contained in:
2025-06-10 19:03:43 -04:00
commit 93ab70180a
62 changed files with 49312 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Eremex.AvaloniaUI.Charts;
using MarketData.MarketDataModel;
using MarketData.MarketDataModel.GainLoss;
using PortfolioManager.DataSeriesViewModels;
namespace PortfolioManager.Models
{
public class MovingAverageModel
{
private MovingAverageModel()
{
}
public static CompositeDataSource Empty()
{
CompositeDataSource compositeDataSource = new CompositeDataSource()
{
DataAdapter = new SortedDateTimeDataAdapter()
};
return compositeDataSource;
}
/// <summary>
/// Creates the moving average composite data source
/// </summary>
/// <param name="gainLossList"></param>
/// <param name="useGainLoss"></param>
/// <returns></returns>
public static CompositeDataSource CreateCompositeDataSource(DMAValues dmaValues)
{
if (null == dmaValues) return Empty();
List<DMAValue> sortedValues = new List<DMAValue>(dmaValues.OrderBy(x => x.Date));
SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter();
foreach (DMAValue dmaValue in sortedValues)
{
sortedDateTimeDataAdapter.Add(dmaValue.Date,dmaValue.MAValue);
}
CompositeDataSource compositeDataSource = new CompositeDataSource()
{
DataAdapter = sortedDateTimeDataAdapter
};
return compositeDataSource;
}
}
}