diff --git a/src/client/spark/Analytics/MarketImpliedVol/VolSurfaceMDUnit.cs b/src/client/spark/Analytics/MarketImpliedVol/VolSurfaceMDUnit.cs index eeb5a21b6..ca02476c2 100644 --- a/src/client/spark/Analytics/MarketImpliedVol/VolSurfaceMDUnit.cs +++ b/src/client/spark/Analytics/MarketImpliedVol/VolSurfaceMDUnit.cs @@ -29,7 +29,7 @@ namespace mbts.analytics { public VolSurfaceMDUnit(NativePriceSize bid, NativePriceSize ask, double mark_price) - : this(bid.price, bid.size_f, ask.price, ask.size_f, mark_price) { + : this(bid.price, bid.size, ask.price, ask.size, mark_price) { } public bool is_two_sided() { return bid_size != 0 && ask_size != 0; } diff --git a/src/client/spark/Daemons/OrderTicketDaemon.cs b/src/client/spark/Daemons/OrderTicketDaemon.cs index dcbb00aa6..51120dcb0 100644 --- a/src/client/spark/Daemons/OrderTicketDaemon.cs +++ b/src/client/spark/Daemons/OrderTicketDaemon.cs @@ -1,7 +1,7 @@ using bts.api; using bts.api.core; using bts.api.orderman; -using bts.spark; +using bts.config; using mbts; using mbts.config; @@ -29,7 +29,6 @@ namespace bts.shell { readonly IBus _bus; readonly OrdersModel _model; readonly UserSettingsHub _settings_hub; - readonly ErrorReporter _error_reporter; readonly bool _close_on_send; IReadOnlyDictionary _accounts = new Dictionary(0); IReadOnlyDictionary _md_map; @@ -37,14 +36,13 @@ namespace bts.shell { IDisposable _dispose; [ImportingConstructor] - public OrderTicketDaemon(IBus bus, OrdersModel model, UserSettingsHub settings_hub, ErrorReporter error_reporter) - : this(bus, model, settings_hub, error_reporter, Configuration.get().CloseOnSend) { } + public OrderTicketDaemon(IBus bus, OrdersModel model, UserSettingsHub settings_hub) + : this(bus, model, settings_hub, Configuration.get().CloseOnSend) { } - public OrderTicketDaemon(IBus bus, OrdersModel model, UserSettingsHub settings_hub, ErrorReporter error_reporter, bool close_on_send) { + public OrderTicketDaemon(IBus bus, OrdersModel model, UserSettingsHub settings_hub, bool close_on_send) { _bus = bus; _model = model; _settings_hub = settings_hub; - _error_reporter = error_reporter; _close_on_send = close_on_send; _dispose = Disposable.Create( model.on_orders.OnDispatcher().Subscribe(o => _orders = o), @@ -120,18 +118,9 @@ namespace bts.shell { DataContext = new ExistingOrderTicketVM(_model, Observable.Return((md, ori.order)), _bus.subscribe(SparkTags.AccountsTag), - Observable.Return(LadderSettings.Default.calculator_buttons) - ) + Observable.Return(LadderSettings.Default.calculator_buttons), + md?.quantity_display) }); } - - LadderSettings _get_settings(SecurityImmutable sec) { - var settings = _settings_hub.current; - if (settings.ladder_profiles.TryGetFirst( - lsp => lsp.security_criteria.includes(sec), out var lsp)) { - return lsp.value; - } - return null; - } } } diff --git a/src/client/spark/Model/Trading/PositionModel.cs b/src/client/spark/Model/Trading/PositionModel.cs index b32751ac1..15f0e2ba3 100644 --- a/src/client/spark/Model/Trading/PositionModel.cs +++ b/src/client/spark/Model/Trading/PositionModel.cs @@ -13,6 +13,7 @@ namespace Spark.Trading { using mbts.spark; using mbts.ui; + using Spark.Api.Orders; using Spark.Api.Reactive; using Spark.Core; using Spark.Core.Data; @@ -90,7 +91,7 @@ namespace Spark.Trading { (acc_orders, pnl_id) => { var (security, account_id, account) = acc_orders.table.state.Values.TryGetFirst(out var tup) ? - (tup.sec, tup.order.account_id(), tup.order.account()) : + (tup.security, tup.order.account_id(), tup.order.account()) : (null, 0, null); return new PNLRowData(pnl_id, security: security, @@ -105,7 +106,7 @@ namespace Spark.Trading { PNLRowData.key_fn) .Where(t => t.has_changes()) .Cache() - .ToObservable()); + .ToObservable(); merged_positions = bootstraps.emplace( ReconcileReportDataSource.create( diff --git a/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs b/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs index deb33cddf..34e0e8f1f 100644 --- a/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs +++ b/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs @@ -190,14 +190,12 @@ Disposable.Create(() => _vm.request_show_ladder -= show_ladder) }; - var sec_mds_src = _bus.subscribe(SparkTags.SecuritiesTag); - var secs_src = security_criteria_src + var all_sec_mds_src = _bus.subscribe(SparkTags.SecuritiesTag); + var sec_mds_src = security_criteria_src .StartWith(() => _security_criteria) - .SelectSeries(sc => sc.subscribe_map(sec_mds_src)); + .SelectSeries(sc => sc.subscribe_md_map(all_sec_mds_src)); var trades_source = TradesSource.create( - _consumer, - secs_src, - _trade_poll_interval); + _consumer, sec_mds_src, _trade_poll_interval); trades_source = TradesSource.with_greeks(trades_source, _bus.subscribe(SparkTags.Greeks)); trades_source = TradesSource.with_volume( trades_source, _bus.subscribe(SparkTags.SecuritiesTag)); diff --git a/src/client/spark/Modules/Trading/PNL/VM/PNLCellIndexBuilder.cs b/src/client/spark/Modules/Trading/PNL/VM/PNLCellIndexBuilder.cs index 51f5c2ef9..58b5e6fda 100644 --- a/src/client/spark/Modules/Trading/PNL/VM/PNLCellIndexBuilder.cs +++ b/src/client/spark/Modules/Trading/PNL/VM/PNLCellIndexBuilder.cs @@ -84,7 +84,7 @@ namespace bts.shell.pnl { get, get_market, new OrderPriceComparer(), - fmt_qty); + qty_display); public PNLCellVM add_working_short( PNLView.Columns key, @@ -98,7 +98,7 @@ namespace bts.shell.pnl { get, get_market, new ReverseComparer(new OrderPriceComparer()), - fmt_qty); + qty_display); PNLCellVM _add_working( PNLView.Columns key, diff --git a/src/client/spark/Notifications/INotificationService.cs b/src/client/spark/Notifications/INotificationService.cs index 9f3d23ddb..c3662924a 100644 --- a/src/client/spark/Notifications/INotificationService.cs +++ b/src/client/spark/Notifications/INotificationService.cs @@ -65,7 +65,7 @@ namespace bts.shell { var trade_secs_src = trade_criteria_src.SelectSeries(criterias => { var secs = bus.subscribe(SparkTags.SecuritiesTag); if (criterias.is_null_or_empty()) { - return secs.Select(smds => MappedDictionary.create(smds, s => s.security)); + return secs; } // Take a snapshot of 'criterias' (IEnumerable) and store it in a List to: // a) prevent potentially expensive repetative enumeration in the callbacks (for ex, @@ -74,7 +74,7 @@ namespace bts.shell { var criterias_list = criterias.ToList(); return secs.Select(smds => smds.Values.Where(s => criterias_list.Any(c => c.includes(s.security))) - .ToDictionary(s => s.id, s => s.security)); + .ToDictionary(s => s.id)); }); _dispose = Disposable.Create( bus.subscribe(SparkTags.LogActivity).Subscribe(_on_activity), diff --git a/src/client/spark/Orders/ExistingOrderTicketVM.cs b/src/client/spark/Orders/ExistingOrderTicketVM.cs index 266f7be5c..ab6fc7d84 100644 --- a/src/client/spark/Orders/ExistingOrderTicketVM.cs +++ b/src/client/spark/Orders/ExistingOrderTicketVM.cs @@ -29,7 +29,7 @@ namespace mbts.spark { OrdersModel model, IObservable<(SecurityMD? security_md, OrderRecordImmutable order)> order_source, IObservable> accounts_source, - IObservable calculator_buttons + IObservable calculator_buttons, TickDisplaySettingsImmutable? qty_display ) { uint? key = null; diff --git a/src/client/spark_api/MarketData/MDConsumerHandle.cs b/src/client/spark_api/MarketData/MDConsumerHandle.cs index 1241d5107..7dbe0b7a7 100644 --- a/src/client/spark_api/MarketData/MDConsumerHandle.cs +++ b/src/client/spark_api/MarketData/MDConsumerHandle.cs @@ -162,7 +162,7 @@ // Compare bids if (direct.int_price == implied.int_price) { - bid[x] = new NativePriceSize(direct.int_price, direct.size_f, implied.size_f); + bid[x] = new(direct.int_price, direct.size, implied.size); dbid_idx++; ibid_idx++; } @@ -185,7 +185,7 @@ // Compare asks if (direct.int_price == implied.int_price) { - ask[x] = new NativePriceSize(direct.int_price, direct.size_f, implied.size_f); + ask[x] = new(direct.int_price, direct.size, implied.size); dask_idx++; iask_idx++; } diff --git a/src/client/spark_api/MarketData/MarketDataClient.cs b/src/client/spark_api/MarketData/MarketDataClient.cs index 25a402c5c..2950635d1 100644 --- a/src/client/spark_api/MarketData/MarketDataClient.cs +++ b/src/client/spark_api/MarketData/MarketDataClient.cs @@ -100,9 +100,12 @@ namespace bts.md { } } - public IObservable> trades(TradesSubscriptionFilter filter) => - TradesSource.create( - _source.consumer, securities(filter.security_criteria), _poll_interval); + public IObservable> trades(TradesSubscriptionFilter filter) { + var sec_mds = filter.security_criteria is null ? + _source.subscribe_securities() : + filter.security_criteria.subscribe_md_map(_source.subscribe_securities()); + return TradesSource.create(_source.consumer, sec_mds, _poll_interval); + } public IObservable> price_ticker( SecurityCriteria? criteria = null) { diff --git a/src/client/spark_api/MarketData/NativePriceSize.cs b/src/client/spark_api/MarketData/NativePriceSize.cs index 9b37a0861..88777f0d7 100644 --- a/src/client/spark_api/MarketData/NativePriceSize.cs +++ b/src/client/spark_api/MarketData/NativePriceSize.cs @@ -46,7 +46,7 @@ namespace mbts.co2 { public override string ToString() => - $"{price} {size_f} ({implied_size})"; + $"{price} {size} ({implied_size})"; public override bool Equals(object obj) => obj is NativePriceSize p ? Equals(p) : base.Equals(obj); diff --git a/src/client/spark_api/MarketData/PriceSize.cs b/src/client/spark_api/MarketData/PriceSize.cs index f291a1298..89b9f4472 100644 --- a/src/client/spark_api/MarketData/PriceSize.cs +++ b/src/client/spark_api/MarketData/PriceSize.cs @@ -1,9 +1,6 @@ -using bts.api; +namespace bts.md { + using System; -using mbts.co2; - -namespace bts.md -{ using Size = System.Single; public class PriceSize { @@ -21,7 +18,7 @@ namespace bts.md public override string ToString() { return $"{price} {size} {implied_size} "; } - public Object ToJsonObj() => new { + public object ToJsonObj() => new { price = this.price, size = this.size, implied_size = this.implied_size diff --git a/src/client/spark_api/MarketData/TradeInfo.cs b/src/client/spark_api/MarketData/TradeInfo.cs index caeb8a462..327ab2ea9 100644 --- a/src/client/spark_api/MarketData/TradeInfo.cs +++ b/src/client/spark_api/MarketData/TradeInfo.cs @@ -1,4 +1,5 @@ using bts.api; +using bts.api.domain; using bts.co2; using mbts.analytics; @@ -7,7 +8,7 @@ using Spark.Core; namespace mbts.spark { public readonly struct TradeInfo : bts.api.IJsonFormatter { - public readonly SecurityImmutable security; + public readonly SecurityMD security_md; public readonly TradeMessageImmutable trade; public readonly GreeksTuple? greeks_tuple; public readonly double volume; diff --git a/src/client/spark_api/MarketData/TradesSource.cs b/src/client/spark_api/MarketData/TradesSource.cs index 5a361ad5c..247f70777 100644 --- a/src/client/spark_api/MarketData/TradesSource.cs +++ b/src/client/spark_api/MarketData/TradesSource.cs @@ -8,7 +8,6 @@ using mbts.analytics; using mbts.co2; - using Spark.Core.Data; using Spark.Core.Disposables; using Spark.Core.Reactive; @@ -21,19 +20,19 @@ public static class TradesSource { public static IObservable> create( MDConsumer consumer, - IObservable> security_map, + IObservable> security_md_map, TimeSpan poll_interval) => - security_map.Scan( + security_md_map.Scan( (channels: ImmutableDictionary.Empty, active: new List(0)), (channel_data, map) => { var (channels, active) = channel_data; - var products = map.Values.Select(s => s.product()).Distinct(); + var products = map.Values.Select(s => s.security.product()).Distinct(); active = new List(); foreach (var p in products) { if (!channels.TryGetValue(p, out var c)) { c = new ChannelConsumer( consumer.get_channel(p.Symbol, p.Type, p.Exchange), - map.Values.Where(s => s.product().Equals(p))); + map.Values.Where(s => s.security.product().Equals(p))); channels = channels.Add(p, c); } active.Add(c); diff --git a/tools/py/build_sparkd.py b/tools/py/build_sparkd.py index c3b7ed92b..c43313462 100644 --- a/tools/py/build_sparkd.py +++ b/tools/py/build_sparkd.py @@ -5,7 +5,7 @@ import subprocess from cmake.cmake_utils import CMakeCompilerPair, CMakeConfigureCommand from core.argparse_utils import add_toggle_opt, get_arg from core.cmake_utils import CMakeCompilerPair, CMakeConfigureCommand -from core.file_utils import CWD, SparkPaths, as_path, create_dir, ensure_exists, link_dir, unlink +from core.file_utils import CWD, SparkPaths, as_path, create_dir from core.iter_utils import distinct, flatten from core.logging import exit_msg from core.str_utils import wrap_dquotes