diff --git a/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs b/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs index f56471f0f..b5450702b 100644 --- a/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs +++ b/src/client/spark/Orders/OrderTypeVMs/StopLimitOrderVM.cs @@ -1,7 +1,7 @@ using bts.api; using mbts.co2; -using mbts.utils; using System; +using System.Reactive.Linq; using StopLimitDef = bts.api.orderman.StopLimitOrderDefinition; using StopLimitDefi = bts.api.orderman.StopLimitOrderDefinitionImmutable; @@ -15,10 +15,8 @@ namespace mbts.spark { public StopLimitOrderVM(AlgoKey key, string display_name, AlgoEditingPermissions editing_permissions) : base(key, display_name, editing_permissions) { _stop_price = new UserProperty(backing(nameof(stop_price), double.NaN)); - _stop_price.Changed += on_stop_price_changed; add_property(def => def.StopPrice, (def, val) => def.StopPrice = val, _stop_price.bypass_setter, () => stop_price); - _resources.Add(() => _stop_price.Changed -= on_stop_price_changed); - void on_stop_price_changed(double oldval, double newval) => validate(); + _resources.Add(_stop_price.Subscribe(_ => validate())); } public override bool is_expanded { @@ -39,16 +37,6 @@ namespace mbts.spark { _stop_price.bypass_setter(value.StopPrice); } - protected void _on_security_changed(SecurityMD? security_md) { - //base._on_security_changed(security_md); - if (double.IsNaN(stop_price) && !_stop_price.setter_called && !security_md.HasValue) { - // 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"