diff --git a/PortfolioManager/Models/BollingerBandModel.cs b/PortfolioManager/Models/BollingerBandModel.cs new file mode 100644 index 0000000..7b9bbf8 --- /dev/null +++ b/PortfolioManager/Models/BollingerBandModel.cs @@ -0,0 +1,189 @@ +using System.Collections.Generic; +using System.Linq; +using Eremex.AvaloniaUI.Charts; +using MarketData.MarketDataModel; +using MarketData.Numerical; +using PortfolioManager.DataSeriesViewModels; + +namespace PortfolioManager.Models +{ + public class BollingerBandModel + { + private BollingerBandModel() + { + } + + public static CompositeDataSource Empty() + { + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = new SortedDateTimeDataAdapter() + }; + return compositeDataSource; + } + + public static CompositeDataSource SMAN(BollingerBands bollingerBands) + { + if (null == bollingerBands || 0 == bollingerBands.Count) return Empty(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + List sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); + foreach (BollingerBandElement bollingerBandElement in sortedBollingerBands) + { + sortedDateTimeDataAdapter.Add(bollingerBandElement.Date, bollingerBandElement.SMAN); + } + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + + public static CompositeDataSource K(BollingerBands bollingerBands) + { + if (null == bollingerBands || 0 == bollingerBands.Count) return Empty(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + List sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); + foreach (BollingerBandElement bollingerBandElement in sortedBollingerBands) + { + sortedDateTimeDataAdapter.Add(bollingerBandElement.Date, bollingerBandElement.K); + } + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + + public static CompositeDataSource KL1(BollingerBands bollingerBands) + { + if (null == bollingerBands || 0 == bollingerBands.Count) return Empty(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + List sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); + foreach (BollingerBandElement bollingerBandElement in sortedBollingerBands) + { + sortedDateTimeDataAdapter.Add(bollingerBandElement.Date, bollingerBandElement.KL1); + } + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + + public static CompositeDataSource L(BollingerBands bollingerBands) + { + if (null == bollingerBands || 0 == bollingerBands.Count) return Empty(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + List sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); + foreach (BollingerBandElement bollingerBandElement in sortedBollingerBands) + { + sortedDateTimeDataAdapter.Add(bollingerBandElement.Date, bollingerBandElement.L); + } + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + + public static CompositeDataSource LP1(BollingerBands bollingerBands) + { + if (null == bollingerBands || 0 == bollingerBands.Count) return Empty(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + List sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); + foreach (BollingerBandElement bollingerBandElement in sortedBollingerBands) + { + sortedDateTimeDataAdapter.Add(bollingerBandElement.Date, bollingerBandElement.LP1); + } + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + + public static CompositeDataSource High(BollingerBands bollingerBands) + { + if (null == bollingerBands || 0 == bollingerBands.Count) return Empty(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + List sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); + foreach (BollingerBandElement bollingerBandElement in sortedBollingerBands) + { + sortedDateTimeDataAdapter.Add(bollingerBandElement.Date, bollingerBandElement.High); + } + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + + public static CompositeDataSource Low(BollingerBands bollingerBands) + { + if (null == bollingerBands || 0 == bollingerBands.Count) return Empty(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + List sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); + foreach (BollingerBandElement bollingerBandElement in sortedBollingerBands) + { + sortedDateTimeDataAdapter.Add(bollingerBandElement.Date, bollingerBandElement.Low); + } + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + + public static CompositeDataSource Close(BollingerBands bollingerBands) + { + if (null == bollingerBands || 0 == bollingerBands.Count) return Empty(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + List sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); + foreach (BollingerBandElement bollingerBandElement in sortedBollingerBands) + { + sortedDateTimeDataAdapter.Add(bollingerBandElement.Date, bollingerBandElement.Close); + } + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + + public static CompositeDataSource Volume(BollingerBands bollingerBands) + { + if (null == bollingerBands || 0 == bollingerBands.Count) return Empty(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + List sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); + foreach (BollingerBandElement bollingerBandElement in sortedBollingerBands) + { + sortedDateTimeDataAdapter.Add(bollingerBandElement.Date, bollingerBandElement.Volume); + } + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + +// 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; + LeastSquaresResult leastSquaresResult = bollingerBands.LeastSquaresFitClose(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + List sortedBollingerBands = bollingerBands.OrderBy(x => x.Date).ToList(); + for (int index = 0; index < bollingerBands.Count; index++) + { + BollingerBandElement element = bollingerBands[index]; + int leastSquaresIndex = (leastSquaresResult.LeastSquares.Length - 1) - index; + sortedDateTimeDataAdapter.Add(element.Date, leastSquaresResult.LeastSquares[leastSquaresIndex]); + } + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + } +} diff --git a/PortfolioManager/Models/GainLossModel.cs b/PortfolioManager/Models/GainLossModel.cs index ced16fb..98e371d 100644 --- a/PortfolioManager/Models/GainLossModel.cs +++ b/PortfolioManager/Models/GainLossModel.cs @@ -4,6 +4,7 @@ using Eremex.AvaloniaUI.Charts; using MarketData.MarketDataModel; using MarketData.MarketDataModel.GainLoss; using MarketData.Numerical; +using MarketData.Utils; using PortfolioManager.DataSeriesViewModels; namespace PortfolioManager.Models @@ -27,16 +28,24 @@ namespace PortfolioManager.Models { if (null == price) return Empty(); SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + sortedDateTimeDataAdapter.Add(price.Date, price.Close); + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } - - // CompositeDataSource compositeDataSource; - // var xData = new EnumerableDataSource(new DateTime[]{price.Date}); - // xData.SetXMapping(x => (x.Ticks / 10000000000.0)); - // var yData = new EnumerableDataSource(new double[]{price.Close}); - // yData.SetYMapping(y => y); - // compositeDataSource = xData.Join(yData); - // return compositeDataSource; - return Empty(); + public static CompositeDataSource CreateCompositeDataSource(DateTime xSource, double ySource) + { + if (Utility.IsEpoch(xSource)) return Empty(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + sortedDateTimeDataAdapter.Add(xSource, ySource); + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; } // This is the active gain/loss as number or percent. diff --git a/PortfolioManager/Models/PortfolioTradeModel.cs b/PortfolioManager/Models/PortfolioTradeModel.cs new file mode 100644 index 0000000..90c5bee --- /dev/null +++ b/PortfolioManager/Models/PortfolioTradeModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml.Linq; +using Eremex.AvaloniaUI.Charts; +using MarketData.MarketDataModel; +using PortfolioManager.DataSeriesViewModels; + +namespace PortfolioManager.Models +{ + public class PortfolioTradeModel + { + private PortfolioTradeModel() + { + } + public static CompositeDataSource PortfolioTrades(PortfolioTrades portfolioTrades) + { + if (null == portfolioTrades || 0 == portfolioTrades.Count) return null; + List sortedPortfolioTrades = portfolioTrades.OrderBy(x => x.TradeDate).ToList(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + foreach (PortfolioTrade portfolioTrade in sortedPortfolioTrades) + { + sortedDateTimeDataAdapter.Add(portfolioTrade.TradeDate, portfolioTrade.Price); + } + + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + } +} \ No newline at end of file diff --git a/PortfolioManager/Models/StopLimitCompositeModel.cs b/PortfolioManager/Models/StopLimitCompositeModel.cs new file mode 100644 index 0000000..c40fdeb --- /dev/null +++ b/PortfolioManager/Models/StopLimitCompositeModel.cs @@ -0,0 +1,41 @@ +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 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; + } + } +} \ No newline at end of file diff --git a/PortfolioManager/ViewModels/BollingerBandViewModel.cs b/PortfolioManager/ViewModels/BollingerBandViewModel.cs index b8c8015..a59aba3 100644 --- a/PortfolioManager/ViewModels/BollingerBandViewModel.cs +++ b/PortfolioManager/ViewModels/BollingerBandViewModel.cs @@ -27,17 +27,21 @@ namespace PortfolioManager.ViewModels private int selectedDayCount = 90; private ObservableCollection symbols = new ObservableCollection(); private String selectedSymbol = default; + private bool showMarkers = false; private InsiderTransactionSummaries insiderTransactionSummaries = null; private Price zeroPrice = null; private PortfolioTrades portfolioTrades; private PortfolioTrades portfolioTradesLots; private StopLimit stopLimit; // This is the stop limit that is looked up in the database and displayed (if there is one) + private StopLimits stopLimits; // These stop limits might be passed in with the SaveParams. (i.e.) MMTRend model passes in StopLimits. If these are passsed in then they are displayed instead of stopLimit. private Prices prices = null; private bool syncTradeToBand = true; private String companyName = default; + private bool useLeastSquaresFit = true; + private CompositeDataSource compositeDataSourceZeroPoint = null; private CompositeDataSource compositeDataSourceStopLimit = null; @@ -119,6 +123,19 @@ namespace PortfolioManager.ViewModels } } + public bool ShowMarkers + { + get + { + return showMarkers; + } + set + { + showMarkers = value; + base.OnPropertyChanged("ShowMarkers"); + } + } + public ObservableCollection Symbols { get @@ -288,29 +305,29 @@ namespace PortfolioManager.ViewModels base.OnPropertyChanged("SMAN"); base.OnPropertyChanged("Volume"); base.OnPropertyChanged("LeastSquares"); - base.OnPropertyChanged("Title"); - base.OnPropertyChanged("TradePoints"); - base.OnPropertyChanged("Markers"); - base.OnPropertyChanged("ZeroPoint"); - base.OnPropertyChanged("ZeroPointMarkers"); - base.OnPropertyChanged("StopLimit"); - base.OnPropertyChanged("StopLimitMarkers"); - base.OnPropertyChanged("RiskFreeRatePoint"); - base.OnPropertyChanged("RiskFreeRatePointMarkers"); + // base.OnPropertyChanged("Title"); + // base.OnPropertyChanged("TradePoints"); + // base.OnPropertyChanged("Markers"); + // base.OnPropertyChanged("ZeroPoint"); + // base.OnPropertyChanged("ZeroPointMarkers"); + // base.OnPropertyChanged("StopLimit"); + // base.OnPropertyChanged("StopLimitMarkers"); + // base.OnPropertyChanged("RiskFreeRatePoint"); + // base.OnPropertyChanged("RiskFreeRatePointMarkers"); - base.OnPropertyChanged("InsiderTransactionPointDisposedSmall"); - base.OnPropertyChanged("InsiderTransactionPointMarkersDisposedSmall"); - base.OnPropertyChanged("InsiderTransactionPointDisposedMedium"); - base.OnPropertyChanged("InsiderTransactionPointMarkersDisposedMedium"); - base.OnPropertyChanged("InsiderTransactionPointDisposedLarge"); - base.OnPropertyChanged("InsiderTransactionPointMarkersDisposedLarge"); + // base.OnPropertyChanged("InsiderTransactionPointDisposedSmall"); + // base.OnPropertyChanged("InsiderTransactionPointMarkersDisposedSmall"); + // base.OnPropertyChanged("InsiderTransactionPointDisposedMedium"); + // base.OnPropertyChanged("InsiderTransactionPointMarkersDisposedMedium"); + // base.OnPropertyChanged("InsiderTransactionPointDisposedLarge"); + // base.OnPropertyChanged("InsiderTransactionPointMarkersDisposedLarge"); - base.OnPropertyChanged("InsiderTransactionPointAcquiredSmall"); - base.OnPropertyChanged("InsiderTransactionPointMarkersAcquiredSmall"); - base.OnPropertyChanged("InsiderTransactionPointAcquiredMedium"); - base.OnPropertyChanged("InsiderTransactionPointMarkersAcquiredMedium"); - base.OnPropertyChanged("InsiderTransactionPointAcquiredLarge"); - base.OnPropertyChanged("InsiderTransactionPointMarkersAcquiredLarge"); + // base.OnPropertyChanged("InsiderTransactionPointAcquiredSmall"); + // base.OnPropertyChanged("InsiderTransactionPointMarkersAcquiredSmall"); + // base.OnPropertyChanged("InsiderTransactionPointAcquiredMedium"); + // base.OnPropertyChanged("InsiderTransactionPointMarkersAcquiredMedium"); + // base.OnPropertyChanged("InsiderTransactionPointAcquiredLarge"); + // base.OnPropertyChanged("InsiderTransactionPointMarkersAcquiredLarge"); }); } else if (eventArgs.PropertyName.Equals("SelectedWatchList")) @@ -340,54 +357,133 @@ namespace PortfolioManager.ViewModels } +// ************************************************* C O M P O S I T E P R O P E R T I E S ******************************************** + + public CompositeDataSource K + { + get + { + return compositeDataSourceK; + } + } + public CompositeDataSource KL1 + { + get + { + return compositeDataSourceKL1; + } + } + + public CompositeDataSource L + { + get + { + return compositeDataSourceL; + } + } + public CompositeDataSource LP1 + { + get + { + return compositeDataSourceLP1; + } + } + public CompositeDataSource High + { + get + { + return compositeDataSourceHigh; + } + } + public CompositeDataSource Low + { + get + { + return compositeDataSourceLow; + } + } + public CompositeDataSource Close + { + get + { + return compositeDataSourceClose; + } + } + public CompositeDataSource SMAN + { + get + { + return compositeDataSourceSMAN; + } + } + public CompositeDataSource Volume + { + get + { + return compositeDataSourceVolume; + } + } + + public CompositeDataSource LeastSquares + { + get + { + if(!useLeastSquaresFit||null==bollingerBands)return null; + return compositeDataSourceLeastSquares; + } + } + + + + // ********************************************************************************************************************************************* + + + public void CreateCompositeDataSources() { - if(null==prices || 0==prices.Count)return; - double minClose=(from Price price in prices select price.Close).Min(); + if (null == prices || 0 == prices.Count) return; + double minClose = (from Price price in prices select price.Close).Min(); + // get the maximum date in the bollinger band series + DateTime maxBollingerDate = (from BollingerBandElement bollingerBandElement in bollingerBands select bollingerBandElement.Date).Max(); + // ensure that the insider transactions are clipped to the bollingerband max date. There are some items in insider transaction summaries (options dated in the future) that will throw the graphic out of proportion + InsiderTransactionSummaries disposedSummaries = new InsiderTransactionSummaries((from InsiderTransactionSummary insiderTransactionSummary in insiderTransactionSummaries where insiderTransactionSummary.NumberOfSharesAcquiredDisposed < 0 && insiderTransactionSummary.TransactionDate.Date <= maxBollingerDate select insiderTransactionSummary).ToList()); + InsiderTransactionSummaries acquiredSummaries = new InsiderTransactionSummaries((from InsiderTransactionSummary insiderTransactionSummary in insiderTransactionSummaries where insiderTransactionSummary.NumberOfSharesAcquiredDisposed > 0 && insiderTransactionSummary.TransactionDate.Date <= maxBollingerDate select insiderTransactionSummary).ToList()); -// get the maximum date in the bollinger band series - DateTime maxBollingerDate=(from BollingerBandElement bollingerBandElement in bollingerBands select bollingerBandElement.Date).Max(); -// ensure that the insider transactions are clipped to the bollingerband max date. There are some items in insider transaction summaries (options dated in the future) that will throw the graphic out of proportion - InsiderTransactionSummaries disposedSummaries=new InsiderTransactionSummaries((from InsiderTransactionSummary insiderTransactionSummary in insiderTransactionSummaries where insiderTransactionSummary.NumberOfSharesAcquiredDisposed<0 && insiderTransactionSummary.TransactionDate.Date<=maxBollingerDate select insiderTransactionSummary).ToList()); - InsiderTransactionSummaries acquiredSummaries=new InsiderTransactionSummaries((from InsiderTransactionSummary insiderTransactionSummary in insiderTransactionSummaries where insiderTransactionSummary.NumberOfSharesAcquiredDisposed>0 && insiderTransactionSummary.TransactionDate.Date<=maxBollingerDate select insiderTransactionSummary).ToList()); + BinCollection disposedSummariesBin = BinHelper.CreateBins(new BinItems(disposedSummaries), 3); + BinCollection acquiredSummariesBin = BinHelper.CreateBins(new BinItems(acquiredSummaries), 3); - BinCollection disposedSummariesBin=BinHelper.CreateBins(new BinItems(disposedSummaries),3); - BinCollection acquiredSummariesBin=BinHelper.CreateBins(new BinItems(acquiredSummaries),3); - - compositeDataSourceZeroPoint = GainLossModel.Price(zeroPrice); -/* - if(null!=stopLimits) + + if (null != stopLimits) { - compositeDataSourceStopLimit=StopLimitCompositeModel.CreateCompositeDataSource(stopLimits); + compositeDataSourceStopLimit = StopLimitCompositeModel.CreateCompositeDataSource(stopLimits); } - else if(null!=stopLimit && null!=zeroPrice) + else if (null != stopLimit && null != zeroPrice) { - compositeDataSourceStopLimit=GainLossModel.CreateCompositeDataSource(zeroPrice.Date,stopLimit.StopPrice); + compositeDataSourceStopLimit = GainLossModel.CreateCompositeDataSource(zeroPrice.Date, stopLimit.StopPrice); } - compositeDataSourceInsiderTransactionPointDisposedSmall=InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(disposedSummariesBin[2]),minClose); - compositeDataSourceInsiderTransactionPointDisposedMedium=InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(disposedSummariesBin[1]),minClose); - compositeDataSourceInsiderTransactionPointDisposedLarge=InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(disposedSummariesBin[0]),minClose); - compositeDataSourceInsiderTransactionPointAcquiredSmall=InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(acquiredSummariesBin[0]),minClose); - compositeDataSourceInsiderTransactionPointAcquiredMedium=InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(acquiredSummariesBin[1]),minClose); - compositeDataSourceInsiderTransactionPointAcquiredLarge=InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(acquiredSummariesBin[2]),minClose); + compositeDataSourceInsiderTransactionPointDisposedSmall = InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(disposedSummariesBin[2]), minClose); + compositeDataSourceInsiderTransactionPointDisposedMedium = InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(disposedSummariesBin[1]), minClose); + compositeDataSourceInsiderTransactionPointDisposedLarge = InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(disposedSummariesBin[0]), minClose); + compositeDataSourceInsiderTransactionPointAcquiredSmall = InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(acquiredSummariesBin[0]), minClose); + compositeDataSourceInsiderTransactionPointAcquiredMedium = InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(acquiredSummariesBin[1]), minClose); + compositeDataSourceInsiderTransactionPointAcquiredLarge = InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(acquiredSummariesBin[2]), minClose); - compositeDataSourceK =BollingerBandModel.K(bollingerBands); - compositeDataSourceKL1 =BollingerBandModel.KL1(bollingerBands); - compositeDataSourceL =BollingerBandModel.L(bollingerBands); - compositeDataSourceLP1 =BollingerBandModel.LP1(bollingerBands); - compositeDataSourceHigh =BollingerBandModel.High(bollingerBands); - compositeDataSourceLow =BollingerBandModel.Low(bollingerBands); - compositeDataSourceClose =BollingerBandModel.Close(bollingerBands); - compositeDataSourceSMAN =BollingerBandModel.SMAN(bollingerBands); - compositeDataSourceVolume =BollingerBandModel.Volume(bollingerBands); + compositeDataSourceK = BollingerBandModel.K(bollingerBands); + compositeDataSourceKL1 = BollingerBandModel.KL1(bollingerBands); + compositeDataSourceL = BollingerBandModel.L(bollingerBands); + compositeDataSourceLP1 = BollingerBandModel.LP1(bollingerBands); + compositeDataSourceHigh = BollingerBandModel.High(bollingerBands); + compositeDataSourceLow = BollingerBandModel.Low(bollingerBands); + compositeDataSourceClose = BollingerBandModel.Close(bollingerBands); + compositeDataSourceSMAN = BollingerBandModel.SMAN(bollingerBands); + compositeDataSourceVolume = BollingerBandModel.Volume(bollingerBands); compositeDataSourceLeastSquares = BollingerBandModel.LeastSquares(bollingerBands); compositeDataSourceTradePoints = PortfolioTradeModel.PortfolioTrades(portfolioTradesLots); -*/ } private void InitializeDataSources() diff --git a/PortfolioManager/ViewModels/InsiderTransactionModel.cs b/PortfolioManager/ViewModels/InsiderTransactionModel.cs new file mode 100644 index 0000000..f50f532 --- /dev/null +++ b/PortfolioManager/ViewModels/InsiderTransactionModel.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using MarketData.MarketDataModel; +using MarketData.Generator; +using PortfolioManager.DataSeriesViewModels; +using Eremex.AvaloniaUI.Charts; + +namespace PortfolioManager.Models +{ + public class InsiderTransactionModel + { + private InsiderTransactionModel() + { + } + + public static CompositeDataSource Empty() + { + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = new SortedDateTimeDataAdapter() + }; + return compositeDataSource; + } + + public static CompositeDataSource InsiderTransactionSummaries(InsiderTransactionSummaries insiderTransactionSummaries, double minPrice) + { + if (null == insiderTransactionSummaries || 0 == insiderTransactionSummaries.Count) return Empty(); + SortedDateTimeDataAdapter sortedDateTimeDataAdapter = new SortedDateTimeDataAdapter(); + List sortedInsiderTransactionSummaries = insiderTransactionSummaries.OrderBy(x => x.TransactionDate).ToList(); + foreach (InsiderTransactionSummary insiderTransactionSummary in sortedInsiderTransactionSummaries) + { + sortedDateTimeDataAdapter.Add(insiderTransactionSummary.TransactionDate, minPrice); + } + CompositeDataSource compositeDataSource = new CompositeDataSource() + { + DataAdapter = sortedDateTimeDataAdapter + }; + return compositeDataSource; + } + } +} \ No newline at end of file diff --git a/PortfolioManager/Views/BollingerBandView.axaml b/PortfolioManager/Views/BollingerBandView.axaml index 9fcc367..2638d30 100644 --- a/PortfolioManager/Views/BollingerBandView.axaml +++ b/PortfolioManager/Views/BollingerBandView.axaml @@ -42,8 +42,6 @@ - - @@ -64,22 +62,10 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -