Handle multiple stop limits in the stop limit table and display them properly.
This commit is contained in:
@@ -16,17 +16,6 @@ namespace TradeBlotter.Model
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static CompositeDataSource CreateCompositeDataSource(DateTime xSource,double ySource)
|
|
||||||
//{
|
|
||||||
// CompositeDataSource compositeDataSource;
|
|
||||||
// var xData=new EnumerableDataSource<DateTime>(new DateTime[] { xSource });
|
|
||||||
// xData.SetXMapping(x => (x.Ticks/10000000000.0));
|
|
||||||
// var yData=new EnumerableDataSource<double>(new double[] { ySource });
|
|
||||||
// yData.SetYMapping(y => y);
|
|
||||||
// compositeDataSource=xData.Join(yData);
|
|
||||||
// return compositeDataSource;
|
|
||||||
//}
|
|
||||||
|
|
||||||
public static CompositeDataSource Price(Price price)
|
public static CompositeDataSource Price(Price price)
|
||||||
{
|
{
|
||||||
if (null == price) return null;
|
if (null == price) return null;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace TradeBlotter.Model
|
|||||||
List<DateTime> stopLimitDates = new List<DateTime>();
|
List<DateTime> stopLimitDates = new List<DateTime>();
|
||||||
foreach(StopLimit stopLimit in stopLimits)
|
foreach(StopLimit stopLimit in stopLimits)
|
||||||
{
|
{
|
||||||
stopLimitDates.Add(stopLimit.EffectiveDate);
|
stopLimitDates.Add(xSource);
|
||||||
}
|
}
|
||||||
var xData=new EnumerableDataSource<DateTime>(stopLimitDates.Select(x => x.Date));
|
var xData=new EnumerableDataSource<DateTime>(stopLimitDates.Select(x => x.Date));
|
||||||
xData.SetXMapping(x => (x.Ticks/10000000000.0));
|
xData.SetXMapping(x => (x.Ticks/10000000000.0));
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ namespace TradeBlotter.ViewModels
|
|||||||
}
|
}
|
||||||
else if(null!=internalStopLimits && null!=zeroPrice)
|
else if(null!=internalStopLimits && null!=zeroPrice)
|
||||||
{
|
{
|
||||||
compositeDataSourceStopLimit=StopLimitCompositeModel.CreateCompositeDataSource(zeroPrice.Date,stopLimits);
|
compositeDataSourceStopLimit=StopLimitCompositeModel.CreateCompositeDataSource(zeroPrice.Date,internalStopLimits);
|
||||||
}
|
}
|
||||||
|
|
||||||
compositeDataSourceInsiderTransactionPointDisposedSmall=InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(disposedSummariesBin[2]),minClose);
|
compositeDataSourceInsiderTransactionPointDisposedSmall=InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(disposedSummariesBin[2]),minClose);
|
||||||
@@ -786,6 +786,7 @@ namespace TradeBlotter.ViewModels
|
|||||||
{
|
{
|
||||||
if (null == zeroPrice) return null;
|
if (null == zeroPrice) return null;
|
||||||
if (null == internalStopLimits || null == zeroPrice || !showTradeLabels) return null;
|
if (null == internalStopLimits || null == zeroPrice || !showTradeLabels) return null;
|
||||||
|
Price latestPrice=prices[0];
|
||||||
for(int index=0;index<internalStopLimits.Count;index++)
|
for(int index=0;index<internalStopLimits.Count;index++)
|
||||||
{
|
{
|
||||||
StopLimit limit=internalStopLimits[index];
|
StopLimit limit=internalStopLimits[index];
|
||||||
@@ -794,33 +795,14 @@ namespace TradeBlotter.ViewModels
|
|||||||
StringBuilder sb=new StringBuilder();
|
StringBuilder sb=new StringBuilder();
|
||||||
sb.Append(limit.StopType).Append(" ");
|
sb.Append(limit.StopType).Append(" ");
|
||||||
sb.Append(Utility.FormatCurrency(limit.StopPrice));
|
sb.Append(Utility.FormatCurrency(limit.StopPrice));
|
||||||
if(index==internalStopLimits.Count-1)
|
|
||||||
{
|
|
||||||
Price latestPrice=prices[0]; // always use the most recent price when calculating the spread (in percent) from the active stop limit.
|
|
||||||
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(")");
|
||||||
}
|
|
||||||
centerTextMarker.Text=sb.ToString();
|
centerTextMarker.Text=sb.ToString();
|
||||||
if(0==index&&internalStopLimits.Count>1) centerTextMarker.VerticalShift="25";
|
if(0==index&&internalStopLimits.Count>1) centerTextMarker.VerticalShift="25";
|
||||||
else centerTextMarker.VerticalShift="40";
|
else centerTextMarker.VerticalShift="40";
|
||||||
centerTextMarker.HorizontalShift="32";
|
centerTextMarker.HorizontalShift="32";
|
||||||
centeredTextMarkers.Add(centerTextMarker);
|
centeredTextMarkers.Add(centerTextMarker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//CenteredTextMarker centerTextMarker=new CenteredTextMarker();
|
|
||||||
//Price latestPrice=prices[0];
|
|
||||||
//double percentOffsetFromLow=((latestPrice.Low-stopLimit.StopPrice)/stopLimit.StopPrice);
|
|
||||||
//StringBuilder sb=new StringBuilder();
|
|
||||||
//sb.Append(stopLimit.StopType).Append(" ");
|
|
||||||
//sb.Append(Utility.FormatCurrency(stopLimit.StopPrice));
|
|
||||||
//sb.Append(" (").Append(percentOffsetFromLow>0?"+":"").Append(Utility.FormatPercent(percentOffsetFromLow)).Append(")");
|
|
||||||
//centerTextMarker.Text=sb.ToString();
|
|
||||||
//centeredTextMarkers.Add(centerTextMarker);
|
|
||||||
//centerTextMarker.VerticalShift="40";
|
|
||||||
//centerTextMarker.HorizontalShift="32";
|
|
||||||
}
|
}
|
||||||
return centeredTextMarkers.ToArray();
|
return centeredTextMarkers.ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user