From 90526a8bfd40481d250a5d48e0953d008ed30e02 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 21 May 2019 14:18:58 -0500 Subject: [PATCH 01/50] SPARK-2464 - ladder cursor provides visual feedback when middle clicking over bid ask cols --- .../Trading/Ladder/View/LadderTactileAdorner.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs index ef8d80395..390c9b3c6 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs @@ -149,11 +149,24 @@ namespace mbts.spark { } void _host_PreviewMouseDown(object sender, MouseButtonEventArgs e) { + // If we middle click over bid or ask columns then change the mouse + // cursor to illustrate sending an order is not applicable + var pos = e.GetPosition(_host); + if (e.MiddleButton == MouseButtonState.Pressed && + (_host._column_for_point(pos).column_type == LadderGridHost.ColumnType.Bid || _host._column_for_point(pos).column_type == LadderGridHost.ColumnType.Ask)) { + _host.Cursor = Cursors.No; + } + _is_mouse_down = true; InvalidateVisual(); } void _host_MouseUp(object sender, MouseButtonEventArgs e) { + // This will reset the cursor appropriately if the middle mouse button + // has been pressed while over the bid or ask columns + var point = e.GetPosition(_host); + _set_current_row_and_column(point); + _is_mouse_down = false; _is_mouse_dragging = false; InvalidateVisual(); From 7e75a71898df2c4e4370ef5c13cfe0476e4795a8 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 28 May 2019 10:47:11 -0500 Subject: [PATCH 02/50] check root algo's can_expand to see if we should draw Cursor.No --- .../Modules/Trading/Ladder/View/LadderTactileAdorner.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs index 390c9b3c6..4316b3c4f 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs @@ -150,10 +150,13 @@ namespace mbts.spark { void _host_PreviewMouseDown(object sender, MouseButtonEventArgs e) { // If we middle click over bid or ask columns then change the mouse - // cursor to illustrate sending an order is not applicable + // cursor to illustrate sending an order is not applicable when the + // selected algo in the left pane's algo root has no additional properties var pos = e.GetPosition(_host); if (e.MiddleButton == MouseButtonState.Pressed && - (_host._column_for_point(pos).column_type == LadderGridHost.ColumnType.Bid || _host._column_for_point(pos).column_type == LadderGridHost.ColumnType.Ask)) { + (_host._column_for_point(pos).column_type == LadderGridHost.ColumnType.Bid || _host._column_for_point(pos).column_type == LadderGridHost.ColumnType.Ask) && + !(_host._vm.order_properties_vm?.selected_algo_definition?.algo_root?.can_expand ?? true) + ) { _host.Cursor = Cursors.No; } From 31b2ba91656bd8a87b797b5c42394738ed6fcc80 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 28 May 2019 14:38:27 -0500 Subject: [PATCH 03/50] PR suggestion - if statement readability --- .../Modules/Trading/Ladder/View/LadderTactileAdorner.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs index 4316b3c4f..68014b14b 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs @@ -153,10 +153,11 @@ namespace mbts.spark { // cursor to illustrate sending an order is not applicable when the // selected algo in the left pane's algo root has no additional properties var pos = e.GetPosition(_host); + var column_type = _host._column_for_point(pos).column_type; + var selected_algo_can_expand = _host._vm.order_properties_vm?.selected_algo_definition?.algo_root?.can_expand ?? true; if (e.MiddleButton == MouseButtonState.Pressed && - (_host._column_for_point(pos).column_type == LadderGridHost.ColumnType.Bid || _host._column_for_point(pos).column_type == LadderGridHost.ColumnType.Ask) && - !(_host._vm.order_properties_vm?.selected_algo_definition?.algo_root?.can_expand ?? true) - ) { + (column_type == LadderGridHost.ColumnType.Bid || column_type == LadderGridHost.ColumnType.Ask) && + !selected_algo_can_expand) { _host.Cursor = Cursors.No; } From e94759cd89aa6e2a384df53d600867bc7c574dc2 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Mon, 3 Jun 2019 15:47:54 -0500 Subject: [PATCH 04/50] Ladder Settings - hide net change group setting for synthetic ladders --- .../spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml | 4 +++- 1 file changed, 3 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 ca4691070..2e5401a0c 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml @@ -13,6 +13,7 @@ TextElement.FontSize="{x:Static u:FontSizes.Small}" > + 4 8 24 @@ -382,7 +383,8 @@ FontStyle="Italic" Foreground="{Binding can_choose_alternate_implied_format, Converter={StaticResource IsEnabledForegroundConverter}}" /> - + Date: Tue, 4 Jun 2019 10:22:10 -0500 Subject: [PATCH 05/50] PR nits from chat --- .../Trading/Ladder/View/LadderTactileAdorner.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs index 68014b14b..f8cbef51c 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderTactileAdorner.cs @@ -149,16 +149,21 @@ namespace mbts.spark { } void _host_PreviewMouseDown(object sender, MouseButtonEventArgs e) { - // If we middle click over bid or ask columns then change the mouse - // cursor to illustrate sending an order is not applicable when the - // selected algo in the left pane's algo root has no additional properties + // When middle click over bid or ask columns: + // Non-parameterizalbe order: change cursor to No indicating sending an order is not possible + // Parameterizable order: if qty is null/0, flash and No cursor var pos = e.GetPosition(_host); var column_type = _host._column_for_point(pos).column_type; var selected_algo_can_expand = _host._vm.order_properties_vm?.selected_algo_definition?.algo_root?.can_expand ?? true; if (e.MiddleButton == MouseButtonState.Pressed && - (column_type == LadderGridHost.ColumnType.Bid || column_type == LadderGridHost.ColumnType.Ask) && - !selected_algo_can_expand) { - _host.Cursor = Cursors.No; + (column_type == LadderGridHost.ColumnType.Bid || column_type == LadderGridHost.ColumnType.Ask)) { + if (!selected_algo_can_expand) { + _host.Cursor = Cursors.No; + } + if (selected_algo_can_expand && (_host._vm.size_calculator.value ?? 0) == 0) { + _host._vm.size_calculator.flash_error(); + _host.Cursor = Cursors.No; + } } _is_mouse_down = true; From f1880615b128fc0a401c08fd206ff674dfc09d0f Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 4 Jun 2019 14:08:46 -0500 Subject: [PATCH 06/50] SPARK-2480 - fixing a particular overload of the OrderSecurity constructor (root_* specific) --- src/client/spark/Orders/OrderSecurity.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/spark/Orders/OrderSecurity.cs b/src/client/spark/Orders/OrderSecurity.cs index 06ebce996..d53bada62 100644 --- a/src/client/spark/Orders/OrderSecurity.cs +++ b/src/client/spark/Orders/OrderSecurity.cs @@ -37,8 +37,8 @@ namespace bts.api.orderman { this.piq = piq; this.algo = algo; this.meta = meta; - root_algo = new AlgoData(order.Def.CustomDef); - root_meta = null; + root_algo = algo ?? new AlgoData(order.Def.CustomDef); + root_meta = meta; } public OrderSecurity(SecurityImmutable? sec, OrderRecordImmutable order, uint? piq, AlgoData? algo, AlgoDefinitionMetadata? meta, AlgoData? rootalgo = null, AlgoDefinitionMetadata? rootmeta = null) { this.security = sec; From 5722fcffc321b70f31929128494f1fe37fe23fea Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 4 Jun 2019 16:08:47 -0500 Subject: [PATCH 07/50] SPARK-2476 OB _get_legs KeyNotFoundException --- .../spark/Modules/Spreader/VM/SyntheticEditorVM.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs index 5eb7226c2..5fd3ddc83 100644 --- a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs +++ b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs @@ -322,12 +322,9 @@ namespace mbts.spark { } static IEnumerable _get_legs(Security synthetic, ExecutionStrategyImmutable strategy) { - try { - var results = synthetic.Synthetic.Legs - .Select(l => new LegSpreaderParamsTuple(l, strategy.LegParamsMap[l.Security.Id].Clone())).ToList(); - return results; - } catch (KeyNotFoundException) { - return Enumerable.Empty(); + foreach (var l in synthetic.Synthetic.Legs) { + if (strategy.LegParamsMap.TryGetValue(l.Security.Id, out var p)) + yield return new LegSpreaderParamsTuple(l, p); } } From 4544180c5ff58707846b0b972ab1c5e66ff57059 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 4 Jun 2019 18:54:43 -0500 Subject: [PATCH 08/50] move 'FillsStartupData' into its own file, change typename to 'FillsSettings' --- .../Market/MarketView/MarketViewWindow.cs | 5 +- .../Market/TimeAndSales/TimeAndSalesWindow.cs | 5 +- .../Modules/Spreader/VM/SyntheticEditorVM.cs | 9 +- .../spark/Modules/Trading/Fills/FillsVM.cs | 21 +-- .../Modules/Trading/Fills/FillsWindow.cs | 18 +- .../Trading/Fills/FillsWindowFactory.cs | 166 +----------------- .../Fills/Settings/FillsFilterStates.cs | 69 ++++++++ .../Trading/Fills/Settings/FillsSettings.cs | 109 ++++++++++++ .../Modules/Trading/OrderBook/OrderBookVM.cs | 5 +- .../Trading/OrderBook/OrderBookWindow.cs | 3 +- .../Settings/OrderBookFillsGridSettings.cs | 9 +- .../OrderBook/Settings/OrderBookSettings.cs | 5 +- .../Modules/Trading/TradingShellModule.cs | 3 +- src/client/spark/core/Bus/SparkCommands.cs | 3 +- src/client/spark/core/Bus/SparkTags.cs | 3 +- .../UserSettings/UserSettings.cs | 4 +- 16 files changed, 232 insertions(+), 205 deletions(-) create mode 100644 src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs create mode 100644 src/client/spark/Modules/Trading/Fills/Settings/FillsSettings.cs diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs index 0363f1db0..10d875227 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs @@ -1,6 +1,7 @@ using bts; using bts.api; using bts.shell; +using bts.shell.fills; using bts.spark; using bts.utils; using mbts.persist; @@ -117,8 +118,8 @@ namespace mbts.spark { // show fills var show_fills_cmd = new DelegateCommand(() => { var sc = _selected_security_criteria; - _bus.post(SparkTags.ShowFillsTag, new FillsWindowFactory.StartupData( - new FillsWindowFactory.FilterStates { + _bus.post(SparkTags.ShowFillsTag, new FillsSettings( + new FillsFilterStates { security = sc.is_defined() ? sc : _state.security_criteria })); }); diff --git a/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs b/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs index 0f2f472cb..b075d16ef 100644 --- a/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs +++ b/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs @@ -1,6 +1,7 @@ using bts; using bts.api; using bts.shell; +using bts.shell.fills; using bts.spark; using mbts.co2; using mbts.persist; @@ -92,8 +93,8 @@ namespace mbts.spark { _initialize(); bool always_true(T _) => true; - FillsWindowFactory.StartupData get_fills_startup_data(IReadOnlyList secs) => - new FillsWindowFactory.StartupData(new FillsWindowFactory.FilterStates { + FillsSettings get_fills_startup_data(IReadOnlyList secs) => + new FillsSettings(new FillsFilterStates { security = secs.Count > 0 ? new SecurityCriteria(secs) : _state.security_criteria }); void update_criteria(SecurityCriteria c) { diff --git a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs index 5eb7226c2..5fd3ddc83 100644 --- a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs +++ b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs @@ -322,12 +322,9 @@ namespace mbts.spark { } static IEnumerable _get_legs(Security synthetic, ExecutionStrategyImmutable strategy) { - try { - var results = synthetic.Synthetic.Legs - .Select(l => new LegSpreaderParamsTuple(l, strategy.LegParamsMap[l.Security.Id].Clone())).ToList(); - return results; - } catch (KeyNotFoundException) { - return Enumerable.Empty(); + foreach (var l in synthetic.Synthetic.Legs) { + if (strategy.LegParamsMap.TryGetValue(l.Security.Id, out var p)) + yield return new LegSpreaderParamsTuple(l, p); } } diff --git a/src/client/spark/Modules/Trading/Fills/FillsVM.cs b/src/client/spark/Modules/Trading/Fills/FillsVM.cs index ce4ed2b72..726c0b633 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsVM.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsVM.cs @@ -2,6 +2,7 @@ using bts.api.core; using bts.api.orderman; using bts.collections; +using bts.shell.fills; using bts.spark; using bts.utils; using mbts.collections; @@ -35,20 +36,20 @@ namespace mbts.spark { class FillsVM : DisposableViewModelBase, IHandleGridSorting { readonly OrdersModel _model; readonly DIYGridSortManager _sort_manager; - readonly IDIYGridFiltersManager _filters_manager; + readonly IDIYGridFiltersManager _filters_manager; readonly ObservableKeyedCollection _columns = new ObservableKeyedCollection(_col_key); List<(ColumnBase col, Columns key, ListSortDirection direction)> _active_comparers = new List<(ColumnBase col, Columns key, ListSortDirection direction)>(); IWindowSettingsManager _settings_manager; int _total_row_count; - public FillsVM(IBus bus, OrdersModel model, IObservable state_obs, IWindowSettingsManager settings_manager) + public FillsVM(IBus bus, OrdersModel model, IObservable state_obs, IWindowSettingsManager settings_manager) : this(bus, model, state_obs, _get_observable(bus, model, state_obs), settings_manager) { } - public FillsVM(IBus bus, OrdersModel model, IObservable state_obs, IObservable> fills_source, IWindowSettingsManager settings_manager) { + public FillsVM(IBus bus, OrdersModel model, IObservable state_obs, IObservable> fills_source, IWindowSettingsManager settings_manager) { _model = model; _settings_manager = settings_manager; /// Columns - var col_tups = new ObservableKeyedCollection, Columns>(c => c.key); + var col_tups = new ObservableKeyedCollection, Columns>(c => c.key); // security add_col(Columns.Security, DefaultColumnHeaders.Security, r => r.security.ToString(), DiscreteValuesFilterVM.Create( @@ -96,7 +97,7 @@ namespace mbts.spark { // row sort/filter managers _sort_manager = new DIYGridSortManager(col_tups.WrapSelector(t => (t.col, t.key)), Columns.FillKey); _filters_manager = DIYGridFiltersManager.create(col_tups); - var rows_manager = new DIYGridRowsManager(_filters_manager, _sort_manager, _get_column_comparer, FillsWindow.window_type_name); + var rows_manager = new DIYGridRowsManager(_filters_manager, _sort_manager, _get_column_comparer, FillsWindow.window_type_name); // grid settings grid_settings_manager = new SimpleGridSettingsManager(columns, new Dictionary { }, rows); // this will initialize the immutable properties that correspond to the col_settings_flags above (e.g. Bid/Ask font_color_override, etc.) @@ -125,7 +126,7 @@ namespace mbts.spark { // Note: settings_manager in turn notifies grid_settings_manager of this update _settings_manager.instance_settings = s.grid; } - var fs = s.filters ?? new FilterStates { + var fs = s.filters ?? new FillsFilterStates { fill_time = new TimeFilterTuple( TimeFilterMode.CMEOpen, TimeTextTuple.FromDateTime(DateTime.Today), @@ -144,7 +145,7 @@ namespace mbts.spark { Width = width }, filter); void add_col_expl(Columns col_key, ColumnBase col, IDataGridColumnPersistentFilter filter) => - col_tups.Add(col_key, DIYGridColumnData.create(col, filter, _get_column_comparer(col_key))); + col_tups.Add(col_key, DIYGridColumnData.create(col, filter, _get_column_comparer(col_key))); // discrete-values-filter factories IDataGridColumnPersistentFilter dv_filter(IReadOnlyCollection items, Func get_row_val) => DiscreteValuesFilterVM.Create(items, get_row_val); IDataGridColumnPersistentFilter dv_filter_rx(IObservable> items, Func get_row_val) => DiscreteValuesFilterVM.Create(items, get_row_val); @@ -175,17 +176,17 @@ namespace mbts.spark { static Columns _col_key(ColumnBase column) => ((IKeyedColumn)column).key; - public FilterStates get_filters() => + public FillsFilterStates get_filters() => _filters_manager.create(); - static IObservable> _get_observable(IBus bus, OrdersModel model, StartupData state) { + static IObservable> _get_observable(IBus bus, OrdersModel model, FillsSettings state) { if (!state.orders.is_null_or_empty()) { var orders_hash = new HashSet(state.orders); return model.on_fill_tuples.Filter(f => orders_hash.Contains(f.fill.OrderKey)); } else return model.on_fill_tuples; } - static IConnectableObservable> _get_observable(IBus bus, OrdersModel model, IObservable state) => + static IConnectableObservable> _get_observable(IBus bus, OrdersModel model, IObservable state) => state.SelectManyInSeries(s => _get_observable(bus, model, s)); static IComparer _get_column_comparer(Columns col) { diff --git a/src/client/spark/Modules/Trading/Fills/FillsWindow.cs b/src/client/spark/Modules/Trading/Fills/FillsWindow.cs index 32b1800b3..9c4e93dab 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsWindow.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsWindow.cs @@ -1,6 +1,7 @@ using bts; using bts.api; using bts.shell; +using bts.shell.fills; using bts.spark; using mbts.persist; using mbts.ui; @@ -13,21 +14,20 @@ using System.Collections.Generic; using System.Linq; using System.Reactive.Linq; using System.Windows; -using StartupData = bts.shell.FillsWindowFactory.StartupData; namespace mbts.spark { - class FillsWindow : SparkWindow, ISharedWindow { + class FillsWindow : SparkWindow, ISharedWindow { public const string window_type_name = "Fills"; readonly AllowOnce _init_guard = new AllowOnce("Fills"); readonly OrdersModel _orders_model; readonly IWindowSettingsManager _settings_manager; FillsVM _vm; FillsView _view; - StartupData _state; + FillsSettings _state; IReadOnlyList _commands; IDisposable _subscriptions; - public FillsWindow(FillsWindowFactory factory, IBus bus, OrdersModel orders_model, StartupData state, WindowSettingsManager settings_manager) + public FillsWindow(FillsWindowFactory factory, IBus bus, OrdersModel orders_model, FillsSettings state, WindowSettingsManager settings_manager) : base("Fills", bus, factory, SparkCommands.ShowFills().icon) { _orders_model = orders_model; _state = state; @@ -35,15 +35,15 @@ namespace mbts.spark { thread_id = config.Configuration.get().fills ? "Fills" : null; } - event Action _state_changed; + event Action _state_changed; public override string window_type => window_type_name; public override UIElement Content => _view; public override IEnumerable Commands => _commands; - public override StartupData SaveState => _state = new StartupData(_state.orders, _vm.get_sorting_criterion().ToList(), _vm.get_filters(), _vm.get_grid_save_state()); + public override FillsSettings SaveState => _state = new FillsSettings(_state.orders, _vm.get_sorting_criterion().ToList(), _vm.get_filters(), _vm.get_grid_save_state()); public override double MinWidth => - StartupData.DefaultGridSettings.columns.Sum(gcs => gcs.width) + FillsSettings.DefaultGridSettings.columns.Sum(gcs => gcs.width) + SPARK_MENU_COLLAPSED_WIDTH + LAUNCHER_BUTTON_BORDER_WIDTH + EXTRA_FOR_NO_HORIZONTAL_SCROLLBAR_WIDTH; @@ -53,7 +53,7 @@ namespace mbts.spark { public void thread_init() { _init_guard.check_access(); Log.notnull(_state); - var state_src = Observable.FromEvent, FillsWindowFactory.StartupData>(cb => _state_changed += cb, cb => _state_changed -= cb).StartWith(_state); + var state_src = Observable.FromEvent, FillsSettings>(cb => _state_changed += cb, cb => _state_changed -= cb).StartWith(_state); _vm = new FillsVM(_bus, _orders_model, state_src, _settings_manager); _view = new FillsView { DataContext = _vm }; @@ -79,7 +79,7 @@ namespace mbts.spark { }; _subscriptions = Disposable.Create(() => _state_changed?.Invoke( - _state = new StartupData(_state.orders, + _state = new FillsSettings(_state.orders, _vm.get_sorting_criterion().ToList(), _vm.get_filters(), _vm.grid_settings_manager.create() diff --git a/src/client/spark/Modules/Trading/Fills/FillsWindowFactory.cs b/src/client/spark/Modules/Trading/Fills/FillsWindowFactory.cs index ce49d6e87..bbd9ddf5e 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsWindowFactory.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsWindowFactory.cs @@ -1,5 +1,6 @@ using bts.api; using bts.api.orderman; +using bts.shell.fills; using mbts.persist; using mbts.spark; using mbts.spark.filters; @@ -16,7 +17,7 @@ using static mbts.ui.controls.DIYGrid; using static mbts.ui.spark.FillsView; namespace bts.shell { - class FillsWindowFactory : ShellWindowFactory { + class FillsWindowFactory : ShellWindowFactory { readonly IBus _bus; readonly OrdersModel _orders_model; readonly UserSettingsHub _settings_hub; @@ -52,13 +53,13 @@ namespace bts.shell { public static string col_id(Columns col) => col.ToString(); - public override Task load(StartupData state) => + public override Task load(FillsSettings state) => Task.FromResult(_create(state)); - public async void show(StartupData state) => + public async void show(FillsSettings state) => _bus.post(SparkTags.ShowWindow, await load(state)); - IShellWindow _create(StartupData state) { + IShellWindow _create(FillsSettings state) { GridSettingsHelper.normalize_sorting_criterion(state.sorting_criterion, _sort_member_to_id); var settings_manager = new WindowSettingsManager(_settings_hub, state.grid, @@ -66,162 +67,5 @@ namespace bts.shell { set: (us, gs) => us.with(provided_fills_gridsettings: gs)); return new FillsWindow(this, _bus, _orders_model, state, settings_manager); } - - [ProtoContract] - public class StartupData { - public const int Version = 1; - - [ProtoMember(1)] - public uint[] orders; - [ProtoMember(2)] - List _sorting_criteria; - [ProtoMember(3)] - public FilterStates filters; - [ProtoMember(4)] - public GridSettings grid; - - public StartupData() { } - public StartupData(uint[] orders) : this(orders, null, null) { } - public StartupData(FilterStates filters) : this(null, null, filters) { } - public StartupData(uint[] orders, List sorting_criteria, FilterStates filters, GridSettings grid = default) { - this.orders = orders; - this._sorting_criteria = sorting_criteria; - this.filters = filters; - this.grid = grid; - } - - public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criterion); - public static GridSettings MiniGridSettings => GridSettings.Default.with(DefaultColumns.Mini.all, DefaultColumns.Mini.sorting_criterion); - public IReadOnlyList sorting_criterion => _sorting_criteria ?? (_sorting_criteria = DefaultColumns.default_sorting_criterion.ToList()); - public static StartupData Default() => - new StartupData(null, null, new FilterStates(), null); - - static class DefaultColumns { - public static GridColumnSettings security => new GridColumnSettings(col_id(Columns.Security), DefaultColumnHeaders.Security, width: DefaultColumnWidths.Security); - public static GridColumnSettings fill_time => new GridColumnSettings(col_id(Columns.FillTime), DefaultColumnHeaders.FillTime, width: DefaultColumnWidths.Time); - public static GridColumnSettings user => new GridColumnSettings(col_id(Columns.User), DefaultColumnHeaders.User, width: DefaultColumnWidths.User); - public static GridColumnSettings account => new GridColumnSettings(col_id(Columns.Account), DefaultColumnHeaders.Account, width: DefaultColumnWidths.Account); - public static GridColumnSettings exchange => new GridColumnSettings(col_id(Columns.Exchange), DefaultColumnHeaders.Exchange, width: DefaultColumnWidths.Exchange); - public static GridColumnSettings time_in_force => new GridColumnSettings(col_id(Columns.TimeInForce), DefaultColumnHeaders.TimeInForce, width: DefaultColumnWidths.TimeInForce); - public static GridColumnSettings order_type => new GridColumnSettings(col_id(Columns.OrderType), DefaultColumnHeaders.OrderType, width: DefaultColumnWidths.OrderType); - public static GridColumnSettings side => new GridColumnSettings(col_id(Columns.Side), DefaultColumnHeaders.Side, width: DefaultColumnWidths.Side); - public static GridColumnSettings quantity => new GridColumnSettings(col_id(Columns.Size), DefaultColumnHeaders.Size, width: DefaultColumnWidths.Size, horizontal_alignment: System.Windows.HorizontalAlignment.Right); - public static GridColumnSettings price => new GridColumnSettings(col_id(Columns.Price), DefaultColumnHeaders.Price, width: DefaultColumnWidths.Price, horizontal_alignment: System.Windows.HorizontalAlignment.Right); - public static GridColumnSettings fill_kind => new GridColumnSettings(col_id(Columns.FillKind), DefaultColumnHeaders.FillKind, width: DefaultColumnWidths.FillKind); - public static GridColumnSettings fill_key => new GridColumnSettings(col_id(Columns.FillKey), DefaultColumnHeaders.FillKey, width: DefaultColumnWidths.FillKey); - public static GridColumnSettings order_key => new GridColumnSettings(col_id(Columns.OrderKey), DefaultColumnHeaders.OrderKey, width: DefaultColumnWidths.OrderKey); - public static GridColumnSettings security_key => new GridColumnSettings(col_id(Columns.SecurityKey), DefaultColumnHeaders.SecurityKey, is_visible: false, width: DefaultColumnWidths.SecurityKey); - public static IEnumerable default_sorting_criterion { - get { - yield return new SortingCriteria(fill_time.id, false); - } - } - - public static IEnumerable all { - get { - yield return security; - yield return fill_time; - yield return user; - yield return account; - yield return exchange; - yield return time_in_force; - yield return order_type; - yield return side; - yield return quantity; - yield return price; - yield return fill_kind; - yield return fill_key; - yield return order_key; - yield return security_key; - } - } - - public static class Mini { - static readonly IReadOnlyDictionary _mini_cols_data = - new Dictionary { - { Columns.Security, (true, null) }, - { Columns.FillTime, (true, ShortColumnWidths.Time) }, - { Columns.OrderType, (true, ShortColumnWidths.OrderType) }, - { Columns.Side, (true, ShortColumnWidths.Side) }, - { Columns.Size, (true, ShortColumnWidths.Size) }, - { Columns.Price, (true, ShortColumnWidths.Price) }, - }; - - public static IEnumerable all => DefaultColumns.all.Select(_convert); - public static IEnumerable sorting_criterion => default_sorting_criterion.Where(c => _try_get_data(c.col_name, out (bool is_visible, double? _) d) && d.is_visible); - - static bool _try_get_data(string id_str, out (bool is_visible, double? width_override) data) { - if (Enum.TryParse(id_str, out Columns k) && _mini_cols_data.TryGetValue(k, out data)) - return true; - data = default; - return false; - } - - static GridColumnSettings _convert(GridColumnSettings default_col) => - _try_get_data(default_col.id, out (bool is_visible, double? width_override) d) ? - default_col.with(is_visible: d.is_visible, width: d.width_override) : - default_col.with(is_visible: false); - } - } - } - - [ProtoContract] - public class FilterStates { - [ProtoMember(1)] - [DIYGridColumnID(nameof(Columns.FillTime))] - public TimeFilterTuple fill_time { get; set; } - - [ProtoMember(2)] - [DIYGridColumnID(nameof(Columns.TimeInForce))] - public TimeInForce[] time_in_force { get; set; } - - [ProtoMember(3)] - [DIYGridColumnID(nameof(Columns.OrderType))] - public CustomOrderDefinition.CustomOneofCase[] order_type { get; set; } - - [ProtoMember(4)] - [DIYGridColumnID(nameof(Columns.Account))] - public string[] account { get; set; } - - [ProtoMember(5)] - [DIYGridColumnID(nameof(Columns.User))] - public string[] user { get; set; } - - [ProtoMember(6)] - [DIYGridColumnID(nameof(Columns.Exchange))] - public Venue[] exchange { get; set; } - - [ProtoMember(7)] - [DIYGridColumnID(nameof(Columns.Security))] - public SecurityCriteria security { get; set; } - - [ProtoMember(8)] - [DIYGridColumnID(nameof(Columns.Side))] - public Side[] side { get; set; } - - [ProtoMember(9)] - [DIYGridColumnID(nameof(Columns.Price))] - public DoubleMinMaxState price { get; set; } - - [ProtoMember(10)] - [DIYGridColumnID(nameof(Columns.Size))] - public DoubleMinMaxState size { get; set; } - - [ProtoMember(11)] - [DIYGridColumnID(nameof(Columns.FillKey))] - public string fill_key { get; set; } - - [ProtoMember(12)] - [DIYGridColumnID(nameof(Columns.OrderKey))] - public string order_key { get; set; } - - [ProtoMember(13)] - [DIYGridColumnID(nameof(Columns.SecurityKey))] - public string security_key { get; set; } - - [ProtoMember(14)] - [DIYGridColumnID(nameof(Columns.FillKind))] - public Fill.Types.FillKind[] fill_kind { get; set; } - } } } \ No newline at end of file diff --git a/src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs b/src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs new file mode 100644 index 000000000..970666bae --- /dev/null +++ b/src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs @@ -0,0 +1,69 @@ +using bts.api; +using bts.api.orderman; +using mbts.spark; +using mbts.spark.filters; +using mbts.ui; +using mbts.ui.controls; +using ProtoBuf; +using Columns = mbts.ui.spark.FillsView.Columns; + +namespace bts.shell.fills { + [ProtoContract] + class FillsFilterStates { + [ProtoMember(1)] + [DIYGridColumnID(nameof(Columns.FillTime))] + public TimeFilterTuple fill_time { get; set; } + + [ProtoMember(2)] + [DIYGridColumnID(nameof(Columns.TimeInForce))] + public TimeInForce[] time_in_force { get; set; } + + [ProtoMember(3)] + [DIYGridColumnID(nameof(Columns.OrderType))] + public CustomOrderDefinition.CustomOneofCase[] order_type { get; set; } + + [ProtoMember(4)] + [DIYGridColumnID(nameof(Columns.Account))] + public string[] account { get; set; } + + [ProtoMember(5)] + [DIYGridColumnID(nameof(Columns.User))] + public string[] user { get; set; } + + [ProtoMember(6)] + [DIYGridColumnID(nameof(Columns.Exchange))] + public Venue[] exchange { get; set; } + + [ProtoMember(7)] + [DIYGridColumnID(nameof(Columns.Security))] + public SecurityCriteria security { get; set; } + + [ProtoMember(8)] + [DIYGridColumnID(nameof(Columns.Side))] + public Side[] side { get; set; } + + [ProtoMember(9)] + [DIYGridColumnID(nameof(Columns.Price))] + public DoubleMinMaxState price { get; set; } + + [ProtoMember(10)] + [DIYGridColumnID(nameof(Columns.Size))] + public DoubleMinMaxState size { get; set; } + + [ProtoMember(11)] + [DIYGridColumnID(nameof(Columns.FillKey))] + public string fill_key { get; set; } + + [ProtoMember(12)] + [DIYGridColumnID(nameof(Columns.OrderKey))] + public string order_key { get; set; } + + [ProtoMember(13)] + [DIYGridColumnID(nameof(Columns.SecurityKey))] + public string security_key { get; set; } + + [ProtoMember(14)] + [DIYGridColumnID(nameof(Columns.FillKind))] + public Fill.Types.FillKind[] fill_kind { get; set; } + } +} \ No newline at end of file diff --git a/src/client/spark/Modules/Trading/Fills/Settings/FillsSettings.cs b/src/client/spark/Modules/Trading/Fills/Settings/FillsSettings.cs new file mode 100644 index 000000000..18ba73b3c --- /dev/null +++ b/src/client/spark/Modules/Trading/Fills/Settings/FillsSettings.cs @@ -0,0 +1,109 @@ +using mbts.ui; +using mbts.ui.settings; +using ProtoBuf; +using System; +using System.Collections.Generic; +using System.Linq; +using static bts.shell.FillsWindowFactory; +using static mbts.ui.controls.DIYGrid; +using Columns = mbts.ui.spark.FillsView.Columns; + +namespace bts.shell.fills { + [ProtoContract] + class FillsSettings { + public const int Version = 1; + + [ProtoMember(1)] + public uint[] orders; + [ProtoMember(2)] + List _sorting_criteria; + [ProtoMember(3)] + public FillsFilterStates filters; + [ProtoMember(4)] + public GridSettings grid; + + public FillsSettings() { } + public FillsSettings(uint[] orders) : this(orders, null, null) { } + public FillsSettings(FillsFilterStates filters) : this(null, null, filters) { } + public FillsSettings(uint[] orders, List sorting_criteria, FillsFilterStates filters, GridSettings grid = default) { + this.orders = orders; + this._sorting_criteria = sorting_criteria; + this.filters = filters; + this.grid = grid; + } + + public static GridSettings DefaultGridSettings => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.default_sorting_criterion); + public static GridSettings MiniGridSettings => GridSettings.Default.with(DefaultColumns.Mini.all, DefaultColumns.Mini.sorting_criterion); + public IReadOnlyList sorting_criterion => _sorting_criteria ?? (_sorting_criteria = DefaultColumns.default_sorting_criterion.ToList()); + public static FillsSettings Default() => + new FillsSettings(null, null, new FillsFilterStates(), null); + + static class DefaultColumns { + public static GridColumnSettings security => new GridColumnSettings(col_id(Columns.Security), DefaultColumnHeaders.Security, width: DefaultColumnWidths.Security); + public static GridColumnSettings fill_time => new GridColumnSettings(col_id(Columns.FillTime), DefaultColumnHeaders.FillTime, width: DefaultColumnWidths.Time); + public static GridColumnSettings user => new GridColumnSettings(col_id(Columns.User), DefaultColumnHeaders.User, width: DefaultColumnWidths.User); + public static GridColumnSettings account => new GridColumnSettings(col_id(Columns.Account), DefaultColumnHeaders.Account, width: DefaultColumnWidths.Account); + public static GridColumnSettings exchange => new GridColumnSettings(col_id(Columns.Exchange), DefaultColumnHeaders.Exchange, width: DefaultColumnWidths.Exchange); + public static GridColumnSettings time_in_force => new GridColumnSettings(col_id(Columns.TimeInForce), DefaultColumnHeaders.TimeInForce, width: DefaultColumnWidths.TimeInForce); + public static GridColumnSettings order_type => new GridColumnSettings(col_id(Columns.OrderType), DefaultColumnHeaders.OrderType, width: DefaultColumnWidths.OrderType); + public static GridColumnSettings side => new GridColumnSettings(col_id(Columns.Side), DefaultColumnHeaders.Side, width: DefaultColumnWidths.Side); + public static GridColumnSettings quantity => new GridColumnSettings(col_id(Columns.Size), DefaultColumnHeaders.Size, width: DefaultColumnWidths.Size, horizontal_alignment: System.Windows.HorizontalAlignment.Right); + public static GridColumnSettings price => new GridColumnSettings(col_id(Columns.Price), DefaultColumnHeaders.Price, width: DefaultColumnWidths.Price, horizontal_alignment: System.Windows.HorizontalAlignment.Right); + public static GridColumnSettings fill_kind => new GridColumnSettings(col_id(Columns.FillKind), DefaultColumnHeaders.FillKind, width: DefaultColumnWidths.FillKind); + public static GridColumnSettings fill_key => new GridColumnSettings(col_id(Columns.FillKey), DefaultColumnHeaders.FillKey, width: DefaultColumnWidths.FillKey); + public static GridColumnSettings order_key => new GridColumnSettings(col_id(Columns.OrderKey), DefaultColumnHeaders.OrderKey, width: DefaultColumnWidths.OrderKey); + public static GridColumnSettings security_key => new GridColumnSettings(col_id(Columns.SecurityKey), DefaultColumnHeaders.SecurityKey, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static IEnumerable default_sorting_criterion { + get { + yield return new SortingCriteria(fill_time.id, false); + } + } + + public static IEnumerable all { + get { + yield return security; + yield return fill_time; + yield return user; + yield return account; + yield return exchange; + yield return time_in_force; + yield return order_type; + yield return side; + yield return quantity; + yield return price; + yield return fill_kind; + yield return fill_key; + yield return order_key; + yield return security_key; + } + } + + public static class Mini { + static readonly IReadOnlyDictionary _mini_cols_data = + new Dictionary { + { Columns.Security, (true, null) }, + { Columns.FillTime, (true, ShortColumnWidths.Time) }, + { Columns.OrderType, (true, ShortColumnWidths.OrderType) }, + { Columns.Side, (true, ShortColumnWidths.Side) }, + { Columns.Size, (true, ShortColumnWidths.Size) }, + { Columns.Price, (true, ShortColumnWidths.Price) }, + }; + + public static IEnumerable all => DefaultColumns.all.Select(_convert); + public static IEnumerable sorting_criterion => default_sorting_criterion.Where(c => _try_get_data(c.col_name, out (bool is_visible, double? _) d) && d.is_visible); + + static bool _try_get_data(string id_str, out (bool is_visible, double? width_override) data) { + if (Enum.TryParse(id_str, out Columns k) && _mini_cols_data.TryGetValue(k, out data)) + return true; + data = default; + return false; + } + + static GridColumnSettings _convert(GridColumnSettings default_col) => + _try_get_data(default_col.id, out (bool is_visible, double? width_override) d) ? + default_col.with(is_visible: d.is_visible, width: d.width_override) : + default_col.with(is_visible: false); + } + } + } +} \ No newline at end of file diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs index cff54d5c4..e92d0d929 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs @@ -3,12 +3,11 @@ using bts.api; using bts.api.core; using bts.api.orderman; using bts.collections; -using bts.md; using bts.shell; +using bts.shell.fills; using bts.shell.orderbook; using bts.spark; using bts.utils; -using mbts.collections; using mbts.persist; using mbts.spark.utilities; using mbts.ui; @@ -45,7 +44,7 @@ namespace mbts.spark { readonly OperableHierarchicalCollection _row_collection; readonly OrderBookColumnCollection _columns; readonly IWindowSettingsManager _settings_manager; - readonly IWindowSettingsManager _fills_settings_manager = new WindowSettingsManager.DisconnectedImpl(FillsWindowFactory.StartupData.MiniGridSettings, FillsWindowFactory.StartupData.MiniGridSettings); + readonly IWindowSettingsManager _fills_settings_manager = new WindowSettingsManager.DisconnectedImpl(FillsSettings.MiniGridSettings, FillsSettings.MiniGridSettings); readonly SelectedOrderParamsMon _selected_params_mon; readonly RightPanelModel _right_panel = new RightPanelModel(); OrderBookFillsGridSettings _cached_fills_settings = OrderBookStartupData.DefaultFillsGrid; diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs index 876d96079..a13669bda 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs @@ -1,6 +1,7 @@ using bts.api; using bts.api.orderman; using bts.shell; +using bts.shell.fills; using bts.shell.orderbook; using bts.spark; using bts.view; @@ -68,7 +69,7 @@ namespace mbts.spark { _vm.load_from(_state); _view = new OrderBookView(_vm); - var show_fills_command = SparkCommands.ShowFills(SparkCommands.KeyGestures.ShowFills).complete(() => new FillsWindowFactory.StartupData(_vm.selected_orders.Select(r => r.Key).ToArray())); + var show_fills_command = SparkCommands.ShowFills(SparkCommands.KeyGestures.ShowFills).complete(() => new FillsSettings(_vm.selected_orders.Select(r => r.Key).ToArray())); var toggle_show_right_panel_command = new SparkCommandCommand( get_toggle_show_right_panel_cmd_title(), diff --git a/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookFillsGridSettings.cs b/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookFillsGridSettings.cs index 9c8489afa..92a1528eb 100644 --- a/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookFillsGridSettings.cs +++ b/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookFillsGridSettings.cs @@ -1,4 +1,5 @@ -using mbts.ui; +using bts.shell.fills; +using mbts.ui; using ProtoBuf; using System.Collections.Generic; using GridSettings = mbts.ui.settings.GridSettings; @@ -9,11 +10,11 @@ namespace bts.shell.orderbook { [ProtoMember(1)] public GridSettings general { get; set; } [ProtoMember(2)] - public FillsWindowFactory.FilterStates filters { get; set; } + public FillsFilterStates filters { get; set; } [ProtoMember(3)] public List sorting_criterion { get; set; } - public FillsWindowFactory.StartupData to_startup_data() => - new FillsWindowFactory.StartupData(null, sorting_criterion, filters, general); + public FillsSettings to_startup_data() => + new FillsSettings(null, sorting_criterion, filters, general); } } \ No newline at end of file diff --git a/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookSettings.cs b/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookSettings.cs index 5c5caa779..236de5dfc 100644 --- a/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookSettings.cs +++ b/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookSettings.cs @@ -1,4 +1,5 @@ using bts.api.orderman; +using bts.shell.fills; using mbts; using mbts.ui; using mbts.ui.controls; @@ -127,11 +128,11 @@ namespace bts.shell.orderbook { public static OrderBookFillsGridSettings DefaultFillsGrid { get { - var default_fills = FillsWindowFactory.StartupData.Default(); + var default_fills = FillsSettings.Default(); var rv = new OrderBookFillsGridSettings { sorting_criterion = default_fills.sorting_criterion.ToList(), filters = default_fills.filters, - general = FillsWindowFactory.StartupData.MiniGridSettings + general = FillsSettings.MiniGridSettings }; return rv; } diff --git a/src/client/spark/Modules/Trading/TradingShellModule.cs b/src/client/spark/Modules/Trading/TradingShellModule.cs index 61234ddde..8188f0b23 100644 --- a/src/client/spark/Modules/Trading/TradingShellModule.cs +++ b/src/client/spark/Modules/Trading/TradingShellModule.cs @@ -1,4 +1,5 @@ using bts.api; +using bts.shell.fills; using bts.shell.manual_fills; using bts.spark; using mbts.persist; @@ -48,7 +49,7 @@ namespace bts.shell { public IEnumerable actions => new [] { SparkCommands.ShowOrders.complete(() => bts.shell.orderbook.OrderBookStartupData.Default), - SparkCommands.ShowFills(null).complete(() => new FillsWindowFactory.StartupData()), + SparkCommands.ShowFills(null).complete(() => new FillsSettings()), SparkCommands.ShowPAndL.complete(() => new PAndLWindowFactory.PAndLStartupData()), SparkCommands.PickLadder, SparkCommands.PickOrderTicket, diff --git a/src/client/spark/core/Bus/SparkCommands.cs b/src/client/spark/core/Bus/SparkCommands.cs index 2dce59fc9..726eff24a 100644 --- a/src/client/spark/core/Bus/SparkCommands.cs +++ b/src/client/spark/core/Bus/SparkCommands.cs @@ -1,6 +1,7 @@ using bts.api; using bts.api.orderman; using bts.shell; +using bts.shell.fills; using bts.shell.manual_fills; using mbts; using mbts.spark; @@ -27,7 +28,7 @@ namespace bts.spark { SparkCommand.create("Order Book", Icons.Book, SparkTags.ShowOrderBookTag); // Fills - public static PartialCommand ShowFills(KeyGesture key_gesture = null) => + public static PartialCommand ShowFills(KeyGesture key_gesture = null) => SparkCommand.create("Fills", Icons.Payment, SparkTags.ShowFillsTag, key_gesture); public static PartialCommand ShowManualFills(KeyGesture key_gesture = null) => diff --git a/src/client/spark/core/Bus/SparkTags.cs b/src/client/spark/core/Bus/SparkTags.cs index c1c683f1c..eef9c6d4e 100644 --- a/src/client/spark/core/Bus/SparkTags.cs +++ b/src/client/spark/core/Bus/SparkTags.cs @@ -1,6 +1,7 @@ using bts.api; using bts.api.orderman; using bts.shell; +using bts.shell.fills; using bts.shell.manual_fills; using bts.spark; using mbts.ui; @@ -52,7 +53,7 @@ namespace mbts.spark #endregion #region Spark Window - public static ITag ShowFillsTag { get; } = new SparkTag(nameof(ShowFillsTag)); + public static ITag ShowFillsTag { get; } = new SparkTag(nameof(ShowFillsTag)); public static ITag ShowManualFillsTag { get; } = new SparkTag(nameof(ShowManualFillsTag)); // TODO: maybe get rid of the singlular ShowLadderTag, and just use the plural ShowLaddersTag. // The owners of the various SparkWindows may remove dependencies on the former at their leasure. diff --git a/src/client/spark/core/ShellInterface/UserSettings/UserSettings.cs b/src/client/spark/core/ShellInterface/UserSettings/UserSettings.cs index 869298646..61068c253 100644 --- a/src/client/spark/core/ShellInterface/UserSettings/UserSettings.cs +++ b/src/client/spark/core/ShellInterface/UserSettings/UserSettings.cs @@ -17,7 +17,7 @@ namespace mbts.spark { _ladder = LadderSettings.Default, _notification = NotificationSettings.Default, _market_view_grid = bts.shell.MarketViewWindowFactory.StartupData.DefaultGridSettings, - _fills_grid = bts.shell.FillsWindowFactory.StartupData.DefaultGridSettings, + _fills_grid = bts.shell.fills.FillsSettings.DefaultGridSettings, _time_and_sales_grid = bts.shell.TimeAndSalesWindowFactory.StartupData.DefaultGridSettings, _synthetic_management_grid = bts.shell.SyntheticManagementWindowFactory.StartupData.DefaultGridSettings, _order_book_grid = bts.shell.orderbook.OrderBookStartupData.DefaultGrid @@ -48,7 +48,7 @@ namespace mbts.spark { public NotificationSettings notification => _notification ?? (_notification = NotificationSettings.Default); public GridSettings market_view_grid => _market_view_grid ?? (_market_view_grid = bts.shell.MarketViewWindowFactory.StartupData.DefaultGridSettings); public GridSettings time_and_sales_grid => _time_and_sales_grid ?? (_time_and_sales_grid = GridSettings.Default.with(bts.shell.TimeAndSalesWindowFactory.StartupData.DefaultColumns.all)); - public GridSettings fills_grid => _fills_grid ?? (_fills_grid = bts.shell.FillsWindowFactory.StartupData.DefaultGridSettings); + public GridSettings fills_grid => _fills_grid ?? (_fills_grid = bts.shell.fills.FillsSettings.DefaultGridSettings); public GridSettings synthetic_management_grid => _synthetic_management_grid ?? (_synthetic_management_grid = bts.shell.SyntheticManagementWindowFactory.StartupData.DefaultGridSettings); public GridSettings pnl_grid => _pnl_grid ?? (_pnl_grid = bts.shell.PAndLWindowFactory.PAndLStartupData.DefaultGridSettings); public bts.shell.orderbook.OrderBookGridSettings order_book_grid => _order_book_grid ?? (_order_book_grid = bts.shell.orderbook.OrderBookStartupData.Default.grid_settings_wrapper()); From 433b1abecd2b8b1aaaf3abab0a9915ed764ea674 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 4 Jun 2019 18:55:41 -0500 Subject: [PATCH 09/50] abstract out OrderBookFilterStates.build_predicate method for generic use --- .../Settings/OrderBookFilterStates.cs | 102 +++++------------- .../DIYGrid/Columns/ColumnPredicateBuilder.cs | 74 +++++++++++++ 2 files changed, 99 insertions(+), 77 deletions(-) create mode 100644 src/client/spark/view/Controls/DIYGrid/Columns/ColumnPredicateBuilder.cs diff --git a/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookFilterStates.cs b/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookFilterStates.cs index 7f2a070c2..1124b94d5 100644 --- a/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookFilterStates.cs +++ b/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookFilterStates.cs @@ -7,8 +7,6 @@ using mbts.spark.filters; using mbts.ui; using ProtoBuf; using System; -using System.Collections.Generic; -using System.Linq; namespace bts.shell.orderbook { [ProtoContract] @@ -121,86 +119,36 @@ namespace bts.shell.orderbook { static class FilterStatesExtensions { public static Func build_predicate(this FilterStates fs) { - var predicates = new List>(); + var pb = new ColumnPredicateBuilder(); // security - if (fs.security_criteria?.is_defined() ?? false) - predicates.Add(o => o.security.HasValue && ContractPickerModel.security_in_criteria(fs.security_criteria, o.security.Value)); + pb.add_security_criteria(fs.security_criteria, o => o.security); // regex - add_regex(fs.order_key_regex, o => o.order.Key.ToString()); - add_regex(fs.exchange_message_regex, o => o.order.State.LastMsg); - add_regex(fs.attached_target_order_key_regex, o => o.order.attached_target_order_key().ToString()); - add_regex(fs.parent_key_regex, o => o.order.ParentKey.ToString()); + pb.add_regex(fs.order_key_regex, o => o.order.Key.ToString()); + pb.add_regex(fs.exchange_message_regex, o => o.order.State.LastMsg); + pb.add_regex(fs.attached_target_order_key_regex, o => o.order.attached_target_order_key().ToString()); + pb.add_regex(fs.parent_key_regex, o => o.order.ParentKey.ToString()); // time - add_time_filter(fs.time_created, o => o.order.created()); - add_time_filter(fs.last_change, o => o.order.last_change()); + pb.add_time_filter(fs.time_created, o => o.order.created()); + pb.add_time_filter(fs.last_change, o => o.order.last_change()); // discrete values - add_discrete_values(fs.users, o => o.order.user()); - add_discrete_values(fs.accounts, o => o.order.account()); - add_discrete_values(fs.exchanges, o => o.security?.Exchange ?? Venue.Unset); - add_discrete_values(fs.tifs, o => o.order.time_in_force()); - add_discrete_values(fs.order_types, o => AlgoID.from_order_def(o.order.Def)); - add_discrete_values(fs.root_algo_types, o => AlgoID.from_algo_key(o.root_algo.key)); - add_discrete_values(fs.order_sub_types, o => o.order.sub_type()); - add_discrete_values(fs.sides, o => o.order.side()); - add_discrete_values(fs.statuses, o => o.order.status()); - add_discrete_values(fs.symbols, o => o.security?.Symbol); + pb.add_discrete_values(fs.users, o => o.order.user()); + pb.add_discrete_values(fs.accounts, o => o.order.account()); + pb.add_discrete_values(fs.exchanges, o => o.security?.Exchange ?? Venue.Unset); + pb.add_discrete_values(fs.tifs, o => o.order.time_in_force()); + pb.add_discrete_values(fs.order_types, o => AlgoID.from_order_def(o.order.Def)); + pb.add_discrete_values(fs.root_algo_types, o => AlgoID.from_algo_key(o.root_algo.key)); + pb.add_discrete_values(fs.order_sub_types, o => o.order.sub_type()); + pb.add_discrete_values(fs.sides, o => o.order.side()); + pb.add_discrete_values(fs.statuses, o => o.order.status()); + pb.add_discrete_values(fs.symbols, o => o.security?.Symbol); // numeric - add_numeric(fs.qty, o => o.order.quantity()); - add_numeric(fs.price, o => o.order.price()); - add_numeric(fs.qty_filled, o => o.order.filled()); - add_numeric(fs.avg_price, o => o.order.avg_price()); - add_numeric(fs.last_price, o => o.order.last_price()); - add_numeric(fs.piq, o => o.piq ?? uint.MaxValue); - return predicates.Count == 0 ? null : new Func(o => predicates.All(p => p(o))); - // local methods (impl) - void add_regex(string str, Func selector) { - var regex = RegexFilterUtils.build_regex(str); - if (regex == null) - return; - predicates.Add(impl); - bool impl(OrderSecurity o) => regex.IsMatch(selector(o) ?? string.Empty); - } - void add_time_filter(TimeFilterTuple t, Func selector) { - if (!t.is_active) - return; - var dt_pred = TimeFilterUtils.build_predicate(t); - predicates.Add(impl); - bool impl(OrderSecurity o) => dt_pred(selector(o)); - } - void add_discrete_values(T[] values, Func selector) { - if (values.is_null_or_empty()) - return; - if (values.Length < 16) { - predicates.Add(impl); - bool impl(OrderSecurity o) => values.Contains(selector(o)); - } else { - var set = new HashSet(values); - predicates.Add(impl); - bool impl(OrderSecurity o) => set.Contains(selector(o)); - } - } - void add_numeric(IMinMaxState value, Func selector) where T : struct, IComparable { - if (value == null) - return; - if (value.minimum.active) { - var min = value.minimum.value.Value; - if (value.maximum.active) { - var max = value.maximum.value.Value; - predicates.Add(impl); - bool impl(OrderSecurity o) { - var v = selector(o); - return min.CompareTo(v) <= 0 && max.CompareTo(v) >= 0; - } - } else { - predicates.Add(impl); - bool impl(OrderSecurity o) => min.CompareTo(selector(o)) <= 0; - } - } else if (value.maximum.active) { - var max = value.maximum.value.Value; - predicates.Add(impl); - bool impl(OrderSecurity o) => max.CompareTo(selector(o)) >= 0; - } - } + pb.add_numeric(fs.qty, o => o.order.quantity()); + pb.add_numeric(fs.price, o => o.order.price()); + pb.add_numeric(fs.qty_filled, o => o.order.filled()); + pb.add_numeric(fs.avg_price, o => o.order.avg_price()); + pb.add_numeric(fs.last_price, o => o.order.last_price()); + pb.add_numeric(fs.piq, o => o.piq ?? uint.MaxValue); + return pb.to_predicate(); } } } diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnPredicateBuilder.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnPredicateBuilder.cs new file mode 100644 index 000000000..9e232df74 --- /dev/null +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnPredicateBuilder.cs @@ -0,0 +1,74 @@ +using bts.api; +using mbts.ui; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace mbts.spark.filters { + class ColumnPredicateBuilder { + readonly List> _predicates = new List>(); + + public void add_discrete_values(T[] values, Func selector) { + if (values.is_null_or_empty()) + return; + if (values.Length < 16) { + _predicates.Add(impl); + bool impl(TRow o) => values.Contains(selector(o)); + } else { + var set = new HashSet(values); + _predicates.Add(impl); + bool impl(TRow o) => set.Contains(selector(o)); + } + } + + public void add_numeric(IMinMaxState value, Func selector) where T : struct, IComparable { + if (value == null) + return; + if (value.minimum.active) { + var min = value.minimum.value.Value; + if (value.maximum.active) { + var max = value.maximum.value.Value; + _predicates.Add(impl); + bool impl(TRow o) { + var v = selector(o); + return min.CompareTo(v) <= 0 && max.CompareTo(v) >= 0; + } + } else { + _predicates.Add(impl); + bool impl(TRow o) => min.CompareTo(selector(o)) <= 0; + } + } else if (value.maximum.active) { + var max = value.maximum.value.Value; + _predicates.Add(impl); + bool impl(TRow o) => max.CompareTo(selector(o)) >= 0; + } + } + + public void add_regex(string str, Func selector) { + var regex = RegexFilterUtils.build_regex(str); + if (regex == null) + return; + _predicates.Add(impl); + bool impl(TRow o) => regex.IsMatch(selector(o) ?? string.Empty); + } + + public void add_security_criteria(SecurityCriteria security_criteria, Func selector) { + if (security_criteria != null && security_criteria.is_defined()) + _predicates.Add(r => { + var sec = selector(r); + return sec.HasValue && ContractPickerModel.security_in_criteria(security_criteria, sec.Value); + }); + } + + public void add_time_filter(TimeFilterTuple t, Func selector) { + if (!t.is_active) + return; + var dt_pred = TimeFilterUtils.build_predicate(t); + _predicates.Add(impl); + bool impl(TRow o) => dt_pred(selector(o)); + } + + public Func to_predicate() => + _predicates.Count == 0 ? null : new Func(o => _predicates.All(p => p(o))); + } +} \ No newline at end of file From 6d3d4e1f5653d2171afd0774f75c748f6b2cef5d Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 4 Jun 2019 18:57:36 -0500 Subject: [PATCH 10/50] SPARK-2481 Filtering in fills window is badly broken --- .../spark/Modules/Trading/Fills/FillsVM.cs | 2 +- .../Fills/Settings/FillsFilterStates.cs | 162 ++++++++++-------- src/client/spark/Orders/FillTuple.cs | 20 +++ .../DIYGrid/Utils/DIYGridRowsManager.cs | 13 +- 4 files changed, 124 insertions(+), 73 deletions(-) diff --git a/src/client/spark/Modules/Trading/Fills/FillsVM.cs b/src/client/spark/Modules/Trading/Fills/FillsVM.cs index 726c0b633..32383f2f1 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsVM.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsVM.cs @@ -97,7 +97,7 @@ namespace mbts.spark { // row sort/filter managers _sort_manager = new DIYGridSortManager(col_tups.WrapSelector(t => (t.col, t.key)), Columns.FillKey); _filters_manager = DIYGridFiltersManager.create(col_tups); - var rows_manager = new DIYGridRowsManager(_filters_manager, _sort_manager, _get_column_comparer, FillsWindow.window_type_name); + var rows_manager = new DIYGridRowsManager(_filters_manager, _sort_manager, _get_column_comparer, FillsWindow.window_type_name, fs => fs.build_predicate()); // grid settings grid_settings_manager = new SimpleGridSettingsManager(columns, new Dictionary { }, rows); // this will initialize the immutable properties that correspond to the col_settings_flags above (e.g. Bid/Ask font_color_override, etc.) diff --git a/src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs b/src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs index 970666bae..3c59147c6 100644 --- a/src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs +++ b/src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs @@ -1,69 +1,95 @@ -using bts.api; -using bts.api.orderman; -using mbts.spark; -using mbts.spark.filters; -using mbts.ui; -using mbts.ui.controls; -using ProtoBuf; -using Columns = mbts.ui.spark.FillsView.Columns; - -namespace bts.shell.fills { - [ProtoContract] - class FillsFilterStates { - [ProtoMember(1)] - [DIYGridColumnID(nameof(Columns.FillTime))] - public TimeFilterTuple fill_time { get; set; } - - [ProtoMember(2)] - [DIYGridColumnID(nameof(Columns.TimeInForce))] - public TimeInForce[] time_in_force { get; set; } - - [ProtoMember(3)] - [DIYGridColumnID(nameof(Columns.OrderType))] - public CustomOrderDefinition.CustomOneofCase[] order_type { get; set; } - - [ProtoMember(4)] - [DIYGridColumnID(nameof(Columns.Account))] - public string[] account { get; set; } - - [ProtoMember(5)] - [DIYGridColumnID(nameof(Columns.User))] - public string[] user { get; set; } - - [ProtoMember(6)] - [DIYGridColumnID(nameof(Columns.Exchange))] - public Venue[] exchange { get; set; } - - [ProtoMember(7)] - [DIYGridColumnID(nameof(Columns.Security))] - public SecurityCriteria security { get; set; } - - [ProtoMember(8)] - [DIYGridColumnID(nameof(Columns.Side))] - public Side[] side { get; set; } - - [ProtoMember(9)] - [DIYGridColumnID(nameof(Columns.Price))] - public DoubleMinMaxState price { get; set; } - - [ProtoMember(10)] - [DIYGridColumnID(nameof(Columns.Size))] - public DoubleMinMaxState size { get; set; } - - [ProtoMember(11)] - [DIYGridColumnID(nameof(Columns.FillKey))] - public string fill_key { get; set; } - - [ProtoMember(12)] - [DIYGridColumnID(nameof(Columns.OrderKey))] - public string order_key { get; set; } - - [ProtoMember(13)] - [DIYGridColumnID(nameof(Columns.SecurityKey))] - public string security_key { get; set; } - - [ProtoMember(14)] - [DIYGridColumnID(nameof(Columns.FillKind))] - public Fill.Types.FillKind[] fill_kind { get; set; } - } +using bts.api; +using bts.api.orderman; +using mbts.spark; +using mbts.spark.filters; +using mbts.ui; +using mbts.ui.controls; +using ProtoBuf; +using System; +using Columns = mbts.ui.spark.FillsView.Columns; + +namespace bts.shell.fills { + [ProtoContract] + class FillsFilterStates { + [ProtoMember(1)] + [DIYGridColumnID(nameof(Columns.FillTime))] + public TimeFilterTuple fill_time { get; set; } + + [ProtoMember(2)] + [DIYGridColumnID(nameof(Columns.TimeInForce))] + public TimeInForce[] time_in_force { get; set; } + + [ProtoMember(3)] + [DIYGridColumnID(nameof(Columns.OrderType))] + public CustomOrderDefinition.CustomOneofCase[] order_type { get; set; } + + [ProtoMember(4)] + [DIYGridColumnID(nameof(Columns.Account))] + public string[] account { get; set; } + + [ProtoMember(5)] + [DIYGridColumnID(nameof(Columns.User))] + public string[] user { get; set; } + + [ProtoMember(6)] + [DIYGridColumnID(nameof(Columns.Exchange))] + public Venue[] exchange { get; set; } + + [ProtoMember(7)] + [DIYGridColumnID(nameof(Columns.Security))] + public SecurityCriteria security { get; set; } + + [ProtoMember(8)] + [DIYGridColumnID(nameof(Columns.Side))] + public Side[] side { get; set; } + + [ProtoMember(9)] + [DIYGridColumnID(nameof(Columns.Price))] + public DoubleMinMaxState price { get; set; } + + [ProtoMember(10)] + [DIYGridColumnID(nameof(Columns.Size))] + public DoubleMinMaxState size { get; set; } + + [ProtoMember(11)] + [DIYGridColumnID(nameof(Columns.FillKey))] + public string fill_key { get; set; } + + [ProtoMember(12)] + [DIYGridColumnID(nameof(Columns.OrderKey))] + public string order_key { get; set; } + + [ProtoMember(13)] + [DIYGridColumnID(nameof(Columns.SecurityKey))] + public string security_key { get; set; } + + [ProtoMember(14)] + [DIYGridColumnID(nameof(Columns.FillKind))] + public Fill.Types.FillKind[] fill_kind { get; set; } + } + + static class FillsFilterStatesExtensions { + public static Func build_predicate(this FillsFilterStates fs) { + var pb = new ColumnPredicateBuilder(); + // fill time + pb.add_time_filter(fs.fill_time, ft => ft.fill_time()); + // security + pb.add_security_criteria(fs.security, ft => ft.security); + // regex + pb.add_regex(fs.fill_key, ft => ft.fill.FillKey); + pb.add_regex(fs.order_key, ft => ft.order_key().ToString()); + // discrete values + pb.add_discrete_values(fs.user, ft => ft.user()); + pb.add_discrete_values(fs.account, ft => ft.account); + pb.add_discrete_values(fs.exchange, ft => ft.exchange()); + pb.add_discrete_values(fs.time_in_force, ft => ft.time_in_force()); + pb.add_discrete_values(fs.order_type, ft => ft.order_type()); + pb.add_discrete_values(fs.side, ft => ft.fill.Side); + pb.add_discrete_values(fs.fill_kind, ft => ft.fill.FillKind); + // numeric + pb.add_numeric(fs.size, ft => ft.fill.LastShares); + pb.add_numeric(fs.price, ft => ft.fill.LastPrice); + return pb.to_predicate(); + } + } } \ No newline at end of file diff --git a/src/client/spark/Orders/FillTuple.cs b/src/client/spark/Orders/FillTuple.cs index bfcd80a5c..40f4f65d6 100644 --- a/src/client/spark/Orders/FillTuple.cs +++ b/src/client/spark/Orders/FillTuple.cs @@ -46,4 +46,24 @@ namespace mbts.spark { order.HasValue ? order.Value.Key.GetHashCode() : 0, security.HasValue ? security.Value.Id.GetHashCode() : 0); } + + static class FillTupleExtensions { + public static DateTime fill_time(this FillTuple fill_tuple) => + fill_tuple.fill.Timestamp.to_local_time(); + + public static TimeInForce time_in_force(this FillTuple fill_tuple) => + fill_tuple.order.HasValue ? fill_tuple.order.Value.time_in_force() : TimeInForce.Undefined; + + public static CustomOrderDefinition.CustomOneofCase order_type(this FillTuple fill_tuple) => + fill_tuple.order.HasValue ? fill_tuple.order.Value.order_type() : CustomOrderDefinition.CustomOneofCase.None; + + public static Venue exchange(this FillTuple fill_tuple) => + fill_tuple.security.HasValue ? fill_tuple.security.Value.Exchange : Venue.Unset; + + public static uint order_key(this FillTuple fill_tuple) => + fill_tuple.order.HasValue ? fill_tuple.order.Value.Key : 0u; + + public static string user(this FillTuple fill_tuple) => + fill_tuple.order.HasValue ? fill_tuple.order.Value.user() : string.Empty; + } } \ No newline at end of file diff --git a/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridRowsManager.cs b/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridRowsManager.cs index 268a6b61a..e8fc509c8 100644 --- a/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridRowsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridRowsManager.cs @@ -13,7 +13,7 @@ namespace mbts.ui.controls { readonly DeferrableActionWrapper _update; bool _filters_dirty, _sorting_dirty; - public DIYGridRowsManager(IDIYGridFiltersManager filters_manager, DIYGridSortManager sort_manager, Func> get_comparer_for_column, string window_name) { + public DIYGridRowsManager(IDIYGridFiltersManager filters_manager, DIYGridSortManager sort_manager, Func> get_comparer_for_column, string window_name, Func> build_filter_from_state = null) { _filters = filters_manager; _sorting = sort_manager; _update = new DeferrableActionWrapper(() => { @@ -59,10 +59,15 @@ namespace mbts.ui.controls { desc = "(none)"; return null; } else { - // TODO: the actual IDataGridFilter implementations should be able to provide a concise description of their filter state/parameters (e.g., for a min/max filter: 'min=40, max=60') desc = string.Join(", ", col_filters.Select(f => f.col)); - var filters = Array.ConvertAll(col_filters, cf => cf.filter); - return new Func(r => filters.All(f => f.filter(r))); + if (build_filter_from_state != null) { + var filter_state = filters_manager.create(); + return build_filter_from_state(filter_state); + } else { + // TODO: the actual IDataGridFilter implementations should be able to provide a concise description of their filter state/parameters (e.g., for a min/max filter: 'min=40, max=60') + var filters = Array.ConvertAll(col_filters, cf => cf.filter); + return new Func(r => filters.All(f => f.filter(r))); + } } } } From dc7cacc126e1436883aa857f1dd5df8d6bee9707 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 5 Jun 2019 10:59:43 -0500 Subject: [PATCH 11/50] get rid of hashset-vs-array optimization (doesn't actually help) --- .../DIYGrid/Columns/ColumnPredicateBuilder.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnPredicateBuilder.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnPredicateBuilder.cs index 9e232df74..03ee224f3 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnPredicateBuilder.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnPredicateBuilder.cs @@ -11,14 +11,9 @@ namespace mbts.spark.filters { public void add_discrete_values(T[] values, Func selector) { if (values.is_null_or_empty()) return; - if (values.Length < 16) { - _predicates.Add(impl); - bool impl(TRow o) => values.Contains(selector(o)); - } else { - var set = new HashSet(values); - _predicates.Add(impl); - bool impl(TRow o) => set.Contains(selector(o)); - } + var set = new HashSet(values); + _predicates.Add(impl); + bool impl(TRow o) => set.Contains(selector(o)); } public void add_numeric(IMinMaxState value, Func selector) where T : struct, IComparable { From 3398bb5b86e2d2a620e662e4509b3f0dc9d438c6 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 5 Jun 2019 11:21:18 -0500 Subject: [PATCH 12/50] FillsVM - remove unusued field '_active_comparers' --- src/client/spark/Modules/Trading/Fills/FillsVM.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/client/spark/Modules/Trading/Fills/FillsVM.cs b/src/client/spark/Modules/Trading/Fills/FillsVM.cs index 32383f2f1..4e5bb8dfc 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsVM.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsVM.cs @@ -38,7 +38,6 @@ namespace mbts.spark { readonly DIYGridSortManager _sort_manager; readonly IDIYGridFiltersManager _filters_manager; readonly ObservableKeyedCollection _columns = new ObservableKeyedCollection(_col_key); - List<(ColumnBase col, Columns key, ListSortDirection direction)> _active_comparers = new List<(ColumnBase col, Columns key, ListSortDirection direction)>(); IWindowSettingsManager _settings_manager; int _total_row_count; From 341eda59621b722410ffb47adc7d66c1be3071b6 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 5 Jun 2019 11:22:56 -0500 Subject: [PATCH 13/50] FillsVM - rows does not need to be an OperableCollection (just a regular ObservableCollection) --- src/client/spark/Modules/Trading/Fills/FillsVM.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/client/spark/Modules/Trading/Fills/FillsVM.cs b/src/client/spark/Modules/Trading/Fills/FillsVM.cs index 4e5bb8dfc..38b65319c 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsVM.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsVM.cs @@ -19,7 +19,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; -using System.ComponentModel; using System.Linq; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -85,15 +84,7 @@ namespace mbts.spark { add_col(Columns.FillKey, DefaultColumnHeaders.FillKey, r => r.fill_key.ToString(), new RegexFilterVM(r => r.fill.FillKey), DataGridFilterKnownTemplates.Regex, DefaultColumnWidths.FillKey); add_col(Columns.OrderKey, DefaultColumnHeaders.OrderKey, r => r.order_key.ToString(), new RegexFilterVM(r => r.fill.OrderKey.ToString()), DataGridFilterKnownTemplates.Regex, DefaultColumnWidths.OrderKey); add_col(Columns.SecurityKey, DefaultColumnHeaders.SecurityKey, r => r.security_key.ToString(), new RegexFilterVM(r => r.fill.SecurityKey.ToString()), DataGridFilterKnownTemplates.Regex, DefaultColumnWidths.SecurityKey); - /// Rows - rows = new OperableCollection( - (ft, fk) => new Row(ft, model), - ft => ft.fill.FillKey, - new ComparerBuilder(new[] { - _get_column_comparer(Columns.FillTime), - _get_column_comparer(Columns.FillKey) - }).to_comparer()); - // row sort/filter managers + // rows _sort_manager = new DIYGridSortManager(col_tups.WrapSelector(t => (t.col, t.key)), Columns.FillKey); _filters_manager = DIYGridFiltersManager.create(col_tups); var rows_manager = new DIYGridRowsManager(_filters_manager, _sort_manager, _get_column_comparer, FillsWindow.window_type_name, fs => fs.build_predicate()); From 0ba311788ca1ddbd27482b8190afad6d4ab2f0dc Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 5 Jun 2019 11:29:26 -0500 Subject: [PATCH 14/50] DIYGridRowsManager - expose fills/sort manager methods, so callers don't need to hang on to fills/sort manager references --- .../spark/Modules/Trading/Fills/FillsVM.cs | 23 ++++++++----------- .../DIYGrid/Utils/DIYGridRowsManager.cs | 22 ++++++++++++++++++ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/client/spark/Modules/Trading/Fills/FillsVM.cs b/src/client/spark/Modules/Trading/Fills/FillsVM.cs index 38b65319c..b4c64bf6a 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsVM.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsVM.cs @@ -34,8 +34,7 @@ using OrderType = bts.api.orderman.CustomOrderDefinition.CustomOneofCase; namespace mbts.spark { class FillsVM : DisposableViewModelBase, IHandleGridSorting { readonly OrdersModel _model; - readonly DIYGridSortManager _sort_manager; - readonly IDIYGridFiltersManager _filters_manager; + readonly DIYGridRowsManager _rows_manager; readonly ObservableKeyedCollection _columns = new ObservableKeyedCollection(_col_key); IWindowSettingsManager _settings_manager; int _total_row_count; @@ -85,16 +84,14 @@ namespace mbts.spark { add_col(Columns.OrderKey, DefaultColumnHeaders.OrderKey, r => r.order_key.ToString(), new RegexFilterVM(r => r.fill.OrderKey.ToString()), DataGridFilterKnownTemplates.Regex, DefaultColumnWidths.OrderKey); add_col(Columns.SecurityKey, DefaultColumnHeaders.SecurityKey, r => r.security_key.ToString(), new RegexFilterVM(r => r.fill.SecurityKey.ToString()), DataGridFilterKnownTemplates.Regex, DefaultColumnWidths.SecurityKey); // rows - _sort_manager = new DIYGridSortManager(col_tups.WrapSelector(t => (t.col, t.key)), Columns.FillKey); - _filters_manager = DIYGridFiltersManager.create(col_tups); - var rows_manager = new DIYGridRowsManager(_filters_manager, _sort_manager, _get_column_comparer, FillsWindow.window_type_name, fs => fs.build_predicate()); + _rows_manager = DIYGridRowsManager.create(FillsWindow.window_type_name, Columns.FillKey, col_tups, col_tups.WrapSelector(t => (t.col, t.key)), _get_column_comparer, fs => fs.build_predicate()); // grid settings grid_settings_manager = new SimpleGridSettingsManager(columns, new Dictionary { }, rows); // this will initialize the immutable properties that correspond to the col_settings_flags above (e.g. Bid/Ask font_color_override, etc.) if (_settings_manager != null) grid_settings_manager.load_from(_settings_manager.current_settings()); - var filter_src = Observable.FromEvent>, Func>(cb => rows_manager.filter_changed += cb, cb => rows_manager.filter_changed -= cb); - var comp_src = Observable.FromEvent>, IComparer>(cb => rows_manager.comparer_changed += cb, cb => rows_manager.comparer_changed -= cb); + var filter_src = Observable.FromEvent>, Func>(cb => _rows_manager.filter_changed += cb, cb => _rows_manager.filter_changed -= cb); + var comp_src = Observable.FromEvent>, IComparer>(cb => _rows_manager.comparer_changed += cb, cb => _rows_manager.comparer_changed -= cb); TableUpdate last_unfiltered_fills = TableUpdate.mk_empty(FillTuple.key_fn); var fills_buffer = Observable.Create>(o => { // this is what .Cache() does, but is a little cheaper, since we know subscriptions and callbacks occur on the same thread (i.e., on this Dispatcher). @@ -122,7 +119,7 @@ namespace mbts.spark { TimeTextTuple.FromDateTime(DateTime.Today), TimeTextTuple.FromDateTime(DateTime.Today.AddDays(1))) }; - rows_manager.on_settings(fs, s.sorting_criterion); + _rows_manager.on_settings(fs, s.sorting_criterion); }), settings_manager == null ? Disposable.empty : settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager), (fills_source as IConnectableObservable>)?.Connect() ?? Disposable.empty @@ -157,18 +154,18 @@ namespace mbts.spark { return grid_settings_manager.create(); } + public FillsFilterStates get_filters() => + _rows_manager.get_filters(); + public IEnumerable get_sorting_criterion() => - _sort_manager.create(); + _rows_manager.get_sorting_criterion(); public void on_sorting(object sender, DIYGridSortingEventArgs e) => - _sort_manager.on_sorting(e); + _rows_manager.on_sorting(e); static Columns _col_key(ColumnBase column) => ((IKeyedColumn)column).key; - public FillsFilterStates get_filters() => - _filters_manager.create(); - static IObservable> _get_observable(IBus bus, OrdersModel model, FillsSettings state) { if (!state.orders.is_null_or_empty()) { var orders_hash = new HashSet(state.orders); diff --git a/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridRowsManager.cs b/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridRowsManager.cs index e8fc509c8..c9f5e4126 100644 --- a/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridRowsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridRowsManager.cs @@ -1,5 +1,6 @@ using bts; using bts.utils; +using mbts.collections; using mbts.utils; using System; using System.Collections.Generic; @@ -7,6 +8,23 @@ using System.ComponentModel; using System.Linq; namespace mbts.ui.controls { + static class DIYGridRowsManager { + public static DIYGridRowsManager create( + string window_name, + TColKey primary_key, + ObservableKeyedCollection, TColKey> columns, + IReadOnlyObservableKeyedCollection<(DIYGrid.ColumnBase col, TColKey key), TColKey> map, + Func> get_comparer_for_column, + Func> build_filter_from_state = null) where TColKey : struct where TFiltersState : new() => + // + new DIYGridRowsManager( + DIYGridFiltersManager.create(columns), + new DIYGridSortManager(map, primary_key), + get_comparer_for_column, + window_name, + build_filter_from_state); + } + class DIYGridRowsManager where TColKey : struct { readonly IDIYGridFiltersManager _filters; readonly DIYGridSortManager _sorting; @@ -75,6 +93,10 @@ namespace mbts.ui.controls { public event Action> filter_changed; public event Action> comparer_changed; + public TFiltersState get_filters() => _filters.create(); + public IEnumerable get_sorting_criterion() => _sorting.create(); + + public void on_sorting(DIYGridSortingEventArgs e) => _sorting.on_sorting(e); public void on_settings(TFiltersState filters, IEnumerable sorting) { using (_update.defer_execution()) { _filters.load_from(filters); From f3be277484684aadacce63b022dc6e14fc01d578 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Tue, 4 Jun 2019 17:06:33 -0400 Subject: [PATCH 15/50] Fixed limits double counting of spread leg fills --- .../actors/order_manager/OrderManager.cpp | 2 +- src/lib/orderman/limiter/LimitStore.h | 12 ++++++------ src/lib/orderman/limiter/Limiter.cpp | 16 ++++++++-------- src/lib/orderman/limiter/Limiter.h | 8 ++++---- src/lib/orderman/orders/NativeOrder.cpp | 14 +++++++------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/lib/orderman/actors/order_manager/OrderManager.cpp b/src/lib/orderman/actors/order_manager/OrderManager.cpp index feae6507d..6aa189e0b 100644 --- a/src/lib/orderman/actors/order_manager/OrderManager.cpp +++ b/src/lib/orderman/actors/order_manager/OrderManager.cpp @@ -118,7 +118,7 @@ void OrderManager::on_fill_recovery( boost::algorithm::trim_copy(ev.fill.account()); me->services_data.limiter.add(*ev.security, trimmed_account_name, ev.fill.side(), - Quantity(ev.fill.last_shares())); + Quantity(ev.fill.last_shares()),false); } me->stored_order_sub = subscribe( diff --git a/src/lib/orderman/limiter/LimitStore.h b/src/lib/orderman/limiter/LimitStore.h index f58877891..d36d26a60 100644 --- a/src/lib/orderman/limiter/LimitStore.h +++ b/src/lib/orderman/limiter/LimitStore.h @@ -62,29 +62,29 @@ public: void copy_positions_from(LimitStore& source); void add_position(const api::Security& security, AccountID account_id, api::Side side, - Quantity quantity){ + Quantity quantity, bool recurse){ SecurityLimitTree* sec_tree = _find_security(security.id()); bts_assert(sec_tree != nullptr); sec_tree->add_position(account_id, side, quantity); - if (security.has_spread()){ + if (recurse && security.has_spread()){ for (const api::ContractLeg& leg : security.spread().legs()){ api::Side effective_leg_side = side == api::Side::SIDE_BUY ? leg.side() : LimiterUtils::invert_side(leg.side()); Quantity effective_leg_qty = Quantity (quantity.value() * std::abs(leg.quantity())); - add_position (leg.security(), account_id, effective_leg_side, effective_leg_qty); + add_position (leg.security(), account_id, effective_leg_side, effective_leg_qty, recurse); } } } void remove_position(const api::Security& security, AccountID account_id, - api::Side side, Quantity quantity){ + api::Side side, Quantity quantity, bool recurse){ SecurityLimitTree* sec_tree = _find_security(security.id()); bts_assert(sec_tree != nullptr); sec_tree->remove_position(account_id, side, quantity); - if (security.has_spread()){ + if (recurse && security.has_spread()){ for (const api::ContractLeg& leg : security.spread().legs()){ api::Side effective_leg_side = side == api::Side::SIDE_BUY ? leg.side() : LimiterUtils::invert_side(leg.side()); Quantity effective_leg_qty = Quantity (quantity.value() * std::abs(leg.quantity())); - remove_position (leg.security(), account_id, effective_leg_side, effective_leg_qty); + remove_position (leg.security(), account_id, effective_leg_side, effective_leg_qty,recurse); } } } diff --git a/src/lib/orderman/limiter/Limiter.cpp b/src/lib/orderman/limiter/Limiter.cpp index bfa21a12c..3d0b6664f 100644 --- a/src/lib/orderman/limiter/Limiter.cpp +++ b/src/lib/orderman/limiter/Limiter.cpp @@ -33,45 +33,45 @@ void Limiter::add_security(api::Security const &security) { _reset(me->limit_store->admin_data()); } void Limiter::add(api::Security const &security, AccountID account_id, - api::Side side, Quantity quantity) { + api::Side side, Quantity quantity, bool recurse) { if (!_contains_security(&security)) add_security(security); if (!me->limit_store->has_account(account_id)) { // add a temporary account, so trades can go in there _add_account_and_reset(account_id); } - me->limit_store->add_position(security, account_id, side, quantity); + me->limit_store->add_position(security, account_id, side, quantity, recurse); } void Limiter::remove(api::Security const &security, AccountID account_id, - api::Side side, Quantity quantity) { + api::Side side, Quantity quantity, bool recurse) { if (!_contains_security(&security)) add_security(security); if (!me->limit_store->has_account(account_id)) { _add_account_and_reset(account_id); } - me->limit_store->remove_position(security, account_id, side, quantity); + me->limit_store->remove_position(security, account_id, side, quantity, recurse); } void Limiter::add(const api::Security &security, const std::string &account_name, api::Side side, - Quantity quantity) { + Quantity quantity, bool recurse) { const auto *acct_ptr = bts::admin::AdminServiceUtils::find_account( me->limit_store->admin_data(), account_name); if (acct_ptr == nullptr) LOG(OrderMan, Error, "Limiter::add can not find account:{}", account_name); else - add(security, AccountID(acct_ptr->id()), side, quantity); + add(security, AccountID(acct_ptr->id()), side, quantity, recurse); } void Limiter::remove(const api::Security &security, const std::string &account_name, api::Side side, - Quantity quantity) { + Quantity quantity, bool recurse) { const auto *acct_ptr = bts::admin::AdminServiceUtils::find_account( me->limit_store->admin_data(), account_name); if (acct_ptr == nullptr) LOG(OrderMan, Error, "Limiter::remove can not find account:{}", account_name); else - remove(security, AccountID(acct_ptr->id()), side, quantity); + remove(security, AccountID(acct_ptr->id()), side, quantity, recurse); } Limiter::LimiterQueryResult Limiter::can_trade(UserID user_id, AccountID account_id) const { diff --git a/src/lib/orderman/limiter/Limiter.h b/src/lib/orderman/limiter/Limiter.h index 79f092a98..fa046b9c6 100644 --- a/src/lib/orderman/limiter/Limiter.h +++ b/src/lib/orderman/limiter/Limiter.h @@ -24,13 +24,13 @@ class Limiter { void add_securities(std::vector const &secs); void add_security(api::Security const &new_sec); - void add(api::Security const &, AccountID, api::Side, Quantity); - void remove(api::Security const &, AccountID, api::Side, Quantity); + void add(api::Security const &, AccountID, api::Side, Quantity, bool recurse); + void remove(api::Security const &, AccountID, api::Side, Quantity, bool recurse); void add(api::Security const &, std::string const & /* account_name */, - api::Side, Quantity); + api::Side, Quantity, bool recurse); void remove(api::Security const &, std::string const & /* account_name */, - api::Side, Quantity); + api::Side, Quantity, bool recurse); struct LimiterQueryResult { bool ok; diff --git a/src/lib/orderman/orders/NativeOrder.cpp b/src/lib/orderman/orders/NativeOrder.cpp index 12eb386f0..c801cac13 100644 --- a/src/lib/orderman/orders/NativeOrder.cpp +++ b/src/lib/orderman/orders/NativeOrder.cpp @@ -270,8 +270,7 @@ NativeOrder::on_init_from_exe_report(ExecutionReport const &er, if (er.max_show.value() == 0) { def.mutable_custom_def()->mutable_limit(); state.mutable_limit(); - } - else { + } else { def.mutable_custom_def()->mutable_glbx_iceberg(); state.mutable_glbx_iceberg(); } @@ -1047,12 +1046,14 @@ void NativeOrder::update_working_position() { me->services->limiter().add( *me->sec, AccountID(me->definition.account_id()), me->definition.side(), - Quantity(current_position.value() - previous_position.value())); + Quantity(current_position.value() - previous_position.value()), + true); else if (previous_position.value() > current_position.value()) me->services->limiter().remove( *me->sec, AccountID(me->definition.account_id()), me->definition.side(), - Quantity(previous_position.value() - current_position.value())); + Quantity(previous_position.value() - current_position.value()), + true); } else LOG(OrderMan, Error, "Order {} ignored for purposes of limit enforcing " @@ -1194,9 +1195,8 @@ void NativeOrder::init_fix() { securities::encode_exchange_price(*me->sec, Price(stop_px)).value(); create_encoding.add(encoded_stop_px, me->price_encoding_precision, -1); - me->update_stop_px_bm= - update_encoding.add(encoded_stop_px, - me->price_encoding_precision, -1); + me->update_stop_px_bm = update_encoding.add( + encoded_stop_px, me->price_encoding_precision, -1); // price me->create_price_bm = create_encoding.add( From 05c3c977132ace39b9bb158fb374a01456d75b90 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Wed, 5 Jun 2019 15:41:50 -0400 Subject: [PATCH 16/50] Hid fills for expired securities. --- src/lib/config/protos/toggles.proto | 4 +- src/lib/domain_model/Security.cpp | 65 ++++++-- src/lib/domain_model/Security.h | 7 + src/lib/domain_model/tests/domain_tests.cpp | 155 ++++++++++++++++---- src/lib/orderman/actors/FillStore.cpp | 18 ++- 5 files changed, 200 insertions(+), 49 deletions(-) diff --git a/src/lib/config/protos/toggles.proto b/src/lib/config/protos/toggles.proto index 31e9f7129..1c53353c4 100644 --- a/src/lib/config/protos/toggles.proto +++ b/src/lib/config/protos/toggles.proto @@ -27,7 +27,9 @@ message ToastNotifications { message SoundNotifications { optional bool enabled = 1 [default = true]; } - +message FilterExpiredFills { + optional bool enabled = 1 [default = true]; +} message VolumeAtPrice{ optional bool enabled = 1 [default = true]; } diff --git a/src/lib/domain_model/Security.cpp b/src/lib/domain_model/Security.cpp index 6f51a5d9d..5a8dbd611 100644 --- a/src/lib/domain_model/Security.cpp +++ b/src/lib/domain_model/Security.cpp @@ -3,31 +3,74 @@ #include +#include "lib/utils/datetime.h" +#include + namespace bts { namespace securities { -std::string to_str (api::Security const&sec) -{ +std::string to_str(api::Security const &sec) { std::string serialized; - google::protobuf::TextFormat::PrintToString (sec, &serialized); + google::protobuf::TextFormat::PrintToString(sec, &serialized); return serialized; } -std::pair from_str(std::string const&str) -{ +std::pair from_str(std::string const &str) { api::Security result; - auto success = google::protobuf::TextFormat::ParseFromString (str,&result); - return std::make_pair(success,result); + auto success = google::protobuf::TextFormat::ParseFromString(str, &result); + return std::make_pair(success, result); } -std::string descriptor(api::Security const&sec) -{ +std::string descriptor(api::Security const &sec) { if (sec.has_glbx()) return sec.glbx().security_desc(); else if (sec.has_ice()) - return sec.ice().security_desc(); + return sec.ice().security_desc(); else return "No descriptor for non glbx exchange"; } -}} +boost::gregorian::date smallest_leg( + ::google::protobuf::RepeatedPtrField<::bts::api::ContractLeg> const &l) { + bts_assert(l.size()); + auto smallest = expiration(l[0].security()); + for (const auto &leg : l) { + auto this_date = expiration(leg.security()); + if (this_date < smallest) { + smallest = this_date; + } + } + return smallest; +} + +boost::gregorian::date expiration(api::Security const &security) { + switch (security.Contract_case()) { + case api::Security::kFuture: + return { + boost::gregorian::greg_year(security.future().expiration_year()), + boost::gregorian::greg_month(security.future().expiration_month()), + boost::gregorian::greg_day(security.future().expiration_day())}; + case api::Security::kOption: + return { + boost::gregorian::greg_year(security.option().expiration_year()), + boost::gregorian::greg_month(security.option().expiration_month()), + boost::gregorian::greg_day(security.option().expiration_day())}; + case api::Security::kSpread: + return smallest_leg(security.spread().legs()); + case api::Security::kSynthetic: + return smallest_leg(security.synthetic().legs()); + default: + return {}; + } +} + +bool is_expired(api::Security const &security) { + auto e = expiration(security); + if (e == boost::gregorian::date()) + return false; + else + return e < boost::posix_time::microsec_clock::universal_time().date(); +} + +} // namespace securities +} // namespace bts diff --git a/src/lib/domain_model/Security.h b/src/lib/domain_model/Security.h index 9227e5b07..003e39930 100644 --- a/src/lib/domain_model/Security.h +++ b/src/lib/domain_model/Security.h @@ -7,6 +7,8 @@ #include "lib/domain_model/common.h" #include "lib/utils/bts_assert.h" +namespace boost {namespace gregorian {class date;}} + namespace bts { namespace api { @@ -149,10 +151,15 @@ inline Price round_to_quote_price(api::Security const &sec, Price in, raw_round_to_quote_price(p, sec.contract_spec().low_tick(), side)); } +boost::gregorian::date expiration(api::Security const&sec); +bool is_expired(api::Security const &security) ; + inline Price tick_size(api::Security const &sec) { return Price(sec.contract_spec().low_tick()); } +boost::gregorian::date expiration(api::Security const &); + // Looking to round md::IntPrice? Look in IntPrice.h // computes the difference between 2 prices in ticks. diff --git a/src/lib/domain_model/tests/domain_tests.cpp b/src/lib/domain_model/tests/domain_tests.cpp index bba06ac39..c2dd3d24d 100644 --- a/src/lib/domain_model/tests/domain_tests.cpp +++ b/src/lib/domain_model/tests/domain_tests.cpp @@ -1,6 +1,10 @@ -#include "catch/catch.hpp" #include "../Security.h" +#include "catch/catch.hpp" +#include "lib/domain_model/Security.h" +#include "lib/utils/PBUtils.h" + +#include namespace bts { namespace test { @@ -8,33 +12,30 @@ namespace test { TEST_CASE("rounding_tests", "[md]") { SECTION("test_price_size") { - const double tick_sizes[] { - // Dan's production system - // ./sparkd configcheck Symbols | grep future | sed -e 's/.*future: \"\(.*\)\"/\1/' | xargs -I{} sh -c "./sparkd md dump {} future glbx" | grep -o low_tick': [0-9.]\+ - 0.0078125, - 0.015625, - 0.03125, - 0.1, - 0.25, - 1, - // From Kevin's ramblings - // 2.5/320, - // 31./32, - // 10./32, - // 10.25/32, - // 10.375/32, - // 10.125/32, - // 10.25/32, - // .0025, - // .0000001, - // 1./32, - // 0.5/32, - // 0.25/32, - // 0.125/32, - // 0.01, - // 0.005, - // 1./100000, - // 1./16, + const double tick_sizes[]{ + // Dan's production system + // ./sparkd configcheck Symbols | grep future | sed -e 's/.*future: + // \"\(.*\)\"/\1/' | xargs -I{} sh -c "./sparkd md dump {} future + // glbx" | grep -o low_tick': [0-9.]\+ + 0.0078125, 0.015625, 0.03125, 0.1, 0.25, 1, + // From Kevin's ramblings + // 2.5/320, + // 31./32, + // 10./32, + // 10.25/32, + // 10.375/32, + // 10.125/32, + // 10.25/32, + // .0025, + // .0000001, + // 1./32, + // 0.5/32, + // 0.25/32, + // 0.125/32, + // 0.01, + // 0.005, + // 1./100000, + // 1./16, }; for (double tick : tick_sizes) { @@ -43,15 +44,105 @@ TEST_CASE("rounding_tests", "[md]") { for (double price = 0; price < 101; price += tick) { // Since all prices are valid ticks rounding should not change them const double epsilon = 1e-9; - for (api::Side side : { api::Side::SIDE_BUY, api::Side::SIDE_SELL }) { - double rounded = securities::raw_round_to_quote_price(price, tick, side); - REQUIRE(std::abs(price-rounded) <= epsilon); + for (api::Side side : {api::Side::SIDE_BUY, api::Side::SIDE_SELL}) { + double rounded = + securities::raw_round_to_quote_price(price, tick, side); + REQUIRE(std::abs(price - rounded) <= epsilon); } } } } } +auto spread_txt = "id: 17\n" + "symbol: \"ES\"\n" + "exchange: VENUE_GLBX\n" + "contract_spec {\n" + " low_tick: 0.05\n" + " high_tick: 0.05\n" + " price_multiplier: 0.01\n" + "}\n" + "spread {\n" + " legs {\n" + " security {\n" + " id: 6\n" + " symbol: \"ES\"\n" + " exchange: VENUE_GLBX\n" + " contract_spec {\n" + " low_tick: 0.25\n" + " high_tick: 0.25\n" + " cash_per_point: 50\n" + " price_multiplier: 0.01\n" + " }\n" + " future {\n" + " expiration_year: 2019\n" + " expiration_month: 1\n" + " expiration_day: 20\n" + " }\n" + " glbx {\n" + " exchange_id: 16145\n" + " security_desc: \"ESZ9\"\n" + " cfi_code: \"FFIXSX\"\n" + " cme_symbol: \"ES\"\n" + " market_segment_id: 64\n" + " }\n" + " }\n" + " quantity: 1\n" + " side: SIDE_SELL\n" + " leg_delta: 1\n" + " }\n" + " legs {\n" + " security {\n" + " id: 2\n" + " symbol: \"ES\"\n" + " exchange: VENUE_GLBX\n" + " contract_spec {\n" + " low_tick: 0.25\n" + " high_tick: 0.25\n" + " cash_per_point: 50\n" + " price_multiplier: 0.01\n" + " }\n" + " future {\n" + " expiration_year: 3020\n" + " expiration_month: 6\n" + " expiration_day: 19\n" + " }\n" + " glbx {\n" + " exchange_id: 21336\n" + " security_desc: \"ESM0\"\n" + " cfi_code: \"FFIXSX\"\n" + " cme_symbol: \"ES\"\n" + " market_segment_id: 64\n" + " }\n" + " }\n" + " quantity: 1\n" + " side: SIDE_BUY\n" + " leg_delta: 1\n" + " }\n" + "}\n" + "glbx {\n" + " exchange_id: 35451\n" + " security_desc: \"ESZ9-ESM0\"\n" + " cfi_code: \"FMIXSX\"\n" + " cme_symbol: \"ES\"\n" + " market_segment_id: 64\n" + "}"; +TEST_CASE("expiration_tests", "[security]") { + SECTION("test_expiration_retrieval") { -}} \ No newline at end of file + using namespace boost::gregorian; + + auto spread = utils::pb::from_string(spread_txt); + REQUIRE(securities::expiration(spread) == + date(greg_year(2019), greg_month(1), greg_day(20))); + auto &leg = spread.spread().legs(1).security(); + REQUIRE(securities::expiration(leg) == + date(greg_year(3020), greg_month(6), greg_day(19))); + REQUIRE(securities::is_expired(spread)); + REQUIRE(!securities::is_expired(leg)); + } +} + +} // namespace test +} // namespace bts diff --git a/src/lib/orderman/actors/FillStore.cpp b/src/lib/orderman/actors/FillStore.cpp index 3d6652726..2de9e5eab 100644 --- a/src/lib/orderman/actors/FillStore.cpp +++ b/src/lib/orderman/actors/FillStore.cpp @@ -1,5 +1,8 @@ #include "FillStore.h" #include "lib/api/services/OrderService.pb.h" +#include "lib/config/config.h" +#include "lib/config/protos/toggles.pb.h" +#include "lib/domain_model/Security.h" #include "lib/orderman/actors/SODPosition.h" #include "lib/orderman/events/NewExecutionReportEvent.h" #include "lib/orderman/events/OrderDefinitionUpdateEvent.h" @@ -53,10 +56,15 @@ void FillStore::init() { auto sec = me->oracle.get_security(SecurityKey(fill.security_key())); if (sec) { - auto fk = kvp.first; - if (!me->sod_pos_map.add_fill_to_sod_pos(fill)) - stored_batch.emplace_back(fill, *sec); - me->known_fills.insert(fk); + if (config::get().enabled() && + securities::is_expired(*sec)) + continue; + else { + auto fk = kvp.first; + if (!me->sod_pos_map.add_fill_to_sod_pos(fill)) + stored_batch.emplace_back(fill, *sec); + me->known_fills.insert(fk); + } } else LOG(persist, Error, "Stored fill {} contains unresolved security {}. ", kvp.first, @@ -78,7 +86,7 @@ void FillStore::init() { // account ids for future execution reports subscribe( [this](auto const &ev) { this->on_order_definition_update(ev); }); -} +} // namespace orderman FillStore::~FillStore() {} From f860649996cd016441dc8373fe0f12a9f0134e8c Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Wed, 5 Jun 2019 21:43:03 +0000 Subject: [PATCH 17/50] Merged in SPARK-2472-rerun (pull request #245) RTM. SPARK-2472 rerun * SPARK-2482 - End Jake's left handed discrimination * SPARK-2472 add * to our order size Approved-by: Pedro Pinto --- .../spark/Modules/Trading/Ladder/View/LadderGridHost.cs | 4 ++-- src/client/spark/view/Spark/Ladder/MBO/MBOPopupModel.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs index a29e78b03..85145bc45 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderGridHost.cs @@ -338,8 +338,8 @@ namespace mbts.spark { if (bs.HasValue) { _send_parameterized_order(point, bs.Value); } else if (column.column_type == ColumnType.Price) { - if (Keyboard.IsKeyDown(Key.LeftShift) || - Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt)) { + if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown (Key.RightShift) || + Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt)) { show_mbo_popup(point).ignore(); } else { _scroll_to_center(); diff --git a/src/client/spark/view/Spark/Ladder/MBO/MBOPopupModel.cs b/src/client/spark/view/Spark/Ladder/MBO/MBOPopupModel.cs index b5bea76dc..f77b6a6ef 100644 --- a/src/client/spark/view/Spark/Ladder/MBO/MBOPopupModel.cs +++ b/src/client/spark/view/Spark/Ladder/MBO/MBOPopupModel.cs @@ -110,7 +110,7 @@ namespace mbts.spark { pdp.row_numbers = p.orders.Select((o, i) => format_text((i+1).ToString(), ismine(o))).ToList(); pdp.numbers_width = _number_width = Math.Max(_number_width, (int)pdp.row_numbers.Max(r => r.Width) + text_margin); - pdp.row_labels = p.orders.Select(o => format_text(o.Size.ToString(), ismine(o))).ToList(); + pdp.row_labels = p.orders.Select(o => format_text(o.Size.ToString() + (ismine(o) ? "*" : ""), ismine(o))).ToList(); var max_label_width = pdp.row_labels.Max(l => l.Width) + text_margin; var available_width = pdp.width - pdp.numbers_width - max_label_width; From c6c2d3448d3f720ac827baff21a8f65e3fe09916 Mon Sep 17 00:00:00 2001 From: Michael Harding Date: Wed, 5 Jun 2019 21:49:54 +0000 Subject: [PATCH 18/50] Merged in net_contracts_fix (pull request #250) RTM. Fix lazyview updating net cotracts --- src/web/ui/src/Accounts/View.fs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/web/ui/src/Accounts/View.fs b/src/web/ui/src/Accounts/View.fs index be6133fbf..0b66c54cb 100644 --- a/src/web/ui/src/Accounts/View.fs +++ b/src/web/ui/src/Accounts/View.fs @@ -348,8 +348,8 @@ let clipLimitsView model dispatch = TableControl.createDataTable (Some headerRow) rws (Button.button "Add" "" "plus-circle" Button.Enabled addRow) ] -let lazyClipLimitsView model dispatch = - lazyView2With (fun a b -> +let lazyClipLimitsView model dispatch = + lazyView2With (fun a b -> LanguagePrimitives.PhysicalEquality a.SelectedClipLimits b.SelectedClipLimits && LanguagePrimitives.PhysicalEquality a.scratch.securityClipLimits b.scratch.securityClipLimits) clipLimitsView @@ -542,10 +542,11 @@ let productLimits model dispatch = br [] ] -let lazyProductLimitsView model dispatch = - lazyView2With (fun a b -> +let lazyProductLimitsView model dispatch = + lazyView2With (fun a b -> LanguagePrimitives.PhysicalEquality a.SelectedPositionLimits b.SelectedPositionLimits && - LanguagePrimitives.PhysicalEquality a.scratch.productPositionLimits b.scratch.productPositionLimits) + LanguagePrimitives.PhysicalEquality a.scratch.productPositionLimits b.scratch.productPositionLimits && + a.scratch.riskLimitEnforcement = b.scratch.riskLimitEnforcement) productLimits model dispatch @@ -764,7 +765,7 @@ let tabContent model dispatch = div [Key (string model.scratch.id); ClassName "is-tab-content"] [ // (match model.tab with (match model.tab, (accountIsSelected model.scratch Access.Accounts.empty) with - | _ , false -> p [Style [ Color "Red" ]] [ str "You are not authorized to view this data" ] + | _ , false -> p [Style [ Color "Red" ]] [ str "You are not authorized to view this data" ] | General, _ -> generalView model dispatch | LimitsTab, _ -> LimitsView model dispatch | ConnectionsTab, _ -> ConnectionsView model dispatch @@ -871,7 +872,7 @@ let menuItem account selectedAccount model dispatch = ] ] ] - else span[][]) + else span[][]) ] let NavRoot (accounts:BTSAccount[]) selectedAccount model dispatch = @@ -881,10 +882,10 @@ let NavRoot (accounts:BTSAccount[]) selectedAccount model dispatch = span [Class "is-size-4"] [str "Accounts"] span [ Class "is-pulled-right circle-icon" ] (if model.can_create then - [ Button.fabutton + [ Button.fabutton "Add Account" "plus-circle" - "" + "" Button.Enabled (fun _ -> dispatch AddAccount) ] else []) @@ -929,7 +930,7 @@ let root (model:Model) dispatch = [ NavRoot data.accounts (selectedAccount model) model dispatch div [ Class "column is-main-content" ] [ - + div [ ClassName "tabs is-boxed" ] [ ul [] [ (if (Array.length data.accounts > 0) then (tabHeader General model.tab dispatch) else span [][] ) From 259355d6299a7223e336870172b91c7f691023d1 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Wed, 5 Jun 2019 17:51:22 -0400 Subject: [PATCH 19/50] Updated release notes. --- doc/user/content/release_notes/_index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index fae378007..31cccd56a 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -8,6 +8,7 @@ insert_anchor_links = "right" ### User Visible Changes - Made our orders easier to spot in MBO display - Changed middle-click on center column to recenter ladder and introduced Alt middle-click on center to bring up the MBO popup + - Fixed Net/Absolute radio button in risk admin UI ## 2.1.4 ### User Visible Changes From 0c17dbb55b6707f4f94172b8187a8b9d627ca451 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Wed, 5 Jun 2019 17:57:11 -0400 Subject: [PATCH 20/50] Updated release notes. --- doc/user/content/release_notes/_index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 31cccd56a..58f2e5c93 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -9,6 +9,7 @@ insert_anchor_links = "right" - Made our orders easier to spot in MBO display - Changed middle-click on center column to recenter ladder and introduced Alt middle-click on center to bring up the MBO popup - Fixed Net/Absolute radio button in risk admin UI + - Added feedback to the ladder when the user attempts to middle click on bid/ask columns using an order that does not have parameters ## 2.1.4 ### User Visible Changes From df681ca209a4aad7dc98a591968b73fa2e8c27cb Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Thu, 6 Jun 2019 11:03:36 -0400 Subject: [PATCH 21/50] Removed duplicate declaration. --- src/lib/domain_model/Security.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib/domain_model/Security.h b/src/lib/domain_model/Security.h index 003e39930..54a35a324 100644 --- a/src/lib/domain_model/Security.h +++ b/src/lib/domain_model/Security.h @@ -158,8 +158,6 @@ inline Price tick_size(api::Security const &sec) { return Price(sec.contract_spec().low_tick()); } -boost::gregorian::date expiration(api::Security const &); - // Looking to round md::IntPrice? Look in IntPrice.h // computes the difference between 2 prices in ticks. From baac6a893d2feefbdcf680e6b18853519e36afac Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Thu, 6 Jun 2019 11:14:56 -0400 Subject: [PATCH 22/50] Re-directed SecurityDB's expiration to securities::expiration --- src/lib/md/SecurityDB.cpp | 40 ++++++++++----------------------------- src/lib/md/SecurityDB.h | 3 +-- src/web/CMakeDeps.cmake | 2 +- 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/lib/md/SecurityDB.cpp b/src/lib/md/SecurityDB.cpp index e16bb7584..be9ef1c60 100644 --- a/src/lib/md/SecurityDB.cpp +++ b/src/lib/md/SecurityDB.cpp @@ -8,6 +8,7 @@ #include "lib/config/protos/system.pb.h" #include "lib/md/Shm/FixedSecurity.h" #include "lib/config/protos/MarketData.pb.h" +#include "lib/domain_model/Security.h" #include #include @@ -141,7 +142,15 @@ Result insert_or_replace(const std::vector& securities) { insert.bind(3, psecurity->exchange()); insert.bind(4, securitytype_of(*psecurity)); insert.bind(5, buffer); - insert.bind(6, expiration(*psecurity).to_short()); + auto greg_date = securities::expiration(*psecurity); + if (greg_date == boost::gregorian::date()) { + insert.bind(6, datetime::Date(9999,1,1).to_short()); + } else { + ushort year = greg_date.year(); + ushort month = greg_date.month(); + ushort day = greg_date.day(); + insert.bind(6, datetime::Date(year,month,day).to_short()); + } insert.exec(); insert.reset(); } @@ -204,33 +213,4 @@ SecurityPtr find_security(SecurityKey) { return nullptr; } #endif -template -datetime::Date smallest_leg(L l) { - // Iterate though all legs and choose the smallest - datetime::Date date(std::numeric_limits::max(),0,0); - for (const auto& leg : l) { - auto legDate = expiration(leg.security()); - if (legDate < date) { - date = legDate; - } - } - return date; -} - -datetime::Date expiration(const api::Security& security) { - switch(security.Contract_case()) { - case api::Security::kFuture: - return datetime::Date(security.future().expiration_year(), security.future().expiration_month(), security.future().expiration_day()); - case api::Security::kOption: - return datetime::Date(security.option().expiration_year(), security.option().expiration_month(), security.option().expiration_day()); - case api::Security::kSpread: - return smallest_leg(security.spread().legs()); - case api::Security::kSynthetic: - return smallest_leg(security.synthetic().legs()); - default: - // return a 0 date which will always be considered expired. - return datetime::Date(); - } -} - }}}//namespace diff --git a/src/lib/md/SecurityDB.h b/src/lib/md/SecurityDB.h index b04f355da..530fdb297 100644 --- a/src/lib/md/SecurityDB.h +++ b/src/lib/md/SecurityDB.h @@ -36,6 +36,5 @@ Result insert_or_replace(const std::vector&); std::vector load_metadata(); bool store_metadata(const api::synthetic::Metadata&); -datetime::Date expiration(const api::Security& security); -}}}//namespace \ No newline at end of file +}}}//namespace diff --git a/src/web/CMakeDeps.cmake b/src/web/CMakeDeps.cmake index 40156daa9..21739132b 100644 --- a/src/web/CMakeDeps.cmake +++ b/src/web/CMakeDeps.cmake @@ -1 +1 @@ -set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/services/AdminService.proto;../lib/api/services/AlgoDefinitionService.proto;../lib/api/services/AlgoService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/AuthService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MBOService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;api/build.sh;api/node_modules/exit/test/fixtures/create-files.sh;api/node_modules/protobufjs/cli/node_modules/acorn-jsx/node_modules/acorn/bin/update_authors.sh;api/node_modules/watch/release.sh;api/quiet_build.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs;ui/src/obj/Debug/netstandard2.0/ui.AssemblyInfo.fs) \ No newline at end of file +set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/services/AdminService.proto;../lib/api/services/AlgoDefinitionService.proto;../lib/api/services/AlgoService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/AuthService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MBOService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;api/build.sh;api/node_modules/cssstyle/scripts/run_tests.sh;api/node_modules/exit/test/fixtures/create-files.sh;api/node_modules/protobufjs/cli/node_modules/acorn-jsx/node_modules/acorn/bin/update_authors.sh;api/node_modules/watch/release.sh;api/quiet_build.sh;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs;ui/src/obj/Debug/netstandard2.0/ui.AssemblyInfo.fs) \ No newline at end of file From dcd8984b33e918a03e41ce7f16b5bdf4d88dceab Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 6 Jun 2019 12:35:09 -0500 Subject: [PATCH 23/50] SPARK-2489 / SPARK-2494 rename 'Column Settings' tab 'Ladder Columns' --- .../spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml index ca4691070..3fd7dcb94 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml @@ -141,8 +141,8 @@ - - + + From a4d63a14210ac6fa3c86ce5c6a9b8b6736697c84 Mon Sep 17 00:00:00 2001 From: Taha Afzal Date: Thu, 6 Jun 2019 19:13:46 -0400 Subject: [PATCH 24/50] this should fix the confusion --- .../orders/algo/algo_orders/LeanAlgo.cpp | 81 ++++++++++++------- .../orders/algo/algo_orders/LeanAlgo.h | 12 ++- 2 files changed, 62 insertions(+), 31 deletions(-) diff --git a/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.cpp b/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.cpp index c1cd50f61..27a451aa2 100644 --- a/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.cpp +++ b/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.cpp @@ -20,11 +20,11 @@ struct LeanAlgo::PImpl { IAlgoServices* algo_services; double tick_size = os::nan(); Status status = Status::WAITING_FOR_MD; - Price initial_observed_price = Price(os::nan()); + // the first observed opp inside price + Price anchor_price = Price(os::nan()); Price observed_price = Price(os::nan()); OrderKey child_key = null_order_key(); ChildTemplate *child_template = nullptr; - md::PriceSize last_opp_inside = md::PriceSize(); Book curr_book; Price out_price = Price(os::nan()); Quantity out_qty = Quantity(0); @@ -106,8 +106,8 @@ void LeanAlgo::on_book(SecurityKey, const Book &book) { switch (me->status) { case LeanAlgo::Status::WAITING_FOR_MD: if (_opp_inside_market().size() != 0) { - me->initial_observed_price = Price(_opp_inside_market().price()); - me->observed_price = me->initial_observed_price; + me->anchor_price = Price(_opp_inside_market().price()); + me->observed_price = me->anchor_price; me->status = LeanAlgo::Status::WORKING; _analyze_and_act(); } @@ -158,11 +158,11 @@ LeanAlgo::_on_toward_behaviour() const { bool LeanAlgo::_book_moved_toward() const { return securities::is_better(_opp_side(), Price(_opp_inside_market().price()), - Price(me->last_opp_inside.price())); + me->anchor_price); } bool LeanAlgo::_book_moved_away() const { return securities::is_better(_opp_side(), - Price(me->last_opp_inside.price()), + me->anchor_price, Price(_opp_inside_market().price())); } md::PriceSize LeanAlgo::_opp_inside_market() const { @@ -173,29 +173,29 @@ api::Side LeanAlgo::_opp_side() const { } bool LeanAlgo::_within_chase_band(Price price) const{ return securities::is_better(algo().definition().side(), - me->initial_observed_price, + me->anchor_price, price) || static_cast(std::abs( securities::price_diff_to_ticks(price.value(), - me->initial_observed_price.value(), + me->anchor_price.value(), me->tick_size))) <= _max_chase_ticks(); } Price LeanAlgo::_chase_limit() const{ double offset=me->tick_size*_max_chase_ticks(); return securities::improve_price(algo().definition().side(), - me->initial_observed_price, + me->anchor_price, Price(offset)); } -LeanAlgo::MarketChange LeanAlgo::_market_change() const{ +LeanAlgo::OppMarketState LeanAlgo::_market_state() const{ md::PriceSize opp_inside=_opp_inside_market(); if(opp_inside.size()==0) - return MarketChange::NO_MARKET; + return OppMarketState::NO_MARKET; else if (_book_moved_away()) - return MarketChange::AWAY; + return OppMarketState::AWAY; else if (_book_moved_toward()) - return MarketChange::TOWARD; + return OppMarketState::TOWARD; else - return MarketChange::SIZE_CHANGE; + return OppMarketState::NO_DIRECTIONAL_CHANGE; } Price LeanAlgo::_get_price_to_pass (Price price) const{ // if it has crossed once, then the @@ -208,24 +208,25 @@ Price LeanAlgo::_get_price_to_pass (Price price) const{ /////////////////////////////////////////////////////////////////////////////// void LeanAlgo::_analyze_and_act() { bts_assert(me->status == LeanAlgo::Status::WORKING); - auto market_change=_market_change(); - me->last_opp_inside=_opp_inside_market(); + auto market_change=_market_state(); switch(market_change){ - case MarketChange::NO_MARKET: + case OppMarketState::NO_MARKET: _go_furthest_possible(); break; - case MarketChange::SIZE_CHANGE: + case OppMarketState::NO_DIRECTIONAL_CHANGE: _try_cross(me->observed_price); break; - case MarketChange::AWAY: + case OppMarketState::AWAY: me->observed_price = Price(_opp_inside_market().price()); _go_furthest_possible(); break; - case MarketChange::TOWARD: + case OppMarketState::TOWARD: _on_toward_me(); break; } } +// since this is more complicated than the +// other market states void LeanAlgo::_on_toward_me() { switch (_on_toward_behaviour()) { case LeanOrderDefinition_OnToward_CANCEL: @@ -242,7 +243,7 @@ void LeanAlgo::_on_toward_me() { algo().cancel("Opposite inside market moved towards order(detaching)"); break; case LeanOrderDefinition_OnToward_REPRICE: - LOG(OrderMan, Diag, + LOG(OrderMan, Info, "LeanAlgo {} changing its target to {} because opposite moved " "towards order", algo().order_key().value(), _opp_inside_market().price()); @@ -250,7 +251,7 @@ void LeanAlgo::_on_toward_me() { _try_cross(me->observed_price); break; case LeanOrderDefinition_OnToward_NO_CHANGE: - LOG(OrderMan, Diag, "LeanAlgo {} ignoring opposite move towards order", + LOG(OrderMan, Info, "LeanAlgo {} ignoring opposite move towards order", algo().order_key().value()); _try_cross(me->observed_price); break; @@ -259,10 +260,11 @@ void LeanAlgo::_on_toward_me() { break; } } -// this assumes the opposite side is there -// and will always try to cross into the other side -// IF the qty threshold AND chase band condition is met. -// it returns true if it successfully crossed. +// if the price is within the chase bands +// (which is only applied on AWAY prices), +// and the cum qty on the opposite side +// up to the price is less than +// the threshold, then it jumps to that price. bool LeanAlgo::_try_cross(Price price) { if(_within_chase_band(price)){ Quantity cumm_qty; @@ -271,6 +273,13 @@ bool LeanAlgo::_try_cross(Price price) { price, me->tick_size, cumm_qty); + // if we are within the chase bands and + // the price happens to be better than + // the opposite inside market (ie for buy orders + // the price < top sell market) + // then cumm_qty will be 0, which + // means the price will always be modified + // to the arg Quantity trigger_quantity = _cross_threshold(); if(cumm_qty.value()observed_price)){ + // this will be false if the observed price + // is outside the chase OR qty threshold + // is not met if(!_try_cross(_chase_limit())){ - // this will only be false if chase_limit is - // on the opposite side and the qty > threshold - // (if it was on the same side, cum_qty==0) + // this will only be false + // if chase_limit is on the opposite side + // and the qty > threshold (if it was on the + // same side, cum_qty==0 and it should go at + // that price, see try_cross) auto opp_inside=_opp_inside_market(); if(opp_inside.size()>0){ + // goes to the opp side, improves a tick to get + // to the same market top, and crosses there auto inside = securities::worsen_price(algo().definition().side(), Price(opp_inside.price()), Price(me->tick_size)); diff --git a/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.h b/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.h index 09aea41ba..b258cea51 100644 --- a/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.h +++ b/src/lib/orderman/orders/algo/algo_orders/LeanAlgo.h @@ -21,7 +21,15 @@ class LeanAlgo : public IAlgoOrder { void on_child_change(OrderKey, ChildState const &) override; private: - enum class MarketChange {NO_MARKET,SIZE_CHANGE,AWAY,TOWARD}; + // this is the state of opposite inside market (oim) + // NO_MARKET: oim.qty==0 + // NO_DIRECTIONAL_CHANGE: oim.price==anchor_price + // AWAY: anchor_price is_better_than oim.price + // TOWARD: oim.price is_better_than anchor_price + // since lean order is placed away from the market + // on the same size, AWAY means opp inside moves + // AWAY from the order, similiarly TOWARD + enum class OppMarketState {NO_MARKET,NO_DIRECTIONAL_CHANGE,AWAY,TOWARD}; struct PImpl; enum class Status; IAlgoServices &algo() const ; @@ -34,7 +42,7 @@ class LeanAlgo : public IAlgoOrder { api::Side _opp_side() const; bool _within_chase_band(Price price) const; Price _chase_limit() const; - MarketChange _market_change() const; + OppMarketState _market_state() const; Price _get_price_to_pass (Price price) const; void _analyze_and_act(); bool _try_cross(Price); From 040960d33bca6e8c4c57e9c2233d73936c46ec5d Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 6 Jun 2019 19:31:36 -0500 Subject: [PATCH 25/50] SPARK-2489 / SPARK-2495 merge 'Volume Display' tab into the 'Ladder Columns' tab --- .../Trading/Ladder/VM/LadderSettingsVM.cs | 30 +- .../Ladder/View/LadderSettingsView.xaml | 676 +++++++++++------- .../Ladder/View/LadderSettingsView.xaml.cs | 9 +- 3 files changed, 433 insertions(+), 282 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs b/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs index 7a379e0f5..6712731b0 100644 --- a/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs +++ b/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs @@ -30,8 +30,8 @@ namespace mbts.spark { _bid = new LadderColumnSettingsVM("Bid"), _price = new LadderColumnSettingsVM("Price"), _ask = new LadderColumnSettingsVM("Ask"), - _last = new LadderColumnSettingsVM("Last", true), - _piq = new LadderColumnSettingsVM("PIQ", true); + _last = new LadderColumnSettingsVM("Last", LadderSettingsView.LastColumnTemplateKey, true), + _piq = new LadderColumnSettingsVM("PIQ", can_toggle_show: true); VolumeColumnVM _volume = new VolumeColumnVM(); LadderMarketBreakLineVM _bid_mkt_line = new LadderMarketBreakLineVM("Bid"), @@ -323,11 +323,12 @@ namespace mbts.spark { readonly DelegateProperty _font_weight; readonly DelegateProperty _font_display_name; readonly Property _show; - readonly bool _can_toggle_visibility; + readonly string _template_key; - public LadderColumnSettingsVM(string name, bool can_toggle_visibility = false) { + public LadderColumnSettingsVM(string name, string template_key = null, bool can_toggle_show = false) { this.name = name; - _can_toggle_visibility = can_toggle_visibility; + _template_key = template_key; + this.can_toggle_show = can_toggle_show; foreground_palettes = new ObservableCollection(ColorPalette.all_presets().Select(p => new ColorPaletteVM(p))); background_palettes = new ObservableCollection(ColorPalette.all_presets().Select(p => new ColorPaletteVM(p))); _show = backing(nameof(show), true); @@ -340,8 +341,14 @@ namespace mbts.spark { _font_display_name = backing(nameof(font_display_name), () => TextUtils.display_name(font_family, font_weight, font_size), nameof(font_family), nameof(font_weight), nameof(font_size)); _font_size.Changed += (oldval, newval) => font_size_changed?.Invoke(oldval, newval); + toggle_show_details_cmd = new DelegateCommand(() => { + show_details = !show_details; + RaisePropertyChanged(nameof(show_details)); + }); } + public event Action font_size_changed; + public string name { get; } public Typeface typeface { get => _typeface.Value; set => _typeface.Value = value; } public FontFamily font_family => _font_family.Value; @@ -350,14 +357,17 @@ namespace mbts.spark { public double font_size { get => _font_size.Value; set => _font_size.Value = value; } public uint width { get; set; } public bool show { get => _show.Value; set => _show.Value = value; } + public bool can_toggle_show { get; } + public bool show_details { get; private set; } public Color foreground { get => _foreground.Value; set => _foreground.Value = value; } public Color background { get => _background.Value; set => _background.Value = value; } public ObservableCollection foreground_palettes { get; } public ObservableCollection background_palettes { get; } - public event Action font_size_changed; - public virtual string sample_text => "999-56789.01234"; - string ITemplateSelectorKey.key => _can_toggle_visibility ? ui.spark.LadderSettingsView.ColumnVisibilityToggleTemplateKey : null; + + public ICommand toggle_show_details_cmd { get; } + + string ITemplateSelectorKey.key => _template_key; public void assign_from(LadderColumnSettings settings) { typeface = new Typeface( @@ -395,7 +405,7 @@ namespace mbts.spark { public Brush badge_border { get; } = new SolidColorBrush(BTSColors.MarketData.ask); public Brush badge_background { get; } = Brushes.White; - string ITemplateSelectorKey.key => ui.spark.LadderSettingsView.OrdersColumnSampleTemplateKey; + string ITemplateSelectorKey.key => ui.spark.LadderSettingsView.OrdersColumnTemplateKey; } public class LadderMarketBreakLineVM : ViewModelBase { @@ -463,7 +473,7 @@ namespace mbts.spark { } } - public LadderColumnSettingsVM general { get; } = new LadderColumnSettingsVM("Volume", true); + public LadderColumnSettingsVM general { get; } = new LadderColumnSettingsVM("Volume", LadderSettingsView.VolumeColumnTemplateKey, true); public VolumeAtPriceAnimationVM buy { get; } public VolumeAtPriceAnimationVM sell { get; } public VolumeAtPriceAnimationVM passive { get; } diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml index 3fd7dcb94..1aa1c1b1f 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml @@ -3,6 +3,7 @@ x:ClassModifier="internal" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:ice="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" xmlns:sp="clr-namespace:mbts.spark" xmlns:u="clr-namespace:mbts.ui" xmlns:c="clr-namespace:mbts.ui.controls" @@ -22,9 +23,24 @@ 6 8 24 + + 57 + 70 + 81 + 160 + 153 + + + LightGray + Black + + + + + @@ -40,71 +56,369 @@ - + + + + + + - + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -134,7 +448,7 @@ Alternate Order Qty - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -470,141 +741,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml.cs b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml.cs index da00027a1..c42bbbaa0 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml.cs +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml.cs @@ -10,10 +10,15 @@ namespace mbts.ui.spark { /// partial class LadderSettingsView : UserControl { public const string - OrdersColumnSampleTemplateKey = nameof(OrdersColumnSampleTemplateKey), - ColumnVisibilityToggleTemplateKey = nameof(ColumnVisibilityToggleTemplateKey), + OrdersColumnTemplateKey = nameof(OrdersColumnTemplateKey), + VolumeColumnTemplateKey = nameof(VolumeColumnTemplateKey), + LastColumnTemplateKey = nameof(LastColumnTemplateKey), FavoriteAlgoAddButtonTemplateKey = nameof(FavoriteAlgoAddButtonTemplateKey); + public static readonly IMultiValueConverter LadderColumnToggleShowToolTipConverter = + ValueConverter.create((can_toggle_show, show, col_name) => + can_toggle_show ? $"{(show ? "Hide" : "Show")} {col_name}" : $"{col_name} cannot be {(show ? "hidden" : "shown")}."); + public LadderSettingsView() => InitializeComponent(); From 4b2f39c536a53a8c5a9b0048aadeab694bc54923 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 6 Jun 2019 22:42:55 -0500 Subject: [PATCH 26/50] LadderSettingsView - drop 'Show/Hide' from 'Advanced' hyperlinks --- .../Modules/Trading/Ladder/View/LadderSettingsView.xaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml index 1aa1c1b1f..b1da2aa83 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml @@ -39,8 +39,6 @@ - - @@ -261,7 +259,7 @@ - + (Advanced) @@ -315,7 +313,7 @@ - + (Advanced) From 31fe708907392aa5a7e3e9a73b08a83f62e497f2 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 6 Jun 2019 23:17:09 -0500 Subject: [PATCH 27/50] touch up LadderSettingsView --- .../Ladder/View/LadderSettingsView.xaml | 134 +++++++++--------- 1 file changed, 70 insertions(+), 64 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml index b1da2aa83..4cfc9e879 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml @@ -36,8 +36,10 @@ LightGray Black + Navy + @@ -64,9 +66,14 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 1518906b7f988bb29716182c230cd0be2cf9cc18 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 6 Jun 2019 23:21:51 -0500 Subject: [PATCH 28/50] SPARK-2489 / SPARK-2498 remove 'Order Badge Style' option --- .../Trading/Ladder/View/LadderSettingsView.xaml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml index 4cfc9e879..a9657a093 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml @@ -436,12 +436,6 @@ - - - - - - @@ -450,13 +444,9 @@ - Order Badge Style - - - Alternate Order Qty - - - + Alternate Order Qty + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + + + + - - - - - - Show Price in Net Change - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + - + + + + + + + + + + + + + - - - + + + - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Show Price in Net Change + + + + + + + + + + + - - + - + + + + + + + + + + + + + + + + - + - + + + + + + - - + + + - - - 'Single Click' Quantity - - - Hint: right click on a bid/ask cell to submit orders with this quantity. - - - - - - - - - - - - - - - - - Number of Columns - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 'Single Click' Quantity + + + Hint: right click on a bid/ask cell to submit orders with this quantity. + + + + + + + + + + + + + + + + + Number of Columns + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From b909a6062e62ca2a6e91b75a01eb5ba5e2554259 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Fri, 7 Jun 2019 15:58:32 -0400 Subject: [PATCH 36/50] Updated release notes --- doc/user/content/release_notes/_index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 58f2e5c93..7fd8e96c3 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -9,7 +9,11 @@ insert_anchor_links = "right" - Made our orders easier to spot in MBO display - Changed middle-click on center column to recenter ladder and introduced Alt middle-click on center to bring up the MBO popup - Fixed Net/Absolute radio button in risk admin UI + - Fixed double counting of spread legs in limits + - Removed expired fills from the system + - Improved handling of orders with undiscovered securities - Added feedback to the ladder when the user attempts to middle click on bid/ask columns using an order that does not have parameters + - Fixed display of algo studio algo types in order book ## 2.1.4 ### User Visible Changes From f6282c067689be9c2bf16c1bb67248a13eba706b Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Fri, 7 Jun 2019 17:20:17 -0400 Subject: [PATCH 37/50] Updated release notes --- doc/user/content/release_notes/_index.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 58f2e5c93..568a5a8a8 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -9,8 +9,13 @@ insert_anchor_links = "right" - Made our orders easier to spot in MBO display - Changed middle-click on center column to recenter ladder and introduced Alt middle-click on center to bring up the MBO popup - Fixed Net/Absolute radio button in risk admin UI + - Fixed double counting of spread legs in limits + - Removed expired fills from the system + - Improved handling of orders with undiscovered securities - Added feedback to the ladder when the user attempts to middle click on bid/ask columns using an order that does not have parameters - + - Fixed display of algo studio algo types in order book + - Hid net change setting in synthetic ladders + ## 2.1.4 ### User Visible Changes - Fixed handling of cancel button in security picker From 1a0836ca6d9f775bae8e78abce05e0c30d045c44 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 7 Jun 2019 20:41:04 -0500 Subject: [PATCH 38/50] RXCollection.connect - always assign local table in callback --- src/client/spark/view/Utility/RXCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/view/Utility/RXCollection.cs b/src/client/spark/view/Utility/RXCollection.cs index 3fd6e23da..11a9a8d5f 100644 --- a/src/client/spark/view/Utility/RXCollection.cs +++ b/src/client/spark/view/Utility/RXCollection.cs @@ -45,8 +45,8 @@ namespace mbts.ui.utility { } // on table update void on_table(TableUpdate new_table) { + table = table == null ? new_table.as_snapshot() : new_table; if (comp != null) { - table = table == null ? new_table.as_snapshot() : new_table; target.RemoveSorted(table.removed.Concat(table.changes.Old()), comp); target.InsertSorted(table.added.Concat(table.changed), comp); } From 300a1ed17fd43d087158e08ba9e35f2ae5a5ca2a Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 7 Jun 2019 23:05:00 -0500 Subject: [PATCH 39/50] SPARK-2481 filtering in fills window is badly broken (2nd take) --- src/client/spark/view/Utility/RXCollection.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/client/spark/view/Utility/RXCollection.cs b/src/client/spark/view/Utility/RXCollection.cs index 11a9a8d5f..57fbd014b 100644 --- a/src/client/spark/view/Utility/RXCollection.cs +++ b/src/client/spark/view/Utility/RXCollection.cs @@ -1,14 +1,11 @@ -using bts; -using bts.api.core; +using bts.api.core; using bts.collections; -using bts.utils; using mbts.utils; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; -using System.Reactive; using System.Reactive.Linq; namespace mbts.ui.utility { @@ -37,11 +34,11 @@ namespace mbts.ui.utility { table_update_source.Subscribe(on_table)); // on comparer void on_comp(IComparer new_comp) { + comp = new_comp; if (table != null) { target.Clear(); - target.InsertSorted(table.state.Values, comp); + target.InsertSorted(table.state.Values, new_comp); } - comp = new_comp; } // on table update void on_table(TableUpdate new_table) { From 96cacb8bb9101bf3ffc224e29da15094a9690c39 Mon Sep 17 00:00:00 2001 From: Taha Afzal Date: Sun, 9 Jun 2019 21:16:41 -0400 Subject: [PATCH 40/50] qho's were reporting their cancelled state twice, which was causing the spreader to cancel it --- .../orders/queue_holder/QueueHolderOrder.cpp | 3 +- .../orders/queue_holder/QueueHolderOrder.h | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/lib/orderman/orders/queue_holder/QueueHolderOrder.cpp b/src/lib/orderman/orders/queue_holder/QueueHolderOrder.cpp index 5c4e7a424..03ebe9f23 100644 --- a/src/lib/orderman/orders/queue_holder/QueueHolderOrder.cpp +++ b/src/lib/orderman/orders/queue_holder/QueueHolderOrder.cpp @@ -24,6 +24,7 @@ _order_builder(), _order_manager(), _services(nullptr), _reported_state(), +_sent_state(), _book(), _state_worker(nullptr), _start_state_worker(this), @@ -120,7 +121,7 @@ void QueueHolderOrder::_switch_state(QueueHolderOrderState new_state) { LOG(OrderMan, Info, "QueueHolderOrder::_switch_state key:{} {}->{}", key(), s0,_state_int()); } -api::orderman::OrderStatus QueueHolderOrder::status(std::string& message) const{ +api::orderman::OrderStatus QueueHolderOrder::_status(std::string& message) const{ QueueHolderOrderState curr_state= _state_worker==nullptr?QueueHolderOrderState::START:_state(); switch (curr_state){ diff --git a/src/lib/orderman/orders/queue_holder/QueueHolderOrder.h b/src/lib/orderman/orders/queue_holder/QueueHolderOrder.h index 1a36c9dc1..6dc798cd3 100644 --- a/src/lib/orderman/orders/queue_holder/QueueHolderOrder.h +++ b/src/lib/orderman/orders/queue_holder/QueueHolderOrder.h @@ -11,6 +11,7 @@ #include "lib/orderman/orders/queue_holder/state_workers/QHOEndStateWorker.h" #include "lib/orderman/orders/queue_holder/QHOOrderManager.h" #include "lib/orderman/orders/OrderOpResult.h" +#include "lib/domain_model/Security.h" namespace bts { namespace api {namespace orderman {class OrderDefinition;}} @@ -83,12 +84,13 @@ private: _termination_reason=termination_reason; _switch_state(QueueHolderOrderState::WAITING_FOR_CANCEL_ALL); } - api::orderman::OrderStatus status(std::string& message) const; + api::orderman::OrderStatus _status(std::string& message) const; // sends orders for the first time void _report_state(){ if(_activated()){ - std::string err_msg; - _reported_state.set_status(status(err_msg)); + std::string& err_msg = *(_reported_state.mutable_last_msg()); + // both status and err_msg are set here + _reported_state.set_status(_status(err_msg)); double filled_price; uint32_t filled_qty; _order_manager.filled_price(filled_price,filled_qty); @@ -104,8 +106,10 @@ private: } _reported_state.set_avg_price(filled_price); _reported_state.set_filled_quantity(filled_qty); - _reported_state.set_last_msg(err_msg); - _services->report_state(_reported_state); + if(!_state_eq()){ + _sent_state=_reported_state; + _services->report_state(_reported_state); + } } } void _set_state_price_qty(Price price, Quantity qty){ @@ -124,6 +128,18 @@ private: oss << str << " key:" << key(); bts_assert_msg(false, oss.str()); } + bool _state_eq() const{ + return _reported_state.status() == _sent_state.status() && + securities::is_same(Price(_reported_state.price()), + Price(_sent_state.price())) && + _reported_state.quantity() == _sent_state.quantity() && + _reported_state.filled_quantity() == _sent_state.filled_quantity() && + securities::is_same(Price(_reported_state.last_price()), + Price(_sent_state.last_price())) && + securities::is_same(Price(_reported_state.avg_price()), + Price(_sent_state.avg_price())) && + _reported_state.last_msg() == _sent_state.last_msg(); + } private: // if the init call succeeded which means // i. order is properly built @@ -138,7 +154,7 @@ private: OrderBuilder _order_builder; QHOOrderManager _order_manager; OrderServices *_services; - api::orderman::OrderState _reported_state; + api::orderman::OrderState _reported_state, _sent_state; Book _book; IQueueHolderOrderStateWorker* _state_worker; QHOStartStateWorker _start_state_worker; From 33b4b88af10089cfd111a2e15ef0089ea99d1767 Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Mon, 10 Jun 2019 10:12:44 -0400 Subject: [PATCH 41/50] For some strange reason the gregorian calender does not start counting days at 0. Maybe 0 hadn't been invented yet. --- src/lib/md/test/md2_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/md/test/md2_tests.cpp b/src/lib/md/test/md2_tests.cpp index d9da74ddd..74370e662 100644 --- a/src/lib/md/test/md2_tests.cpp +++ b/src/lib/md/test/md2_tests.cpp @@ -1270,10 +1270,10 @@ struct Co2RelayTests { // That's right. Expirations daily. out_producers->push_back( producer.add_security( - *mkfixedfuture("FOO", invalid_security_key, 2017, 1+(x/28), x%28))); + *mkfixedfuture("FOO", invalid_security_key, 2017, 1+(x/28), x%27+1))); out_producers->push_back( producer.add_security( - *mkfixedfuture("FOOF", invalid_security_key, 2017, 1+(x/28), x%28))); + *mkfixedfuture("FOOF", invalid_security_key, 2017, 1+(x/28), x%27+1))); } assign_ids(out_producers->begin(), out_producers->end(), 1000); From 0223e43aa268e6e3c4c0a5f018bdd50f69c94308 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 10 Jun 2019 10:20:51 -0400 Subject: [PATCH 42/50] Updated release notes. --- doc/user/content/release_notes/_index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 568a5a8a8..6bd6473be 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -15,7 +15,8 @@ insert_anchor_links = "right" - Added feedback to the ladder when the user attempts to middle click on bid/ask columns using an order that does not have parameters - Fixed display of algo studio algo types in order book - Hid net change setting in synthetic ladders - + - Fixed a number of problems with filtering on the Fills form + ## 2.1.4 ### User Visible Changes - Fixed handling of cancel button in security picker From 0ff4624778fcd5337ef933c24d783ad3cfe37879 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 10 Jun 2019 11:05:59 -0400 Subject: [PATCH 43/50] Updated release notes. --- doc/user/content/release_notes/_index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 6bd6473be..21d5272ed 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -16,7 +16,8 @@ insert_anchor_links = "right" - Fixed display of algo studio algo types in order book - Hid net change setting in synthetic ladders - Fixed a number of problems with filtering on the Fills form - + - On the Lean algo, OnToward and Away are now calculated with respect to the opposite inside market at time of the order launch + - Iceberg Spreaders with queue holders are not erroneously cancelled after the first fill ## 2.1.4 ### User Visible Changes - Fixed handling of cancel button in security picker From ac60a1447eec8318252303c7ae7c625dd6231408 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 10 Jun 2019 11:32:35 -0500 Subject: [PATCH 44/50] stack FillsView.Columns enum values vertically (easier to merge column changes) --- .../Modules/Trading/Fills/FillsView.xaml.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/client/spark/Modules/Trading/Fills/FillsView.xaml.cs b/src/client/spark/Modules/Trading/Fills/FillsView.xaml.cs index 55fb8fe2e..ac6e2d71a 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsView.xaml.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsView.xaml.cs @@ -7,7 +7,22 @@ namespace mbts.ui.spark { /// Interaction logic for FillsView.xaml /// partial class FillsView : UserControl { - public enum Columns { FillTime, User, Account, Exchange, Security, TimeInForce, OrderType, Side, Price, Size, FillKind, FillKey, OrderKey, SecurityKey } + public enum Columns { + FillTime, + User, + Account, + Exchange, + Security, + TimeInForce, + OrderType, + Side, + Price, + Size, + FillKind, + FillKey, + OrderKey, + SecurityKey + } public FillsView() => InitializeComponent(); From 0bc24fa7b7839c7466c0d722844d83c7fd62b2e5 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 10 Jun 2019 11:48:09 -0500 Subject: [PATCH 45/50] SPARK-2508 Fills - add 'Symbol' column --- src/client/spark/Modules/Trading/Fills/FillsVM.cs | 9 +++++++++ src/client/spark/Modules/Trading/Fills/FillsView.xaml.cs | 1 + .../Modules/Trading/Fills/Settings/FillsFilterStates.cs | 5 +++++ .../Modules/Trading/Fills/Settings/FillsSettings.cs | 2 ++ 4 files changed, 17 insertions(+) diff --git a/src/client/spark/Modules/Trading/Fills/FillsVM.cs b/src/client/spark/Modules/Trading/Fills/FillsVM.cs index b4c64bf6a..87c6ee4d3 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsVM.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsVM.cs @@ -61,6 +61,14 @@ namespace mbts.spark { equality_comparer: SecurityDataHelper.EqualityComparer.IDComparer, comparer: Comparer.Default ), DataGridFilterKnownTemplates.DiscreteValues, DefaultColumnWidths.Security); + // symbol + add_col(Columns.Symbol, DefaultColumnHeaders.Symbol, r => r.security.Symbol, + DiscreteValuesFilterVM.Create( + co2.UserSymbol.get_all().Select(u => u.symbol).Distinct().ToList(), + ft => ft.security?.Symbol ?? string.Empty, + nameof(OrderBookRowVM.symbol)), + DataGridFilterKnownTemplates.DiscreteValues, + DefaultColumnWidths.Symbol); // order type var order_type_filter = dv_filter(OrderDataHelper.all_order_types, r => r.order?.order_type() ?? OrderType.None); add_col_expl(Columns.OrderType, @@ -190,6 +198,7 @@ namespace mbts.spark { case Columns.SecurityKey: return wrap(ft => ft.fill.SecurityKey); case Columns.Side: return wrap_default(ft => ft.fill.Side); case Columns.Size: return wrap(ft => ft.fill.LastShares); + case Columns.Symbol: return wrap(ft => ft.security?.Symbol ?? string.Empty); case Columns.TimeInForce: return wrap_default(ft => ft.order?.time_in_force() ?? TimeInForce.Undefined); case Columns.User: return wrap(ft => ft.order?.user() ?? string.Empty); default: goto case Columns.FillTime; diff --git a/src/client/spark/Modules/Trading/Fills/FillsView.xaml.cs b/src/client/spark/Modules/Trading/Fills/FillsView.xaml.cs index ac6e2d71a..4b74769eb 100644 --- a/src/client/spark/Modules/Trading/Fills/FillsView.xaml.cs +++ b/src/client/spark/Modules/Trading/Fills/FillsView.xaml.cs @@ -13,6 +13,7 @@ namespace mbts.ui.spark { Account, Exchange, Security, + Symbol, TimeInForce, OrderType, Side, diff --git a/src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs b/src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs index 3c59147c6..d981552be 100644 --- a/src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs +++ b/src/client/spark/Modules/Trading/Fills/Settings/FillsFilterStates.cs @@ -66,6 +66,10 @@ namespace bts.shell.fills { [ProtoMember(14)] [DIYGridColumnID(nameof(Columns.FillKind))] public Fill.Types.FillKind[] fill_kind { get; set; } + + [ProtoMember(15)] + [DIYGridColumnID(nameof(Columns.Symbol))] + public string[] symbol { get; set; } } static class FillsFilterStatesExtensions { @@ -86,6 +90,7 @@ namespace bts.shell.fills { pb.add_discrete_values(fs.order_type, ft => ft.order_type()); pb.add_discrete_values(fs.side, ft => ft.fill.Side); pb.add_discrete_values(fs.fill_kind, ft => ft.fill.FillKind); + pb.add_discrete_values(fs.symbol, ft => ft.security?.Symbol ?? string.Empty); // numeric pb.add_numeric(fs.size, ft => ft.fill.LastShares); pb.add_numeric(fs.price, ft => ft.fill.LastPrice); diff --git a/src/client/spark/Modules/Trading/Fills/Settings/FillsSettings.cs b/src/client/spark/Modules/Trading/Fills/Settings/FillsSettings.cs index 18ba73b3c..63ace677e 100644 --- a/src/client/spark/Modules/Trading/Fills/Settings/FillsSettings.cs +++ b/src/client/spark/Modules/Trading/Fills/Settings/FillsSettings.cs @@ -40,6 +40,7 @@ namespace bts.shell.fills { static class DefaultColumns { public static GridColumnSettings security => new GridColumnSettings(col_id(Columns.Security), DefaultColumnHeaders.Security, width: DefaultColumnWidths.Security); + public static GridColumnSettings symbol => new GridColumnSettings(col_id(Columns.Symbol), DefaultColumnHeaders.Symbol, width: DefaultColumnWidths.Symbol); public static GridColumnSettings fill_time => new GridColumnSettings(col_id(Columns.FillTime), DefaultColumnHeaders.FillTime, width: DefaultColumnWidths.Time); public static GridColumnSettings user => new GridColumnSettings(col_id(Columns.User), DefaultColumnHeaders.User, width: DefaultColumnWidths.User); public static GridColumnSettings account => new GridColumnSettings(col_id(Columns.Account), DefaultColumnHeaders.Account, width: DefaultColumnWidths.Account); @@ -62,6 +63,7 @@ namespace bts.shell.fills { public static IEnumerable all { get { yield return security; + yield return symbol; yield return fill_time; yield return user; yield return account; From ecd384501ea7a400969e0c4bd95ff20a12ae3600 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 10 Jun 2019 12:22:05 -0500 Subject: [PATCH 46/50] align LadderSettingsView (content in settings dialog) with hamburger button --- .../Controls/DIYGrid/Settings/SimpleGridSettingsDialog.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsDialog.xaml b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsDialog.xaml index 2a642bccc..d114c1cb1 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsDialog.xaml +++ b/src/client/spark/view/Controls/DIYGrid/Settings/SimpleGridSettingsDialog.xaml @@ -77,7 +77,7 @@ - + From cd41632b5386a9047e662fb3a686131574cba2a1 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 10 Jun 2019 14:27:54 -0500 Subject: [PATCH 47/50] LadderSettingsView - touch up 'Order Quantities' tab --- .../Modules/Trading/Ladder/View/LadderSettingsView.xaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml index 83c508ac3..aa80663e4 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml @@ -731,7 +731,7 @@ - + @@ -745,7 +745,7 @@ - + @@ -779,7 +779,7 @@ - 'Single Click' Quantity + 'Single Click' Quantity Hint: right click on a bid/ask cell to submit orders with this quantity. From ee19f7c7da1e32dce2a52b637d8ec35873f8fd29 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 10 Jun 2019 15:44:00 -0400 Subject: [PATCH 48/50] Updated release notes. --- doc/user/content/release_notes/_index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index 21d5272ed..cf891b4cc 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -18,6 +18,8 @@ insert_anchor_links = "right" - Fixed a number of problems with filtering on the Fills form - On the Lean algo, OnToward and Away are now calculated with respect to the opposite inside market at time of the order launch - Iceberg Spreaders with queue holders are not erroneously cancelled after the first fill + - Security symbol added for fills window + ## 2.1.4 ### User Visible Changes - Fixed handling of cancel button in security picker From 1bc451086200ec7f9314d90ab44ef27e1152380d Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 10 Jun 2019 15:12:38 -0500 Subject: [PATCH 49/50] LadderSettingsView - touch up 'Market Price And Size Display' tab --- .../Modules/Trading/Ladder/LadderSettings.cs | 10 +- .../Trading/Ladder/VM/LadderSettingsVM.cs | 54 +---- .../Ladder/View/LadderSettingsView.xaml | 197 ++++++++---------- 3 files changed, 99 insertions(+), 162 deletions(-) diff --git a/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs b/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs index ce6e4743b..e20468abe 100644 --- a/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs +++ b/src/client/spark/Modules/Trading/Ladder/LadderSettings.cs @@ -327,7 +327,15 @@ namespace mbts.spark { public enum BadgeStyle { Normal, Alternate } - public enum NetChangeTerms { None, Dollars, Ticks } + // TODO: rename to PriceDisplayFormat (today is merge monday, since this isn't a functional change, it is not worth the potential merge headaches right now) + public enum NetChangeTerms { + [Description("Standard Ticks")] + None, + [Description("Net Change Dollars")] + Dollars, + [Description("Net Change Ticks")] + Ticks + } [ProtoMember(1)] public double row_height { get; set; } diff --git a/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs b/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs index 6712731b0..e1c33486b 100644 --- a/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs +++ b/src/client/spark/Modules/Trading/Ladder/VM/LadderSettingsVM.cs @@ -23,6 +23,7 @@ namespace mbts.spark { readonly Property _badge_style; readonly Property _alternate_order_size; readonly DelegateProperty _row_height; + LadderSettings.NetChangeTerms _price_format; Func _get_order_entry_panel_width, _get_zoom_factor; LadderSettings _current; LadderColumnSettingsVM @@ -59,10 +60,6 @@ namespace mbts.spark { _cancel_buys_visibility = new OrderEntryPanelItemVisibilityVM("Cancel Buys"), _cancel_sells_visibility = new OrderEntryPanelItemVisibilityVM("Cancel Sells"), _cancel_all_visibility = new OrderEntryPanelItemVisibilityVM("Cancel All"); - readonly Property - _show_in_net_change, - _show_in_net_change_dollars, - _show_in_net_change_ticks; public LadderSettingsVM(OrdersModel model, bool is_synthetic, Func get_left_panel_width, Func get_zoom_factor) { this.is_synthetic = is_synthetic; @@ -74,10 +71,6 @@ namespace mbts.spark { _alternate_order_size = backing(nameof(alternate_order_size)); _get_order_entry_panel_width = get_left_panel_width; _get_zoom_factor = get_zoom_factor; - _show_in_net_change = backing(nameof(show_in_net_change)); - _show_in_net_change_dollars = backing(nameof(show_in_net_change_dollars)); - _show_in_net_change_ticks = backing(nameof(show_in_net_change_ticks)); - // 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; @@ -110,6 +103,8 @@ namespace mbts.spark { } public MarketSizeDisplayVM size_display { get; } = new MarketSizeDisplayVM(); + public LadderSettings.NetChangeTerms price_format { get => _price_format; set => Set(ref _price_format, value); } + public IEnumerable price_format_options => EnumHelper.get_values(); public FavoriteAlgosVM favorite_algos_vm { get; } public double row_height => _row_height.Value; @@ -175,32 +170,6 @@ namespace mbts.spark { } } - public bool show_in_net_change { - get => _show_in_net_change.Value; - set { - // when unchecking, clear out dollars and ticks - if (!value) { - show_in_net_change_dollars = false; - show_in_net_change_ticks = false; - } - // when checking, by defalt check dollars - if (value) { - show_in_net_change_dollars = true; - } - _show_in_net_change.Value = value; - } - } - public bool show_in_net_change_dollars { - get => _show_in_net_change_dollars.Value; - set => _show_in_net_change_dollars.Value = value; - } - - public bool show_in_net_change_ticks { - get => _show_in_net_change_ticks.Value; - set => _show_in_net_change_ticks.Value = value; - } - - public string key => GridSettingsTemplateKeys.Ladder; public void load(LadderSettings settings) { @@ -241,13 +210,11 @@ namespace mbts.spark { _cancel_buys_visibility.show = settings.cancel_buys_visible; _cancel_sells_visibility.show = settings.cancel_sells_visible; _cancel_all_visibility.show = settings.cancel_all_visible; + price_format = settings.net_change; // do not read the order entry panel width here from settings // because it could have changed from the UI // there might be a better way of doing this, like how // does the widths of the ladder grid column pull this off? - show_in_net_change = settings.net_change != LadderSettings.NetChangeTerms.None; - show_in_net_change_dollars = settings.net_change == LadderSettings.NetChangeTerms.Dollars; - show_in_net_change_ticks = settings.net_change == LadderSettings.NetChangeTerms.Ticks; } public LadderSettings get_result() { @@ -291,19 +258,8 @@ namespace mbts.spark { clone.order_entry_panel_initial_width = _get_order_entry_panel_width(); clone.zoom_slider_visible = _zoom_slider_visbility.show; clone.zoom_factor = _get_zoom_factor(); - clone.net_change = _create_net_change_terms(show_in_net_change_dollars, show_in_net_change_ticks); + clone.net_change = price_format; return clone; - - LadderSettings.NetChangeTerms _create_net_change_terms(bool dollars, bool ticks) { - if (dollars) { - return LadderSettings.NetChangeTerms.Dollars; - } - if (ticks) { - return LadderSettings.NetChangeTerms.Ticks; - } - return LadderSettings.NetChangeTerms.None; - } - } public void Dispose() => favorite_algos_vm.Dispose(); diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml index aa80663e4..879ac260f 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderSettingsView.xaml @@ -607,125 +607,98 @@ - - - - - - - - + - - + - - - - - - Show Price in Net Change - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + From c652032ddfb92bf5117655ce57f1ec8d22940cc9 Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 10 Jun 2019 17:27:46 -0400 Subject: [PATCH 50/50] Updated release notes. --- doc/user/content/release_notes/_index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index cf891b4cc..09b6c5ed3 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -18,7 +18,8 @@ insert_anchor_links = "right" - Fixed a number of problems with filtering on the Fills form - On the Lean algo, OnToward and Away are now calculated with respect to the opposite inside market at time of the order launch - Iceberg Spreaders with queue holders are not erroneously cancelled after the first fill - - Security symbol added for fills window + - Added security symbol column to fills window + - Re-organized ladder settings dialog to make it clearer and easier to use ## 2.1.4 ### User Visible Changes