diff --git a/Model/GainLossModel.cs b/Model/GainLossModel.cs index 7df0a22..53fef50 100644 --- a/Model/GainLossModel.cs +++ b/Model/GainLossModel.cs @@ -15,16 +15,18 @@ namespace TradeBlotter.Model private GainLossModel() { } - public static CompositeDataSource CreateCompositeDataSource(DateTime xSource,double ySource) - { - CompositeDataSource compositeDataSource; - var xData=new EnumerableDataSource(new DateTime[] { xSource }); - xData.SetXMapping(x => (x.Ticks/10000000000.0)); - var yData=new EnumerableDataSource(new double[] { ySource }); - yData.SetYMapping(y => y); - compositeDataSource=xData.Join(yData); - return compositeDataSource; - } + + //public static CompositeDataSource CreateCompositeDataSource(DateTime xSource,double ySource) + //{ + // CompositeDataSource compositeDataSource; + // var xData=new EnumerableDataSource(new DateTime[] { xSource }); + // xData.SetXMapping(x => (x.Ticks/10000000000.0)); + // var yData=new EnumerableDataSource(new double[] { ySource }); + // yData.SetYMapping(y => y); + // compositeDataSource=xData.Join(yData); + // return compositeDataSource; + //} + public static CompositeDataSource Price(Price price) { if (null == price) return null; diff --git a/Model/StopLimitCompositeModel.cs b/Model/StopLimitCompositeModel.cs index e655d5b..096b8b0 100644 --- a/Model/StopLimitCompositeModel.cs +++ b/Model/StopLimitCompositeModel.cs @@ -14,6 +14,7 @@ namespace TradeBlotter.Model private StopLimitCompositeModel() { } + public static CompositeDataSource CreateCompositeDataSource(StopLimits stopLimits) { if(null==stopLimits) return null; @@ -25,5 +26,22 @@ namespace TradeBlotter.Model compositeDataSource=xData.Join(yData); return compositeDataSource; } + + public static CompositeDataSource CreateCompositeDataSource(DateTime xSource,StopLimits stopLimits) + { + if(null==stopLimits) return null; + CompositeDataSource compositeDataSource; + List stopLimitDates = new List(); + foreach(StopLimit stopLimit in stopLimits) + { + stopLimitDates.Add(stopLimit.EffectiveDate); + } + var xData=new EnumerableDataSource(stopLimitDates.Select(x => x.Date)); + xData.SetXMapping(x => (x.Ticks/10000000000.0)); + var yData=new EnumerableDataSource(stopLimits.Select(y => y.StopPrice)); + yData.SetYMapping(y => y); + compositeDataSource=xData.Join(yData); + return compositeDataSource; + } } } diff --git a/ViewModels/BollingerBandViewModel.cs b/ViewModels/BollingerBandViewModel.cs index 795ad0d..de7380f 100644 --- a/ViewModels/BollingerBandViewModel.cs +++ b/ViewModels/BollingerBandViewModel.cs @@ -36,7 +36,7 @@ namespace TradeBlotter.ViewModels private static readonly String BAND_MESSAGE="Generating Bollinger Band..."; private static readonly String DATA_MESSAGE="Loading Pricing Data..."; private BollingerBands bollingerBands; - private StopLimit stopLimit; // This is the stop limit that is looked up in the database and displayed (if there is one) + private StopLimits internalStopLimits; // This is the stop limit that is looked up in the database and displayed (if there is one) private StopLimits stopLimits; // These stop limits might be passed in with the SaveParams. (i.e.) MMTRend model passes in StopLimits. If these are passsed in then they are displayed instead of stopLimit. private String symbol; private String companyName; @@ -220,7 +220,7 @@ namespace TradeBlotter.ViewModels prices=null; portfolioTrades=null; portfolioTradesLots=null; - stopLimit=null; + internalStopLimits=null; } if (eventArgs.PropertyName.Equals("SyncTradeToBand")|| @@ -238,7 +238,7 @@ namespace TradeBlotter.ViewModels BusyContent=DATA_MESSAGE; // DEBUG - stopLimit=StopLimitDA.GetStopLimit(symbol); + internalStopLimits=StopLimitDA.GetStopLimits(symbol); portfolioTrades = PortfolioDA.GetTradesSymbol(symbol); portfolioTradesLots=LotAggregator.CombineLots(portfolioTrades); if (null != portfolioTrades && 0 != portfolioTrades.Count) @@ -442,9 +442,9 @@ namespace TradeBlotter.ViewModels { compositeDataSourceStopLimit=StopLimitCompositeModel.CreateCompositeDataSource(stopLimits); } - else if(null!=stopLimit && null!=zeroPrice) + else if(null!=internalStopLimits && null!=zeroPrice) { - compositeDataSourceStopLimit=GainLossModel.CreateCompositeDataSource(zeroPrice.Date,stopLimit.StopPrice); + compositeDataSourceStopLimit=StopLimitCompositeModel.CreateCompositeDataSource(zeroPrice.Date,stopLimits); } compositeDataSourceInsiderTransactionPointDisposedSmall=InsiderTransactionModel.InsiderTransactionSummaries(new InsiderTransactionSummaries(disposedSummariesBin[2]),minClose); @@ -784,19 +784,43 @@ namespace TradeBlotter.ViewModels } else { - if(null==zeroPrice)return null; - if(null==stopLimit||null==zeroPrice||!showTradeLabels) return null; - 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"; + if (null == zeroPrice) return null; + if (null == internalStopLimits || null == zeroPrice || !showTradeLabels) return null; + for(int index=0;index0?"+":"").Append(Utility.FormatPercent(percentOffsetFromLow)).Append(")"); + } + centerTextMarker.Text=sb.ToString(); + if(0==index&&internalStopLimits.Count>1) centerTextMarker.VerticalShift="25"; + else centerTextMarker.VerticalShift="40"; + centerTextMarker.HorizontalShift="32"; + 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(); }