Commit Latest
This commit is contained in:
@@ -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<BollingerBandElement> sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList();
|
||||
|
||||
@@ -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<PortfolioTrade> 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()
|
||||
|
||||
Reference in New Issue
Block a user