From 8c4a7ae0f08a883d91eccbb9912c99ee9bb1e396 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 3 May 2018 20:54:00 -0400 Subject: [PATCH] Ladder - add\implement market-break-line settings --- .../Modules/Trading/TradingShellModule.cs | 23 ++- src/client/spark/view/Spark/Core/TickUtils.cs | 9 -- .../spark/view/Spark/Ladder/LadderGridHost.cs | 147 +++++++++++++----- .../spark/view/Spark/Ladder/LadderSettings.cs | 51 ++++-- .../view/Spark/Ladder/LadderSettingsVM.cs | 54 ++++++- .../view/Spark/Ladder/LadderSettingsView.xaml | 125 ++++++++++++++- .../spark/view/Spark/Ladder/LaderRender.cs | 11 +- 7 files changed, 349 insertions(+), 71 deletions(-) diff --git a/src/client/spark/Modules/Trading/TradingShellModule.cs b/src/client/spark/Modules/Trading/TradingShellModule.cs index bfb542351..75e14834d 100644 --- a/src/client/spark/Modules/Trading/TradingShellModule.cs +++ b/src/client/spark/Modules/Trading/TradingShellModule.cs @@ -22,10 +22,28 @@ namespace bts.shell { [ImportingConstructor] public TradingShellModule(IBus bus, IWindowManager wm, UserSettingsHub settings_hub, OrdersModel orders_model, PAndLModel pandl_model) { _lwf = new LadderWindowFactory(this, bus, wm, - new WindowSettingsManagerFactory(settings_hub, us => us.ladder, (us, v) => us.with(v)), orders_model); + new WindowSettingsManagerFactory( + settings_hub, + us => sanitize_ladder_settings(us.ladder), + (us, v) => us.with(sanitize_ladder_settings(v))), + orders_model); _obwf = new OrderBookWindowFactory(this, bus, orders_model); _fwf = new FillsWindowFactory(this, bus, orders_model); _plwf = new PAndLWindowFactory(this, bus, pandl_model); + + // if there are new props, make sure they are not null, invalid, etc. + LadderSettings sanitize_ladder_settings(LadderSettings s) { + // these MarketBreakLines are new settings props, ensure they are not null, and "show" is true for at least 1 of them + if (s.bid_break_line == null) + s.bid_break_line = LadderSettings.Default.bid_break_line; + if (s.ask_break_line == null) + s.ask_break_line = LadderSettings.Default.ask_break_line; + if (s.mid_break_line == null) + s.mid_break_line = LadderSettings.Default.mid_break_line; + if (!s.bid_break_line.show && !s.ask_break_line.show && !s.mid_break_line.show) + s.bid_break_line.show = true; + return s; + } } public ImageSource icon => Icons.Trades; @@ -58,5 +76,4 @@ namespace bts.shell { if (i != null) i.Dispose(); } } - -} +} \ No newline at end of file diff --git a/src/client/spark/view/Spark/Core/TickUtils.cs b/src/client/spark/view/Spark/Core/TickUtils.cs index a909be2c6..22f602df8 100644 --- a/src/client/spark/view/Spark/Core/TickUtils.cs +++ b/src/client/spark/view/Spark/Core/TickUtils.cs @@ -146,15 +146,6 @@ namespace mbts.spark { return raw_mid - (raw_mid % tick_size); } - public static double atm_tick(ContractSpecificationImmutable spec, double bid, double ask, MarketBreakType atm_line) { - switch (atm_line) { - case MarketBreakType.Bid: return double.IsNaN(bid) ? ask : bid; - case MarketBreakType.Ask: return double.IsNaN(ask) ? bid : ask; - case MarketBreakType.Mid: - default: return mid_tick(spec, bid, ask); - } - } - public static IReadOnlyList all_present_ticks() => _ticks_cache.Values.ToReadOnlyList(); diff --git a/src/client/spark/view/Spark/Ladder/LadderGridHost.cs b/src/client/spark/view/Spark/Ladder/LadderGridHost.cs index 141fdadb2..30cbca7a6 100644 --- a/src/client/spark/view/Spark/Ladder/LadderGridHost.cs +++ b/src/client/spark/view/Spark/Ladder/LadderGridHost.cs @@ -24,7 +24,9 @@ namespace mbts.spark { readonly VisualHost _visualHost = new VisualHost(); readonly LadderOrdersHost _ordershost; readonly DrawingVisual - _midvis = new DrawingVisual(), + _mid_mkt_break_vis = new DrawingVisual(), + _bid_mkt_break_vis = new DrawingVisual(), + _ask_mkt_break_vis = new DrawingVisual(), _gridvis = new DrawingVisual(); readonly VisualGlyphTuple _bid_vis_tup = new VisualGlyphTuple(), @@ -42,12 +44,14 @@ namespace mbts.spark { bool _price_dirty = false; double[] _price_list = null; IComparer _price_comparer; - double _last_market_break; + double _last_origin_price; + MarketBreakLines _mkt_break_lines; NativePriceSize _last_trade; public LadderGridHost() { AllowDrop = true; UseLayoutRounding = true; + _mkt_break_lines = new MarketBreakLines(this); _ordershost = new LadderOrdersHost(this) { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Stretch }; var scrollViewerFactory = new FrameworkElementFactory(typeof(ScrollViewer)); scrollViewerFactory.SetValue(FocusableProperty, false); @@ -309,7 +313,7 @@ namespace mbts.spark { case ColumnType.Ask: render_market_col(_asks); break; } void render_market_col(NativePriceSize[] depth) { - var mid = LadderRender.index_of(_price_list, _last_market_break, _price_comparer); + var mid = LadderRender.index_of(_price_list, _last_origin_price, _price_comparer); LadderRender.render_sizes(column.visual_tup.visual, column.visual_tup.glyph_context, mid, _price_list, depth, _settings.row_height, security.ContractSpec, column.settings); } } @@ -344,8 +348,8 @@ namespace mbts.spark { void _scroll_to_center() { if (_scrollViewer != null && _settings != null) { - int index = _price_list != null && !double.IsNaN(_last_market_break) ? - LadderRender.index_of(_price_list, _last_market_break, _price_comparer) : + int index = _price_list != null && !double.IsNaN(_last_origin_price) ? + LadderRender.index_of(_price_list, _last_origin_price, _price_comparer) : _row_count / 2; double target_position = index * _settings.row_height - (ActualHeight / 2); if (_settings.animate_recenter) { @@ -372,22 +376,23 @@ namespace mbts.spark { ulong unused = 0; _vm.md.get_last_trade(ref unused, out NativePriceSize last, out DateTime _, out ulong __); bool depth_changed = _vm.md.get_depth(ref _prices_updated, ref _bids, ref _asks); - double market_break = _get_market_break(); + // + _mkt_break_lines.refresh(); bool update_prices = _price_dirty || - (double.IsNaN(_last_market_break) && !double.IsNaN(market_break)) || - (market_break >= _price_list[0] || market_break <= _price_list[_price_list.Length - 1]); + (double.IsNaN(_last_origin_price) && !double.IsNaN(_mkt_break_lines.origin)) || + _mkt_break_lines.origin >= _price_list[0] || _mkt_break_lines.origin <= _price_list[_price_list.Length - 1]; if (!update_prices && _prices_out_of_range(out double low, out double high)) { // The market can be wider than the 1001 rows (ticks) we [initially] allot. // Rendering prices is expensive, and will lock up the ui if done continuously. // Therefore, ensure a minimum time interval has elapsed before rendering prices again. var now = DateTime.Now; if ((now - _last_price_range_calc_time) > _price_out_of_range_render_interval) { - SparkUtils.lazy_warn(!double.IsNaN(market_break) && market_break >= low && market_break <= high, - () => fmt_log_msg($"market break ({market_break}) is unacceptable for the market range ({low} - {high})")); + SparkUtils.lazy_warn(!double.IsNaN(_mkt_break_lines.origin) && _mkt_break_lines.origin >= low && _mkt_break_lines.origin <= high, + () => fmt_log_msg($"market break ({_mkt_break_lines.origin}) is unacceptable for the market range ({low} - {high})")); int prev_row_count = _row_count; - int n_ticks_to_low = TickUtils.normalized_tick_diff(security.ContractSpec, market_break, low); - int n_ticks_to_high = TickUtils.normalized_tick_diff(security.ContractSpec, high, market_break); + int n_ticks_to_low = TickUtils.normalized_tick_diff(security.ContractSpec, _mkt_break_lines.origin, low); + int n_ticks_to_high = TickUtils.normalized_tick_diff(security.ContractSpec, high, _mkt_break_lines.origin); int desired_row_count = Math.Max(n_ticks_to_low, n_ticks_to_high) * 2 + 1; _row_count = Math.Min(_max_row_count, desired_row_count); if (_row_count != prev_row_count) { @@ -401,7 +406,7 @@ namespace mbts.spark { _ordershost.Height = height; _render_grid_lines(); } else { - update_prices = market_break != _last_market_break; + update_prices = _mkt_break_lines.origin != _last_origin_price; } _last_price_range_calc_time = now; // @@ -411,7 +416,7 @@ namespace mbts.spark { } if (update_prices) { var prev_price_list = _price_list; - _price_list = LadderRender.render_prices(_price_vis_tup.visual, _price_vis_tup.glyph_context, market_break, _row_count, _settings.row_height, _settings.price_column, security.ContractSpec); + _price_list = LadderRender.render_prices(_price_vis_tup.visual, _price_vis_tup.glyph_context, _mkt_break_lines.origin, _row_count, _settings.row_height, _settings.price_column, security.ContractSpec); _ordershost.update_settings(_price_list, _price_comparer, _settings.row_height, _settings.orders_column); if (prev_price_list != null) { // maintain previous visible price range if possible @@ -428,11 +433,14 @@ namespace mbts.spark { } } } - int market_break_index = LadderRender.index_of(_price_list, market_break, _price_comparer); - if (update_prices || market_break != _last_market_break) { - _last_market_break = market_break; - LadderRender.render_mid(_midvis, market_break_index, _settings.row_height); - } + // render market breaks + if (update_prices || _mkt_break_lines.bid_dirty) + render_mkt_break(_bid_mkt_break_vis, _mkt_break_lines.bid, _settings.bid_break_line.color); + if (update_prices || _mkt_break_lines.ask_dirty) + render_mkt_break(_ask_mkt_break_vis, _mkt_break_lines.ask, _settings.ask_break_line.color); + if (update_prices || _mkt_break_lines.mid_dirty) + render_mkt_break(_mid_mkt_break_vis, _mkt_break_lines.mid, _settings.mid_break_line.color); + // if (update_prices || _last_trade != last) { _last_trade = last; var last_index = LadderRender.index_of(_price_list, last.price, _price_comparer); @@ -442,36 +450,50 @@ namespace mbts.spark { } if (update_prices || depth_changed) { Logger.assert_d(_price_list != null); - LadderRender.render_sizes(_bid_vis_tup.visual, _bid_vis_tup.glyph_context, market_break_index, _price_list, _bids, _settings.row_height, security.ContractSpec, _settings.bid_column); - LadderRender.render_sizes(_ask_vis_tup.visual, _ask_vis_tup.glyph_context, market_break_index, _price_list, _asks, _settings.row_height, security.ContractSpec, _settings.ask_column); + int origin_index = LadderRender.index_of(_price_list, _mkt_break_lines.origin, _price_comparer); + LadderRender.render_sizes(_bid_vis_tup.visual, _bid_vis_tup.glyph_context, origin_index, _price_list, _bids, _settings.row_height, security.ContractSpec, _settings.bid_column); + LadderRender.render_sizes(_ask_vis_tup.visual, _ask_vis_tup.glyph_context, origin_index, _price_list, _asks, _settings.row_height, security.ContractSpec, _settings.ask_column); } + _last_origin_price = _mkt_break_lines.origin; _price_dirty = false; + // + void render_mkt_break(DrawingVisual vis, double price, uint color) { + int index = LadderRender.index_of(_price_list, price, _price_comparer); + LadderRender.render_mkt_break(vis, index, _settings.row_height, color); + } } } - double _get_market_break() { + #region Market Break Utils + double _get_bid_market_break() { double best_bid = _get_top_price(_bids); double best_ask = _get_top_price(_asks); - switch (_settings.market_break_type) { - case MarketBreakType.Bid: - return double.IsNaN(best_bid) ? - double.IsNaN(best_ask) ? _vm.low : security.ContractSpec.tickdown(best_ask) : - best_bid; - case MarketBreakType.Ask: - return double.IsNaN(best_ask) ? - double.IsNaN(best_bid) ? security.ContractSpec.tickdown(_vm.high) : best_bid : - security.ContractSpec.tickdown(best_ask); - case MarketBreakType.Mid: - return double.IsNaN(best_bid) ? - double.IsNaN(best_ask) ? 0.5 * (_vm.low + _vm.high) : security.ContractSpec.tickdown(best_ask) : - double.IsNaN(best_ask) ? best_bid : TickUtils.mid_tick(security.ContractSpec, best_bid, best_ask); - default: throw new NotImplementedException($"Unknown MarketBreakType ({_settings.market_break_type})"); - } - double _get_top_price(NativePriceSize[] prices) => - prices != null && prices.Length > 0 ? prices[0].price : double.NaN; + return double.IsNaN(best_bid) ? + double.IsNaN(best_ask) ? _vm.low : security.ContractSpec.tickdown(best_ask) : + best_bid; } - void _settings_updated(LadderSettings s) { + double _get_ask_market_break() { + double best_bid = _get_top_price(_bids); + double best_ask = _get_top_price(_asks); + return double.IsNaN(best_ask) ? + double.IsNaN(best_bid) ? security.ContractSpec.tickdown(_vm.high) : best_bid : + security.ContractSpec.tickdown(best_ask); + } + + double _get_mid_market_break() { + double best_bid = _get_top_price(_bids); + double best_ask = _get_top_price(_asks); + return double.IsNaN(best_bid) ? + double.IsNaN(best_ask) ? 0.5 * (_vm.low + _vm.high) : security.ContractSpec.tickdown(best_ask) : + double.IsNaN(best_ask) ? best_bid : TickUtils.mid_tick(security.ContractSpec, best_bid, best_ask); + } + + static double _get_top_price(NativePriceSize[] prices) => + prices != null && prices.Length > 0 ? prices[0].price : double.NaN; + #endregion + + void _settings_updated(LadderSettings s) { _settings = s; _bid_vis_tup.glyph_context = glyph_context(s.bid_column); _ask_vis_tup.glyph_context = glyph_context(s.ask_column); @@ -504,7 +526,9 @@ namespace mbts.spark { } // Renders the grid lines _visualHost.AddVisualChild(_gridvis); - _visualHost.AddVisualChild(_midvis); + _visualHost.AddVisualChild(_mid_mkt_break_vis); + _visualHost.AddVisualChild(_ask_mkt_break_vis); + _visualHost.AddVisualChild(_bid_mkt_break_vis); _init_tactile_adorner(); // this effectively sets the background of the "Last" column if (_scrollViewer != null) @@ -569,5 +593,46 @@ namespace mbts.spark { public static bool operator !=(Column x, Column y) => !(x == y); } + + class MarketBreakLines { + readonly LadderGridHost _owner; + + public MarketBreakLines(LadderGridHost owner) => + _owner = owner; + + public bool bid_dirty { get; private set; } + public bool ask_dirty { get; private set; } + public bool mid_dirty { get; private set; } + public bool origin_dirty { get; private set; } + + public double bid { get; private set; } + public double ask { get; private set; } + public double mid { get; private set; } + public double origin { get; private set; } + + public void refresh() { + double new_bid = _owner._settings.bid_break_line.show ? _owner._get_bid_market_break() : double.NaN; + double new_ask = _owner._settings.ask_break_line.show ? _owner._get_ask_market_break() : double.NaN; + double new_mid = _owner._settings.mid_break_line.show ? _owner._get_mid_market_break() : double.NaN; + // + if ((bid_dirty = !new_bid.Equals(bid))) + bid = new_bid; + if ((ask_dirty = !new_ask.Equals(ask))) + ask = new_ask; + if ((mid_dirty = !new_mid.Equals(mid))) + mid = new_mid; + // + double new_origin; + if (!double.IsNaN(bid)) + new_origin = bid; + else if (!double.IsNaN(ask)) + new_origin = ask; + else new_origin = mid; + if (double.IsNaN(new_origin)) + new_origin = _owner._get_bid_market_break(); + if ((origin_dirty = !new_origin.Equals(origin))) + origin = new_origin; + } + } } } \ No newline at end of file diff --git a/src/client/spark/view/Spark/Ladder/LadderSettings.cs b/src/client/spark/view/Spark/Ladder/LadderSettings.cs index ce4e9fdb9..bfa9ae4c0 100644 --- a/src/client/spark/view/Spark/Ladder/LadderSettings.cs +++ b/src/client/spark/view/Spark/Ladder/LadderSettings.cs @@ -6,8 +6,6 @@ using System.Linq; using System.Windows; namespace mbts.spark { - public enum MarketBreakType { Bid, Ask, Mid } - // IMPORTANT: BE SURE TO ADD ANY NEW PROPERTIES TO THE EQUALS FUNCTION! // 1 important reason at this time: // From the settings dialog, default settings will only be persisted when they are NOT EQUAL to the current default settings. @@ -75,6 +73,26 @@ namespace mbts.spark { public static bool operator !=(LadderColumnSettings x, LadderColumnSettings y) => !(x == y); } + [ProtoContract] + public class LadderMarketBreakLine : IEquatable { + [ProtoMember(1)] + public bool show { get; set; } + [ProtoMember(2)] + public uint color { get; set; } + + public bool Equals(LadderMarketBreakLine other) => + other != null && + other.show == show && + other.color == color; + + public override bool Equals(object obj) => + Equals(obj as LadderMarketBreakLine); + + public override int GetHashCode() => + show.GetHashCode() + + (int)color; + } + // IMPORTANT: BE SURE TO ADD ANY NEW PROPERTIES TO THE EQUALS FUNCTION! // 1 important reason at this time: // From the settings dialog, default settings will only be persisted when they are NOT EQUAL to the current default settings. @@ -99,7 +117,6 @@ namespace mbts.spark { return new LadderSettings { row_height = 20, grid_line_color = 0x535353, - market_break_type = MarketBreakType.Bid, orders_column = orders_column, bid_column = bid_column, ask_column = ask_column, @@ -111,7 +128,10 @@ namespace mbts.spark { seconds_to_recenter = 300, default_order_type = CustomOrderDefinition.CustomOneofCase.Limit, default_time_in_force = TimeInForce.Day, - animate_recenter = true + animate_recenter = true, + bid_break_line = new LadderMarketBreakLine { color = 0, show = true }, + ask_break_line = new LadderMarketBreakLine { color = 0, show = false }, + mid_break_line = new LadderMarketBreakLine { color = 0, show = false } }; } } @@ -122,8 +142,8 @@ namespace mbts.spark { public double row_height { get; set; } [ProtoMember(2)] public uint grid_line_color { get; set; } - [ProtoMember(3)] - public MarketBreakType market_break_type { get; set; } + //[ProtoMember(3)] + //public MarketBreakType market_break_type { get; set; } // Column settings [ProtoMember(4)] @@ -156,11 +176,17 @@ namespace mbts.spark { [ProtoMember(17)] public BadgeStyle badge_style { get; set; } + [ProtoMember(18)] + public LadderMarketBreakLine bid_break_line { get; set; } + [ProtoMember(19)] + public LadderMarketBreakLine ask_break_line { get; set; } + [ProtoMember(20)] + public LadderMarketBreakLine mid_break_line { get; set; } + public bool Equals(LadderSettings other) => other != null && other.row_height == row_height && other.grid_line_color == grid_line_color && - other.market_break_type == market_break_type && other.orders_column.safe_equals(orders_column) && other.bid_column.safe_equals(bid_column) && other.ask_column.safe_equals(ask_column) && @@ -173,14 +199,16 @@ namespace mbts.spark { other.default_time_in_force == default_time_in_force && other.seconds_to_recenter == size && other.animate_recenter == animate_recenter && - other.badge_style == badge_style; + other.badge_style == badge_style && + other.bid_break_line.safe_equals(bid_break_line) && + other.ask_break_line.safe_equals(ask_break_line) && + other.mid_break_line.safe_equals(mid_break_line); public override bool Equals(object obj) => Equals(obj as LadderSettings); public override int GetHashCode() => row_height.GetHashCode() + grid_line_color.GetHashCode() + - market_break_type.GetHashCode() + orders_column.GetHashCode() + bid_column.GetHashCode() + ask_column.GetHashCode() + @@ -193,6 +221,9 @@ namespace mbts.spark { default_order_type.GetHashCode() + default_time_in_force.GetHashCode() + seconds_to_recenter.GetHashCode() + - animate_recenter.GetHashCode(); + animate_recenter.GetHashCode() + + bid_break_line.GetHashCode() + + ask_break_line.GetHashCode() + + mid_break_line.GetHashCode(); } } \ No newline at end of file diff --git a/src/client/spark/view/Spark/Ladder/LadderSettingsVM.cs b/src/client/spark/view/Spark/Ladder/LadderSettingsVM.cs index 2f241461f..56b660b34 100644 --- a/src/client/spark/view/Spark/Ladder/LadderSettingsVM.cs +++ b/src/client/spark/view/Spark/Ladder/LadderSettingsVM.cs @@ -19,6 +19,10 @@ namespace mbts.spark { _price = new LadderColumnSettingsVM("Price"), _ask = new LadderColumnSettingsVM("Ask"), _last = new LadderColumnSettingsVM("Last"); + LadderMarketBreakLineVM + _bid_mkt_line = new LadderMarketBreakLineVM("Bid"), + _ask_mkt_line = new LadderMarketBreakLineVM("Ask"), + _mid_mkt_line = new LadderMarketBreakLineVM("Mid"); public LadderSettingsVM() => _badge_style = backing(nameof(badge_style)); @@ -38,6 +42,20 @@ namespace mbts.spark { } } + public LadderColumnSettingsVM orders_column => _orders; + public LadderColumnSettingsVM bid_column => _bid; + public LadderColumnSettingsVM price_column => _price; + public LadderColumnSettingsVM ask_column => _ask; + public LadderColumnSettingsVM last_column => _last; + + public IEnumerable mkt_break_items { + get { + yield return _bid_mkt_line; + yield return _ask_mkt_line; + yield return _mid_mkt_line; + } + } + public void load(LadderSettings settings) { _current = settings; badge_style = settings.badge_style; @@ -46,6 +64,9 @@ namespace mbts.spark { _ask.assign_from(_current.ask_column); _price.assign_from(_current.price_column); _last.assign_from(_current.last_column); + _bid_mkt_line.assign_from(_current.bid_break_line); + _ask_mkt_line.assign_from(_current.ask_break_line); + _mid_mkt_line.assign_from(_current.mid_break_line); } public LadderSettings get_result() { @@ -56,9 +77,12 @@ namespace mbts.spark { clone.price_column = _price.get_settings(); clone.ask_column = _ask.get_settings(); clone.last_column = _last.get_settings(); + clone.bid_break_line = _bid_mkt_line.get_settings(); + clone.ask_break_line = _ask_mkt_line.get_settings(); + clone.mid_break_line = _mid_mkt_line.get_settings(); return clone; } - + public class LadderColumnSettingsVM : ViewModelBase { readonly Property _font_size; readonly Property _foreground, _background; @@ -122,5 +146,33 @@ namespace mbts.spark { }; } } + + public class LadderMarketBreakLineVM : ViewModelBase { + readonly Property _color; + readonly Property _show; + + public LadderMarketBreakLineVM(string name) { + this.name = name; + palettes = new ObservableCollection(ColorPalette.all_presets().Select(p => new ColorPaletteVM(p))); + _color = backing(nameof(color), Colors.Black); + _show = backing(nameof(show), false); + } + + public string name { get; } + public Color color { get => _color.Value; set => _color.Value = value; } + public bool show { get => _show.Value; set => _show.Value = value; } + public ObservableCollection palettes { get; } + + public void assign_from(LadderMarketBreakLine settings) { + color = settings.color.rgb_color(); + show = settings.show; + } + + public LadderMarketBreakLine get_settings() => + new LadderMarketBreakLine { + color = new BTSColor(color).ToUint(), + show = show + }; + } } } \ No newline at end of file diff --git a/src/client/spark/view/Spark/Ladder/LadderSettingsView.xaml b/src/client/spark/view/Spark/Ladder/LadderSettingsView.xaml index 270759adc..f45b507fb 100644 --- a/src/client/spark/view/Spark/Ladder/LadderSettingsView.xaml +++ b/src/client/spark/view/Spark/Ladder/LadderSettingsView.xaml @@ -6,10 +6,12 @@ xmlns:sp="clr-namespace:mbts.spark" xmlns:u="clr-namespace:mbts.ui" xmlns:c="clr-namespace:mbts.ui.controls" + xmlns:usp="clr-namespace:mbts.ui.spark" TextElement.FontSize="{x:Static u:FontSizes.Small}" > - + + @@ -20,7 +22,7 @@ Order Badge Style - + @@ -99,5 +101,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/client/spark/view/Spark/Ladder/LaderRender.cs b/src/client/spark/view/Spark/Ladder/LaderRender.cs index 68a445c2b..e550528e1 100644 --- a/src/client/spark/view/Spark/Ladder/LaderRender.cs +++ b/src/client/spark/view/Spark/Ladder/LaderRender.cs @@ -74,7 +74,7 @@ namespace mbts.spark { public static void render_sizes( DrawingVisual dv, GlyphContext glyph_context, - int market_break_index, + int origin_index, double[] prices, NativePriceSize[] rungs, double row_height, @@ -85,10 +85,10 @@ namespace mbts.spark { using (var dc = dv.RenderOpen()) using (_draw_with_clip(dc, settings, row_height, prices.Length)) { dc.DrawRectangle(background, null, new Rect(0, 0, settings.width, prices.Length * row_height)); - if (!prices.within_range(market_break_index) || rungs.is_null_or_empty()) + if (!prices.within_range(origin_index) || rungs.is_null_or_empty()) return; var foreground = new SolidColorBrush(settings.foreground.rgb_color()); - int curr_index = market_break_index; + int curr_index = origin_index; double curr_price = prices[curr_index]; foreach (var nps in rungs) { if (nps.is_nan) break; @@ -114,9 +114,10 @@ namespace mbts.spark { } } - public static void render_mid(DrawingVisual dv, int midIndex, double row_height) { + public static void render_mkt_break(DrawingVisual dv, int index, double row_height, uint color) { using (var dc = dv.RenderOpen()) { - dc.DrawRectangle(Brushes.Black, null, new Rect(0, midIndex * row_height - 1, SystemParameters.FullPrimaryScreenWidth, 3)); + if (index >= 0) + dc.DrawRectangle(color.rgb_brush(), null, new Rect(0, index * row_height - 1, SystemParameters.FullPrimaryScreenWidth, 3)); } }