diff --git a/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs b/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs index 33c002cb8..bcc02c483 100644 --- a/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs +++ b/src/client/spark/Modules/Trading/Ladder/VM/LadderOrderVM.cs @@ -46,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?, AlgoDefinitionMetadata?) op, double real_price, LadderVM owner, IBus bus, IObservable bs) { + public LadderOrderVM((OrderRecordImmutable, uint?, AlgoData?, AlgoDefinitionMetadata?) op, double real_price, LadderVM owner, IBus bus, IObservable bs) { _owner = owner; _bus = bus; _bs = bs; @@ -114,7 +114,7 @@ namespace mbts.spark { 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; + algo_studio_abbreviation = string.IsNullOrEmpty(opm.meta?.abbreviation) ? _generate_abbreviation_for_algo_studio_algo(opm.algo) : opm.meta?.abbreviation; border = opm.meta?.badge_color?.rgb_color().rgb_brush() ?? border; } if (single_order.order_type().is_bts_algo_type()) { @@ -131,6 +131,25 @@ namespace mbts.spark { _set_badge_text(); + string _generate_abbreviation_for_algo_studio_algo(AlgoData? a) { + char[] delim = { ' ' }; + if (a.HasValue) { + var algo_name = a.Value.name; + var words = algo_name.Split(delim); + if (words.Length == 1) { + var single_word = words[0]; + if (single_word.Length > 1) { + return words[0].Substring(0, 2).ToUpper(); + } else { + return single_word; + } + } else { + return words.Take(2).Select(w => w.Substring(0, 1)).list_string(string.Empty).ToUpper(); + } + } + return string.Empty; + } + } private void _set_badge_text() { @@ -138,7 +157,7 @@ namespace mbts.spark { RaisePropertyChanged(nameof(text_lines)); } - public void add_order((OrderRecordImmutable order, uint? p, AlgoDefinitionMetadata? meta) new_op) { + public void add_order((OrderRecordImmutable order, uint? p, AlgoData? algo, AlgoDefinitionMetadata? meta) new_op) { _orders[new_op.order.Key] = new_op; } diff --git a/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs b/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs index f04b526bf..9a650fb04 100644 --- a/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs +++ b/src/client/spark/Modules/Trading/Ladder/VM/LadderVM.cs @@ -180,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, os.meta)); + slot_vm.add_order((wo, os.piq, os.algo, os.meta)); } else { - slot_vm = new LadderOrderVM((wo, os.piq, os.meta), slot_price_target, this, _bus, _settings_manager.subscribe_current().Select(s => s.badge_style)); + slot_vm = new LadderOrderVM((wo, os.piq, os.algo, 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; } @@ -326,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? _, AlgoDefinitionMetadata? meta) op) { + internal OrderRecordImmutable get_root_at_price((OrderRecordImmutable order, uint? _, AlgoData? __, AlgoDefinitionMetadata? meta) op) { var order = op.order; double p = order.price(); foreach (var o in lineage(order.ParentKey)) {