Handle multiple stop limits for single symbol.
This commit is contained in:
@@ -11,4 +11,19 @@ namespace MarketData.MarketDataModel
|
||||
public String StopType{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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
lock(this)
|
||||
|
||||
@@ -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<int,LineGraph> bollingerBandGraphs=new Dictionary<int,LineGraph>();
|
||||
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;
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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)=>
|
||||
|
||||
Reference in New Issue
Block a user