Commit Latest
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
vscode settings are in C:\Users\skess\AppData\Roaming\Code\User/settings.json
|
||||||
|
|
||||||
|
|
||||||
dotnet new avalonia.window -na EditPositionDialog -n PortfolioManager.Dialog
|
dotnet new avalonia.window -na EditPositionDialog -n PortfolioManager.Dialog
|
||||||
dotnet new avalonia.usercontrol -na [namespace] -n [name]
|
dotnet new avalonia.usercontrol -na [namespace] -n [name]
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ namespace PortfolioManager.Renderers
|
|||||||
private int selectedDayCount = int.MinValue;
|
private int selectedDayCount = int.MinValue;
|
||||||
private Price latestPrice = default;
|
private Price latestPrice = default;
|
||||||
private Price zeroPrice = default;
|
private Price zeroPrice = default;
|
||||||
private bool showLabels = true;
|
|
||||||
private bool showMarkers = true;
|
private bool showMarkers = true;
|
||||||
private bool showLegend = false;
|
private bool showLegend = false;
|
||||||
private bool showTradeLabels = true;
|
private bool showTradeLabels = true;
|
||||||
@@ -90,13 +89,7 @@ namespace PortfolioManager.Renderers
|
|||||||
|
|
||||||
private void OnBollingerBandRendererPropertyChanged(Object sender, PropertyChangedEventArgs eventArgs)
|
private void OnBollingerBandRendererPropertyChanged(Object sender, PropertyChangedEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (eventArgs.PropertyName.Equals("ShowLabels"))
|
if (eventArgs.PropertyName.Equals("ShowLegend"))
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (eventArgs.PropertyName.Equals("ShowMarkers"))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (eventArgs.PropertyName.Equals("ShowLegend"))
|
|
||||||
{
|
{
|
||||||
if (!ShowLegend) Plotter.Plot.HideLegend();
|
if (!ShowLegend) Plotter.Plot.HideLegend();
|
||||||
else Plotter.Plot.ShowLegend();
|
else Plotter.Plot.ShowLegend();
|
||||||
@@ -106,10 +99,6 @@ namespace PortfolioManager.Renderers
|
|||||||
if (!ShowLegend) Plotter.Plot.HideLegend();
|
if (!ShowLegend) Plotter.Plot.HideLegend();
|
||||||
else Plotter.Plot.ShowLegend();
|
else Plotter.Plot.ShowLegend();
|
||||||
}
|
}
|
||||||
// else if (eventArgs.PropertyName.Equals("ShowInsiderTransactions"))
|
|
||||||
// {
|
|
||||||
// SetData(selectedSymbol, selectedDayCount);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Render()
|
public void Render()
|
||||||
@@ -169,12 +158,15 @@ namespace PortfolioManager.Renderers
|
|||||||
bollingerBands = BollingerBandGenerator.GenerateBollingerBands(prices);
|
bollingerBands = BollingerBandGenerator.GenerateBollingerBands(prices);
|
||||||
CalculateOffsets();
|
CalculateOffsets();
|
||||||
GenerateBollingerBands();
|
GenerateBollingerBands();
|
||||||
GenerateZeroPoint(zeroPrice);
|
|
||||||
GenerateInsiderTransactions();
|
GenerateInsiderTransactions();
|
||||||
GenerateStopLimits();
|
GenerateStopLimits();
|
||||||
GenerateTradePoints();
|
GenerateTradePoints();
|
||||||
|
GenerateZeroPoint(zeroPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// These offsets are used to place markers relative to the area in which the graph occupies.
|
||||||
|
/// </summary>
|
||||||
private void CalculateOffsets()
|
private void CalculateOffsets()
|
||||||
{
|
{
|
||||||
double maxBollingerDate = bollingerBands.Max(x => x.Date).ToOADate();
|
double maxBollingerDate = bollingerBands.Max(x => x.Date).ToOADate();
|
||||||
@@ -276,7 +268,7 @@ namespace PortfolioManager.Renderers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (null == zeroPrice) return;
|
if (null == zeroPrice) return;
|
||||||
if (null == stopLimit || null == zeroPrice || !showTradeLabels) return;
|
if (null == stopLimit || null == zeroPrice) return;
|
||||||
Price latestPrice = prices[0];
|
Price latestPrice = prices[0];
|
||||||
double percentOffsetFromLow = ((latestPrice.Low - stopLimit.StopPrice) / stopLimit.StopPrice);
|
double percentOffsetFromLow = ((latestPrice.Low - stopLimit.StopPrice) / stopLimit.StopPrice);
|
||||||
|
|
||||||
@@ -295,7 +287,7 @@ namespace PortfolioManager.Renderers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void GenerateTradePoints()
|
private void GenerateTradePoints()
|
||||||
{
|
{
|
||||||
if (null == portfolioTradesLots || 0 == portfolioTradesLots.Count || !showTradeLabels) return;
|
if (null == portfolioTradesLots || 0 == portfolioTradesLots.Count) return;
|
||||||
// Here we add the image markers
|
// Here we add the image markers
|
||||||
Image tradePointMarker = TextMarkerImageGenerator.ToSPImage(ImageCache.GetInstance().GetImage(ImageCache.ImageType.YellowTriangleUp));
|
Image tradePointMarker = TextMarkerImageGenerator.ToSPImage(ImageCache.GetInstance().GetImage(ImageCache.ImageType.YellowTriangleUp));
|
||||||
for (int index = 0; index < portfolioTradesLots.Count; index++)
|
for (int index = 0; index < portfolioTradesLots.Count; index++)
|
||||||
@@ -305,6 +297,8 @@ namespace PortfolioManager.Renderers
|
|||||||
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, tradePointMarker, SizeFactor.Normal);
|
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, tradePointMarker, SizeFactor.Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showTradeLabels)
|
||||||
|
{
|
||||||
// This adds the text markers
|
// This adds the text markers
|
||||||
for (int index = 0; index < portfolioTradesLots.Count; index++)
|
for (int index = 0; index < portfolioTradesLots.Count; index++)
|
||||||
{
|
{
|
||||||
@@ -320,6 +314,7 @@ namespace PortfolioManager.Renderers
|
|||||||
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate Insider Transactions
|
/// Generate Insider Transactions
|
||||||
@@ -524,16 +519,16 @@ namespace PortfolioManager.Renderers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShowLabels
|
public bool ShowTradeLabels
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return showLabels;
|
return showTradeLabels;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
showLabels = value;
|
showTradeLabels = value;
|
||||||
base.OnPropertyChanged("ShowLabels");
|
base.OnPropertyChanged("ShowTradeLabels");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,11 @@ using System.Threading.Tasks;
|
|||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using MarketData;
|
using MarketData;
|
||||||
using MarketData.Cache;
|
|
||||||
using MarketData.DataAccess;
|
using MarketData.DataAccess;
|
||||||
using MarketData.MarketDataModel;
|
using MarketData.MarketDataModel;
|
||||||
using MarketData.Utils;
|
using MarketData.Utils;
|
||||||
using PortfolioManager.Renderers;
|
using PortfolioManager.Renderers;
|
||||||
using PortfolioManager.UIUtils;
|
using PortfolioManager.UIUtils;
|
||||||
using ScottPlot.Avalonia;
|
|
||||||
|
|
||||||
namespace PortfolioManager.ViewModels
|
namespace PortfolioManager.ViewModels
|
||||||
{
|
{
|
||||||
@@ -30,6 +28,8 @@ namespace PortfolioManager.ViewModels
|
|||||||
private String companyName = default;
|
private String companyName = default;
|
||||||
private BollingerBandRenderer bollingerBandRenderer = default;
|
private BollingerBandRenderer bollingerBandRenderer = default;
|
||||||
private bool showInsiderTransactions = true;
|
private bool showInsiderTransactions = true;
|
||||||
|
private bool showTradeLabels = true;
|
||||||
|
private bool syncTradeToBand = true;
|
||||||
|
|
||||||
public ScottPlotViewModel()
|
public ScottPlotViewModel()
|
||||||
{
|
{
|
||||||
@@ -45,6 +45,23 @@ namespace PortfolioManager.ViewModels
|
|||||||
base.OnDispose();
|
base.OnDispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override String Title
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (null == selectedSymbol) return DisplayName;
|
||||||
|
return "Bollinger " + "(" + selectedSymbol + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override String DisplayName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Bollinger Band";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void Initialize(bool executePropertyChanged = true)
|
private void Initialize(bool executePropertyChanged = true)
|
||||||
{
|
{
|
||||||
Task workerTask = Task.Factory.StartNew(() =>
|
Task workerTask = Task.Factory.StartNew(() =>
|
||||||
@@ -96,19 +113,23 @@ namespace PortfolioManager.ViewModels
|
|||||||
{
|
{
|
||||||
companyName = PricingDA.GetNameForSymbol(selectedSymbol);
|
companyName = PricingDA.GetNameForSymbol(selectedSymbol);
|
||||||
bollingerBandRenderer = new BollingerBandRenderer(Plotter);
|
bollingerBandRenderer = new BollingerBandRenderer(Plotter);
|
||||||
bollingerBandRenderer.ShowInsiderTransactions=showInsiderTransactions;
|
bollingerBandRenderer.SyncTradeToBand = syncTradeToBand;
|
||||||
|
bollingerBandRenderer.ShowInsiderTransactions = showInsiderTransactions;
|
||||||
|
bollingerBandRenderer.ShowTradeLabels = showTradeLabels;
|
||||||
bollingerBandRenderer.SetData(selectedSymbol, selectedDayCount);
|
bollingerBandRenderer.SetData(selectedSymbol, selectedDayCount);
|
||||||
bollingerBandRenderer.Render();
|
bollingerBandRenderer.Render();
|
||||||
});
|
});
|
||||||
workerTask.ContinueWith((continuation) =>
|
workerTask.ContinueWith((continuation) =>
|
||||||
{
|
{
|
||||||
base.OnPropertyChanged("GraphTitle");
|
base.OnPropertyChanged("GraphTitle");
|
||||||
|
base.OnPropertyChanged("Title");
|
||||||
IsBusy = false;
|
IsBusy = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ********************************************** P E R S I S T E N C E *************************
|
// ********************************************** P E R S I S T E N C E *************************
|
||||||
|
|
||||||
public override bool CanPersist()
|
public override bool CanPersist()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -117,6 +138,29 @@ namespace PortfolioManager.ViewModels
|
|||||||
public override SaveParameters GetSaveParameters()
|
public override SaveParameters GetSaveParameters()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
// SaveParameters saveParams = new SaveParameters();
|
||||||
|
// if (String.IsNullOrEmpty(selectedSymbol)) return null;
|
||||||
|
// saveParams.Add(new KeyValuePair<String, String>("Type", GetType().Namespace + "." + GetType().Name));
|
||||||
|
// saveParams.Add(new KeyValuePair<String, String>("SelectedSymbol", selectedSymbol));
|
||||||
|
// saveParams.Add(new KeyValuePair<String, String>("SelectedWatchList", selectedWatchList));
|
||||||
|
// saveParams.Add(new KeyValuePair<String, String>("SelectedDayCount", selectedDayCount.ToString()));
|
||||||
|
// saveParams.Add(new KeyValuePair<String, String>("SyncTradeToBand", syncTradeToBand.ToString()));
|
||||||
|
// saveParams.Add(new KeyValuePair<String, String>("ShowTradeLabels", showTradeLabels.ToString()));
|
||||||
|
// saveParams.Add(new KeyValuePair<String, String>("UseLeastSquaresFit", useLeastSquaresFit.ToString()));
|
||||||
|
// saveParams.Add(new KeyValuePair<String, String>("ShowInsiderTransactions", showInsiderTransactions.ToString()));
|
||||||
|
// if (null != stopLimits && 0 != stopLimits.Count)
|
||||||
|
// {
|
||||||
|
// saveParams.Add(new KeyValuePair<String, String>("StopHistoryCount", stopLimits.Count.ToString()));
|
||||||
|
// for (int index = 0; index < stopLimits.Count; index++)
|
||||||
|
// {
|
||||||
|
// String strItemKey = String.Format("StopHistory_{0}", index);
|
||||||
|
// StopLimit stopLimit = stopLimits[index];
|
||||||
|
// NVPCollection nvpCollection = stopLimit.ToNVPCollection();
|
||||||
|
// String strStopHistoryItem = nvpCollection.ToString();
|
||||||
|
// saveParams.Add(new KeyValuePair<String, String>(strItemKey, strStopHistoryItem));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return saveParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetSaveParameters(SaveParameters saveParameters)
|
public override void SetSaveParameters(SaveParameters saveParameters)
|
||||||
@@ -125,8 +169,6 @@ namespace PortfolioManager.ViewModels
|
|||||||
|
|
||||||
// ****************************************************** P R O P E R T I E S ************************************************
|
// ****************************************************** P R O P E R T I E S ************************************************
|
||||||
|
|
||||||
// public AvaPlot Plotter { get; set; } = default;
|
|
||||||
|
|
||||||
public String GraphTitle
|
public String GraphTitle
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -235,26 +277,16 @@ namespace PortfolioManager.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override String Title
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (null == selectedSymbol) return DisplayName;
|
|
||||||
return "Bollinger " + "(" + selectedSymbol + ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SyncTradeToBand
|
public bool SyncTradeToBand
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (null == bollingerBandRenderer) return false;
|
return syncTradeToBand;
|
||||||
return bollingerBandRenderer.SyncTradeToBand;
|
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
bollingerBandRenderer.SyncTradeToBand = value;
|
syncTradeToBand = value;
|
||||||
|
base.OnPropertyChanged("SyncTradeToBand");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,13 +294,12 @@ namespace PortfolioManager.ViewModels
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (null == bollingerBandRenderer) return false;
|
return showTradeLabels;
|
||||||
return bollingerBandRenderer.ShowLabels;
|
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
bollingerBandRenderer.ShowLabels = value;
|
showTradeLabels = value;
|
||||||
|
base.OnPropertyChanged("ShowTradeLabels");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,7 +316,6 @@ namespace PortfolioManager.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public async Task Refresh()
|
public async Task Refresh()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user