Commit Latest
This commit is contained in:
@@ -28,7 +28,7 @@ namespace PortfolioManager.Renderers
|
|||||||
}
|
}
|
||||||
public static class FontFactor
|
public static class FontFactor
|
||||||
{
|
{
|
||||||
public const int FontSize = 10;
|
public const int FontSize = 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BollingerBandRenderer : ModelBase
|
public class BollingerBandRenderer : ModelBase
|
||||||
@@ -48,6 +48,11 @@ namespace PortfolioManager.Renderers
|
|||||||
private BollingerBands bollingerBands;
|
private BollingerBands bollingerBands;
|
||||||
private InsiderTransactionSummaries insiderTransactionSummaries = null;
|
private InsiderTransactionSummaries insiderTransactionSummaries = null;
|
||||||
|
|
||||||
|
double maxBollingerDate = 0.00;
|
||||||
|
double minBollingerDate = 0.00;
|
||||||
|
double spread = 0.00;
|
||||||
|
double percentShift3PC = 0.00;
|
||||||
|
double percentShift1PC = 0.00;
|
||||||
|
|
||||||
public BollingerBandRenderer(AvaPlot plotter)
|
public BollingerBandRenderer(AvaPlot plotter)
|
||||||
{
|
{
|
||||||
@@ -122,6 +127,13 @@ namespace PortfolioManager.Renderers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bollingerBands = BollingerBandGenerator.GenerateBollingerBands(prices);
|
bollingerBands = BollingerBandGenerator.GenerateBollingerBands(prices);
|
||||||
|
|
||||||
|
maxBollingerDate = bollingerBands.Max(x=>x.Date).ToOADate();
|
||||||
|
minBollingerDate = bollingerBands.Min(x=>x.Date).ToOADate();
|
||||||
|
spread = (maxBollingerDate - minBollingerDate);
|
||||||
|
percentShift3PC = spread * .03;
|
||||||
|
percentShift1PC = spread * .01;
|
||||||
|
|
||||||
GenerateBollingerBands();
|
GenerateBollingerBands();
|
||||||
GenerateZeroPoint(zeroPrice);
|
GenerateZeroPoint(zeroPrice);
|
||||||
GenerateInsiderTransactions();
|
GenerateInsiderTransactions();
|
||||||
@@ -158,8 +170,6 @@ namespace PortfolioManager.Renderers
|
|||||||
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate Stop Limits
|
/// Generate Stop Limits
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -176,6 +186,7 @@ namespace PortfolioManager.Renderers
|
|||||||
}
|
}
|
||||||
(DateTime[] dates, double[] values) = StopLimits.ToXYData();
|
(DateTime[] dates, double[] values) = StopLimits.ToXYData();
|
||||||
|
|
||||||
|
// Add the markers
|
||||||
Image imageStopLimitMarker = TextMarkerImageGenerator.ToSPImage(ImageCache.GetInstance().GetImage(ImageCache.ImageType.RedTriangleUp));
|
Image imageStopLimitMarker = TextMarkerImageGenerator.ToSPImage(ImageCache.GetInstance().GetImage(ImageCache.ImageType.RedTriangleUp));
|
||||||
for (int index = 0; index < dates.Length; index++)
|
for (int index = 0; index < dates.Length; index++)
|
||||||
{
|
{
|
||||||
@@ -185,6 +196,7 @@ namespace PortfolioManager.Renderers
|
|||||||
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, imageStopLimitMarker, SizeFactor.Normal);
|
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, imageStopLimitMarker, SizeFactor.Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the text marker
|
||||||
if (null != stopLimits)
|
if (null != stopLimits)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < stopLimits.Count; index++)
|
for (int index = 0; index < stopLimits.Count; index++)
|
||||||
@@ -196,12 +208,13 @@ namespace PortfolioManager.Renderers
|
|||||||
sb.Append(Utility.FormatCurrency(limit.StopPrice));
|
sb.Append(Utility.FormatCurrency(limit.StopPrice));
|
||||||
if (index == stopLimits.Count - 1)
|
if (index == stopLimits.Count - 1)
|
||||||
{
|
{
|
||||||
Price latestPrice = prices[0];
|
Price latestPrice = prices[0];
|
||||||
double percentOffsetFromLow = ((latestPrice.Low - limit.StopPrice) / limit.StopPrice);
|
double percentOffsetFromLow = ((latestPrice.Low - limit.StopPrice) / limit.StopPrice);
|
||||||
sb.Append(" (").Append(percentOffsetFromLow > 0 ? "+" : "").Append(Utility.FormatPercent(percentOffsetFromLow)).Append(")");
|
sb.Append(" (").Append(percentOffsetFromLow > 0 ? "+" : "").Append(Utility.FormatPercent(percentOffsetFromLow)).Append(")");
|
||||||
}
|
}
|
||||||
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), 150, 24, FontFactor.FontSize);
|
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), 155, 24, FontFactor.FontSize);
|
||||||
Coordinates coordinates = new Coordinates(dates[0].ToOADate(), values[0] - 5.00);
|
// Coordinates coordinates = new Coordinates(dates[0].ToOADate()-1, values[0] - 5.00);
|
||||||
|
Coordinates coordinates = new Coordinates(limit.EffectiveDate.ToOADate(), limit.StopPrice - 5.00);
|
||||||
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -217,8 +230,9 @@ namespace PortfolioManager.Renderers
|
|||||||
sb.Append(Utility.FormatCurrency(stopLimit.StopPrice));
|
sb.Append(Utility.FormatCurrency(stopLimit.StopPrice));
|
||||||
sb.Append(" (").Append(percentOffsetFromLow > 0 ? "+" : "").Append(Utility.FormatPercent(percentOffsetFromLow)).Append(")");
|
sb.Append(" (").Append(percentOffsetFromLow > 0 ? "+" : "").Append(Utility.FormatPercent(percentOffsetFromLow)).Append(")");
|
||||||
|
|
||||||
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), 150, 24, FontFactor.FontSize);
|
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), 155, 24, FontFactor.FontSize);
|
||||||
Coordinates coordinates = new Coordinates(latestPrice.Date.ToOADate(), stopLimit.StopPrice - 5.00);
|
// Coordinates coordinates = new Coordinates(latestPrice.Date.ToOADate()/(1+onePercent), stopLimit.StopPrice - 5.00);
|
||||||
|
Coordinates coordinates = new Coordinates(latestPrice.Date.ToOADate()-percentShift3PC, stopLimit.StopPrice - 5.00);
|
||||||
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,6 +242,31 @@ namespace PortfolioManager.Renderers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void GenerateTradePoints()
|
private void GenerateTradePoints()
|
||||||
{
|
{
|
||||||
|
if (null == portfolioTradesLots || 0 == portfolioTradesLots.Count || !showTradeLabels) return;
|
||||||
|
// Here we add the image markers
|
||||||
|
|
||||||
|
Image tradePointMarker = TextMarkerImageGenerator.ToSPImage(ImageCache.GetInstance().GetImage(ImageCache.ImageType.YellowTriangleUp));
|
||||||
|
for (int index = 0; index < portfolioTradesLots.Count; index++)
|
||||||
|
{
|
||||||
|
PortfolioTrade portfolioTrade = portfolioTradesLots[index];
|
||||||
|
Coordinates coordinates = new Coordinates(portfolioTrade.TradeDate.ToOADate(), portfolioTrade.Price);
|
||||||
|
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, tradePointMarker, SizeFactor.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This adds the text markers
|
||||||
|
for (int index = 0; index < portfolioTradesLots.Count; index++)
|
||||||
|
{
|
||||||
|
PortfolioTrade portfolioTrade = portfolioTradesLots[index];
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.Append(portfolioTrade.BuySell.Equals("B") ? "Buy " : "Sell ");
|
||||||
|
sb.Append(Utility.FormatNumber(portfolioTrade.Shares));
|
||||||
|
sb.Append("@");
|
||||||
|
sb.Append(Utility.FormatCurrency(portfolioTrade.Price));
|
||||||
|
|
||||||
|
Image image = TextMarkerImageGenerator.GenerateImage(sb.ToString(), 150, 24, FontFactor.FontSize);
|
||||||
|
Coordinates coordinates = new Coordinates(portfolioTrade.TradeDate.ToOADate(), portfolioTrade.Price - 5.00);
|
||||||
|
ImageMarker imageMarker = Plotter.Plot.Add.ImageMarker(coordinates, image);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user