Commit Latest
This commit is contained in:
@@ -27,17 +27,21 @@ namespace PortfolioManager.ViewModels
|
||||
private int selectedDayCount = 90;
|
||||
private ObservableCollection<String> symbols = new ObservableCollection<String>();
|
||||
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<String> 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<InsiderTransactionSummary> disposedSummariesBin = BinHelper<InsiderTransactionSummary>.CreateBins(new BinItems<InsiderTransactionSummary>(disposedSummaries), 3);
|
||||
BinCollection<InsiderTransactionSummary> acquiredSummariesBin = BinHelper<InsiderTransactionSummary>.CreateBins(new BinItems<InsiderTransactionSummary>(acquiredSummaries), 3);
|
||||
|
||||
BinCollection<InsiderTransactionSummary> disposedSummariesBin=BinHelper<InsiderTransactionSummary>.CreateBins(new BinItems<InsiderTransactionSummary>(disposedSummaries),3);
|
||||
BinCollection<InsiderTransactionSummary> acquiredSummariesBin=BinHelper<InsiderTransactionSummary>.CreateBins(new BinItems<InsiderTransactionSummary>(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()
|
||||
|
||||
42
PortfolioManager/ViewModels/InsiderTransactionModel.cs
Normal file
42
PortfolioManager/ViewModels/InsiderTransactionModel.cs
Normal file
@@ -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<InsiderTransactionSummary> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user