Commit Latest
This commit is contained in:
189
PortfolioManager/Models/BollingerBandModel.cs
Normal file
189
PortfolioManager/Models/BollingerBandModel.cs
Normal file
@@ -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<BollingerBandElement> 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<BollingerBandElement> 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<BollingerBandElement> 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<BollingerBandElement> 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<BollingerBandElement> 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<BollingerBandElement> 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<BollingerBandElement> 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<BollingerBandElement> 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<BollingerBandElement> 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<BollingerBandElement> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<DateTime>(new DateTime[]{price.Date});
|
||||
// xData.SetXMapping(x => (x.Ticks / 10000000000.0));
|
||||
// var yData = new EnumerableDataSource<double>(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.
|
||||
|
||||
33
PortfolioManager/Models/PortfolioTradeModel.cs
Normal file
33
PortfolioManager/Models/PortfolioTradeModel.cs
Normal file
@@ -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<PortfolioTrade> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
PortfolioManager/Models/StopLimitCompositeModel.cs
Normal file
41
PortfolioManager/Models/StopLimitCompositeModel.cs
Normal file
@@ -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<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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,6 @@
|
||||
<RowDefinition Height="89*" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Vertical">
|
||||
<!-- Fields go here -->
|
||||
|
||||
<Label Content="Watch List" HorizontalAlignment="Left" ></Label>
|
||||
<ComboBox ItemsSource="{Binding Path=WatchListNames, Mode=OneWay}" SelectedItem="{Binding Path=SelectedWatchList}">
|
||||
<ComboBox.ItemsPanel>
|
||||
@@ -64,22 +62,10 @@
|
||||
|
||||
<Label Content="Day Count" HorizontalAlignment="Left" ></Label>
|
||||
<ComboBox ItemsSource="{Binding Path=DayCounts, Mode=OneWay}" SelectedItem="{Binding Path=SelectedDayCount}"/>
|
||||
|
||||
<!--
|
||||
<Label Content="Watch List" HorizontalAlignment="Left"></Label>
|
||||
<ComboBox ItemsSource="{Binding Path=WatchListNames, Mode=OneTime}" SelectedItem="{Binding Path=SelectedWatchList}" ></ComboBox>
|
||||
<Label Content="Symbol" HorizontalAlignment="Left"></Label>
|
||||
<ComboBox Name="cbSymbols" ItemsSource="{Binding Path=Symbols, Mode=OneWay}" SelectedItem="{Binding Path=SelectedSymbol}" UseLayoutRounding="False" >
|
||||
<ComboBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel/>
|
||||
</ItemsPanelTemplate>true
|
||||
</ComboBox.ItemsPanel>
|
||||
</ComboBox>
|
||||
<Label Content="Day Count" HorizontalAlignment="Left" ></Label>
|
||||
<ComboBox ItemsSource="{Binding Path=DayCounts, Mode=OneWay}" SelectedItem="{Binding Path=SelectedDayCount}" ></ComboBox>
|
||||
<Button Margin="0,2" Content="Refresh" HorizontalAlignment="Left" Command="{Binding Path=RefreshCommand}"></Button> -->
|
||||
</StackPanel>
|
||||
<!--
|
||||
<Button Margin="0,2" Content="Refresh" HorizontalAlignment="Left" Command="{Binding Path=RefreshCommand}"></Button> -->
|
||||
|
||||
<!-- <CheckBox Content="Sync Trade To Band" IsChecked="{Binding Mode=TwoWay,Path=SyncTradeToBand}" Grid.ColumnSpan="3" Grid.Row="3" Height="16" HorizontalAlignment="Left" Margin="5,6,0,0" VerticalAlignment="Top" />
|
||||
<CheckBox Content="Show Trade Labels" IsChecked="{Binding Mode=TwoWay,Path=ShowTradeLabels}" Grid.ColumnSpan="3" Grid.Row="4" Height="16" HorizontalAlignment="Left" Margin="5,6,0,0" VerticalAlignment="Top" />
|
||||
<CheckBox Content="Show Insider Transactions" IsChecked="{Binding Mode=TwoWay,Path=CheckBoxShowInsiderTransactions}" Grid.ColumnSpan="3" Grid.Row="5" Height="16" HorizontalAlignment="Left" Margin="5,6,0,0" VerticalAlignment="Top" />
|
||||
@@ -93,13 +79,67 @@
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<mxc:CartesianChart Grid.Row="0">
|
||||
<!-- <mxc:CartesianChart.Series>
|
||||
<mxc:CartesianSeries Name="PerformanceSeries" DataAdapter="{Binding Data.DataAdapter}" >
|
||||
<mxc:CartesianLineSeriesView Color="MidnightBlue" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>
|
||||
<mxc:CartesianChart.AxesY>
|
||||
<mxc:AxisY Title="Price">
|
||||
<mxc:AxisYRange AlwaysShowZeroLevel="False" />
|
||||
</mxc:AxisY>
|
||||
</mxc:CartesianChart.AxesY>
|
||||
|
||||
<mxc:CartesianChart.Series>
|
||||
<mxc:CartesianSeries Name="KSeries" DataAdapter="{Binding K.DataAdapter}" >
|
||||
<mxc:CartesianLineSeriesView Color="Green" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="3"/>
|
||||
</mxc:CartesianSeries>
|
||||
</mxc:CartesianChart.Series> -->
|
||||
</mxc:CartesianChart.Series>
|
||||
|
||||
<mxc:CartesianChart.Series>
|
||||
<mxc:CartesianSeries Name="KL1Series" DataAdapter="{Binding KL1.DataAdapter}" >
|
||||
<mxc:CartesianLineSeriesView Color="Green" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>
|
||||
</mxc:CartesianSeries>
|
||||
</mxc:CartesianChart.Series>
|
||||
|
||||
<mxc:CartesianChart.Series>
|
||||
<mxc:CartesianSeries Name="LSeries" DataAdapter="{Binding L.DataAdapter}" >
|
||||
<mxc:CartesianLineSeriesView Color="Green" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="3"/>
|
||||
</mxc:CartesianSeries>
|
||||
</mxc:CartesianChart.Series>
|
||||
|
||||
<mxc:CartesianChart.Series>
|
||||
<mxc:CartesianSeries Name="LP1Series" DataAdapter="{Binding LP1.DataAdapter}" >
|
||||
<mxc:CartesianLineSeriesView Color="Green" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>
|
||||
</mxc:CartesianSeries>
|
||||
</mxc:CartesianChart.Series>
|
||||
|
||||
<mxc:CartesianChart.Series>
|
||||
<mxc:CartesianSeries Name="HighSeries" DataAdapter="{Binding High.DataAdapter}" >
|
||||
<mxc:CartesianLineSeriesView Color="Blue" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>
|
||||
</mxc:CartesianSeries>
|
||||
</mxc:CartesianChart.Series>
|
||||
|
||||
<mxc:CartesianChart.Series>
|
||||
<mxc:CartesianSeries Name="LowSeries" DataAdapter="{Binding Low.DataAdapter}" >
|
||||
<mxc:CartesianLineSeriesView Color="Red" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>
|
||||
</mxc:CartesianSeries>
|
||||
</mxc:CartesianChart.Series>
|
||||
|
||||
<mxc:CartesianChart.Series>
|
||||
<mxc:CartesianSeries Name="CloseSeries" DataAdapter="{Binding Close.DataAdapter}" >
|
||||
<mxc:CartesianLineSeriesView Color="Black" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>
|
||||
</mxc:CartesianSeries>
|
||||
</mxc:CartesianChart.Series>
|
||||
|
||||
<mxc:CartesianChart.Series>
|
||||
<mxc:CartesianSeries Name="LeastSquares" DataAdapter="{Binding LeastSquares.DataAdapter}" >
|
||||
<mxc:CartesianLineSeriesView Color="Orange" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>
|
||||
</mxc:CartesianSeries>
|
||||
</mxc:CartesianChart.Series>
|
||||
|
||||
<mxc:CartesianChart.Series>
|
||||
<mxc:CartesianSeries Name="SMANSeries" DataAdapter="{Binding SMAN.DataAdapter}" >
|
||||
<mxc:CartesianLineSeriesView Color="Purple" MarkerSize="4" ShowMarkers="{Binding Path=ShowMarkers, Mode=TwoWay}" Thickness="2"/>
|
||||
</mxc:CartesianSeries>
|
||||
</mxc:CartesianChart.Series>
|
||||
|
||||
</mxc:CartesianChart>
|
||||
<!-- The Chart goes here at grid.row =0 -->
|
||||
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
|
||||
Reference in New Issue
Block a user