From 0f18d733ebb2f962618ef012fb93e949eedaf05e Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 31 Jan 2019 22:03:27 -0600 Subject: [PATCH] AlgoStudio - default stop limit order stop price to 0 instead of NaN to remove red-error-border --- .../spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs b/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs index 3e61bdb29..e651a1393 100644 --- a/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs +++ b/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs @@ -45,6 +45,18 @@ namespace mbts.spark { // TODO: the StopLimitOrderDefinition needs relative vs absolute prices to function as a useful template (talk to Pedro) } + protected override void _on_security_changed(SecurityMD? security_md) { + base._on_security_changed(security_md); + if (!security_md.HasValue) { + if (double.IsNaN(stop_price)) { + // If security is null, then it is safe to default to 0.0 and clear the error + // (obviously the user isn't placing any orders with a null security!), thus removing the red error border. + // Note: algo vms in AlgoStudioWindow pass a null security_md down the pipe (1/31/2019). + stop_price = 0; + } + } + } + // no need to constantly poll the md, just check the inline props when the popup opens, and right before sending an order // (if the user never looks at the popup, assume that the bid_price will be used) // TODO: add settings so the trigger-price can default to something relative to the md, e.g "bid-price" or "ask-price - nticks" or "best-bid-price with a minimum size of 10"