Handle multiple stop limits for single symbol.

This commit is contained in:
2026-02-18 21:51:02 -05:00
parent ea96097828
commit 315cf51da4
5 changed files with 65 additions and 17 deletions

View File

@@ -11,4 +11,19 @@ namespace MarketData.MarketDataModel
public String StopType{get;set;} public String StopType{get;set;}
public int Active{get;set;} public int Active{get;set;}
} }
public class StopLimits : List<StopLimit>
{
public StopLimits()
{
}
public StopLimits(List<StopLimit> stopLimits)
{
foreach(StopLimit stopLimit in stopLimits) Add(stopLimit);
}
public void Add(StopLimits stopLimits)
{
foreach(StopLimit stopLimit in stopLimits)this.Add(stopLimit);
}
}
} }

View File

@@ -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<StopLimits>(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) public ServiceResult GetPortfolioTradesWithParityPrice(String symbol)
{ {
lock(this) lock(this)

View File

@@ -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}; public enum Band{K=0,KL1=1,L=2,LP1=3,High=4,Low=5,Close=6,SMAN=7};
private Dictionary<int,LineGraph> bollingerBandGraphs=new Dictionary<int,LineGraph>(); private Dictionary<int,LineGraph> bollingerBandGraphs=new Dictionary<int,LineGraph>();
private PortfolioTradesWithParityPrice portfolioTradesWithParityPrice; private PortfolioTradesWithParityPrice portfolioTradesWithParityPrice;
private StopLimit stopLimit; private StopLimits stopLimits;
private DateGenerator dateGenerator=new DateGenerator(); private DateGenerator dateGenerator=new DateGenerator();
private bool deviceIsTablet=false; private bool deviceIsTablet=false;
@@ -51,10 +51,10 @@ namespace Navigator.Renderers
set{deviceIsTablet=value;} set{deviceIsTablet=value;}
} }
public StopLimit StopLimit public StopLimits StopLimits
{ {
get{return stopLimit;} get{return stopLimits;}
set{stopLimit=value;} set{stopLimits=value;}
} }
public PortfolioTradesWithParityPrice PortfolioTradesWithParityPrice public PortfolioTradesWithParityPrice PortfolioTradesWithParityPrice
@@ -221,10 +221,13 @@ namespace Navigator.Renderers
public void RenderStopLimitPointMarker(SKCanvas canvas,PointMapping pointMapping,SKPaint stopLimitPointMarkerStroke,SKPaint stopLimitPointMarkerFill) public void RenderStopLimitPointMarker(SKCanvas canvas,PointMapping pointMapping,SKPaint stopLimitPointMarkerStroke,SKPaint stopLimitPointMarkerFill)
{ {
if(null==stopLimit)return; if(null==stopLimits)return;
SKPoint stopLimitPoint=new SKPoint((float)(pointMapping.XDataExtent),(float)stopLimit.StopPrice); foreach(StopLimit stopLimit in stopLimits)
stopLimitPoint=pointMapping.MapPoint(stopLimitPoint); {
DrawTriangle(canvas,stopLimitPoint,stopLimitPointMarkerStroke,stopLimitPointMarkerFill); 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) public void DrawTriangle(SKCanvas canvas,SKPoint point,SKPaint paintStrokeMarker,SKPaint paintFillMarker)
@@ -306,9 +309,12 @@ namespace Navigator.Renderers
{ {
yExtents.Add(portfolioTradesWithParityPrice.ParityPrice.Close); 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; double maxDataExtent=yExtents.Count>0?yExtents.Max(x=>x):0;
return maxDataExtent; return maxDataExtent;
@@ -331,9 +337,12 @@ namespace Navigator.Renderers
{ {
yExtents.Add(portfolioTradesWithParityPrice.ParityPrice.Close); 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; double minDataExtent=yExtents.Count>0?yExtents.Min(x=>x):0;
return minDataExtent; return minDataExtent;

View File

@@ -15,7 +15,7 @@ namespace Navigator.ViewModels
private String ipAddress; private String ipAddress;
private RelayCommand ipAddressCommand; private RelayCommand ipAddressCommand;
private RelayCommand onResetCommand; private RelayCommand onResetCommand;
private static readonly String VERSION = "1.0.0.6"; private static readonly String VERSION = "1.0.0.7";
public AboutViewModel() public AboutViewModel()
{ {

View File

@@ -94,9 +94,9 @@ namespace Navigator.ViewModels
Task workerTask=Task.Factory.StartNew(()=> Task workerTask=Task.Factory.StartNew(()=>
{ {
StopLimit stopLimit=null; StopLimits stopLimits=null;
serviceResult=MarketDataServiceClient.GetInstance().GetStopLimit(selectedSymbol); serviceResult=MarketDataServiceClient.GetInstance().GetStopLimits(selectedSymbol);
if(serviceResult.Success)stopLimit=(StopLimit)serviceResult.ContextSpecificResult; if(serviceResult.Success)stopLimits=(StopLimits)serviceResult.ContextSpecificResult;
serviceResult = MarketDataServiceClient.GetInstance().GetPortfolioTradesWithParityPrice(selectedSymbol); serviceResult = MarketDataServiceClient.GetInstance().GetPortfolioTradesWithParityPrice(selectedSymbol);
if (serviceResult.Success) portfolioTradesWithParityPrice=(PortfolioTradesWithParityPrice)serviceResult.ContextSpecificResult; if (serviceResult.Success) portfolioTradesWithParityPrice=(PortfolioTradesWithParityPrice)serviceResult.ContextSpecificResult;
float change=float.NaN; float change=float.NaN;
@@ -149,7 +149,7 @@ namespace Navigator.ViewModels
bollingerBandRenderer.High=BollingerBandModel.High(bollingerBands); bollingerBandRenderer.High=BollingerBandModel.High(bollingerBands);
bollingerBandRenderer.Low=BollingerBandModel.Low(bollingerBands); bollingerBandRenderer.Low=BollingerBandModel.Low(bollingerBands);
bollingerBandRenderer.Close=BollingerBandModel.Close(bollingerBands); bollingerBandRenderer.Close=BollingerBandModel.Close(bollingerBands);
bollingerBandRenderer.StopLimit=stopLimit; bollingerBandRenderer.StopLimits=stopLimits;
bollingerBandRenderer.Refresh(); bollingerBandRenderer.Refresh();
}); });
workerTask.ContinueWith((TaskContinuationOptions)=> workerTask.ContinueWith((TaskContinuationOptions)=>