diff --git a/src/client/spark/Orders/OrdersModel.cs b/src/client/spark/Orders/OrdersModel.cs index 4c7406d07..0107af243 100644 --- a/src/client/spark/Orders/OrdersModel.cs +++ b/src/client/spark/Orders/OrdersModel.cs @@ -206,9 +206,11 @@ namespace mbts.spark { public static IObservable security_total_position(this OrdersModel orders_model, uint security_key, string account) => // PositionUnit.Account is actually the clearing account; this code assumes that clearing account and account are equivalent. // However, it still must match account to PositionUnit.Account.Trimmed() because the exchange likes to slap spaces on the end. - orders_model.on_security_positions(security_key).filter(p => p.Account == account).Scan(0.0, (pos, table) => - // the state should always have 1 element, since the PositionUnit-identity is security + account - pos + (table.added.Sum(p => p.total_pos()) - table.removed.Sum(p => p.total_pos()))); + orders_model.on_security_positions(security_key) + .filter(p => p.Account == account) + // the state should always have 1 element, since the PositionUnit-identity is security + account + .Scan(0.0, (pos, table) => pos + (table.added.Sum(p => p.total_pos()) - table.removed.Sum(p => p.total_pos()))) + .StartWith(double.NaN); public static IObservable> on_security_root_orders(this OrdersModel orders_model, uint security_key) => orders_model.on_security_orders(security_key).Scan(new RootOrderData(), (rod, table) => { diff --git a/src/client/spark/view/Converters/Numeric/DoubleTextConverter.cs b/src/client/spark/view/Converters/Numeric/DoubleTextConverter.cs index 15bcec2e7..d474c763a 100644 --- a/src/client/spark/view/Converters/Numeric/DoubleTextConverter.cs +++ b/src/client/spark/view/Converters/Numeric/DoubleTextConverter.cs @@ -13,18 +13,17 @@ namespace mbts.ui.converters Minimum = Double.NaN; Maximum = Double.NaN; Multiplier = Double.NaN; - HideNaN = true; } public double Minimum { get; set; } public double Maximum { get; set; } public double Multiplier { get; set; } public string Format { get; set; } - public bool HideNaN { get; set; } + public string NaNText { get; set; } = string.Empty; public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var text = (value as string ?? string.Empty).Trim().ToLower(); - if (text == string.Empty || text == "nan") return double.NaN; + if (text == string.Empty || text == "nan" || text == NaNText) return double.NaN; if (double.TryParse(text, out double d) && !double.IsNaN(d)) { if ((!double.IsNaN(Minimum) && d < Minimum) || (!double.IsNaN(Maximum) && d > Maximum)) return new ValidationResult(false, null); return double.IsNaN(Multiplier) ? d : d / Multiplier; @@ -40,7 +39,7 @@ namespace mbts.ui.converters return string.IsNullOrEmpty(Format) ? d.ToString() : d.ToString(Format); } } - return HideNaN ? string.Empty : "NaN"; + return NaNText; } } diff --git a/src/client/spark/view/Spark/Ladder/LadderView.xaml b/src/client/spark/view/Spark/Ladder/LadderView.xaml index 933b75260..53164d14e 100644 --- a/src/client/spark/view/Spark/Ladder/LadderView.xaml +++ b/src/client/spark/view/Spark/Ladder/LadderView.xaml @@ -26,6 +26,7 @@ +