commit latest

This commit is contained in:
2025-07-13 08:43:51 -04:00
parent 56e750c4ee
commit b543620e86
2 changed files with 42 additions and 10 deletions

View File

@@ -20,13 +20,21 @@ using MarketData.Numerical;
namespace PortfolioManager.Renderers
{
// ********************************************************************************************************************************
public class TextPlot
{
public TextPlot()
{
}
Coordinates Coordinates { get; set; }
SKRect BoundingRect { get; set; }
public TextPlot(SKRect boundingRect)
{
BoundingRect = boundingRect;
}
public Coordinates Coordinates { get; set; }
public SKRect BoundingRect { get; set; }
}
public class TextPlots : List<TextPlot>
@@ -34,15 +42,22 @@ namespace PortfolioManager.Renderers
public TextPlots()
{
}
public bool pointInRects(Coordinates coordinates)
{
foreach(TextPlot textPlot in this)
{
if(coordinates.X > textPlot.BoundingRect.Left && coordinates.X < textPlot.BoundingRect.Right &&
coordinates.Y > textPlot.BoundingRect.Bottom && coordinates.Y < textPlot.BoundingRect.Top)
{
return true;
}
}
return false;
}
}
// xp, yp = point
// for rect in rectangles:
// x1, y1, x2, y2 = rect
// if x1 < xp < x2 and y1 < yp < y2:
// return True
// return False
// *********************************************************************************************************************************************
public class BollingerBandRenderer : ModelBase
{
@@ -63,6 +78,7 @@ namespace PortfolioManager.Renderers
private Prices prices = default;
private BollingerBands bollingerBands;
private InsiderTransactionSummaries insiderTransactionSummaries = null;
private TextPlots textPlots = new TextPlots();
private OffsetDictionary offsets = new OffsetDictionary();
@@ -148,6 +164,7 @@ namespace PortfolioManager.Renderers
}
}
bollingerBands = BollingerBandGenerator.GenerateBollingerBands(prices);
textPlots.Clear();
CalculateOffsets();
GenerateBollingerBands();
GenerateLeastSquares();
@@ -232,6 +249,10 @@ namespace PortfolioManager.Renderers
image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
coordinates = new Coordinates(dates[0].ToOADate() - offsets.Offset(OffsetDictionary.OffsetType.HorizontalOffset3PC),
values[0] - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset6P5PC));
SKRect markerRect = new SKRect(){Left=(float)coordinates.X,Top=(float)coordinates.Y,Right=(float)coordinates.X+image.Width,Bottom=(float)coordinates.Y+image.Height};
textPlots.Add(new TextPlot(markerRect));
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
}
@@ -282,6 +303,10 @@ namespace PortfolioManager.Renderers
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
Coordinates coordinates = new Coordinates(limit.EffectiveDate.ToOADate(),
limit.StopPrice - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset6P5PC));
SKRect markerRect = new SKRect(){Left=(float)coordinates.X,Top=(float)coordinates.Y,Right=(float)coordinates.X+image.Width,Bottom=(float)coordinates.Y+image.Height};
textPlots.Add(new TextPlot(markerRect));
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
}
}
@@ -299,6 +324,10 @@ namespace PortfolioManager.Renderers
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
Coordinates coordinates = new Coordinates(latestPrice.Date.ToOADate() - offsets.Offset(OffsetDictionary.OffsetType.HorizontalOffset3PC),
stopLimit.StopPrice - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset6P5PC));
SKRect markerRect = new SKRect(){Left=(float)coordinates.X,Top=(float)coordinates.Y,Right=(float)coordinates.X+image.Width,Bottom=(float)coordinates.Y+image.Height};
textPlots.Add(new TextPlot(markerRect));
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
}
}
@@ -333,6 +362,10 @@ namespace PortfolioManager.Renderers
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
Coordinates coordinates = new Coordinates(portfolioTrade.TradeDate.ToOADate(),
portfolioTrade.Price - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset6P5PC));
SKRect markerRect = new SKRect(){Left=(float)coordinates.X,Top=(float)coordinates.Y,Right=(float)coordinates.X+image.Width,Bottom=(float)coordinates.Y+image.Height};
textPlots.Add(new TextPlot(markerRect));
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
}
}

View File

@@ -27,7 +27,6 @@ public static class TextMarkerImageGenerator
return new ScottPlot.Image(memoryStream.ToArray());
}
// public static Image GenerateImage(String text,int fontSize=12)
public static Image GenerateImage(String text,int fontSize=11)
{
ImageHelper imageHelper = new ImageHelper();