diff --git a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml index fc8977181..49bfb654f 100644 --- a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml +++ b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml @@ -420,7 +420,6 @@ - , IHaveFontParams + { + IDictionary _value_store = new Dictionary(); + public QuoteQueueHolderModel() + { + } + public override string display_name { get; } = "Queue Holder Length"; + public override string help_text { get; } = "How many levels of queue to hold"; + public override string man_page { get; } = string.Empty; + public override ParameterSection[] section_path { get; } = new[] { Sections.Quote }; + public FontWeight font_weight => FontWeights.SemiBold; + + public void apply_value(LegSpreaderParamsTuple leg_tup) => + leg_tup.leg_params.QuoteParams.NQueueHolderOrders = _value_from_store(leg_tup); + + public override uint get_value(LegSpreaderParamsTuple leg_tup) => + _get_value(leg_tup).NQueueHolderOrders; + + public override void set_value(LegSpreaderParamsTuple leg_tup, uint value) + { + _value_store[leg_tup.SecurityKey] = value; + leg_tup.leg_params.QuoteParams.NQueueHolderOrders = value ; + } + + protected override bool _get_enabled(LegSpreaderParamsTuple leg_tup) => + _get_value(leg_tup) != null; + + QuoteParams _get_value(LegSpreaderParamsTuple leg_tup) => + leg_tup.leg_params.QuoteParams; + + uint _value_from_store(LegSpreaderParamsTuple leg_tup) => + _value_store.GetValueOrDefault(leg_tup.SecurityKey, _ => 0u); + } + } +} \ No newline at end of file diff --git a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs index 334651129..297cf49d9 100644 --- a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs +++ b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs @@ -200,14 +200,16 @@ namespace mbts.spark { var post_hedge_opposite_market_based_cross_threshold = new PostHedgeOppositeMarketVolumeBasedCrossThresholdModel(); var post_hedge_opposite_market_based_cross_cross_ticks = new PostHedgeOppositeMarketVolumeBasedCrossCrossTicksModel(); + var is_quote_model = new IsQuoteModel(); rows = new IRowModel[] { _quantity_model, _price_mult_model, - new IsQuoteModel(), + is_quote_model, //new EnableHedgeModel(), //TAHA_SPREADER new HedgeRatioModel(), //new MinLeanQtyModel(), //TAHA_SPREADER //new QuoteHiddenModel(), + new QuoteQueueHolderModel(), new MarketDataTypeModel(), new QuoteThrottleEnabledModel(quote_throttle_inside_ticks, quote_throttle_outside_ticks), quote_throttle_inside_ticks, diff --git a/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs b/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs index 2f0b8baa7..33c002cb8 100644 --- a/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs +++ b/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs @@ -37,6 +37,7 @@ namespace mbts.spark { readonly Property _foreground, _background, _hoverbackground, _border; readonly Property _has_multiple_orders_at_same_level, _is_hedge_order; readonly Property _algo_type; + readonly Property _algo_studio_abbreviation; IObservable _bs; LadderSettings.BadgeStyle _current_badge_style; int _n_active_price_change_ops = 0; @@ -45,9 +46,9 @@ namespace mbts.spark { int working_quantity; LadderModel model => _owner.model; - Dictionary _orders = new Dictionary(); + Dictionary _orders = new Dictionary(); - public LadderOrderVM((OrderRecordImmutable, uint?) op, double real_price, LadderVM owner, IBus bus, IObservable bs) { + public LadderOrderVM((OrderRecordImmutable, uint?, AlgoDefinitionMetadata?) op, double real_price, LadderVM owner, IBus bus, IObservable bs) { _owner = owner; _bus = bus; _bs = bs; @@ -64,6 +65,7 @@ namespace mbts.spark { _has_multiple_orders_at_same_level = backing(nameof(has_multiple_orders_at_same_level), false); _is_hedge_order = backing(nameof(is_hedge_order), false); _algo_type = backing(nameof(algo_type), CustomOrderDefinition.CustomOneofCase.None); + _algo_studio_abbreviation = backing(nameof(algo_studio_abbreviation), string.Empty); FontFamily get_font_family(LadderSettings s) => new FontFamily(s.orders_column.font_family); FontWeight get_font_weight(LadderSettings s) => ui.utility.text.TextUtils.from_open_type_weight_safe(s.orders_column.font_weight); double get_font_size(LadderSettings s) => s.orders_column.font_size; @@ -111,6 +113,10 @@ namespace mbts.spark { var single_order = _root_nodes().First(); var single_order_metadata = _owner.model.order_gateway.factory.get_metadata(single_order); border = single_order_metadata.Color.rgb_brush(); + if (_orders.TryGetValue(single_order.Key, out var opm)) { + algo_studio_abbreviation = opm.meta?.abbreviation ?? string.Empty; + border = opm.meta?.badge_color?.rgb_color().rgb_brush() ?? border; + } if (single_order.order_type().is_bts_algo_type()) { algo_type = single_order.order_type(); } else { @@ -132,7 +138,7 @@ namespace mbts.spark { RaisePropertyChanged(nameof(text_lines)); } - public void add_order((OrderRecordImmutable order, uint? p) new_op) { + public void add_order((OrderRecordImmutable order, uint? p, AlgoDefinitionMetadata? meta) new_op) { _orders[new_op.order.Key] = new_op; } @@ -186,6 +192,7 @@ namespace mbts.spark { public bool has_multiple_orders_at_same_level { get => _has_multiple_orders_at_same_level.Value; private set => _has_multiple_orders_at_same_level.Value = value; } public bool is_hedge_order { get => _is_hedge_order.Value; private set => _is_hedge_order.Value = value; } public CustomOrderDefinition.CustomOneofCase algo_type { get => _algo_type.Value; private set => _algo_type.Value = value; } + public string algo_studio_abbreviation { get => _algo_studio_abbreviation.Value; private set => _algo_studio_abbreviation.Value = value; } public IReadOnlyList order_keys => _orders.Keys.ToReadOnlyList(); public IEnumerable root_orders => _root_nodes(); diff --git a/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs b/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs index 56e3ff166..6972c606b 100644 --- a/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs +++ b/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs @@ -145,10 +145,25 @@ namespace mbts.spark { account_positions, size_calculator = new CalculatorLogic(0, _settings_manager.subscribe_current().Select(s => s.calculator_buttons)), bus.subscribe(SparkTags.LogActivity).OnDispatcher().Subscribe(status_update), + // we need to hook this up to model.orders which is filtered for just the security model.order_gateway.working_orders_with_piq.OnDispatcher().Subscribe(working => { // Here we manage N orders to 1 price slot in the ladder Dictionary> orders_used_in_this_update = new Dictionary>(_equality); - _cache = working; + + // In master we originally had something similar to this snippet to restrict the foreach to just the orders + // for this ladder. In 1944, at one point we made use of model.orders, which made use of the on_security_working_orders demuxer. + // When we merged PIQ into 1944, we moved from that demuxer to working_orders_with_piq, so we reintroduce this little snippet here + // to once again restrict the processing to those working orders that match the criteria. Check with John to see if we can + // make a demuxer from working_orders_with_piq, which is an IReadOnlyDictionary; that probably won't work, but I have no doubt + // there is a better way. + var ladders_orders = + working.Values + .Where(o => + o.order.Def.SecurityKey == security.Id && + (o.order.HasState && o.order.State.DisplayStatus == OrderState.Types.DisplayStatus.Visible)) + .ToReadOnlyDictionary(os => os.order.Key, os => os); + + _cache = ladders_orders; foreach (var os in _cache.Values) { var wo = os.order; @@ -165,9 +180,9 @@ namespace mbts.spark { } if (_slot_price_vs_orders.TryGetValue(slot_price_target, out LadderOrderVM slot_vm)) { - slot_vm.add_order((wo, os.piq)); + slot_vm.add_order((wo, os.piq, os.meta)); } else { - slot_vm = new LadderOrderVM((wo, os.piq), slot_price_target, this, _bus, _settings_manager.subscribe_current().Select(s => s.badge_style)); + slot_vm = new LadderOrderVM((wo, os.piq, os.meta), slot_price_target, this, _bus, _settings_manager.subscribe_current().Select(s => s.badge_style)); _slot_price_vs_orders[slot_price_target] = slot_vm; } @@ -311,7 +326,7 @@ namespace mbts.spark { public uint volume_column_width { get => _volume_column_width.Value; set => _volume_column_width.set(value); } internal LadderModel model => _model; internal IObservable settings => _settings_manager.subscribe_current(); - internal OrderRecordImmutable get_root_at_price((OrderRecordImmutable order, uint? _) op) { + internal OrderRecordImmutable get_root_at_price((OrderRecordImmutable order, uint? _, AlgoDefinitionMetadata? meta) op) { var order = op.order; double p = order.price(); foreach (var o in lineage(order.ParentKey)) { diff --git a/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml b/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml index f5355fd6b..7b4a662c2 100644 --- a/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml +++ b/src/client/spark/Modules/Trading/Ladder/View/LadderView.xaml @@ -489,6 +489,15 @@ + + + + + Auto Clear + + - - - - - Auto Clear -