commit latest
This commit is contained in:
@@ -20,13 +20,21 @@ using MarketData.Numerical;
|
|||||||
|
|
||||||
namespace PortfolioManager.Renderers
|
namespace PortfolioManager.Renderers
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// ********************************************************************************************************************************
|
||||||
public class TextPlot
|
public class TextPlot
|
||||||
{
|
{
|
||||||
public TextPlot()
|
public TextPlot()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Coordinates Coordinates { get; set; }
|
public TextPlot(SKRect boundingRect)
|
||||||
SKRect BoundingRect { get; set; }
|
{
|
||||||
|
BoundingRect = boundingRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Coordinates Coordinates { get; set; }
|
||||||
|
|
||||||
|
public SKRect BoundingRect { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TextPlots : List<TextPlot>
|
public class TextPlots : List<TextPlot>
|
||||||
@@ -34,15 +42,22 @@ namespace PortfolioManager.Renderers
|
|||||||
public TextPlots()
|
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
|
public class BollingerBandRenderer : ModelBase
|
||||||
{
|
{
|
||||||
@@ -63,6 +78,7 @@ namespace PortfolioManager.Renderers
|
|||||||
private Prices prices = default;
|
private Prices prices = default;
|
||||||
private BollingerBands bollingerBands;
|
private BollingerBands bollingerBands;
|
||||||
private InsiderTransactionSummaries insiderTransactionSummaries = null;
|
private InsiderTransactionSummaries insiderTransactionSummaries = null;
|
||||||
|
private TextPlots textPlots = new TextPlots();
|
||||||
|
|
||||||
private OffsetDictionary offsets = new OffsetDictionary();
|
private OffsetDictionary offsets = new OffsetDictionary();
|
||||||
|
|
||||||
@@ -148,6 +164,7 @@ namespace PortfolioManager.Renderers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bollingerBands = BollingerBandGenerator.GenerateBollingerBands(prices);
|
bollingerBands = BollingerBandGenerator.GenerateBollingerBands(prices);
|
||||||
|
textPlots.Clear();
|
||||||
CalculateOffsets();
|
CalculateOffsets();
|
||||||
GenerateBollingerBands();
|
GenerateBollingerBands();
|
||||||
GenerateLeastSquares();
|
GenerateLeastSquares();
|
||||||
@@ -232,6 +249,10 @@ namespace PortfolioManager.Renderers
|
|||||||
image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
|
image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
|
||||||
coordinates = new Coordinates(dates[0].ToOADate() - offsets.Offset(OffsetDictionary.OffsetType.HorizontalOffset3PC),
|
coordinates = new Coordinates(dates[0].ToOADate() - offsets.Offset(OffsetDictionary.OffsetType.HorizontalOffset3PC),
|
||||||
values[0] - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset6P5PC));
|
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);
|
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,6 +303,10 @@ namespace PortfolioManager.Renderers
|
|||||||
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
|
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
|
||||||
Coordinates coordinates = new Coordinates(limit.EffectiveDate.ToOADate(),
|
Coordinates coordinates = new Coordinates(limit.EffectiveDate.ToOADate(),
|
||||||
limit.StopPrice - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset6P5PC));
|
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);
|
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,6 +324,10 @@ namespace PortfolioManager.Renderers
|
|||||||
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
|
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
|
||||||
Coordinates coordinates = new Coordinates(latestPrice.Date.ToOADate() - offsets.Offset(OffsetDictionary.OffsetType.HorizontalOffset3PC),
|
Coordinates coordinates = new Coordinates(latestPrice.Date.ToOADate() - offsets.Offset(OffsetDictionary.OffsetType.HorizontalOffset3PC),
|
||||||
stopLimit.StopPrice - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset6P5PC));
|
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);
|
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,6 +362,10 @@ namespace PortfolioManager.Renderers
|
|||||||
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
|
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
|
||||||
Coordinates coordinates = new Coordinates(portfolioTrade.TradeDate.ToOADate(),
|
Coordinates coordinates = new Coordinates(portfolioTrade.TradeDate.ToOADate(),
|
||||||
portfolioTrade.Price - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset6P5PC));
|
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);
|
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public static class TextMarkerImageGenerator
|
|||||||
return new ScottPlot.Image(memoryStream.ToArray());
|
return new ScottPlot.Image(memoryStream.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static Image GenerateImage(String text,int fontSize=12)
|
|
||||||
public static Image GenerateImage(String text,int fontSize=11)
|
public static Image GenerateImage(String text,int fontSize=11)
|
||||||
{
|
{
|
||||||
ImageHelper imageHelper = new ImageHelper();
|
ImageHelper imageHelper = new ImageHelper();
|
||||||
|
|||||||
Reference in New Issue
Block a user