From 05d0eee8c76219d50b562c21c065af220ffddd5a Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 4 Dec 2018 14:45:08 -0600 Subject: [PATCH 1/6] MV filters - reevaluate fitler when data changes --- .../Market/MarketView/MarketViewRow.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs index 8c604dca4..73a84082c 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs @@ -266,7 +266,36 @@ namespace mbts.spark { _working_best_ask.on_next_distinct(_order_summarizer.best_working_ask, ref dirty); _inside_bids.on_next_distinct(_order_summarizer.best_working_bid >= bid_price, ref dirty); _inside_asks.on_next_distinct(_order_summarizer.best_working_ask <= ask_price, ref dirty); - RaisePropertyChanged(nameof(working_bids_text), nameof(working_asks_text)); + + // Here we need to RaisePropertyChanged for the non-Property<> cols that are bound to a filter + // (Property implements INotifyPropretyChanged, so this is taken for us autmagically) + // This is so that when the data changes behind the filter, the filter runs again for evaulation + // on whether to show or hide the row + RaisePropertyChanged( + nameof(security), + nameof(volume), + // last price is a Property<> + nameof(last_size), + nameof(position), + nameof(working_bid_volume), + nameof(bid_implied_size), + nameof(bid_direct_size), + nameof(bid_merged_size), + // bid price is a Property<> + // ask price is a Property<> + nameof(ask_merged_size), + nameof(ask_direct_size), + nameof(ask_implied_size), + nameof(working_ask_volume), + // setlltement is a Property<> + // change is a Property<> + // low is a Property<> + // high is a Property<> + nameof(security_key), + + nameof(working_bids_text), + nameof(working_asks_text) + ); } #endregion From 631158ebbc9503e542e201eab20b2164131330eb Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 5 Dec 2018 16:07:44 -0600 Subject: [PATCH 2/6] PR suggestions --- .../Market/MarketView/MarketViewRow.cs | 36 +++++++++---------- .../view/Controls/DIYGrid/CellProperty.cs | 14 +++++--- .../spark/view/Spark/PAndL/PnLSummaryRow.cs | 14 ++++---- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs index 73a84082c..e4e5e6e9b 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs @@ -45,28 +45,28 @@ namespace mbts.spark { _security_text = smd.security.ToString(); _security_key_text = security_key.ToString(); string format_price(double price) => security.ContractSpec.format(price); - _position = new CellProperty(0); + _position = new CellProperty(this, nameof(position), 0); _bid_price = backing(nameof(bid_price), double.NaN); _ask_price = backing(nameof(ask_price), double.NaN); _last_price = backing(nameof(last_price), double.NaN); - _last_size = new CellProperty(0); + _last_size = new CellProperty(this, nameof(last_size), 0); _day_change = backing(nameof(day_change), double.NaN); _session_low = backing(nameof(session_low), double.NaN); _session_high = backing(nameof(session_high), double.NaN); _settlement = backing(nameof(settlement), double.NaN); - _volume = new CellProperty(0); - _inside_bids = new CellProperty(); - _inside_asks = new CellProperty(); - _working_bid_volume = new CellProperty(); - _working_ask_volume = new CellProperty(); + _volume = new CellProperty(this, nameof(volume), 0); + _inside_bids = new CellProperty(this, nameof(inside_bids)); + _inside_asks = new CellProperty(this, nameof(inside_asks)); + _working_bid_volume = new CellProperty(this, nameof(working_bid_volume)); + _working_ask_volume = new CellProperty(this, nameof(working_ask_volume)); // _working_orders = new ObservableFilterCollection(_orders, o => o.is_active()); _working_bids = new ObservableFilterCollection(_working_orders, o => o.Def.Side == Side.Buy); _working_asks = new ObservableFilterCollection(_working_orders, o => o.Def.Side == Side.Sell); - _working_best_bid = new CellProperty(format_price, double.NaN); - _working_best_ask = new CellProperty(format_price, double.NaN); - _working_bids_text = new CellProperty(string.Empty); - _working_asks_text = new CellProperty(string.Empty); + _working_best_bid = new CellProperty(this, nameof(working_best_bid), format_price, double.NaN); + _working_best_ask = new CellProperty(this, nameof(working_best_ask), format_price, double.NaN); + _working_bids_text = new CellProperty(this, nameof(working_bids_text), string.Empty); + _working_asks_text = new CellProperty(this, nameof(working_asks_text), string.Empty); // default_command = new DelegateCommand(_show_ladder); bid_price_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.Bid)); @@ -267,17 +267,17 @@ namespace mbts.spark { _inside_bids.on_next_distinct(_order_summarizer.best_working_bid >= bid_price, ref dirty); _inside_asks.on_next_distinct(_order_summarizer.best_working_ask <= ask_price, ref dirty); - // Here we need to RaisePropertyChanged for the non-Property<> cols that are bound to a filter - // (Property implements INotifyPropretyChanged, so this is taken for us autmagically) + // Here we need to RaisePropertyChanged for the non-Property/CellProperty<> cols that are bound to a filter + // (Property and CellProperty implement INotifyPropretyChanged and/or IRaiseNotifyPropertyChanged, so this is taken care of for us autmagically) // This is so that when the data changes behind the filter, the filter runs again for evaulation // on whether to show or hide the row RaisePropertyChanged( nameof(security), - nameof(volume), + // volume is a CellProperty<> // last price is a Property<> - nameof(last_size), - nameof(position), - nameof(working_bid_volume), + // last_size is a CellProperty<> + // position is a CellProperty<> + // working_bid_volume is a CellProperty<> nameof(bid_implied_size), nameof(bid_direct_size), nameof(bid_merged_size), @@ -286,7 +286,7 @@ namespace mbts.spark { nameof(ask_merged_size), nameof(ask_direct_size), nameof(ask_implied_size), - nameof(working_ask_volume), + // working_ask_volume is a CellProperty // setlltement is a Property<> // change is a Property<> // low is a Property<> diff --git a/src/client/spark/view/Controls/DIYGrid/CellProperty.cs b/src/client/spark/view/Controls/DIYGrid/CellProperty.cs index 758d0474d..754ee552d 100644 --- a/src/client/spark/view/Controls/DIYGrid/CellProperty.cs +++ b/src/client/spark/view/Controls/DIYGrid/CellProperty.cs @@ -1,16 +1,21 @@ -using System; +using mbts.ui.shell; +using System; using System.Reactive.Linq; using System.Reactive.Subjects; namespace mbts.spark { class CellProperty : ISubject { readonly Func _format; + readonly IRaiseNotifyPropertyChanged _owner; + readonly string _prop_name; string _text; - public CellProperty(T initial_value = default) - : this(t => t.ToString(), initial_value) { } + public CellProperty(IRaiseNotifyPropertyChanged owner, string prop_name, T initial_value = default) + : this(owner, prop_name, t => t.ToString(), initial_value) { } - public CellProperty(Func format, T initial_value = default) { + public CellProperty(IRaiseNotifyPropertyChanged owner, string prop_name, Func format, T initial_value = default) { + _owner = owner; + _prop_name = prop_name; _format = format; value = initial_value; } @@ -24,6 +29,7 @@ namespace mbts.spark { if (!value.Equals(this.value)) { OnNext(value); dirty = true; + _owner.raise_notify_property_changed(_prop_name); } } diff --git a/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs b/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs index c571fbd3b..a107179d3 100644 --- a/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs +++ b/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs @@ -15,7 +15,7 @@ namespace mbts.spark { class PnLSummaryRow : ViewModelBase, IEquatable, DIYGrid.IRowVM { static readonly SignedDataStore _brushes; readonly PnLDoubleBrushCell _start_pnl, _day_pnl, _total_pnl; - readonly PnLPriceCell _pnl_price, _weighted_average_buy, _weighted_average_sell; + readonly CellProperty _pnl_price, _weighted_average_buy, _weighted_average_sell; (string account, Venue? exchange, string symbol, SecurityImmutable? security, SecurityMD? sec_md, SecurityType? sec_type) key; IEnumerable _fills; double _driver; @@ -38,9 +38,9 @@ namespace mbts.spark { day_short_quantity = day_sell_quant; total_net_position = net_pos; start_net_position = sod_pos; - _pnl_price = new PnLPriceCell(this, nameof(pnl_price)); - _weighted_average_buy = new PnLPriceCell(this, nameof(weighted_average_buy), wavg_buy); - _weighted_average_sell = new PnLPriceCell(this, nameof(weighted_average_sell), wavg_sell); + _pnl_price = new CellProperty(this, nameof(pnl_price), price => this.security.spec_or_default().format(price), 0); + _weighted_average_buy = new CellProperty(this, nameof(weighted_average_buy), price => this.security.spec_or_default().format(price), wavg_buy); + _weighted_average_sell = new CellProperty(this, nameof(weighted_average_sell), price => this.security.spec_or_default().format(price), wavg_sell); _fills = fills; // set the initial pnl and pnl_price when there has been a @@ -193,10 +193,9 @@ namespace mbts.spark { class PnLDoubleBrushCell : CellProperty { Brush _background; - public PnLDoubleBrushCell(PnLSummaryRow owner, string prop) : base(d => double.IsNaN(d) ? string.Empty : d.ToString("N2"), double.NaN) => + public PnLDoubleBrushCell(PnLSummaryRow owner, string prop) : base(owner, prop, d => double.IsNaN(d) ? string.Empty : d.ToString("N2"), double.NaN) => _value_set += _ => { _background = null; - owner.RaisePropertyChanged(prop); }; public Brush background => _background ?? (_background = _brushes.get(value)); @@ -204,8 +203,7 @@ namespace mbts.spark { class PnLPriceCell : CellProperty { public PnLPriceCell(PnLSummaryRow owner, string prop, double init = 0) - : base(price => owner.security.spec_or_default().format(price), init) => - _value_set += _ => owner.RaisePropertyChanged(prop); + : base(owner, prop, price => owner.security.spec_or_default().format(price), init) { } } } } \ No newline at end of file From fba8233c639683481c7eba2271fd2bff9ec6451e Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 5 Dec 2018 16:09:53 -0600 Subject: [PATCH 3/6] Removing PnLPriceCell which is no longer used after previous PR edits --- src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs b/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs index a107179d3..0b276cc26 100644 --- a/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs +++ b/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs @@ -201,9 +201,5 @@ namespace mbts.spark { public Brush background => _background ?? (_background = _brushes.get(value)); } - class PnLPriceCell : CellProperty { - public PnLPriceCell(PnLSummaryRow owner, string prop, double init = 0) - : base(owner, prop, price => owner.security.spec_or_default().format(price), init) { } - } } } \ No newline at end of file From bdbf7e53e884dcd3e2a7e0a5018416bbc3b0fe68 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Thu, 6 Dec 2018 12:48:32 -0600 Subject: [PATCH 4/6] more PR edits --- .../Market/MarketView/MarketViewRow.cs | 64 +++++++------------ 1 file changed, 24 insertions(+), 40 deletions(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs index e4e5e6e9b..4dce5ec3a 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs @@ -35,7 +35,7 @@ namespace mbts.spark { readonly CellProperty _working_bids_text, _working_asks_text; readonly MyOrderSummarizer _order_summarizer = new MyOrderSummarizer(); readonly MDDisplayHelper.SizeFormatter _size_formatter = MDDisplayHelper.get_formatter(MarketSizeDisplay.get_default()); - uint _bid_direct_size, _bid_merged_size, _ask_direct_size, _ask_merged_size; + Property _bid_direct_size, _bid_merged_size, _ask_direct_size, _ask_merged_size; string _bid_merged_size_text, _ask_merged_size_text; ulong _bbo_ref, _last_ref; @@ -60,6 +60,11 @@ namespace mbts.spark { _working_bid_volume = new CellProperty(this, nameof(working_bid_volume)); _working_ask_volume = new CellProperty(this, nameof(working_ask_volume)); // + _bid_direct_size = backing(nameof(bid_direct_size), default(uint)); + _bid_merged_size = backing(nameof(bid_merged_size), default(uint)); + _ask_direct_size = backing(nameof(ask_direct_size), default(uint)); + _ask_merged_size = backing(nameof(ask_merged_size), default(uint)); + // _working_orders = new ObservableFilterCollection(_orders, o => o.is_active()); _working_bids = new ObservableFilterCollection(_working_orders, o => o.Def.Side == Side.Buy); _working_asks = new ObservableFilterCollection(_working_orders, o => o.Def.Side == Side.Sell); @@ -100,15 +105,15 @@ namespace mbts.spark { public double last_price => _last_price.Value; public uint last_size => _last_size.value; public double bid_price => _bid_price.Value; - public uint bid_direct_size => _bid_direct_size; - public uint bid_implied_size => _bid_merged_size - _bid_direct_size; - public uint bid_merged_size => _bid_merged_size; - public string bid_merged_size_text => _bid_merged_size_text ?? (_bid_merged_size_text = _size_formatter(_bid_merged_size, bid_implied_size)); + public uint bid_direct_size => _bid_direct_size.Value; + public uint bid_implied_size => _bid_merged_size.Value - _bid_direct_size.Value; + public uint bid_merged_size => _bid_merged_size.Value; + public string bid_merged_size_text => _bid_merged_size_text ?? (_bid_merged_size_text = _size_formatter(_bid_merged_size.Value, bid_implied_size)); public double ask_price => _ask_price.Value; - public uint ask_direct_size => _ask_direct_size; - public uint ask_implied_size => _ask_merged_size - _ask_direct_size; - public uint ask_merged_size => _ask_merged_size; - public string ask_merged_size_text => _ask_merged_size_text ?? (_ask_merged_size_text = _size_formatter(_ask_merged_size, ask_implied_size)); + public uint ask_direct_size => _ask_direct_size.Value; + public uint ask_implied_size => _ask_merged_size.Value - _ask_direct_size.Value; + public uint ask_merged_size => _ask_merged_size.Value; + public string ask_merged_size_text => _ask_merged_size_text ?? (_ask_merged_size_text = _size_formatter(_ask_merged_size.Value, ask_implied_size)); public ulong volume => _volume.value; public double settlement => _settlement.Value; public double day_change => _day_change.Value; @@ -144,9 +149,9 @@ namespace mbts.spark { bool dirty = false; if (md.md.get_bbo(ref _bbo_ref, out NativePriceSize b, out NativePriceSize a)) { _bid_price.set(b.price); - refresh_size(ref b, ref _bid_direct_size, ref _bid_merged_size, ref _bid_merged_size_text, nameof(bid_merged_size_text)); + refresh_size(ref b, _bid_direct_size, _bid_merged_size, ref _bid_merged_size_text, nameof(bid_merged_size_text)); _ask_price.set(a.price); - refresh_size(ref a, ref _ask_direct_size, ref _ask_merged_size, ref _ask_merged_size_text, nameof(ask_merged_size_text)); + refresh_size(ref a, _ask_direct_size, _ask_merged_size, ref _ask_merged_size_text, nameof(ask_merged_size_text)); _inside_bids.on_next_distinct(_bid_price.Value >= _working_best_bid.value, ref dirty); _inside_asks.on_next_distinct(_ask_price.Value <= _working_best_ask.value, ref dirty); } @@ -162,10 +167,10 @@ namespace mbts.spark { if (dirty) invalidated?.Invoke(); - void refresh_size(ref NativePriceSize nps, ref uint direct, ref uint merged, ref string text, string text_prop) { - if (nps.size != merged || nps.direct_size != direct) { - merged = nps.size; - direct = nps.direct_size; + void refresh_size(ref NativePriceSize nps, Property direct, Property merged, ref string text, string text_prop) { + if (nps.size != merged.Value || nps.direct_size != direct.Value) { + merged.set(nps.size); + direct.set(nps.direct_size); text = null; dirty = true; RaisePropertyChanged(text_prop); @@ -267,32 +272,11 @@ namespace mbts.spark { _inside_bids.on_next_distinct(_order_summarizer.best_working_bid >= bid_price, ref dirty); _inside_asks.on_next_distinct(_order_summarizer.best_working_ask <= ask_price, ref dirty); - // Here we need to RaisePropertyChanged for the non-Property/CellProperty<> cols that are bound to a filter - // (Property and CellProperty implement INotifyPropretyChanged and/or IRaiseNotifyPropertyChanged, so this is taken care of for us autmagically) - // This is so that when the data changes behind the filter, the filter runs again for evaulation - // on whether to show or hide the row RaisePropertyChanged( - nameof(security), - // volume is a CellProperty<> - // last price is a Property<> - // last_size is a CellProperty<> - // position is a CellProperty<> - // working_bid_volume is a CellProperty<> - nameof(bid_implied_size), - nameof(bid_direct_size), - nameof(bid_merged_size), - // bid price is a Property<> - // ask price is a Property<> - nameof(ask_merged_size), - nameof(ask_direct_size), - nameof(ask_implied_size), - // working_ask_volume is a CellProperty - // setlltement is a Property<> - // change is a Property<> - // low is a Property<> - // high is a Property<> - nameof(security_key), - + // Implied might not be ever set, so it probably does not RaisePropertyChanged either + // This might be part of the filter funk? + //nameof(bid_implied_size), + //nameof(ask_implied_size), nameof(working_bids_text), nameof(working_asks_text) ); From fc78475037eb1d49aa89108ee3eb69404cc3063e Mon Sep 17 00:00:00 2001 From: Pedro Pinto Date: Mon, 17 Dec 2018 15:59:49 +0000 Subject: [PATCH 5/6] Updated release notes. --- doc/user/docs/release_notes.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/user/docs/release_notes.md b/doc/user/docs/release_notes.md index 57228870c..be23e6659 100644 --- a/doc/user/docs/release_notes.md +++ b/doc/user/docs/release_notes.md @@ -3,7 +3,8 @@ ### Software Development Kit (SDK) Improvements - Added authentication to API calls - +### Bug Fixes + - The Market View form now honors filters when new securities are added ## 1.4.2 From e749a24a775a02ffe07337b8d7b4d4db49621f1d Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Mon, 17 Dec 2018 14:05:48 -0500 Subject: [PATCH 6/6] Fix stream with qualifier broken by api_security merge --- src/lib/api/service_compiler/templates/cpp/client.pb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/api/service_compiler/templates/cpp/client.pb.cc b/src/lib/api/service_compiler/templates/cpp/client.pb.cc index 105646be3..629c29178 100644 --- a/src/lib/api/service_compiler/templates/cpp/client.pb.cc +++ b/src/lib/api/service_compiler/templates/cpp/client.pb.cc @@ -18,7 +18,7 @@ using namespace rxcpp::operators; {{#if server_streaming}} rxcpp::observable<{{cap name}}Update> {{../name}}::subscribe_{{name}}(std::string const&qualifier) { return - _pchannel->subscribe<{{output_type_cpp}}>({{@index}}, "{{name}}/", qualifier) + _pchannel->subscribe<{{output_type_cpp}}>({{@index}}, "{{name}}", qualifier) | (bts::api::reconstitute,const {{key_type.cpptype}}, {{../name}}>()); } rxcpp::observable<{{cap name}}Update> {{../name}}::subscribe_{{name}}() {