From 3ca4cedf54d5b29319687eb26a0da7bfe5326cbe Mon Sep 17 00:00:00 2001 From: John Colvin Date: Sat, 21 Jun 2025 01:38:56 -0400 Subject: [PATCH] ui (mview): Add min order qty/notional value columns --- .../Market/MarketView/MarketViewColumnType.cs | 2 ++ .../Market/MarketView/MarketViewFilterStates.cs | 6 ++++++ .../Modules/Market/MarketView/MarketViewRow.cs | 13 +++++++++++-- .../Modules/Market/MarketView/MarketViewSettings.cs | 2 ++ .../spark/Modules/Market/MarketView/MarketViewVM.cs | 8 ++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewColumnType.cs b/src/client/spark/Modules/Market/MarketView/MarketViewColumnType.cs index d94b54b44..464e2368a 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewColumnType.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewColumnType.cs @@ -40,5 +40,7 @@ namespace mbts.spark { Rho, Currency, CashPerPoint, + MinOrderQuantity, + MinOrderNotional } } diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewFilterStates.cs b/src/client/spark/Modules/Market/MarketView/MarketViewFilterStates.cs index e5845cf4b..98975e205 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewFilterStates.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewFilterStates.cs @@ -130,6 +130,10 @@ namespace bts.shell.market_view { public DoubleMinMaxState rho { get; set; } [ProtoMember(39)] public DoubleMinMaxState cash_per_point { get; set; } + [ProtoMember(40)] + public DoubleMinMaxState min_order_quantity { get; set; } + [ProtoMember(41)] + public DoubleMinMaxState min_order_notional { get; set; } public Func build_predicate() { var pb = new ColumnPredicateBuilder(); @@ -188,6 +192,8 @@ namespace bts.shell.market_view { pb.add_numeric(theta, r => r.theta); pb.add_numeric(rho, r => r.rho); pb.add_numeric(cash_per_point, r => r.cash_per_point); + pb.add_numeric(min_order_quantity, r => r.min_order_quantity); + pb.add_numeric(min_order_notional, r => r.min_order_notional); return pb.to_predicate(); } } diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs index 1389caea4..fbeab5e50 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs @@ -210,6 +210,12 @@ namespace mbts.spark { public uint security_key => security_md.security.Id; public string currency => security_md.security.Currency; public double cash_per_point => security_md.security.ContractSpec.CashPerPoint; + public double min_order_quantity => _spec.QuantityInfos.TryGetFirst(out var qi) + ? qi.TickUnit.safe_divide(qi.TickBase) + : security_md.security.tick_factors().tick_unit_frac(); + public double min_order_notional => _spec.NotionalQuantityInfos.TryGetFirst(out var qi) + ? qi.MinValue + : security_md.security.tick_factors().tick_unit_frac(); public bool inside_bids => _inside_bids.value; public bool inside_asks => _inside_asks.value; @@ -345,6 +351,9 @@ namespace mbts.spark { TickDisplaySettingsImmutable _qty_display => security_md.quantity_display; + ContractSpecificationImmutable _spec => + security_md.security.spec_or_default(); + public string format_price(double price) => security.ContractSpec.format(price); @@ -448,9 +457,9 @@ namespace mbts.spark { _bus.post(SparkTags.ShowOrderTicketTag, get_params(last_price, last_qty)); break; } - + OrderTicketParams get_params(double price, double quantity = 0) => - new(new(new() {SecurityKey = security_key }), price, quantity); + new(new(new() { SecurityKey = security_key }), price, quantity); } void _refresh_orders(ref bool dirty) { diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewSettings.cs b/src/client/spark/Modules/Market/MarketView/MarketViewSettings.cs index 50135ba5a..1b874ff9c 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewSettings.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewSettings.cs @@ -147,6 +147,8 @@ namespace bts.shell.market_view { public static GridColumnSettings theta => _mk(Columns.Theta, "Theta", ColWidth.Greeks, false); public static GridColumnSettings rho => _mk(Columns.Rho, "Rho", ColWidth.Greeks, false); public static GridColumnSettings cash_per_point => _mk(Columns.CashPerPoint, "CPP", ColWidth.Greeks, false); + public static GridColumnSettings min_order_quantity => _mk(Columns.MinOrderQuantity, "Min Order Qty", 60, false); + public static GridColumnSettings min_notional_value => _mk(Columns.MinOrderNotional, "Min Order Notional", 60, false); public static IEnumerable default_sorting_criteria { get { diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs index 67ef1e516..e942f04c3 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs @@ -199,6 +199,8 @@ namespace mbts.spark { add_col(ColKey.Theta, r => fmt_greek(r.theta), nameof(Row.theta), theta_filter, FilterType.DoubleMinMax, ColWidth.Greeks); add_col(ColKey.Rho, r => fmt_greek(r.rho), nameof(Row.rho), rho_filter, FilterType.DoubleMinMax, ColWidth.Greeks); add_col(ColKey.CashPerPoint, r => r.cash_per_point.ToString("0.00#####"), nameof(Row.cash_per_point), cash_per_point_filter, FilterType.DoubleMinMax, ColWidth.Greeks); + add_col(ColKey.MinOrderQuantity, r => r.min_order_quantity.ToString("0.00#####"), nameof(Row.min_order_quantity), min_order_quantity_filter, FilterType.DoubleMinMax, ColWidth.Qty); + add_col(ColKey.MinOrderNotional, r => r.min_order_notional.ToString("0.00#####"), nameof(Row.min_order_notional), min_order_notional_filter, FilterType.DoubleMinMax, ColWidth.Qty); // row vm filter // Althoguh securities are filtered at the row 'model' level (SecurityMD), the column base filters have to be applied at the row vm level, @@ -438,6 +440,8 @@ namespace mbts.spark { public IDataGridColumnPersistentFilter theta_filter { get; } = new DoubleMinMax(r => r.theta, nameof(Row.theta)); public IDataGridColumnPersistentFilter rho_filter { get; } = new DoubleMinMax(r => r.rho, nameof(Row.rho)); public IDataGridColumnPersistentFilter cash_per_point_filter { get; } = new DoubleMinMax(r => r.cash_per_point, nameof(Row.cash_per_point)); + public IDataGridColumnPersistentFilter min_order_quantity_filter { get; } = new DoubleMinMax(r => r.min_order_quantity, nameof(Row.min_order_quantity)); + public IDataGridColumnPersistentFilter min_order_notional_filter { get; } = new DoubleMinMax(r => r.min_order_notional, nameof(Row.min_order_notional)); IEnumerable> _all_filters => _filter_getters.Select(g => g(this)); @@ -480,6 +484,8 @@ namespace mbts.spark { ColKey.Theta => wrap(r => r.theta), ColKey.Rho => wrap(r => r.rho), ColKey.CashPerPoint => wrap(r => r.cash_per_point), + ColKey.MinOrderQuantity => wrap(r => r.min_order_quantity), + ColKey.MinOrderNotional => wrap(r => r.min_order_notional), _ => null, }; @@ -587,6 +593,8 @@ namespace mbts.spark { theta = theta_filter.get_state(), rho = rho_filter.get_state(), cash_per_point = cash_per_point_filter.get_state(), + min_order_quantity = min_order_quantity_filter.get_state(), + min_order_notional = min_order_notional_filter.get_state(), }; public void load_filters(MarketViewFilterStates filters) {