Commit Latest

This commit is contained in:
2025-07-05 21:55:47 -04:00
parent 754113fbdc
commit c644cf12dd
4 changed files with 133 additions and 13 deletions

View File

@@ -35,7 +35,7 @@ namespace PortfolioManager.Renderers
{
public enum OffsetType
{
VerticalOffset5PC, VerticalOffset3PC, VerticalOffset1PC, HorizontalOffset5PC, HorizontalOffset3PC, HorizontalOffset1PC,
VerticalOffset15PC, VerticalOffset10PC, VerticalOffset5PC, VerticalOffset3PC, VerticalOffset1PC, HorizontalOffset5PC, HorizontalOffset3PC, HorizontalOffset1PC,
MinBollingerDate, MaxBollingerDate, MinBollingerValue, MaxBollingerValue
};
@@ -107,7 +107,7 @@ namespace PortfolioManager.Renderers
Plotter.Plot.Axes.Left.TickGenerator = new ScottPlot.TickGenerators.NumericAutomatic()
{
LabelFormatter = (double value) => value.ToString("C") // "C" format specifier formats as currency
};
};
Plotter.Plot.Axes.DateTimeTicksBottom();
Plotter.Plot.Axes.AutoScale();
Plotter.Plot.XLabel("Date");
@@ -196,6 +196,8 @@ namespace PortfolioManager.Renderers
offsets.Add(OffsetDictionary.OffsetType.VerticalOffset1PC,spreadVert * .01);
offsets.Add(OffsetDictionary.OffsetType.VerticalOffset3PC,spreadVert *.03);
offsets.Add(OffsetDictionary.OffsetType.VerticalOffset5PC,spreadVert * .05);
offsets.Add(OffsetDictionary.OffsetType.VerticalOffset10PC,spreadVert * .10);
offsets.Add(OffsetDictionary.OffsetType.VerticalOffset15PC,spreadVert * .15);
}
/// <summary>
@@ -233,13 +235,13 @@ namespace PortfolioManager.Renderers
coordinates = new Coordinates(dates[0].ToOADate(), values[0]);
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image, SizeFactor.Normal);
if(!showTradeLabels)return;
// Place the text marker
StringBuilder sb = new StringBuilder();
sb.Append("Even ");
sb.Append(Utility.FormatCurrency(zeroPrice.Close));
double parityOffsetPercent = (latestPrice.Close - zeroPrice.Close) / zeroPrice.Close;
sb.Append("(").Append(parityOffsetPercent < 0 ? "" : "+").Append(Utility.FormatPercent(parityOffsetPercent)).Append(")");
// image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), 130, 24, FontFactor.FontSize);
image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
coordinates = new Coordinates(dates[0].ToOADate() - offsets.Offset(OffsetDictionary.OffsetType.HorizontalOffset3PC), values[0] - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset5PC));
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
@@ -271,6 +273,8 @@ namespace PortfolioManager.Renderers
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, imageStopLimitMarker, SizeFactor.Normal);
}
if(!showTradeLabels)return;
// Add the text marker
if (null != stopLimits)
{
@@ -287,7 +291,6 @@ namespace PortfolioManager.Renderers
double percentOffsetFromLow = ((latestPrice.Low - limit.StopPrice) / limit.StopPrice);
sb.Append(" (").Append(percentOffsetFromLow > 0 ? "+" : "").Append(Utility.FormatPercent(percentOffsetFromLow)).Append(")");
}
// Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), 155, 24, FontFactor.FontSize);
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), FontFactor.FontSize);
Coordinates coordinates = new Coordinates(limit.EffectiveDate.ToOADate(), limit.StopPrice - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset5PC));
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
@@ -304,7 +307,6 @@ namespace PortfolioManager.Renderers
sb.Append(stopLimit.StopType).Append(" ");
sb.Append(Utility.FormatCurrency(stopLimit.StopPrice));
sb.Append(" (").Append(percentOffsetFromLow > 0 ? "+" : "").Append(Utility.FormatPercent(percentOffsetFromLow)).Append(")");
// Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), 155, 24, FontFactor.FontSize);
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.VerticalOffset5PC));
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
@@ -382,7 +384,7 @@ namespace PortfolioManager.Renderers
{
DateTime date = dates[index];
double value = values[index];
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset5PC));
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset15PC));
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, imageDisposed, SizeFactor.Small);
}
}
@@ -393,7 +395,7 @@ namespace PortfolioManager.Renderers
{
DateTime date = dates[index];
double value = values[index];
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset5PC));
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset15PC));
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, imageDisposed, SizeFactor.Normal);
}
}
@@ -404,7 +406,7 @@ namespace PortfolioManager.Renderers
{
DateTime date = dates[index];
double value = values[index];
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset5PC));
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset15PC));
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, imageDisposed, SizeFactor.Large);
}
}
@@ -416,7 +418,7 @@ namespace PortfolioManager.Renderers
{
DateTime date = dates[index];
double value = values[index];
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset5PC));
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset15PC));
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, imageAcquired, SizeFactor.Small);
}
}
@@ -427,7 +429,7 @@ namespace PortfolioManager.Renderers
{
DateTime date = dates[index];
double value = values[index];
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset5PC));
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset15PC));
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, imageAcquired, SizeFactor.Normal);
}
}
@@ -438,7 +440,7 @@ namespace PortfolioManager.Renderers
{
DateTime date = dates[index];
double value = values[index];
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset5PC));
coordinates = new Coordinates(date.ToOADate(),offsets.Offset(OffsetDictionary.OffsetType.MinBollingerValue) - offsets.Offset(OffsetDictionary.OffsetType.VerticalOffset15PC));
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, imageAcquired, SizeFactor.Large);
}
}
@@ -519,6 +521,19 @@ namespace PortfolioManager.Renderers
// *********************************************************** P R O P E R T I E S *****************************************************
public StopLimits ExternalStopLimits
{
get
{
return stopLimits;
}
set
{
stopLimits = value;
base.OnPropertyChanged("ExternalStopLimits");
}
}
public Prices Prices
{
get