41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Eremex.AvaloniaUI.Charts;
|
|
using MarketData.MarketDataModel;
|
|
using PortfolioManager.DataSeriesViewModels;
|
|
|
|
namespace PortfolioManager.Models
|
|
{
|
|
public class StopLimitCompositeModel
|
|
{
|
|
private StopLimitCompositeModel()
|
|
{
|
|
}
|
|
|
|
public static CompositeDataSource Empty()
|
|
{
|
|
CompositeDataSource compositeDataSource = new CompositeDataSource()
|
|
{
|
|
DataAdapter = new SortedDateTimeDataAdapter()
|
|
};
|
|
return compositeDataSource;
|
|
}
|
|
|
|
public static CompositeDataSource CreateCompositeDataSource(StopLimits stopLimits)
|
|
{
|
|
if (null == stopLimits || 0 == stopLimits.Count) return Empty();
|
|
SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter();
|
|
List<StopLimit> sortedStopLimits = stopLimits.OrderBy(x => x.EffectiveDate).ToList();
|
|
foreach (StopLimit stopLimit in sortedStopLimits)
|
|
{
|
|
sortedDateTimeDataAdapter.Add(stopLimit.EffectiveDate, stopLimit.StopPrice);
|
|
}
|
|
CompositeDataSource compositeDataSource = new CompositeDataSource()
|
|
{
|
|
DataAdapter = sortedDateTimeDataAdapter
|
|
};
|
|
return compositeDataSource;
|
|
}
|
|
}
|
|
} |