From 78964a53d33d520a093279cc8d2f7450260be42e Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 14 Jul 2025 22:07:35 -0400 Subject: [PATCH] Commit Latest --- .../Renderers/BollingerBandRenderer.cs | 18 ++++++++++++------ .../ViewModels/PlotterWorkspaceViewModel.cs | 2 +- PortfolioManager/Views/BollingerBandView.axaml | 1 - 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/PortfolioManager/Renderers/BollingerBandRenderer.cs b/PortfolioManager/Renderers/BollingerBandRenderer.cs index e0dc306..b84e4ac 100644 --- a/PortfolioManager/Renderers/BollingerBandRenderer.cs +++ b/PortfolioManager/Renderers/BollingerBandRenderer.cs @@ -19,6 +19,7 @@ using SkiaSharp; using MarketData.Numerical; using MarketData; using Avalonia.Controls.Platform; +using System.Threading; namespace PortfolioManager.Renderers { @@ -55,8 +56,10 @@ namespace PortfolioManager.Renderers { foreach(TextPlot textPlot in this) { - if(Math.Round(screenCoordinates.X,2) >= Math.Round(textPlot.BoundingRect.Left,2) && Math.Round(screenCoordinates.X,2) <= Math.Round(textPlot.BoundingRect.Right,2) && - Math.Round(screenCoordinates.Y,2) >= Math.Round(textPlot.BoundingRect.Top,2) && Math.Round(screenCoordinates.Y,2) <= Math.Round(textPlot.BoundingRect.Bottom,2)) + if(Math.Round(screenCoordinates.X,2) >= Math.Round(textPlot.BoundingRect.Left,2) && + Math.Round(screenCoordinates.X,2) <= Math.Round(textPlot.BoundingRect.Right,2) && + Math.Round(screenCoordinates.Y,2) >= Math.Round(textPlot.BoundingRect.Top,2) && + Math.Round(screenCoordinates.Y,2) <= Math.Round(textPlot.BoundingRect.Bottom,2)) { MDTrace.WriteLine(LogLevel.DEBUG,$"The text {markerText} at Point:X:{screenCoordinates.X}:Y:{screenCoordinates.Y} is within Rect:L({textPlot.BoundingRect.Left}),T({textPlot.BoundingRect.Top}),R({textPlot.BoundingRect.Right}),B({textPlot.BoundingRect.Bottom}) with text {textPlot.MarkerText} which is plotted at Coordinates:X:{textPlot.ScreenCoordinates.X} Y:{textPlot.ScreenCoordinates.Y}"); SKRect lowestRect = FindLowestAdjacentRect(textPlot.BoundingRect); @@ -74,7 +77,7 @@ namespace PortfolioManager.Renderers /// private SKRect FindLowestAdjacentRect(SKRect rect) { - List adjacentRects = this.Where(x=> rect.Left>=x.BoundingRect.Left && rect.Right<=x.BoundingRect.Right).Select(x=>x.BoundingRect).ToList(); + List adjacentRects = this.Where(x=> rect.Left >= x.BoundingRect.Left && rect.Right <= x.BoundingRect.Right).Select(x=>x.BoundingRect).ToList(); if(null == adjacentRects || 0==adjacentRects.Count)return new SKRect(){Left=0,Top=0,Right=0,Bottom=0}; adjacentRects = adjacentRects.OrderByDescending(x=>x.Bottom).ToList(); return adjacentRects[0]; @@ -102,7 +105,7 @@ namespace PortfolioManager.Renderers private Prices prices = default; private BollingerBands bollingerBands; private InsiderTransactionSummaries insiderTransactionSummaries = null; - private TextPlots textPlots = new TextPlots(); +// private TextPlots textPlots = new TextPlots(); private OffsetDictionary offsets = new OffsetDictionary(); @@ -128,6 +131,7 @@ namespace PortfolioManager.Renderers public void Render() { + MDTrace.WriteLine(LogLevel.DEBUG,$"[Render] ENTER"); Plotter.Plot.Axes.Left.TickGenerator = new ScottPlot.TickGenerators.NumericAutomatic() { LabelFormatter = (double value) => value.ToString("C") // "C" format specifier formats as currency @@ -138,10 +142,12 @@ namespace PortfolioManager.Renderers Plotter.Plot.YLabel("Price"); Plotter.Refresh(); base.OnPropertyChanged("ShowLegend"); + MDTrace.WriteLine(LogLevel.DEBUG,$"[Render] LEAVE"); } public void SetData(String selectedSymbol, int selectedDayCount) { + MDTrace.WriteLine(LogLevel.DEBUG,$"[SetData] ENTER"); this.selectedSymbol = selectedSymbol; this.selectedDayCount = selectedDayCount; stopLimit = PortfolioDA.GetStopLimit(selectedSymbol); @@ -189,7 +195,6 @@ namespace PortfolioManager.Renderers } bollingerBands = BollingerBandGenerator.GenerateBollingerBands(prices); // textPlots.Clear(); -// textPlots = new TextPlots(); CalculateOffsets(); GenerateBollingerBands(); GenerateLeastSquares(); @@ -197,6 +202,7 @@ namespace PortfolioManager.Renderers GenerateStopLimits(); GenerateTradePoints(); GenerateZeroPoint(zeroPrice); + MDTrace.WriteLine(LogLevel.DEBUG,$"[SetData] LEAVE"); } /// @@ -537,7 +543,7 @@ namespace PortfolioManager.Renderers Low = BollingerBandModel.Low(bollingerBands); Close = BollingerBandModel.Close(bollingerBands); SMAN = BollingerBandModel.SMAN(bollingerBands); - Volume = BollingerBandModel.Volume(bollingerBands); +// Volume = BollingerBandModel.Volume(bollingerBands); Scatter scatter = default; { diff --git a/PortfolioManager/ViewModels/PlotterWorkspaceViewModel.cs b/PortfolioManager/ViewModels/PlotterWorkspaceViewModel.cs index d85bb92..34ed1bf 100644 --- a/PortfolioManager/ViewModels/PlotterWorkspaceViewModel.cs +++ b/PortfolioManager/ViewModels/PlotterWorkspaceViewModel.cs @@ -10,7 +10,7 @@ namespace PortfolioManager.ViewModels public abstract class PlotterWorkspaceViewModel : WorkspaceViewModel { - public AvaPlot Plotter { get; set; } + public AvaPlot Plotter { get; set; } public EventHandler OnPlotterLoadedEventHandler; diff --git a/PortfolioManager/Views/BollingerBandView.axaml b/PortfolioManager/Views/BollingerBandView.axaml index c7e57f1..bec8b68 100644 --- a/PortfolioManager/Views/BollingerBandView.axaml +++ b/PortfolioManager/Views/BollingerBandView.axaml @@ -80,7 +80,6 @@ -