diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs index 4d60f5167..cfcd3b414 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs @@ -14,6 +14,7 @@ using mbts.ui.utility.text; using mbts.utils; using Spark.Core.Disposables; +using Spark.Core.Math; using System; using System.Collections; @@ -1114,7 +1115,7 @@ namespace mbts.spark { Log.assert(_price_dirty); _price_list = new LadderPriceList { length = _initial_row_count, - security = security + regional_tick = _spec }; var mid_tick = security.tickdiff(_mkt_break_lines.origin, 0) ?? 0; if (mid_tick > int.MaxValue) { @@ -1364,7 +1365,7 @@ namespace mbts.spark { return; if (_price_list is null) { _price_list = new LadderPriceList { - security = security + regional_tick = _spec }; } _price_list.reset(null, null, _initial_row_count); @@ -1458,7 +1459,13 @@ namespace mbts.spark { _pending_scroll_to_origin |= _settings == null; _invalidate_spec(); if (_price_list != null) { - _price_list.security = security; + _pending_price_list = null; + if (_price_list.Count > 0) { + var high_price = _price_list.First(); + var new_tickdiff = _spec.count_ticks(high_price); + _price_list.high_tick = (long)new_tickdiff; + } + _price_list.regional_tick = _spec; } _bid_vis_tup.glyph_context = glyph_context(s.bid_column); _ask_vis_tup.glyph_context = glyph_context(s.ask_column); @@ -1543,6 +1550,7 @@ namespace mbts.spark { // } scroll_to_pending_target(); visible_columns_changed?.Invoke(); + _refresh_all_visuals(); } // This is designed to be a redundant null check for _fmt_mkt_depth_item_impl. diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderPriceList.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderPriceList.cs index 9675a2292..f23420400 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderPriceList.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderPriceList.cs @@ -16,33 +16,34 @@ namespace mbts.spark { long _length; long _high_tick; SecurityImmutable? _security; - RegionalTickFactors _regional_tick_backing; - RegionalTickFactors _regional_tick => - _regional_tick_backing ??= TickUtils.get_regional_ticks(_security); - public LadderPriceList() { } + public LadderPriceList() + : this(RegionalTickFactors.Default) { } + + public LadderPriceList(RegionalTickFactors regional_tick) => + this.regional_tick = regional_tick; public LadderPriceList(LadderPriceList other) { _length = other._length; _high_tick = other._high_tick; _security = other._security; + regional_tick = other.regional_tick; } public event NotifyCollectionChangedEventHandler CollectionChanged; - public SecurityImmutable? security { - get => _security; + RegionalTickFactors _regional_tick; + public RegionalTickFactors regional_tick { + get => _regional_tick; set { - if (value == _security) { - return; + if (value is null) { + _regional_tick = RegionalTickFactors.Default; + } else { + _regional_tick = value; } - _security = value; - _regional_tick_backing = null; } } - public ContractSpecificationImmutable spec { get; set; } - public long high_tick { get => _high_tick; set => _high_tick = value; @@ -54,8 +55,8 @@ namespace mbts.spark { } public double start { - get => _regional_tick.tickup(0, (uint)high_tick); - set => high_tick = _regional_tick.tickdiff(value, 0) ?? high_tick; + get => regional_tick.tickup(0, (uint)high_tick); + set => high_tick = regional_tick.tickdiff(value, 0) ?? high_tick; } public long length { @@ -80,7 +81,7 @@ namespace mbts.spark { public bool IsReadOnly => false; public double this[int idx] { - get => _regional_tick.tick(0, high_tick - idx); + get => regional_tick.tick(0, high_tick - idx); set => throw new NotSupportedException(); } @@ -94,7 +95,7 @@ namespace mbts.spark { GetEnumerator(); public int IndexOf(double item) { - var idx = _regional_tick.tickdiff(start, item) ?? -1; + var idx = regional_tick.tickdiff(start, item) ?? -1; if (idx < 0 || idx >= length) { return -1; } @@ -209,7 +210,7 @@ namespace mbts.spark { other != null && _high_tick == other._high_tick && _length == other._length && - _regional_tick.safe_equals(other._regional_tick); + regional_tick.safe_equals(other.regional_tick); public override bool Equals(object obj) => Equals(obj as LadderPriceList); @@ -218,7 +219,7 @@ namespace mbts.spark { HashCode.Combine(_high_tick, _length); double _tick_to_price(long tick) => - _regional_tick.tick(0, tick); + regional_tick.tick(0, tick); void _add_tick(long tick) { int idx;