From 315cf51da499f27f6fc5fd8f8668ab4f0f37a745 Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 18 Feb 2026 21:51:02 -0500 Subject: [PATCH] Handle multiple stop limits for single symbol. --- MarketDataLib/MarketDataModel/StopLimit.cs | 15 +++++++++ .../Service/MarketDataServiceClient.cs | 24 ++++++++++++++ Navigator/Renderers/BollingerBandRenderer.cs | 33 ++++++++++++------- Navigator/ViewModels/AboutViewModel.cs | 2 +- .../ViewModels/BollingerBandViewModel.cs | 8 ++--- 5 files changed, 65 insertions(+), 17 deletions(-) diff --git a/MarketDataLib/MarketDataModel/StopLimit.cs b/MarketDataLib/MarketDataModel/StopLimit.cs index a2992fe..8efeaf2 100644 --- a/MarketDataLib/MarketDataModel/StopLimit.cs +++ b/MarketDataLib/MarketDataModel/StopLimit.cs @@ -11,4 +11,19 @@ namespace MarketData.MarketDataModel public String StopType{get;set;} public int Active{get;set;} } + + public class StopLimits : List + { + public StopLimits() + { + } + public StopLimits(List stopLimits) + { + foreach(StopLimit stopLimit in stopLimits) Add(stopLimit); + } + public void Add(StopLimits stopLimits) + { + foreach(StopLimit stopLimit in stopLimits)this.Add(stopLimit); + } + } } \ No newline at end of file diff --git a/MarketDataLib/Service/MarketDataServiceClient.cs b/MarketDataLib/Service/MarketDataServiceClient.cs index c948b97..3af1c91 100644 --- a/MarketDataLib/Service/MarketDataServiceClient.cs +++ b/MarketDataLib/Service/MarketDataServiceClient.cs @@ -339,6 +339,30 @@ namespace MarketData.Service } } + public ServiceResult GetStopLimits(String symbol) + { + lock(this) + { + try + { + if(!IsNetworkAvailable())return new ServiceResult(false,"No network."); + if (!IsAuthorized()) return new ServiceResult(false,"Unauthorized."); + StringBuilder sb = new StringBuilder(); + sb.Append("/api/Portfolio/GetStopLimits?").Append("token=").Append(accessToken).Append("&").Append("symbol=").Append(symbol); + String json = httpClient.GetStringAsync(sb.ToString()).Result; + if(null==json)return new ServiceResult(null); + StopLimits stopLimits = JsonConvert.DeserializeObject(json); + return new ServiceResult(stopLimits); + } + catch (Exception exception) + { + exceptions.Add(exception); + Debug.WriteLine(exception.ToString()); + return new ServiceResult(false,exception.ToString()); + } + } + } + public ServiceResult GetPortfolioTradesWithParityPrice(String symbol) { lock(this) diff --git a/Navigator/Renderers/BollingerBandRenderer.cs b/Navigator/Renderers/BollingerBandRenderer.cs index fd2776c..2c6c783 100644 --- a/Navigator/Renderers/BollingerBandRenderer.cs +++ b/Navigator/Renderers/BollingerBandRenderer.cs @@ -31,7 +31,7 @@ namespace Navigator.Renderers public enum Band{K=0,KL1=1,L=2,LP1=3,High=4,Low=5,Close=6,SMAN=7}; private Dictionary bollingerBandGraphs=new Dictionary(); private PortfolioTradesWithParityPrice portfolioTradesWithParityPrice; - private StopLimit stopLimit; + private StopLimits stopLimits; private DateGenerator dateGenerator=new DateGenerator(); private bool deviceIsTablet=false; @@ -51,10 +51,10 @@ namespace Navigator.Renderers set{deviceIsTablet=value;} } - public StopLimit StopLimit + public StopLimits StopLimits { - get{return stopLimit;} - set{stopLimit=value;} + get{return stopLimits;} + set{stopLimits=value;} } public PortfolioTradesWithParityPrice PortfolioTradesWithParityPrice @@ -221,10 +221,13 @@ namespace Navigator.Renderers public void RenderStopLimitPointMarker(SKCanvas canvas,PointMapping pointMapping,SKPaint stopLimitPointMarkerStroke,SKPaint stopLimitPointMarkerFill) { - if(null==stopLimit)return; - SKPoint stopLimitPoint=new SKPoint((float)(pointMapping.XDataExtent),(float)stopLimit.StopPrice); - stopLimitPoint=pointMapping.MapPoint(stopLimitPoint); - DrawTriangle(canvas,stopLimitPoint,stopLimitPointMarkerStroke,stopLimitPointMarkerFill); + if(null==stopLimits)return; + foreach(StopLimit stopLimit in stopLimits) + { + SKPoint stopLimitPoint=new SKPoint((float)(pointMapping.XDataExtent),(float)stopLimit.StopPrice); + stopLimitPoint=pointMapping.MapPoint(stopLimitPoint); + DrawTriangle(canvas,stopLimitPoint,stopLimitPointMarkerStroke,stopLimitPointMarkerFill); + } } public void DrawTriangle(SKCanvas canvas,SKPoint point,SKPaint paintStrokeMarker,SKPaint paintFillMarker) @@ -306,9 +309,12 @@ namespace Navigator.Renderers { yExtents.Add(portfolioTradesWithParityPrice.ParityPrice.Close); } - if(null!=stopLimit) + if(null!=stopLimits) { - yExtents.Add(stopLimit.StopPrice); + foreach(StopLimit stopLimit in stopLimits) + { + yExtents.Add(stopLimit.StopPrice); + } } double maxDataExtent=yExtents.Count>0?yExtents.Max(x=>x):0; return maxDataExtent; @@ -331,9 +337,12 @@ namespace Navigator.Renderers { yExtents.Add(portfolioTradesWithParityPrice.ParityPrice.Close); } - if(null!=stopLimit) + if(null!=stopLimits) { - yExtents.Add(stopLimit.StopPrice); + foreach(StopLimit stopLimit in stopLimits) + { + yExtents.Add(stopLimit.StopPrice); + } } double minDataExtent=yExtents.Count>0?yExtents.Min(x=>x):0; return minDataExtent; diff --git a/Navigator/ViewModels/AboutViewModel.cs b/Navigator/ViewModels/AboutViewModel.cs index 830942e..1f3bb80 100644 --- a/Navigator/ViewModels/AboutViewModel.cs +++ b/Navigator/ViewModels/AboutViewModel.cs @@ -15,7 +15,7 @@ namespace Navigator.ViewModels private String ipAddress; private RelayCommand ipAddressCommand; private RelayCommand onResetCommand; - private static readonly String VERSION = "1.0.0.6"; + private static readonly String VERSION = "1.0.0.7"; public AboutViewModel() { diff --git a/Navigator/ViewModels/BollingerBandViewModel.cs b/Navigator/ViewModels/BollingerBandViewModel.cs index 95aca97..d6f79a5 100644 --- a/Navigator/ViewModels/BollingerBandViewModel.cs +++ b/Navigator/ViewModels/BollingerBandViewModel.cs @@ -94,9 +94,9 @@ namespace Navigator.ViewModels Task workerTask=Task.Factory.StartNew(()=> { - StopLimit stopLimit=null; - serviceResult=MarketDataServiceClient.GetInstance().GetStopLimit(selectedSymbol); - if(serviceResult.Success)stopLimit=(StopLimit)serviceResult.ContextSpecificResult; + StopLimits stopLimits=null; + serviceResult=MarketDataServiceClient.GetInstance().GetStopLimits(selectedSymbol); + if(serviceResult.Success)stopLimits=(StopLimits)serviceResult.ContextSpecificResult; serviceResult = MarketDataServiceClient.GetInstance().GetPortfolioTradesWithParityPrice(selectedSymbol); if (serviceResult.Success) portfolioTradesWithParityPrice=(PortfolioTradesWithParityPrice)serviceResult.ContextSpecificResult; float change=float.NaN; @@ -149,7 +149,7 @@ namespace Navigator.ViewModels bollingerBandRenderer.High=BollingerBandModel.High(bollingerBands); bollingerBandRenderer.Low=BollingerBandModel.Low(bollingerBands); bollingerBandRenderer.Close=BollingerBandModel.Close(bollingerBands); - bollingerBandRenderer.StopLimit=stopLimit; + bollingerBandRenderer.StopLimits=stopLimits; bollingerBandRenderer.Refresh(); }); workerTask.ContinueWith((TaskContinuationOptions)=>