From 09679ff49451a5711e85be398d4685d2d73b3152 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 8 Nov 2019 10:38:10 -0600 Subject: [PATCH 1/6] adding enforce_max_clip and max_clip to proto --- .../spark/Modules/Trading/Ladder/LadderSettings.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs b/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs index c025e90ed..1a19037cc 100644 --- a/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs +++ b/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs @@ -249,6 +249,7 @@ namespace mbts.spark { const double _default_order_entry_panel_width = 110.0; const double _default_zoom_factor = 1.0; const bool _default_show_warn_on_cross = true; + const bool _default_enforce_max_clip = false; public static readonly IEqualityComparer profile_equality_comparer = EqualityComparer.Create(profile_equals); // this class is 100% mutable (there are literally 0 readonly members), @@ -282,6 +283,7 @@ namespace mbts.spark { use_defaults = true; favorite_algos = new LadderFavoriteAlgosSettings(null, 2, null); show_warn_on_cross = _default_show_warn_on_cross; + enforce_max_clip = _default_enforce_max_clip; } public static LadderSettings Default { @@ -347,6 +349,7 @@ namespace mbts.spark { zoom_factor = _default_zoom_factor, net_change = NetChangeTerms.None, mini_ob = new LadderMiniOrderBookSettings(bts.shell.orderbook.OrderBookStartupData.default_mini_grid.general), + max_clip = 0, }; rv.row_height = LadderRender.measure_row_height(rv); return rv; @@ -499,6 +502,12 @@ namespace mbts.spark { [ProtoMember(57)] public double left_panel_scroll_position { get; set; } + [ProtoMember(58), DefaultValue(_default_enforce_max_clip)] + public bool enforce_max_clip { get; set; } + + [ProtoMember(59)] + public uint max_clip { get; set; } + public void sanitize() => sanitize(this); @@ -600,7 +609,9 @@ namespace mbts.spark { a.favorite_algos == b.favorite_algos && a.net_change == b.net_change && a.show_warn_on_cross == b.show_warn_on_cross && - a.mini_ob == b.mini_ob; + a.mini_ob == b.mini_ob && + a.enforce_max_clip == b.enforce_max_clip && + a.max_clip == b.max_clip; public bool Equals(LadderSettings other) => profile_equals(this, other) && From 12d532a17ff29667f58dc16087586e1e3862cd97 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 8 Nov 2019 10:39:38 -0600 Subject: [PATCH 2/6] adding enforce_max_clip and max_clip to settings vm --- .../Modules/Trading/Ladder/VM/LadderSettingsVM.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs b/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs index 68fffdeb8..69154edee 100644 --- a/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs +++ b/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs @@ -29,7 +29,7 @@ using TextUtils = mbts.ui.utility.text.TextUtils; namespace mbts.spark { class LadderSettingsVM : DisposableViewModelBase, IWindowSettingsVM, IValueFactory, IObservable, ITemplateSelectorKey { readonly Property _badge_style; - readonly Property _alternate_order_size; + readonly Property _alternate_order_size, _max_clip; readonly DelegateProperty _row_height; readonly UserProperty _default_account; readonly UserProperty _default_algo; @@ -42,7 +42,7 @@ namespace mbts.spark { TimeInForce _default_time_in_force; LadderSettings.NetChangeTerms _price_format; double _order_entry_panel_width, _zoom_factor; - bool _auto_clear, _show_warn_on_cross; + bool _auto_clear, _show_warn_on_cross, _enforce_max_clip; LadderSettings _current; LadderColumnSettingsVM _orders = new OrdersColumnSettingsVM(), @@ -91,6 +91,7 @@ namespace mbts.spark { _alternate_order_size = backing(nameof(alternate_order_size)); _default_account = user_backing(nameof(default_account)); _default_algo = user_backing(nameof(default_algo)); + _max_clip = backing(nameof(max_clip)); // be sure to initialize backings before this measure_row_height call _row_height = backing(nameof(row_height), () => LadderRender.measure_row_height(get_result())); _orders.font_size_changed += on_font_size_changed; @@ -182,6 +183,8 @@ namespace mbts.spark { public double zoom_factor { get => _zoom_factor; set => Set(ref _zoom_factor, value); } // safety checks public bool show_warn_on_cross { get => _show_warn_on_cross; set => Set(ref _show_warn_on_cross, value); } + public bool enforce_max_clip { get => _enforce_max_clip; set => Set(ref _enforce_max_clip, value); } + public uint max_clip { get => _max_clip.Value; set => _max_clip.Value = value; } // favorites public FavoriteAlgosVM favorite_algos_vm { get; } @@ -356,6 +359,8 @@ namespace mbts.spark { price_format = settings.net_change; // safety checks show_warn_on_cross = settings.show_warn_on_cross; + enforce_max_clip = settings.enforce_max_clip; + max_clip = settings.max_clip; } } @@ -430,6 +435,8 @@ namespace mbts.spark { clone.net_change = price_format; // safety checks clone.show_warn_on_cross = show_warn_on_cross; + clone.enforce_max_clip = enforce_max_clip; + clone.max_clip = max_clip; return clone; } From b6b33f14ef3b3987fece92a452529c6fc4680f5a Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 8 Nov 2019 10:40:43 -0600 Subject: [PATCH 3/6] enforce max clip at order entry --- src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs b/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs index 174a14b69..28a0ec70a 100644 --- a/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs +++ b/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs @@ -397,6 +397,8 @@ namespace mbts.spark { public uint volume_column_width { get => _volume_column_width.Value; set => _volume_column_width.set(value); } public uint alternate_order_size_from_settings => current_settings.alternate_order_size; public bool show_warn_on_cross_from_settings => current_settings.show_warn_on_cross; + public bool enforce_max_clip_from_settings => current_settings.enforce_max_clip; + public uint max_clip_from_settings => current_settings.max_clip; internal LadderModel model => _model; internal IObservable settings { get; } @@ -470,6 +472,10 @@ namespace mbts.spark { size_calculator.flash_error(); } else { uint size = size_from_alternate ? current_settings.alternate_order_size : (uint)Math.Abs(size_calculator.value ?? 0); + // enforce max clip + if (enforce_max_clip_from_settings && size > max_clip_from_settings) { + size = max_clip_from_settings; + } return send_order_async(args.side.Value, size, args.price); } } From 55134bf172c558dc08bb32929aa405c4be9096ec Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 8 Nov 2019 10:42:23 -0600 Subject: [PATCH 4/6] check max clip for crossing market dialog as well --- .../Modules/Trading/Ladder/View/LadderGridHost.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs index b78519f62..ef5975766 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs @@ -350,6 +350,17 @@ namespace mbts.spark { } } else if (_vm != null) { uint size = e.ChangedButton == MouseButton.Right ? _vm.alternate_order_size_from_settings : _vm.size_calculator.value ?? 0; + + // does the size violate the local max clip + if (_vm.enforce_max_clip_from_settings && size > _vm.max_clip_from_settings) { + // note this size is only used for the cross market message, not the actual order command + size = _vm.max_clip_from_settings; + // only update the calculator value when it's a standard left-click order + if (e.ChangedButton == MouseButton.Left) { + _vm.size_calculator.value = _vm.max_clip_from_settings; + } + } + // if warning enabled && (buy above opposite inside market || ask below opposite inside market) // when 1-sided market, _get_top_price will return NaN, and so the price comparison is false // meaning show no warning == correct From 24f366491b375bdf3af50d0d684fa43b65c2c0e2 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Fri, 8 Nov 2019 10:44:03 -0600 Subject: [PATCH 5/6] update view with appropriate controls for enforce_max_clip and max_clip --- .../Ladder/View/LadderSettingsView.xaml | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml index 92ab62e4d..badf93008 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml @@ -178,6 +178,14 @@ + + @@ -991,21 +999,45 @@ + + + - + + + + + + + + + + + From 51fb0684695b083e1b1e42095eeff09cde727f5c Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 14 Nov 2019 15:51:40 -0600 Subject: [PATCH 6/6] adding manual test --- testing/manual/settings/Ladder_MaxClip.txt | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 testing/manual/settings/Ladder_MaxClip.txt diff --git a/testing/manual/settings/Ladder_MaxClip.txt b/testing/manual/settings/Ladder_MaxClip.txt new file mode 100644 index 000000000..f4757c100 --- /dev/null +++ b/testing/manual/settings/Ladder_MaxClip.txt @@ -0,0 +1,41 @@ +1. Verify you can place orders +Launch a Ladder +Place a 10 lot order away from the market and make sure the order is not rejected +Cancel the order + +2. Verify the Max Order Quantity limit works +Click on the Settings button +Click on the Safety Checks tab +Click on the checkbox next to Max Order Quantity and specify 5 + You should additionally observe that the text has gone from a disabled appearance to active + The ticker box is also now active +Hit apply +Back in the ladder, attempt to place another 10 lot order away from the market. You should observe the following: + You are now working a 5 lot order + The qty in the qty box additionally reads 5 +Cancel the 5 lot order + +3. Verify the Max Order Quantity when disabled allows you to place a 10 lot order +This is essentially the same as step 1, except now we're explicitly unchecking the checkbox, ergo... +Uncheck the Max Order Quantity chechbox and observe that: + The Max order quantity text is disabled + The ticker box is disabled +Click Apply +In the ladder, click the 5 button so that your qty box reads 10, which is a quantity greater than the disabled 5 + A 10 lot order should now be working +Cancel the 10 lot order. + +4. Right click / Alternate order qty respects the limit +Re-enable the Max Order Quantity (5 is still fine) +On the Order Quantities tab, specify 7 as your 'Single Click' Quantity +In the ladder, Right click to work an order attempting to use your single click quantity + You should be working a a 5 lot order now i.e. your max order quantity + Observe that the qty box did NOT update with your alternate order quantity + +5. Cross market alert communicates respects the limit +Back on the Safety Checks tab, make sure Warn on Market Cross is checked +Attempt to place a 10 lot bid order (higher than your max of 5) on the sell side of the market + You should observe the message respects your max order quantity and warns you about buying 5 + Feel free to click whichever button you desire on the warning dialog + +FIN