diff --git a/.vscode/launch.json b/.vscode/launch.json index 0cd375b54..fd68a6626 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -75,6 +75,7 @@ "name": "SparkVM Launch", "type": "cppdbg", "request": "launch", + "program": "/home/bts/spark/build/ninja_debug/server/sparkd", "args": ["run"], "stopAtEntry": false, @@ -96,7 +97,12 @@ "description": "Skip STL", "text": "skip -gfi /usr/include/c++/7/bits/*.h", "ignoreFailures": true - } + }, + { + "description": "LD LIBRARY", + "text": "set env LD_LIBRARY_PATH=.", + "ignoreFailures": false + } ], "pipeTransport": { "pipeCwd": "${workspaceRoot}", @@ -208,10 +214,10 @@ "name": "MD Tests", "type": "cppdbg", "request": "launch", - "program": "/home/bts/spark/build/ninja_debug/src/server/sparkd/sparkd", + "program": "/home/bts/spark/build/ninja_debug/server/sparkd", "args": ["test", "[md]"], "stopAtEntry": false, - "cwd": "/home/bts/spark/build/ninja_debug/src/server/sparkd/", + "cwd": "/home/bts/spark/build/ninja_debug/server/", "environment": [], "externalConsole": true, "MIMode": "gdb", diff --git a/CMakeLists.txt b/CMakeLists.txt index a4395bfcf..be98723f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,8 @@ else () COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/web ${CMAKE_BINARY_DIR}/server COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/data_files ${CMAKE_BINARY_DIR}/server COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/lib/libspark.so ${CMAKE_BINARY_DIR}/server + COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.13.0.0 ${CMAKE_BINARY_DIR}/server + COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libACE-5.7.5.so ${CMAKE_BINARY_DIR}/server COMMAND mkdir ARGS -p ${CMAKE_BINARY_DIR}/server/plugins COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/sdk/examples/order_plugin_example.so ${CMAKE_BINARY_DIR}/server/plugins/ COMMENT "Creating server runtime layout" diff --git a/doc/user/content/bts_spark/Spreader/index.md b/doc/user/content/bts_spark/Spreader/index.md index 56ae31714..a69a3731e 100644 --- a/doc/user/content/bts_spark/Spreader/index.md +++ b/doc/user/content/bts_spark/Spreader/index.md @@ -5,6 +5,7 @@ sort_by = "weight" insert_anchor_links = "right" +++ +{{ youtube(id="RZU9Wj0cETo") }}
diff --git a/doc/user/content/bts_spark/Trading/index.md b/doc/user/content/bts_spark/Trading/index.md index bdca5dc4b..1edcf1850 100644 --- a/doc/user/content/bts_spark/Trading/index.md +++ b/doc/user/content/bts_spark/Trading/index.md @@ -406,6 +406,8 @@ insert_anchor_links = "right" ## Algo Studio +{{ youtube(id="DHIa5tnifKc") }} + - The BTS Algo Studio was built for users to experience algo composability never seen before in a professional futures trading system. diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index d8d3199cd..71d637fd7 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -4,6 +4,26 @@ weight = 3 sort_by = "weight" insert_anchor_links = "right" +++ +## 1.5.7 +### User Visible Changes + - New videos have been added to the manual describing the [Algo Studio](./bts_spark/Trading/index.md#algo-studio) and [Spreader](./bts_spark/Spreader/index.md) + - Fixed a bug that occasionally would cause windows to be position outside the visible screen on startup + - Fixed a bug in the order book form that would occasionally cause the Recreate Order option to be unavailable + - Added a confirmation step to Cancel All, Cancel Buys and Cancel Sells commands + - Fixed Aggressor coloring and ladder high/low coloring in the SIM execution gateway + - Added initial support for ICE market data + - In an effort to streamline the PnL report we've made the following changes: + - The PnL report will by default filter for Futures contracts only + - If you wish to see Spread contracts again you may change Security Type column filter + - The PnL report will now only show rows in which there is a position (net and/or day) + - The Exchange, Start PnL, Total Net Pos, and Total Net PnL columns are now hidden by default + - These columns can be restored by toggling their visibility within the PnL's Settings form + - A new Traded Today column has been added to the PnL + - Filtering on this column will allow a user to restrict the report to only show today's position +### Internal changes + - Improved organization of the shell notification architecture + - Added logging to help troubleshoot shell exit hang + ## 1.5.6 ### User Visible Changes - Fixed a bug that could cause limits to be erroneously enforced diff --git a/doc/user/sass/book.scss b/doc/user/sass/book.scss index 207cac8b0..af81ecfc1 100644 --- a/doc/user/sass/book.scss +++ b/doc/user/sass/book.scss @@ -54,3 +54,8 @@ img { background: #ccc; border: 1px solid #aaa; } + +iframe { + width:560px; + height:315px; +} \ No newline at end of file diff --git a/ops_notes.txt b/ops_notes.txt index 1975dd799..2f9b5a6d5 100644 --- a/ops_notes.txt +++ b/ops_notes.txt @@ -1,3 +1,6 @@ +1.5.7 +- Fixed Aggressor coloring and ladder high/low coloring in SIM + 1.4.2 - Be sure the system has a bts user before deployment. bts is the superuser, he has all permissions and can see all market data - After deployment re-permission all existing users for trading, riskadmin, and/or md admin permissions as appropriate diff --git a/src/client/spark/App.xaml.cs b/src/client/spark/App.xaml.cs index 196a404c2..d19652c96 100644 --- a/src/client/spark/App.xaml.cs +++ b/src/client/spark/App.xaml.cs @@ -66,6 +66,7 @@ namespace mbts.ui.shell protected override void OnExit(ExitEventArgs e) { + Log.Gen.info("Application.OnExit"); if (_runtime != null) _runtime.Dispose(); utils.BTSNativeMethods.finit_spark_lib(); base.OnExit(e); diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs index 5eda77cdf..9f7b69efe 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewRow.cs @@ -137,6 +137,12 @@ namespace mbts.spark { public ICommand ask_implied_size_click { get; } public ICommand working_asks_click { get; } public ICommand default_command { get; } + public string market_description {get;} + public string cleared_alias { get; } + public string product_description { get; } + public string hub_alias { get; } + public string strip_name{ get; } + public string mic_code { get; } public ObservableCollection row_animations { get; } = new ObservableCollection(); diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs index c193f506c..65644a29e 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewVM.cs @@ -57,6 +57,13 @@ namespace mbts.spark { add_col(Columns.SessionLow, "Low", r => r.format_price(r.session_low), nameof(Row.session_low), DefaultColumnWidths.Price, session_low_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right); add_col(Columns.SessionHigh, "High", r => r.format_price(r.session_high), nameof(Row.session_high), DefaultColumnWidths.Price, session_high_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right); add_col(Columns.SecurityKey, "Security Key", r => r.security_key.ToString(), nameof(Row.security_key), DefaultColumnWidths.SecurityKey, security_key_filter, DataGridFilterKnownTemplates.Regex); + + add_col(Columns.MarketDescription, "Market Description", r => r.md.security.HasIce ? r.md.security.Ice.MarketDescription : string.Empty, nameof(Row.market_description), DefaultColumnWidths.SecurityKey, market_description_filter, DataGridFilterKnownTemplates.Regex); + add_col(Columns.ClearedAlias, "Cleared Alias", r => r.md.security.HasIce ? r.md.security.Ice.ClearedAlias : string.Empty, nameof(Row.cleared_alias), DefaultColumnWidths.SecurityKey, cleared_alias_filter, DataGridFilterKnownTemplates.Regex); + add_col(Columns.ProductDescription, "Product Description", r => r.md.security.HasIce ? r.md.security.Ice.ProductName : string.Empty, nameof(Row.product_description), DefaultColumnWidths.SecurityKey, product_description_filter, DataGridFilterKnownTemplates.Regex); + add_col(Columns.HubAlias, "Hub Alias", r => r.md.security.HasIce ? r.md.security.Ice.HubAlias : string.Empty, nameof(Row.hub_alias), DefaultColumnWidths.SecurityKey, hub_alias_filter, DataGridFilterKnownTemplates.Regex); + add_col(Columns.StripName, "Strip Name", r => r.md.security.HasIce ? r.md.security.Ice.StripName : string.Empty, nameof(Row.strip_name), DefaultColumnWidths.SecurityKey, strip_name_filter, DataGridFilterKnownTemplates.Regex); + add_col(Columns.MicCode, "Mic Code", r => r.md.security.HasIce ? r.md.security.Ice.MicCode : string.Empty, nameof(Row.mic_code), DefaultColumnWidths.SecurityKey, mic_code_filter, DataGridFilterKnownTemplates.Regex); // void add_col(Columns col_key, string header, Func get_text, string prop, double width, IDataGridColumnFilter filter, string filter_template, bool is_animatable = false, Color? font_color = null, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) => columns.Add(new RenderTextColumn(col_key, get_text, filter, filter_template) { @@ -194,6 +201,14 @@ namespace mbts.spark { public IDataGridColumnPersistentFilter working_ask_volume_filter { get; } = new IntMinMax(r => r.working_ask_volume, nameof(Row.working_ask_volume)); public IDataGridColumnPersistentFilter volume_filter { get; } = new ULongMinMax(r => r.volume, nameof(Row.volume)); public IDataGridColumnPersistentFilter security_key_filter { get; } = new RegexFilterVM(r => r.security_key.ToString(), nameof(Row.security_key)); + + public IDataGridColumnPersistentFilter market_description_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.MarketDescription : "", nameof(Row.market_description)); + public IDataGridColumnPersistentFilter cleared_alias_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.ClearedAlias : "", nameof(Row.cleared_alias)); + public IDataGridColumnPersistentFilter product_description_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.ProductName : "", nameof(Row.product_description)); + public IDataGridColumnPersistentFilter hub_alias_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.HubAlias : "", nameof(Row.hub_alias)); + public IDataGridColumnPersistentFilter strip_name_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.StripName : "", nameof(Row.strip_name)); + public IDataGridColumnPersistentFilter mic_code_filter { get; } = new RegexFilterVM(r => r.security.HasIce ? r.security.Ice.MicCode : "", nameof(Row.mic_code)); + public FilterStates get_filter_states() { return new FilterStates { @@ -216,7 +231,13 @@ namespace mbts.spark { working_bid_volume = working_bid_volume_filter.get_state(), working_ask_volume = working_ask_volume_filter.get_state(), volume = volume_filter.get_state(), - security_key = security_key_filter.get_state() + security_key = security_key_filter.get_state(), + market_description = market_description_filter.get_state(), + cleared_alias = cleared_alias_filter.get_state(), + product_description = product_description_filter.get_state(), + hub_alias = hub_alias_filter.get_state(), + strip_name = strip_name_filter.get_state(), + mic_code = mic_code_filter.get_state(), }; } #endregion diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs b/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs index 5f4107956..edbea884b 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewView.xaml.cs @@ -8,7 +8,9 @@ namespace mbts.ui.spark { /// Interaction logic for MarketSheetsView.xaml /// partial class MarketViewView : UserControl { - public enum Columns { Security, Volume, Last, LastSize, Position, WorkingBids, Bid, BidMergedSize, BidDirectSize, BidImpliedSize, Ask, AskMergedSize, AskDirectSize, AskImpliedSize, WorkingAsks, Settlement, DayChange, SessionLow, SessionHigh, SecurityKey } + public enum Columns { Security, Volume, Last, LastSize, Position, WorkingBids, Bid, BidMergedSize, BidDirectSize, BidImpliedSize, Ask, AskMergedSize, AskDirectSize, AskImpliedSize, WorkingAsks, Settlement, DayChange, SessionLow, SessionHigh, SecurityKey, + MarketDescription, ClearedAlias, ProductDescription, HubAlias, StripName, MicCode + } public MarketViewView() { InitializeComponent(); diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs index 44759c0c5..38931a3eb 100644 --- a/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs +++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindowFactory.cs @@ -97,6 +97,12 @@ namespace bts.shell { public static GridColumnSettings session_low => new GridColumnSettings(col_id(Columns.SessionLow), DefaultColumnHeaders.SessionLow, width: DefaultColumnWidths.Price, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings session_high => new GridColumnSettings(col_id(Columns.SessionHigh), DefaultColumnHeaders.SessionHigh, width: DefaultColumnWidths.Price, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings security_key => new GridColumnSettings(col_id(Columns.SecurityKey), DefaultColumnHeaders.SecurityKey, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings market_description => new GridColumnSettings(col_id(Columns.MarketDescription), DefaultColumnHeaders.MarketDescription, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings cleared_alias => new GridColumnSettings(col_id(Columns.ClearedAlias), DefaultColumnHeaders.ClearedAlias, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings product_description => new GridColumnSettings(col_id(Columns.ProductDescription), DefaultColumnHeaders.ProductDescription, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings hub_alias => new GridColumnSettings(col_id(Columns.HubAlias), DefaultColumnHeaders.HubAlias, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings strip_name => new GridColumnSettings(col_id(Columns.StripName), DefaultColumnHeaders.StripName, is_visible: false, width: DefaultColumnWidths.SecurityKey); + public static GridColumnSettings mic_code => new GridColumnSettings(col_id(Columns.MicCode), DefaultColumnHeaders.MicCode, is_visible: false, width: DefaultColumnWidths.SecurityKey); @@ -128,6 +134,12 @@ namespace bts.shell { yield return session_low; yield return session_high; yield return security_key; + yield return market_description; + yield return cleared_alias; + yield return product_description; + yield return hub_alias; + yield return strip_name; + yield return mic_code; } } @@ -177,6 +189,18 @@ namespace bts.shell { public UIntMinMaxState ask_direct_size; [ProtoMember(20)] public UIntMinMaxState ask_implied_size; + [ProtoMember(21)] + public string market_description; + [ProtoMember(22)] + public string cleared_alias; + [ProtoMember(23)] + public string product_description; + [ProtoMember(24)] + public string hub_alias; + [ProtoMember(25)] + public string strip_name; + [ProtoMember(26)] + public string mic_code; } } } \ No newline at end of file diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs index 864cdf9ec..734e6e959 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs @@ -6,11 +6,13 @@ using mbts.ui; using mbts.ui.controls; using mbts.ui.shell; using System; +using System.Reactive; using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; +using System.Reactive.Linq; namespace mbts.spark { partial class OrderBookRowVM : DisposableViewModelBase, IEquatable, DIYGrid.IRowVM { @@ -44,6 +46,19 @@ namespace mbts.spark { modify_order_price?.TryRaiseCanExecuteChanged(); } + //// This takes care of the case where the OB has all rows visible + //// and an order is cancelled outside of the OB (say via the ladder). + //// Since the OB window Commands only revaluate their CanExecuteChanged + //// when the OrderBookVM.selected_order_changes, this emulates the selected + //// order changing since the current_row setter invokes the selected_order_changed + //// handler + public IObservable subscribe_data() { + return Observable.FromEvent( + cb => () => cb(order_tuple), + cb => invalidated += cb, + cb => invalidated -= cb); + } + protected override void Dispose(bool disposing) { this.invalidated -= OrderBookRowVM_invalidated; base.Dispose(disposing); diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs index ee9c17ecb..525b0716a 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs @@ -28,7 +28,6 @@ using _GridSettingsManager = mbts.ui.GridSettingsManager< mbts.spark.OrderBookRowVM, bts.api.orderman.OrderSecurity, - bts.shell.INotificationServiceDataCache, mbts.OrderRecordTuplePredicate, bts.shell.OrderBookWindowFactory.OrderBookGridSettings>; using Columns = mbts.spark.OrderBookGridView.ColumnKeys; @@ -428,21 +427,25 @@ namespace mbts.spark { col_settings_flags[c.ToString()] = GridColumnSettingsFeatureFlags.ImmutableFontColor | GridColumnSettingsFeatureFlags.ImmutableFontWeight; } return new _GridSettingsManager( - owner_title, bus, notification_service, model, rows, columns, + owner_title, bus, model, rows, columns, + () => new OrderRecordTuplePredicate(), () => { - var pvm = PredicateBuilderVMWrapper.create( + var pvm = PredicateVMWrapper.create( OrderRecordTuplePredicateVMFactory.get_oneofs(bus, model), rp => rp.predicate_type_case); pvm.selected_predicate_type = pvm.predicate_types.FirstOrDefault(); return pvm; }, col_id => { - var pvm = PredicateBuilderVMWrapper.create( + var pvm = PredicateVMWrapper.create( OrderRecordTuplePredicateVMFactory.get_oneofs(bus, model), rp => rp.predicate_type_case); pvm.selected_predicate_type = _corresponding_predicate_type(EnumHelper.parse_or_default(col_id)); return pvm; }, - (gen, anims) => new OrderBookGridSettings(gen, anims.Select(a => new OrderRecordTuplePredicateAnimations(a.predicate_builder, a.cell_animations, a.row_animations, a.sound_notifications))), - (notification_service == null) ? null : notification_service.data_cache, + (gen, anims) => new OrderBookGridSettings(gen, anims.Select(a => new OrderRecordTuplePredicateAnimations(a.predicate_data, a.cell_animations, a.row_animations, a.sound_notifications))), + p => p.create_predicate(notification_service.data_cache), + p => p.create_notification_predicate(notification_service.data_cache), + notification_service == null ? new Func, SoundNotification, IDisposable>((p, sn) => Disposable.empty) : notification_service.link_to_order, + notification_service == null ? new Func, IDisposable>(t => Disposable.empty) : notification_service.link_to_order, col_settings_flags); } diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs index 1fe500cfe..761e9e6d7 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs @@ -78,17 +78,41 @@ namespace mbts.spark { var cancel_buy_orders_command = SparkCommands.CancelBuyOrders.complete( _model.working_orders.Select(os => os.Values.Where(o => o.order.side() == Side.Buy).Select(o => o.order.Key)), - wbids => wbids.Any() + wbids => wbids.Any(), + () => { + var resp = BTSMessageBox.Show( + "Are you sure you want to cancel all working buy orders?", + "Cancel Buy Orders", + BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No, + MessageBoxImage.Question); + return resp == BTSMessageBoxButtons.Yes; + } ); var cancel_sell_orders_command = SparkCommands.CancelSellOrders.complete( _model.working_orders.Select(os => os.Values.Where(o => o.order.side() == Side.Sell).Select(o => o.order.Key)), - wasks => wasks.Any() + wasks => wasks.Any(), + () => { + var resp = BTSMessageBox.Show( + "Are you sure you want to cancel all working sell orders?", + "Cancel Sell Orders", + BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No, + MessageBoxImage.Question); + return resp == BTSMessageBoxButtons.Yes; + } ); var cancel_all_orders_command = SparkCommands.CancelOrders.complete( _model.working_orders.Select(os => os.Select(o => o.Key)), - worders => worders.Any() + worders => worders.Any(), + () => { + var resp = BTSMessageBox.Show( + "Are you sure you want to cancel all working orders?", + "Cancel All Orders", + BTSMessageBoxButtons.Yes | BTSMessageBoxButtons.No, + MessageBoxImage.Question); + return resp == BTSMessageBoxButtons.Yes; + } ); var cancel_selected_orders_command = SparkCommands.CancelSelectedOrders.complete( diff --git a/src/client/spark/Modules/Trading/PAndLWindowFactory.cs b/src/client/spark/Modules/Trading/PAndLWindowFactory.cs index 27eba0300..486e261a9 100644 --- a/src/client/spark/Modules/Trading/PAndLWindowFactory.cs +++ b/src/client/spark/Modules/Trading/PAndLWindowFactory.cs @@ -84,17 +84,17 @@ namespace bts.shell { static class DefaultColumns { public static GridColumnSettings account => new GridColumnSettings(col_id(Columns.Account), DefaultColumnHeaders.Account, width: DefaultColumnWidths.Account); - public static GridColumnSettings exchange => new GridColumnSettings(col_id(Columns.Exchange), DefaultColumnHeaders.Exchange, width: DefaultColumnWidths.Exchange); + public static GridColumnSettings exchange => new GridColumnSettings(col_id(Columns.Exchange), DefaultColumnHeaders.Exchange, false, width: DefaultColumnWidths.Exchange); public static GridColumnSettings symbol => new GridColumnSettings(col_id(Columns.Symbol), DefaultColumnHeaders.Symbol, width: DefaultColumnWidths.Symbol); public static GridColumnSettings security => new GridColumnSettings(col_id(Columns.Security), DefaultColumnHeaders.Security, width: DefaultColumnWidths.Security); public static GridColumnSettings security_type => new GridColumnSettings(col_id(Columns.SecurityType), DefaultColumnHeaders.SecurityType, width: DefaultColumnWidths.SecurityType); public static GridColumnSettings start_net_position => new GridColumnSettings(col_id(Columns.StartNetPos), DefaultColumnHeaders.StartNetPos, width: DefaultColumnWidths.Start_Net_Pos, horizontal_alignment: System.Windows.HorizontalAlignment.Right); - public static GridColumnSettings start_pnl => new GridColumnSettings(col_id(Columns.StartPNL), DefaultColumnHeaders.StartPnL, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); + public static GridColumnSettings start_pnl => new GridColumnSettings(col_id(Columns.StartPNL), DefaultColumnHeaders.StartPnL, false, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings day_long_pnl => new GridColumnSettings(col_id(Columns.DayLong), DefaultColumnHeaders.DayLong, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings day_short_pnl => new GridColumnSettings(col_id(Columns.DayShort), DefaultColumnHeaders.DayShort, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings day_pnl => new GridColumnSettings(col_id(Columns.DayPNL), DefaultColumnHeaders.DayPnL, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); - public static GridColumnSettings total_net_pos => new GridColumnSettings(col_id(Columns.TotalNetPos), DefaultColumnHeaders.TotalNetPos, width: DefaultColumnWidths.Total_Net_Pos, horizontal_alignment: System.Windows.HorizontalAlignment.Right); - public static GridColumnSettings total_pnl => new GridColumnSettings(col_id(Columns.TotalPNL), DefaultColumnHeaders.TotalPnL, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); + public static GridColumnSettings total_net_pos => new GridColumnSettings(col_id(Columns.TotalNetPos), DefaultColumnHeaders.TotalNetPos, false, width: DefaultColumnWidths.Total_Net_Pos, horizontal_alignment: System.Windows.HorizontalAlignment.Right); + public static GridColumnSettings total_pnl => new GridColumnSettings(col_id(Columns.TotalPNL), DefaultColumnHeaders.TotalPnL, false, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static GridColumnSettings pnl_price => new GridColumnSettings(col_id(Columns.PNLPrice), DefaultColumnHeaders.PnLPrice, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right); public static IEnumerable default_sorting_criterion { @@ -158,6 +158,8 @@ namespace bts.shell { // ProtoMember 13 cannot be used further [ProtoMember(14)] public SecurityType[] security_types; + [ProtoMember(15)] + public bool[] has_day_trades; } } diff --git a/src/client/spark/Notifications/INotificationService.cs b/src/client/spark/Notifications/INotificationService.cs index 7f5decc95..a95ac2048 100644 --- a/src/client/spark/Notifications/INotificationService.cs +++ b/src/client/spark/Notifications/INotificationService.cs @@ -12,7 +12,6 @@ using System.Collections.Generic; using System.ComponentModel.Composition; using System.Linq; using System.Reactive.Linq; -using OrderTuple = System.ValueTuple; namespace bts.shell { interface INotificationService { @@ -20,40 +19,14 @@ namespace bts.shell { INotificationServiceDataCache data_cache { get; } IDisposable link_to_activity(IPredicate predicate, SoundNotification sound); IDisposable link_to_activity(INotificationPredicate toast_notification_predicate); - IDisposable link_to_order(IPredicate predicate, SoundNotification sound); - IDisposable link_to_order(INotificationPredicate toast_notification_predicate); - } - - static class NotificationServiceExtensions { - /// TODO: remove this extension and force callers to use the appropriate 'link' method in (it is smelly, and is NOT ACTUALLY STRONGLY TYPED) - public static IDisposable link(this INotificationService notification_service, IPredicate predicate, SoundNotification sound) { - if (predicate is IPredicate orp) - return notification_service.link_to_order(orp, sound); - if (predicate is IPredicate osp) { - // Note: watch out for implicit types as generic type arguments (although OrderSecurity can be implicitly cast to OrderTuple, IPredicate CANNOT be implicitly cast to IPredicate) - return notification_service.link_to_order(PredicateBuilder.create(ot => osp.trigger(new OrderSecurity(ot.Item1, ot.Item2))), sound); - } - if (predicate is IPredicate ap) - return notification_service.link_to_activity(ap, sound); - Log.Ui.error($"Unable to activate sound-trigger (unrecognized predicate type '{typeof(T)}')."); - return Disposable.empty; - } - - /// TODO: remove this extension and force callers to use the appropriate 'link' method in (it is smelly, and is NOT ACTUALLY STRONGLY TYPED) - public static IDisposable link(this INotificationService notification_service, INotificationPredicate toast_notification_predicate) { - if (toast_notification_predicate is INotificationPredicate orp) - return notification_service.link_to_order(orp); - if (toast_notification_predicate is INotificationPredicate ap) - return notification_service.link_to_activity(ap); - Log.Ui.error($"Unable to activate toast-notification-trigger (unrecognized predicate type '{typeof(T)}')."); - return Disposable.empty; - } + IDisposable link_to_order(IPredicate predicate, SoundNotification sound); + IDisposable link_to_order(INotificationPredicate toast_notification_predicate); } [Export(typeof(INotificationService))] partial class NotificationService : INotificationService, IDisposable { readonly NotificationProcessor _activity_notifications; - readonly NotificationProcessor _order_notifications; + readonly NotificationProcessor _order_notifications; readonly DataCache _data_cache = new DataCache(); IDisposable _dispose; @@ -62,7 +35,7 @@ namespace bts.shell { public NotificationService(IBus bus, INotifier notifier, OrdersModel orders_model) { this.notifier = notifier; _activity_notifications = new NotificationProcessor(notifier); - _order_notifications = new NotificationProcessor(notifier); + _order_notifications = new NotificationProcessor(notifier); _dispose = Disposable.Create( bus.subscribe(SparkTags.LogActivity).Subscribe(_on_activity), orders_model.on_orders.Subscribe(_on_orders) @@ -75,8 +48,8 @@ namespace bts.shell { public IDisposable link_to_activity(IPredicate predicate, SoundNotification sound) => _activity_notifications.link(predicate, sound); public IDisposable link_to_activity(INotificationPredicate toast_notification_predicate) => _activity_notifications.link(toast_notification_predicate); - public IDisposable link_to_order(IPredicate predicate, SoundNotification sound) => _order_notifications.link(predicate, sound); - public IDisposable link_to_order(INotificationPredicate toast_notification_predicate) => _order_notifications.link(toast_notification_predicate); + public IDisposable link_to_order(IPredicate predicate, SoundNotification sound) => _order_notifications.link(predicate, sound); + public IDisposable link_to_order(INotificationPredicate toast_notification_predicate) => _order_notifications.link(toast_notification_predicate); public void Dispose() => Disposable.dispose(ref _dispose); void _on_activity(Activity activity) => diff --git a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteStringPredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteStringPredicate.cs index afba058c3..34e077f30 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteStringPredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteStringPredicate.cs @@ -4,7 +4,7 @@ using System; namespace mbts { [ProtoContract] - class DiscreteStringPredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class DiscreteStringPredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] string[] _values; [ProtoMember(2)] diff --git a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs index 97514e6c7..af8ef653b 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteUIntPredicate.cs @@ -4,7 +4,7 @@ using System; namespace mbts { [ProtoContract] - class DiscreteUIntPredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class DiscreteUIntPredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] uint[] _values; [ProtoMember(2)] @@ -16,7 +16,7 @@ namespace mbts { public uint[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negated); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(DiscreteUIntPredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as DiscreteUIntPredicate); diff --git a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs index f885c60e9..478eda180 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/DiscreteValuesPredicate.cs @@ -8,14 +8,14 @@ using System.Collections.Generic; using System.Linq; namespace mbts { - interface IDiscreteValuesPredicateBuilder : IPredicateBuilder { + interface IDiscreteValuesPredicateData { TSingle is_value { get; set; } TSingle not_value { get; set; } TMulti in_set { get; set; } TMulti not_in_set { get; set; } DiscreteValuesOneofCase predicate_type_case { get; } } - interface IDiscreteValuesPredicateBuilder : IDiscreteValuesPredicateBuilder { } + interface IDiscreteValuesPredicateData : IDiscreteValuesPredicateData { } public enum DiscreteValuesOneofCase { None, @@ -32,8 +32,8 @@ namespace mbts { namespace mbts.ui.settings { static class DiscreteValuesPredicateUtils { - public static bool equals(IDiscreteValuesPredicateBuilder a, IDiscreteValuesPredicateBuilder b) => a.safe_equals(b, _equals); - static bool _equals(IDiscreteValuesPredicateBuilder a, IDiscreteValuesPredicateBuilder b) { + public static bool equals(IDiscreteValuesPredicateData a, IDiscreteValuesPredicateData b) => a.safe_equals(b, _equals); + static bool _equals(IDiscreteValuesPredicateData a, IDiscreteValuesPredicateData b) { var dvoc = a.predicate_type_case; if (dvoc != b.predicate_type_case) return false; @@ -47,8 +47,8 @@ namespace mbts.ui.settings { } } - public static bool equals(IDiscreteValuesPredicateBuilder a, IDiscreteValuesPredicateBuilder b) => a.safe_equals(b, _equals); - public static bool _equals(IDiscreteValuesPredicateBuilder a, IDiscreteValuesPredicateBuilder b) { + public static bool equals(IDiscreteValuesPredicateData a, IDiscreteValuesPredicateData b) => a.safe_equals(b, _equals); + public static bool _equals(IDiscreteValuesPredicateData a, IDiscreteValuesPredicateData b) { var dvoc = a.predicate_type_case; if (dvoc != b.predicate_type_case) return false; @@ -62,7 +62,7 @@ namespace mbts.ui.settings { } } - public static int hash(IDiscreteValuesPredicateBuilder a) { + public static int hash(IDiscreteValuesPredicateData a) { switch (a.predicate_type_case) { case DiscreteValuesOneofCase.IsValue: return a.is_value.GetHashCode() % MathUtils.Primes.P_17191; case DiscreteValuesOneofCase.NotValue: return a.not_value.GetHashCode() % MathUtils.Primes.P_83987; @@ -72,7 +72,7 @@ namespace mbts.ui.settings { } } - public static int hash(IDiscreteValuesPredicateBuilder a) { + public static int hash(IDiscreteValuesPredicateData a) { switch (a.predicate_type_case) { case DiscreteValuesOneofCase.IsValue: return a.is_value.GetHashCode() % MathUtils.Primes.P_17191; case DiscreteValuesOneofCase.NotValue: return a.not_value.GetHashCode() % MathUtils.Primes.P_83987; @@ -88,7 +88,7 @@ namespace mbts.ui.settings { (negated ? DiscreteValuesOneofCase.NotValue : DiscreteValuesOneofCase.IsValue) : (negated ? DiscreteValuesOneofCase.NotInSet : DiscreteValuesOneofCase.IsInSet); - public static DiscreteValuesOneofCase get_predicate_type_case(IDiscreteValuesPredicateBuilder predicate_builder) { + public static DiscreteValuesOneofCase get_predicate_type_case(IDiscreteValuesPredicateData predicate_builder) { if (predicate_builder.is_value != null) return DiscreteValuesOneofCase.IsValue; if (predicate_builder.not_value != null) return DiscreteValuesOneofCase.NotValue; if (predicate_builder.in_set != null) return DiscreteValuesOneofCase.IsInSet; @@ -96,7 +96,7 @@ namespace mbts.ui.settings { return DiscreteValuesOneofCase.None; } - public static IPredicate create(IDiscreteValuesPredicateBuilder predicate_builder) { + public static IPredicate create(IDiscreteValuesPredicateData predicate_builder) { switch (predicate_builder.predicate_type_case) { case DiscreteValuesOneofCase.IsValue: return PredicateBuilder.equals(predicate_builder.is_value); case DiscreteValuesOneofCase.NotValue: return PredicateBuilder.not_equals(predicate_builder.not_value); @@ -106,7 +106,7 @@ namespace mbts.ui.settings { } } - public static IPredicate create(IDiscreteValuesPredicateBuilder predicate_builder) where T : struct { + public static IPredicate create(IDiscreteValuesPredicateData predicate_builder) where T : struct { switch (predicate_builder.predicate_type_case) { case DiscreteValuesOneofCase.IsValue: return PredicateBuilder.equals(predicate_builder.is_value.Value); case DiscreteValuesOneofCase.NotValue: return PredicateBuilder.not_equals(predicate_builder.not_value.Value); @@ -118,13 +118,13 @@ namespace mbts.ui.settings { } static class DiscreteValuesPredicateVMFactory { public static Dictionary> get_oneofs_value_type(IEnumerable items) - where T : struct where TPredicate : IDiscreteValuesPredicateBuilder => + where T : struct where TPredicate : IDiscreteValuesPredicateData => // get_oneofs(identity_view_value_collection(items), val => val.Value, val => val, vals => vals ?? Enumerable.Empty(), vals => vals?.ToArray() ?? new T[0], get_identity_view); public static Dictionary> get_oneofs( IObservableCollection> items, Func from_single, Func to_single, Func> from_multi, Func, TMulti> to_multi, Func get_view) - where TPredicate : IDiscreteValuesPredicateBuilder { + where TPredicate : IDiscreteValuesPredicateData { // return new Dictionary> { { DiscreteValuesOneofCase.IsValue, PropertyWrapperVMUtils.create_selector_vm( @@ -153,14 +153,14 @@ namespace mbts.ui.settings { public static Dictionary> get_oneofs( IEnumerable items, Func key, Func from_single, Func to_single, Func> from_multi, Func, TMulti> to_multi) where TKey : struct, IEquatable - where TPredicate : IDiscreteValuesPredicateBuilder => + where TPredicate : IDiscreteValuesPredicateData => // get_oneofs(RXCollection.from_enumerable(items.Select>(v => new ViewValueTuple(v, v))), key, from_single, to_single, from_multi, to_multi); public static Dictionary> get_oneofs( IObservableCollection> items, Func key, Func from_single, Func to_single, Func> from_multi, Func, TMulti> to_multi) where TKey : struct, IEquatable - where TPredicate : IDiscreteValuesPredicateBuilder { + where TPredicate : IDiscreteValuesPredicateData { // return new Dictionary> { { DiscreteValuesOneofCase.IsValue, PropertyWrapperVMUtils.create_keyed_selector_vm, TKey>( diff --git a/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs index b8d43d093..61d07f88f 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/ExchangePredicate.cs @@ -5,7 +5,7 @@ using System; namespace mbts { [ProtoContract] - class ExchangePredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class ExchangePredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] Venue[] _values; [ProtoMember(2)] @@ -17,7 +17,7 @@ namespace mbts { public Venue[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negated); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(ExchangePredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as ExchangePredicate); diff --git a/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs index 8f30fb79f..441b0f557 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/OrderStatusPredicate.cs @@ -5,7 +5,7 @@ using System; namespace mbts { [ProtoContract] - class OrderStatusPredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class OrderStatusPredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] OrderStatus[] _values; [ProtoMember(2)] @@ -17,7 +17,7 @@ namespace mbts { public OrderStatus[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negated); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(OrderStatusPredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as OrderStatusPredicate); diff --git a/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs index c27537fde..8a8e10f48 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/OrderSubTypePredicate.cs @@ -5,7 +5,7 @@ using System; namespace mbts { [ProtoContract] - class OrderSubTypePredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class OrderSubTypePredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] OrderSubType[] _values; [ProtoMember(2)] @@ -17,7 +17,7 @@ namespace mbts { public OrderSubType[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negated); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(OrderSubTypePredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as OrderSubTypePredicate); diff --git a/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs index 9b88ab3a7..719e39fa8 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/OrderTypePredicate.cs @@ -5,7 +5,7 @@ using OrderType = bts.api.orderman.CustomOrderDefinition.CustomOneofCase; namespace mbts { [ProtoContract] - class OrderTypePredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class OrderTypePredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] OrderType[] _values; [ProtoMember(2)] @@ -17,7 +17,7 @@ namespace mbts { public OrderType[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negated); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(OrderTypePredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as OrderTypePredicate); diff --git a/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs b/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs index e56b96d7d..98e5c84e4 100644 --- a/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs +++ b/src/client/spark/Predicates/Data/DiscreteValues/TimeInForcePredicate.cs @@ -5,7 +5,7 @@ using System; namespace mbts { [ProtoContract] - class TimeInForcePredicate : IDiscreteValuesPredicateBuilder, IEquatable { + class TimeInForcePredicate : IDiscreteValuesPredicateData, IEquatable { [ProtoMember(1)] TimeInForce[] _values; [ProtoMember(2)] @@ -17,7 +17,7 @@ namespace mbts { public TimeInForce[] not_in_set { get => _get_set(true); set => _set(true, value); } public DiscreteValuesOneofCase predicate_type_case => DiscreteValuesPredicateUtils.get_predicate_type_case(_values, _negate); - public IPredicate create(object obj) => DiscreteValuesPredicateUtils.create(this); + public IPredicate create() => DiscreteValuesPredicateUtils.create(this); public bool Equals(TimeInForcePredicate other) => DiscreteValuesPredicateUtils.equals(this, other); public override bool Equals(object obj) => Equals(obj as TimeInForcePredicate); diff --git a/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs b/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs index 9ed71bb6e..ea9172dd1 100644 --- a/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs +++ b/src/client/spark/Predicates/Data/Events/OrderCanceledEventPredicate.cs @@ -4,7 +4,6 @@ using bts.shell; using bts.utils; using mbts.spark; using mbts.ui.settings; -using mbts.utils; using ProtoBuf; using System; using System.Collections.Generic; @@ -14,7 +13,7 @@ namespace mbts { static class OrderCanceledEventPredicateVMFactory { public static Dictionary> get_oneofs(IBus bus) => new Dictionary> { - { OrderCanceledEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateBuilderVMWrapper.create(p => p.security = null) }, + { OrderCanceledEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateVMWrapper.create(p => p.security = null) }, { OrderCanceledEventPredicate.PredicateTypeOneofCase.SecurityOrder, SecurityCriteriaVMFactory.create(bus, o => o.security?.is_value ?? new SecurityCriteria(), (p, s) => { if (p.security == null) @@ -26,7 +25,7 @@ namespace mbts { } [ProtoContract] - class OrderCanceledEventPredicate : IPredicateBuilder, IEquatable { + class OrderCanceledEventPredicate : IEquatable { public enum PredicateTypeOneofCase { [Description("(any order)")] AnyOrder, @@ -52,7 +51,7 @@ namespace mbts { OrderEventPredicateHelper.create_status_transition_predicate(OrderStatus.Canceled, security, data_cache); public INotificationPredicate create_toast(INotificationServiceDataCache data_cache) => - new MyToaster(security?.create(data_cache), data_cache); + new MyToaster(security?.create(), data_cache); public bool Equals(OrderCanceledEventPredicate other) => other != null && other.security.safe_equals(other.security); public override bool Equals(object obj) => Equals(obj as OrderCanceledEventPredicate); diff --git a/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs b/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs index f6942d908..a543fecb4 100644 --- a/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs +++ b/src/client/spark/Predicates/Data/Events/OrderCompletedEventPredicate.cs @@ -4,7 +4,6 @@ using bts.shell; using bts.utils; using mbts.spark; using mbts.ui.settings; -using mbts.utils; using ProtoBuf; using System; using System.Collections.Generic; @@ -14,7 +13,7 @@ namespace mbts { static class OrderCompletedEventPredicateVMFactory { public static Dictionary> get_oneofs(IBus bus) => new Dictionary> { - { OrderCompletedEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateBuilderVMWrapper.create(p => p.security = null) }, + { OrderCompletedEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateVMWrapper.create(p => p.security = null) }, { OrderCompletedEventPredicate.PredicateTypeOneofCase.SecurityOrder, SecurityCriteriaVMFactory.create(bus, o => o.security?.is_value ?? new SecurityCriteria(), (p, s) => { if (p.security == null) @@ -26,7 +25,7 @@ namespace mbts { } [ProtoContract] - class OrderCompletedEventPredicate : IPredicateBuilder, IEquatable { + class OrderCompletedEventPredicate : IEquatable { public enum PredicateTypeOneofCase { [Description("(any order)")] AnyOrder, @@ -52,7 +51,7 @@ namespace mbts { OrderEventPredicateHelper.create_status_transition_predicate(OrderStatus.Completed, security, data_cache); public INotificationPredicate create_toast(INotificationServiceDataCache data_cache) => - new MyToaster(security?.create(data_cache), data_cache); + new MyToaster(security?.create(), data_cache); public bool Equals(OrderCompletedEventPredicate other) => other != null && other.security.safe_equals(other.security); public override bool Equals(object obj) => Equals(obj as OrderCompletedEventPredicate); diff --git a/src/client/spark/Predicates/Data/Events/OrderEventPredicateHelper.cs b/src/client/spark/Predicates/Data/Events/OrderEventPredicateHelper.cs index f9e27e62f..e13a5a908 100644 --- a/src/client/spark/Predicates/Data/Events/OrderEventPredicateHelper.cs +++ b/src/client/spark/Predicates/Data/Events/OrderEventPredicateHelper.cs @@ -2,8 +2,6 @@ using bts.api.orderman; using bts.shell; using bts.utils; -using mbts.spark; -using mbts.utils; using System; namespace mbts { @@ -39,7 +37,7 @@ namespace mbts { } public static IPredicate create_status_transition_predicate(OrderStatus status, SecurityPredicate security_predicate, INotificationServiceDataCache data_cache) => - new OrderStatusTransitionPredicate(status, security_predicate?.create(data_cache), data_cache); + new OrderStatusTransitionPredicate(status, security_predicate?.create(), data_cache); class OrderStatusTransitionPredicate : IPredicate, IEquatable { readonly IPredicate _security_predicate; diff --git a/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs b/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs index 80767eec6..f8ca8f2ab 100644 --- a/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs +++ b/src/client/spark/Predicates/Data/Events/OrderFilledEventPredicate.cs @@ -11,7 +11,7 @@ namespace mbts { static class OrderFilledEventPredicateVMFactory { public static Dictionary> get_oneofs(IBus bus) => new Dictionary> { - { OrderFilledEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateBuilderVMWrapper.create(p => p.security = null) }, + { OrderFilledEventPredicate.PredicateTypeOneofCase.AnyOrder, PredicateVMWrapper.create(p => p.security = null) }, { OrderFilledEventPredicate.PredicateTypeOneofCase.SecurityOrder, SecurityCriteriaVMFactory.create(bus, o => o.security?.is_value ?? new SecurityCriteria(), (p, s) => { if (p.security == null) { @@ -24,7 +24,7 @@ namespace mbts { } [ProtoContract] - class OrderFilledEventPredicate : IPredicateBuilder, IEquatable { + class OrderFilledEventPredicate : IEquatable { public enum PredicateTypeOneofCase { [PredicateCase("(any order)")] AnyOrder, @@ -59,7 +59,7 @@ namespace mbts { public override int GetHashCode() => security == null ? 0 : security.GetHashCode(); FillTriggerModel _create_model(INotificationServiceDataCache nsdc) => - new FillTriggerModel(nsdc, security?.create(nsdc)); + new FillTriggerModel(nsdc, security?.create()); class FillTriggerModel { readonly IPredicate _security_predicate; diff --git a/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs b/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs index b9a793e55..c137f7d0b 100644 --- a/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs +++ b/src/client/spark/Predicates/Data/OrderRecordTuplePredicate.cs @@ -56,12 +56,12 @@ namespace mbts { Func key, Dictionary> oneofs) where TChildPredicateOneof : struct where TChildPredicate : new() => // - PredicateBuilderVMWrapper.wrap_child_oneof(get, set, key, oneofs); + PredicateVMWrapper.wrap_child_oneof(get, set, key, oneofs); } } [ProtoContract] - class OrderRecordTuplePredicate : INotificationPredicateBuilder, IEquatable { + class OrderRecordTuplePredicate : IEquatable { SecurityPredicate _security; SidePredicate _side; DoublePredicate _price, _last_price, _avg_price; @@ -213,40 +213,37 @@ namespace mbts { public IPredicate create_predicate(INotificationServiceDataCache data_cache) { switch (predicate_type_case) { - case PTOC.Security: return wrap(_security, r => r.security ?? SecurityDataHelper.Defaults.SecurityImmutable); - case PTOC.Time: return wrap(_time_created, r => r.order.created()); - case PTOC.LastChange: return wrap(_last_change, r => r.order.last_change()); - case PTOC.User: return wrap(_user, r => r.order.user_id()); - case PTOC.Account: return wrap(_account, r => r.order.account_id()); - case PTOC.Exchange: return wrap(_exchange, r => r.security.exchange_or_default()); - case PTOC.TimeInForce: return wrap(_time_in_force, r => r.order.time_in_force()); - case PTOC.OrderType: return wrap(_order_type, r => r.order.order_type()); - case PTOC.SubType: return wrap(_order_sub_type, r => r.order.sub_type()); - case PTOC.Side: return wrap(_side, r => r.order.side()); - case PTOC.Size: return wrap(_quantity, r => r.order.quantity()); - case PTOC.Price: return wrap(_price, r => r.order.price()); - case PTOC.Filled: return wrap(_filled_quantity, r => r.order.filled()); - case PTOC.AvgFilled: return wrap(_avg_price, r => r.order.avg_price()); - case PTOC.LastPrice: return wrap(_last_price, r => r.order.last_price()); - case PTOC.Status: return wrap(_order_status, r => r.order.status()); - case PTOC.LastMessage: return wrap(_last_message, r => r.order.last_msg()); - case PTOC.SecurityKey: return wrap(_security_key, r => r.order.security_key()); - case PTOC.OrderKey: return wrap(_order_key, r => r.order.Key); - case PTOC.ParentKey: return wrap(_parent_key, r => r.order.ParentKey); + case PTOC.Security: return wrap(_security.create(), r => r.security ?? SecurityDataHelper.Defaults.SecurityImmutable); + case PTOC.Time: return wrap(_time_created.create(), r => r.order.created()); + case PTOC.LastChange: return wrap(_last_change.create(), r => r.order.last_change()); + case PTOC.User: return wrap(_user.create(), r => r.order.user_id()); + case PTOC.Account: return wrap(_account.create(), r => r.order.account_id()); + case PTOC.Exchange: return wrap(_exchange.create(), r => r.security.exchange_or_default()); + case PTOC.TimeInForce: return wrap(_time_in_force.create(), r => r.order.time_in_force()); + case PTOC.OrderType: return wrap(_order_type.create(), r => r.order.order_type()); + case PTOC.SubType: return wrap(_order_sub_type.create(), r => r.order.sub_type()); + case PTOC.Side: return wrap(_side.create(), r => r.order.side()); + case PTOC.Size: return wrap(_quantity.create(), r => r.order.quantity()); + case PTOC.Price: return wrap(_price.create(), r => r.order.price()); + case PTOC.Filled: return wrap(_filled_quantity.create(), r => r.order.filled()); + case PTOC.AvgFilled: return wrap(_avg_price.create(), r => r.order.avg_price()); + case PTOC.LastPrice: return wrap(_last_price.create(), r => r.order.last_price()); + case PTOC.Status: return wrap(_order_status.create(), r => r.order.status()); + case PTOC.LastMessage: return wrap(_last_message.create(), r => r.order.last_msg()); + case PTOC.SecurityKey: return wrap(_security_key.create(), r => r.order.security_key()); + case PTOC.OrderKey: return wrap(_order_key.create(), r => r.order.Key); + case PTOC.ParentKey: return wrap(_parent_key.create(), r => r.order.ParentKey); case PTOC.FilledEvent: return _filled_event.create_predicate(data_cache); case PTOC.CompletedEvent: return _completed_event.create_predicate(data_cache); case PTOC.CanceledEvent: return _canceled_event.create(data_cache); - case PTOC.AttachedTargetOrderKey: return wrap(_attached_target_order_key, r => r.order.attached_target_order_key()); + case PTOC.AttachedTargetOrderKey: return wrap(_attached_target_order_key.create(), r => r.order.attached_target_order_key()); default: return null; } // - IPredicate wrap(IPredicateBuilder trigger, Func select) => - trigger.create(data_cache).wrap(select); + IPredicate wrap(IPredicate trigger, Func select) => + trigger.wrap(select); } - IPredicate IPredicateBuilder.create(object obj) => - create_predicate((INotificationServiceDataCache)obj); - public INotificationPredicate create_notification_predicate(INotificationServiceDataCache notification_service_data_cache) { if (!is_toast_enabled) return null; @@ -258,9 +255,6 @@ namespace mbts { } } - INotificationPredicate INotificationPredicateBuilder.create_notification_predicate(object obj) => - create_notification_predicate((INotificationServiceDataCache)obj); - public bool Equals(OrderRecordTuplePredicate other) { if (other == null) return false; @@ -387,9 +381,9 @@ namespace mbts { _sound_animations = new List ( sound_animations ); } - public OrderRecordTuplePredicate predicate_builder => _predicate; + public OrderRecordTuplePredicate predicate_data => _predicate; public IReadOnlyList cell_animations => _cell_animations ?? (_cell_animations = new List()); public IReadOnlyList row_animations => _row_animations ?? (_row_animations = new List()); public IReadOnlyList sound_notifications => _sound_animations ?? (_sound_animations = new List()); } -} \ No newline at end of file +} diff --git a/src/client/spark/Predicates/Data/Primitive/DoublePredicate.cs b/src/client/spark/Predicates/Data/Primitive/DoublePredicate.cs index d0a5dfb16..814ba0b54 100644 --- a/src/client/spark/Predicates/Data/Primitive/DoublePredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/DoublePredicate.cs @@ -1,7 +1,6 @@ using bts.proto; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; using ProtoBuf; using System; @@ -24,7 +23,7 @@ namespace mbts { } [ProtoContract] - class DoublePredicate : IPredicateBuilder, IEquatable { + class DoublePredicate : IEquatable { // not using a 'negate' flag here bc its meaning is not consistent for all value-types // greater than vs less than for specific values, or inside vs outside for value-ranges // trading a little more code for more clarity @@ -62,7 +61,7 @@ namespace mbts { } } - public IPredicate create(object obj) { + public IPredicate create() { switch (predicate_type_case) { case PredicateTypeOneofCase.GreaterThan: return PredicateBuilder.greater_than(_greater_than.Value); case PredicateTypeOneofCase.LessThan: return PredicateBuilder.less_than(_less_than.Value); diff --git a/src/client/spark/Predicates/Data/Primitive/SidePredicate.cs b/src/client/spark/Predicates/Data/Primitive/SidePredicate.cs index b15486b76..a08300e5a 100644 --- a/src/client/spark/Predicates/Data/Primitive/SidePredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/SidePredicate.cs @@ -1,7 +1,6 @@ using bts.api; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; using mbts.ui.utility; using ProtoBuf; @@ -23,7 +22,7 @@ namespace mbts { } [ProtoContract] - class SidePredicate : IPredicateBuilder, IEquatable { + class SidePredicate : IEquatable { Side? _is_value; Side? _not_value; @@ -48,7 +47,7 @@ namespace mbts { } } - public IPredicate create(object obj) { + public IPredicate create() { switch (predicate_type_case) { case PredicateTypeOneofCase.IsValue: return PredicateBuilder.equals(_is_value.Value); case PredicateTypeOneofCase.NotValue: return PredicateBuilder.not_equals(_not_value.Value); diff --git a/src/client/spark/Predicates/Data/Primitive/StringPredicate.cs b/src/client/spark/Predicates/Data/Primitive/StringPredicate.cs index 3f7a9679f..f4e40eafd 100644 --- a/src/client/spark/Predicates/Data/Primitive/StringPredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/StringPredicate.cs @@ -1,9 +1,7 @@ using bts.proto; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; -using mbts.utils; using ProtoBuf; using System; using System.Collections.Generic; @@ -27,7 +25,7 @@ namespace mbts { } [ProtoContract] - class StringPredicate : IPredicateBuilder, IEquatable { + class StringPredicate : IEquatable { StringIgnoreCase? _is_string, _not_string, _contains_string, _not_contains_string; public enum PredicateTypeOneofCase { @@ -61,7 +59,7 @@ namespace mbts { } } - public IPredicate create(object obj) { + public IPredicate create() { switch (predicate_type_case) { case PTOC.IsMatch: return PredicateBuilder.equals(_is_string.Value.text, _get_eq_comparer(_is_string)); case PTOC.NotMatch: return PredicateBuilder.not_equals(_not_string.Value.text, _get_eq_comparer(_not_string)); diff --git a/src/client/spark/Predicates/Data/Primitive/TimePredicate.cs b/src/client/spark/Predicates/Data/Primitive/TimePredicate.cs index 2ee8a55f7..cdaf5ab1a 100644 --- a/src/client/spark/Predicates/Data/Primitive/TimePredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/TimePredicate.cs @@ -1,7 +1,6 @@ using bts.proto; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; using ProtoBuf; using System; @@ -21,7 +20,7 @@ namespace mbts { } [ProtoContract] - class TimePredicate : IPredicateBuilder, IEquatable { + class TimePredicate : IEquatable { // not using a 'negate' flag here bc its meaning is not consistent for all value-types // before vs after for specific times, or inside vs outside for time-ranges // trading a little more code for clarity @@ -59,7 +58,7 @@ namespace mbts { } } - public IPredicate create(object obj) { + public IPredicate create() { switch (predicate_type_case) { case PTOC.Before: return PredicateBuilder.less_than(_before.Value.get_date_time()); case PTOC.After: return PredicateBuilder.greater_than(_after.Value.get_date_time()); diff --git a/src/client/spark/Predicates/Data/Primitive/UIntPredicate.cs b/src/client/spark/Predicates/Data/Primitive/UIntPredicate.cs index 8d0df7dea..def76f26c 100644 --- a/src/client/spark/Predicates/Data/Primitive/UIntPredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/UIntPredicate.cs @@ -1,7 +1,6 @@ using bts.proto; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; using ProtoBuf; using System; @@ -24,7 +23,7 @@ namespace mbts { } [ProtoContract] - class UIntPredicate : IPredicateBuilder, IEquatable { + class UIntPredicate : IEquatable { // not using a 'negate' flag here bc its meaning is not consistent for all value-types // greater than vs less than for specific values, or inside vs outside for value-ranges // trading a little more code for more clarity @@ -62,7 +61,7 @@ namespace mbts { } } - public IPredicate create(object obj) { + public IPredicate create() { switch (predicate_type_case) { case PredicateTypeOneofCase.GreaterThan: return PredicateBuilder.greater_than(_greater_than.Value); case PredicateTypeOneofCase.LessThan: return PredicateBuilder.less_than(_less_than.Value); diff --git a/src/client/spark/Predicates/Data/Primitive/UShortPredicate.cs b/src/client/spark/Predicates/Data/Primitive/UShortPredicate.cs index c3f61af67..5525aea19 100644 --- a/src/client/spark/Predicates/Data/Primitive/UShortPredicate.cs +++ b/src/client/spark/Predicates/Data/Primitive/UShortPredicate.cs @@ -1,7 +1,6 @@ using bts.proto; using bts.utils; using mbts.spark; -using mbts.spark.utilities; using mbts.ui.spark; using ProtoBuf; using System; @@ -24,7 +23,7 @@ namespace mbts { } [ProtoContract] - class UShortPredicate : IPredicateBuilder, IEquatable { + class UShortPredicate : IEquatable { // not using a 'negate' flag here bc its meaning is not consistent for all value-types // greater than vs less than for specific values, or inside vs outside for value-ranges // trading a little more code for more clarity diff --git a/src/client/spark/Predicates/Data/SecurityPredicate.cs b/src/client/spark/Predicates/Data/SecurityPredicate.cs index 0bdd2f3e6..95d2dc01e 100644 --- a/src/client/spark/Predicates/Data/SecurityPredicate.cs +++ b/src/client/spark/Predicates/Data/SecurityPredicate.cs @@ -23,7 +23,7 @@ namespace mbts { } [ProtoContract] - class SecurityPredicate : IPredicateBuilder, IEquatable { + class SecurityPredicate : IEquatable { [ProtoMember(1)] SecurityCriteria _criteria; [ProtoMember(2)] @@ -43,7 +43,8 @@ namespace mbts { _criteria == null ? PTOC.None : _negate ? PTOC.NotInCriteria : PTOC.InCriteria; - public IPredicate create(object obj) => _criteria.is_defined() ? new MyPredicate(_criteria, _negate) : null; + public IPredicate create() => _criteria.is_defined() ? new MyPredicate(_criteria, _negate) : null; + public bool Equals(SecurityPredicate other) => other != null && _negate == other._negate && diff --git a/src/client/spark/Predicates/IPredicate.cs b/src/client/spark/Predicates/IPredicate.cs index 5f1b376cc..bd881c697 100644 --- a/src/client/spark/Predicates/IPredicate.cs +++ b/src/client/spark/Predicates/IPredicate.cs @@ -1,6 +1,4 @@ -using bts.shell; -using bts.utils; -using mbts.utils; +using bts.utils; using System; using System.Collections.Generic; using System.ComponentModel; @@ -14,23 +12,6 @@ namespace mbts { bool trigger(T value); } - interface IPredicateBuilder { - IPredicate create(object obj); - } - - interface INotificationPredicateBuilder : IPredicateBuilder { - bool is_toast_enabled { get; set; } - INotificationPredicate create_notification_predicate(object obj); - } - - interface IPredicateBuilder : IPredicateBuilder { - IPredicate create_predicate(TArg arg); - } - - interface INotificationPredicateBuilder : IPredicateBuilder, INotificationPredicateBuilder { - INotificationPredicate create_notification_predicate(TArg arg); - } - public enum PredicateCategory { Normal, Event diff --git a/src/client/spark/Predicates/IPredicateBuilderVM.cs b/src/client/spark/Predicates/IPredicateVM.cs similarity index 65% rename from src/client/spark/Predicates/IPredicateBuilderVM.cs rename to src/client/spark/Predicates/IPredicateVM.cs index 41e319b6c..d98708ca8 100644 --- a/src/client/spark/Predicates/IPredicateBuilderVM.cs +++ b/src/client/spark/Predicates/IPredicateVM.cs @@ -13,25 +13,23 @@ using System.Reactive.Linq; using System.Windows.Data; namespace mbts.ui.settings { - interface IPredicateBuilderVM : ITemplatedPropertyWrapperVM - where TPredicateBuilder : IPredicateBuilder - where TPredicateBuilderOneof : struct { - IReadOnlyCollection predicate_types { get; } + interface IPredicateVM : ITemplatedPropertyWrapperVM where TPredicateDataOneof : struct { + IReadOnlyCollection predicate_types { get; } ICollectionView predicate_types_view { get; } - TPredicateBuilderOneof selected_predicate_type { get; set; } - ITemplatedPropertyWrapperVM selected_predicate { get; } + TPredicateDataOneof selected_predicate_type { get; set; } + ITemplatedPropertyWrapperVM selected_predicate { get; } bool can_enable_toast_notifications { get; } bool toast_notifications_enabled { get; } } - interface IChildPredicateBuilderVM : ITemplatedPropertyWrapperVM where TChildPredicateBuilderOneof : struct { - IReadOnlyCollection predicate_types { get; } + interface IChildPredicateVM : ITemplatedPropertyWrapperVM where TChildPredicateOneof : struct { + IReadOnlyCollection predicate_types { get; } ICollectionView predicate_types_view { get; } - TChildPredicateBuilderOneof selected_predicate_type { get; set; } - ITemplatedPropertyWrapperVM selected_predicate { get; } + TChildPredicateOneof selected_predicate_type { get; set; } + ITemplatedPropertyWrapperVM selected_predicate { get; } } - static class PredicateBuilderVMWrapper { + static class PredicateVMWrapper { static readonly bool _toast_notifications_enabled_global = Configuration.get().enabled; public static ITemplatedPropertyWrapperVM wrap_child_oneof( @@ -39,14 +37,17 @@ namespace mbts.ui.settings { where TChildOneof : struct where TChild : new() => // - new PredicateChildWrapperVM(get, set, get_child_oneof, oneof_vms); + new ChildImpl(get, set, get_child_oneof, oneof_vms); - public static IPredicateBuilderVM create( - Dictionary> oneofs, Func key) - where TPredicateOneof : struct - where TPredicate : IPredicateBuilder, new() => + public static IPredicateVM create( + Dictionary> oneofs, Func key) where TPredicateOneof : struct => // - new PredicateWrapperVM(oneofs, key); + new Impl(oneofs, key, _ => false, (p, b) => { }); + + public static IPredicateVM create( + Dictionary> oneofs, Func key, Func get_is_toast_enabled, Action set_is_toast_enabled) where TPredicateOneof : struct => + // + new Impl(oneofs, key, get_is_toast_enabled, set_is_toast_enabled); public static ITemplatedPropertyWrapperVM create(Action set = null) => new PredicatePlaceholderVM(set); @@ -63,35 +64,30 @@ namespace mbts.ui.settings { return cv; } - class PredicateWrapperVM : DisposableViewModelBase, IPredicateBuilderVM, ITemplatedPropertyWrapperVM - where TPredicateOneof : struct - where TPredicate : IPredicateBuilder, new() { + class Impl : DisposableViewModelBase, IPredicateVM, ITemplatedPropertyWrapperVM + where TPredicateOneof : struct { readonly Dictionary> _oneofs; readonly Property _selected_predicate_type; readonly Property> _selected_predicate; readonly DelegateProperty _can_enable_toast_notifications; readonly Property _toast_notifications_enabled; readonly Func _key_selector; + readonly Func _get_is_toast_enabled; + readonly Action _set_is_toast_enabeled; - public PredicateWrapperVM(Dictionary> oneofs, Func key_selector) { + public Impl(Dictionary> oneofs, Func key_selector, Func get_is_toast_enabled, Action set_is_toast_enabled) { _oneofs = oneofs; _key_selector = key_selector; + _get_is_toast_enabled = get_is_toast_enabled; + _set_is_toast_enabeled = set_is_toast_enabled; _selected_predicate = backing>(nameof(selected_predicate)); _selected_predicate_type = backing(nameof(selected_predicate_type)); predicate_types_view = _create_predicate_types_view(predicate_types); - if (typeof(TPredicate).GetInterfaces().Contains(typeof(INotificationPredicateBuilder))) { - // simple_predicates are only referred to when TPredicate is an INotificationPredicateBuilder, but does not support INotificationPredicates for every predicate-case - // (this way we can gradually add notifications as-needed beasis) - // for ex: we may release a cut that supports fill notifications without having to create a notification-predicate for every predicate-case in OrderRecordTuplePredicate. - // Note: it is assumed that all TPredicateOneof cases DO SUPPORT notification-predicates UNLESS THEY SPECIFY OTHERWISE IN A PREDICATECASEATTRIBUTE. - var simple_predicates = new HashSet(oneofs.Keys.Where(k => { - var pca = EnumHelper.get_attribute(k); - return pca != null && !pca.is_toastable; - })); - _can_enable_toast_notifications = backing(nameof(can_enable_toast_notifications), () => !simple_predicates.Contains(selected_predicate_type), nameof(selected_predicate_type)); - } else { - _can_enable_toast_notifications = backing(nameof(can_enable_toast_notifications), () => false); - } + var toastable_predicates = new HashSet(oneofs.Keys.Where(k => { + var pca = EnumHelper.get_attribute(k); + return pca != null && pca.is_toastable; + })); + _can_enable_toast_notifications = backing(nameof(can_enable_toast_notifications), () => toastable_predicates.Contains(selected_predicate_type), nameof(selected_predicate_type)); _toast_notifications_enabled = backing(nameof(toast_notifications_enabled)); selected_predicate_type = predicate_types.FirstOrDefault(); } @@ -118,19 +114,18 @@ namespace mbts.ui.settings { public void load_from(TPredicate value) { selected_predicate_type = _key_selector(value); selected_predicate?.load_from(value); - if (can_enable_toast_notifications) { - _toast_notifications_enabled.set(((INotificationPredicateBuilder)value).is_toast_enabled); - } + if (can_enable_toast_notifications) + _toast_notifications_enabled.set(_get_is_toast_enabled(value)); } public void assign_to(TPredicate value) { selected_predicate?.assign_to(value); - if (toast_notifications_enabled && value is INotificationPredicateBuilder tp) - tp.is_toast_enabled = true; + if (can_enable_toast_notifications) + _set_is_toast_enabeled(value, toast_notifications_enabled); } } - class PredicateChildWrapperVM : DisposableViewModelBase, IChildPredicateBuilderVM where TChildKey : struct where TChild : new() { + class ChildImpl : DisposableViewModelBase, IChildPredicateVM where TChildKey : struct where TChild : new() { readonly Property> _selected_predicate; readonly Property _selected_predicate_type; readonly Dictionary> _children; @@ -139,7 +134,7 @@ namespace mbts.ui.settings { readonly Func _key; readonly string _template_key; - public PredicateChildWrapperVM(Func get, Action set, Func key, + public ChildImpl(Func get, Action set, Func key, Dictionary> oneofs, string template = PredicateTemplateKeys.Recursive) { _get = get; _set = set; diff --git a/src/client/spark/core/Bus/SparkCommand.cs b/src/client/spark/core/Bus/SparkCommand.cs index 102bfff6c..69ceb190b 100644 --- a/src/client/spark/core/Bus/SparkCommand.cs +++ b/src/client/spark/core/Bus/SparkCommand.cs @@ -1,4 +1,4 @@ -using bts.api; +using bts.api; using mbts; using mbts.ui; using System; @@ -75,16 +75,19 @@ namespace bts.spark { new SparkCommand(title, icon, tag, parameter, can_execute, key_gesture); public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter, KeyGesture key_gesture = null) => - create(title, icon, tag, parameter, _ => true, key_gesture); + create(title, icon, tag, parameter, _ => true, key_gesture: key_gesture); - public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter, Func can_execute, KeyGesture key_gesture = null) => - create(title, icon, tag, parameter, parameter.Select(can_execute), key_gesture); + public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter, Func can_execute, Func is_confirmation_affirmed = null, KeyGesture key_gesture = null) => + create(title, icon, tag, parameter, parameter.Select(can_execute), is_confirmation_affirmed, key_gesture); - public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter_source, Func parameter_source_where, Func parameter_selector, KeyGesture key_gesture = null) => - create(title, icon, tag, parameter_source.Select(parameter_selector), parameter_source.Select(parameter_source_where), key_gesture); + public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter_source, Func parameter_source_where, Func parameter_selector, Func is_confirmation_affirmed = null, KeyGesture key_gesture = null) => + create(title, icon, tag, parameter_source.Select(parameter_selector), parameter_source.Select(parameter_source_where), is_confirmation_affirmed, key_gesture); - public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter, IObservable can_execute, KeyGesture key_gesture = null) => - new SparkCommandParamObserver(title, icon, tag, parameter, can_execute, key_gesture); + public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter_source, Func parameter_source_where, Func parameter_selector) => + create(title, icon, tag, parameter_source.Select(parameter_selector), parameter_source.Select(parameter_source_where)); + + public static SparkCommandParamObserver create(string title, ImageSource icon, ITag tag, IObservable parameter, IObservable can_execute, Func is_confirmation_affirmed = null, KeyGesture key_gesture = null) => + new SparkCommandParamObserver(title, icon, tag, parameter, can_execute, is_confirmation_affirmed, key_gesture); } public static class SparkCommandExtensions { @@ -135,13 +138,16 @@ namespace bts.spark { SparkCommand.create(title, icon, tag, value, can_execute, _key_gesture); public SparkCommandParamObserver complete(IObservable value, Func can_execute) => - SparkCommand.create(title, icon, tag, value, can_execute, _key_gesture); + SparkCommand.create(title, icon, tag, value, can_execute, key_gesture: _key_gesture); + + public SparkCommandParamObserver complete(IObservable value, Func can_execute, Func is_confirmation_affirmed) => + SparkCommand.create(title, icon, tag, value, can_execute, is_confirmation_affirmed, _key_gesture); public SparkCommandParamObserver complete(IObservable value_source, Func value_source_where, Func value_selector) => - SparkCommand.create(title, icon, tag, value_source, value_source_where, value_selector, _key_gesture); + SparkCommand.create(title, icon, tag, value_source, value_source_where, value_selector, key_gesture: _key_gesture); public SparkCommandParamObserver complete(IObservable parameter, IObservable can_execute) => - SparkCommand.create(title, icon, tag, parameter, can_execute, _key_gesture); + SparkCommand.create(title, icon, tag, parameter, can_execute, key_gesture: _key_gesture); } public class SparkCommandWrapper : SparkCommand, IDisposable { @@ -227,9 +233,10 @@ namespace bts.spark { } public class SparkCommandParamObserver : SparkCommand, IDisposable { - public SparkCommandParamObserver(string title, ImageSource icon, ITag tag, IObservable parameter, IObservable can_execute, KeyGesture key_gesture = null) + public SparkCommandParamObserver(string title, ImageSource icon, ITag tag, IObservable parameter, IObservable can_execute, Func is_confirmation_affirmed = null, KeyGesture key_gesture = null) : base(title, icon, key_gesture: key_gesture) { _tag = tag; + _is_confirmation_affirmed = is_confirmation_affirmed; _subs = Disposable.Create( parameter.OnDispatcher().Subscribe(p => _parameter = p), can_execute.OnDispatcher().Subscribe(ce => { @@ -243,10 +250,12 @@ namespace bts.spark { IDisposable _subs; T _parameter; bool _can_execute; + Func _is_confirmation_affirmed; + public override bool canExecute() => _can_execute; public override void execute(IBus bus) { - if (_can_execute) { + if (_can_execute && (_is_confirmation_affirmed == null || _is_confirmation_affirmed())) { try { bus.post(_tag, _parameter); } catch (Exception e) { @@ -334,3 +343,4 @@ namespace bts.spark { } } } + diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs index d91936652..a2df086d1 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs @@ -100,7 +100,14 @@ namespace mbts.ui.controls { PnLPrice = "PnL Price", Cancel = "Cancel", Attach = "Attach", - Detach = "Detach"; + Detach = "Detach", + MarketDescription = "Market Description", + ClearedAlias = "Cleared Alias", + ProductDescription = "Product Description", + HubAlias = "Hub Alias", + StripName = "Strip Name", + MicCode = "Mic Code" + ; } public interface IKeyedColumn { @@ -250,4 +257,4 @@ namespace mbts.ui.controls { public TColKey key { get; } } } -} \ No newline at end of file +} diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs b/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs index 0601158dd..2c40bbb28 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/Animation/IPredicateAnimations.cs @@ -11,26 +11,26 @@ namespace mbts.ui { IReadOnlyList sound_notifications { get; } } - interface IPredicateAnimationsData where TPredicateBuilder : IPredicateBuilder { - TPredicateBuilder predicate_builder { get; } + interface IPredicateAnimationsData { + TPredicateData predicate_data { get; } IReadOnlyList cell_animations { get; } IReadOnlyList row_animations { get; } IReadOnlyList sound_notifications { get; } } static class PredicateAnimations { - public static IPredicateAnimationsData create_data(TPredicateBuilder predicate_builder, IReadOnlyList cell_animations, IReadOnlyList row_animations, IReadOnlyList sounds) - where TPredicateBuilder : IPredicateBuilder => new PredicateAnimationsData(predicate_builder, cell_animations, row_animations, sounds); + public static IPredicateAnimationsData create_data(TPredicateData predicate_data, IReadOnlyList cell_animations, IReadOnlyList row_animations, IReadOnlyList sounds) + => new PredicateAnimationsData(predicate_data, cell_animations, row_animations, sounds); - class PredicateAnimationsData : IPredicateAnimationsData where TPredicateBuilder : IPredicateBuilder { - public PredicateAnimationsData(TPredicateBuilder predicate_builder, IReadOnlyList cell_animations, IReadOnlyList row_animations, IReadOnlyList sound_notifications) { - this.predicate_builder = predicate_builder; + class PredicateAnimationsData : IPredicateAnimationsData { + public PredicateAnimationsData(TPredicateData predicate_data, IReadOnlyList cell_animations, IReadOnlyList row_animations, IReadOnlyList sound_notifications) { + this.predicate_data = predicate_data; this.cell_animations = cell_animations; this.row_animations = row_animations; this.sound_notifications = sound_notifications; } - public TPredicateBuilder predicate_builder { get; } + public TPredicateData predicate_data { get; } public IReadOnlyList cell_animations { get; } public IReadOnlyList row_animations { get; } public IReadOnlyList sound_notifications { get; } diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs index 8e042dcc6..dd05d5978 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettingsVM.cs @@ -27,15 +27,15 @@ namespace mbts.spark { ImmutableFontWeight } - partial class GridSettingsVM { - public interface IColumnVM : ISimpleColumnVM, IValueFactory<(GridColumnSettings settings, ILookup animations)>, IDisposable { + partial class GridSettingsVM { + public interface IColumnVM : ISimpleColumnVM, IValueFactory<(GridColumnSettings settings, ILookup animations)>, IDisposable { ObservableEditableCollection predicate_animations { get; } - new (GridColumnSettings settings, ILookup animations) create(); - new void load_from((GridColumnSettings settings, ILookup animations) args); + new (GridColumnSettings settings, ILookup animations) create(); + new void load_from((GridColumnSettings settings, ILookup animations) args); } public class ColumnVM : DisposableViewModelBase, IColumnVM { - public readonly GridSettingsVM owner; + public readonly GridSettingsVM owner; readonly Property _id, _display_name; readonly Property _width; @@ -44,7 +44,7 @@ namespace mbts.spark { readonly Property _font_weight_override; GridColumnSettings _settings; - public ColumnVM(GridSettingsVM owner) { + public ColumnVM(GridSettingsVM owner) { this.owner = owner; _id = backing(nameof(id), string.Empty); _display_name = backing(nameof(display_name), string.Empty); @@ -60,7 +60,7 @@ namespace mbts.spark { _font_weight_override = backing(nameof(font_weight_override), FontWeights.Normal); // animations predicate_animations = new ObservableEditableCollection(() => - new PredicateCellAnimationVM(id, owner._create_column_predicate_vm(id)), true); + new PredicateCellAnimationVM(id, owner._create_column_predicate_vm(id), owner._predicate_data_factory), true); predicate_animations.CollectionChanged += WPFHelper.create_collection_changed_cb(on_items_added: (_, __) => owner.show_cell_predicate_animations = true); _dispose = Disposable.Create(() => predicate_animations.OfType().DisposeAll()); } @@ -81,17 +81,17 @@ namespace mbts.spark { // animations public ObservableEditableCollection predicate_animations { get; } - public (GridColumnSettings settings, ILookup animations) create() { + public (GridColumnSettings settings, ILookup animations) create() { var settings = _settings.with(display_name, is_visible, null, is_font_weight_overridden ? new NullableFontWeightProto(font_weight_override) : default, is_font_color_overridden ? new NullableColorProto(font_color_override.color) : default, width, horizontal_alignment); - var animations_lookup = predicate_animations.ToFlatLookup(pa => pa.predicate.create_assigned(), pa => pa.animations.Select(a => a.create())); + var animations_lookup = predicate_animations.ToFlatLookup(pa => pa.predicate.create_assigned(owner._predicate_data_factory), pa => pa.animations.Select(a => a.create())); return (settings, animations_lookup); } - public void load_from((GridColumnSettings settings, ILookup animations) value) { + public void load_from((GridColumnSettings settings, ILookup animations) value) { _settings = value.settings; _id.set(_settings.id); _display_name.set(_settings.display_name); @@ -107,7 +107,7 @@ namespace mbts.spark { font_color_override.load_from(new SolidColorBrush(_settings.font_color_override.Value)); } predicate_animations.SetItems(value.animations.empty_if_null().Select(g => { - var vm = new PredicateCellAnimationVM(id, owner._create_column_predicate_vm(id)); + var vm = new PredicateCellAnimationVM(id, owner._create_column_predicate_vm(id), owner._predicate_data_factory); vm.load_from((g.Key, g)); return vm; })); @@ -131,17 +131,19 @@ namespace mbts.spark { create().settings; void IValueFactory.load_from(GridColumnSettings value) => - load_from((value, new Dictionary().ToLookup(kv => kv.Key, kv => kv.Value))); + load_from((value, new Dictionary().ToLookup(kv => kv.Key, kv => kv.Value))); } - public class PredicateCellAnimationVM : DisposableViewModelBase, IValueFactory<(TPredicateBuilder predicate, IEnumerable animations)> { + public class PredicateCellAnimationVM : DisposableViewModelBase, IValueFactory<(TPredicateData predicate, IEnumerable animations)> { // readonly string _col_id; readonly Property _show_animations; + readonly Func _predicate_data_factory; - public PredicateCellAnimationVM(string col_id, IPropertyWrapperVM predicate) { + public PredicateCellAnimationVM(string col_id, IPropertyWrapperVM predicate, Func predicate_data_factory) { _col_id = col_id; this.predicate = predicate; + _predicate_data_factory = predicate_data_factory; _show_animations = backing(nameof(show_animations), true); animations = new ObservableEditableCollection(() => { var vm = new CellAnimationVM(col_id); @@ -152,15 +154,15 @@ namespace mbts.spark { _dispose = predicate as IDisposable; } - public IPropertyWrapperVM predicate { get; } + public IPropertyWrapperVM predicate { get; } public ObservableEditableCollection animations { get; } public IEnumerable animation_types { get; } = EnumHelper.get_values_except(CellAnimation.AnimationTypeOneofCase.None); public bool show_animations { get => _show_animations.Value; set => _show_animations.set(value); } - public (TPredicateBuilder predicate, IEnumerable animations) create() => - (predicate.create_assigned(), animations.Select(a => a.create())); + public (TPredicateData predicate, IEnumerable animations) create() => + (predicate.create_assigned(_predicate_data_factory), animations.Select(a => a.create())); - public void load_from((TPredicateBuilder predicate, IEnumerable animations) args) { + public void load_from((TPredicateData predicate, IEnumerable animations) args) { predicate.load_from(args.predicate); animations.SetItems(args.animations.Select(a => { var vm = new CellAnimationVM(_col_id); diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs index b3c153195..ee9025e06 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs @@ -5,8 +5,6 @@ using mbts.collections; using mbts.spark; using mbts.ui.settings; using mbts.ui.shell; -using mbts.ui.spark; -using mbts.ui.utility; using mbts.utils; using System; using System.Collections.Generic; @@ -17,16 +15,14 @@ using System.Windows.Media; using static mbts.ui.controls.DIYGrid; namespace mbts.ui { - class GridSettingsManager : + class GridSettingsManager : ViewModelBase, IValueFactory, IObserver, IDisposable where TRow : IRowVM - where TPredicateBuilder : IPredicateBuilder, new() - where TSettingsData : class, IGridSettingsWithNotifications { + where TSettingsData : class, IGridSettingsWithNotifications { // readonly IBus _bus; readonly OrdersModel _orders_model; - readonly INotificationService _notification_service; - readonly List _resources, _notification_subs = new List(); + readonly List _notification_subs = new List(); readonly ObservableCollection _columns; readonly ObservableCollection _rows; readonly Property _grid_settings; @@ -35,30 +31,45 @@ namespace mbts.ui { readonly DelegateProperty _font_size; readonly DelegateProperty _font_color, _selection_highlight; readonly SetMap, AnimationDefinitionWrapper> _animation_defs = new SetMap, AnimationDefinitionWrapper>(); - readonly TPredicateBuilderArg _arg; - readonly Func> _create_predicate_vm; - readonly Func> _create_column_predicate_vm; - readonly Func>, TSettingsData> _create_settings_obj; + readonly Func _predicate_data_factory; + readonly Func> _predicate_factory; + readonly Func> _notification_predicate_factory; + readonly Func> _create_predicate_vm; + readonly Func> _create_column_predicate_vm; + readonly Func>, TSettingsData> _create_settings_obj; + readonly Func, SoundNotification, IDisposable> _link_sound; + readonly Func, IDisposable> _link_toast_notification; readonly IReadOnlyDictionary _column_flags; - IEnumerable> _predicate_animations_data; + IEnumerable> _predicate_animations_data; public GridSettingsManager( - IObservable owner_title, IBus bus, INotificationService notification_service, OrdersModel orders_model, - ObservableCollection rows, ObservableCollection columns, - Func> create_predicate_vm, - Func> create_column_predicate_vm, - Func>, TSettingsData> create_settings_obj, - TPredicateBuilderArg arg, IReadOnlyDictionary column_flags = null) { + IObservable owner_title, + IBus bus, + OrdersModel orders_model, + ObservableCollection rows, + ObservableCollection columns, + Func predicate_data_factory, + Func> create_predicate_vm, + Func> create_column_predicate_vm, + Func>, TSettingsData> create_settings_obj, + Func> predicate_factory, + Func> notification_predicate_factory, + Func, SoundNotification, IDisposable> link_sound, + Func, IDisposable> link_toast_notification, + IReadOnlyDictionary column_flags = null) { // _bus = bus; - _notification_service = notification_service; _orders_model = orders_model; _rows = rows; _columns = columns; + _predicate_data_factory = predicate_data_factory; + _predicate_factory = predicate_factory; + _notification_predicate_factory = notification_predicate_factory; _create_predicate_vm = create_predicate_vm; _create_column_predicate_vm = create_column_predicate_vm; _create_settings_obj = create_settings_obj; - _arg = arg; + _link_sound = link_sound; + _link_toast_notification = link_toast_notification; _column_flags = column_flags.ToDictionary(kv => kv.Key, kv => ImmutableColumnSettingStore.create(kv.Value)); _grid_settings = backing(nameof(grid_settings), GridSettings.Default); _font_family = backing(nameof(font_family), () => new FontFamily(grid_settings.font_family), nameof(grid_settings)); @@ -66,32 +77,10 @@ namespace mbts.ui { _font_size = backing(nameof(font_size), () => grid_settings.font_size, nameof(font_size)); _font_color = backing(nameof(font_color), () => grid_settings.font_color.rgb_solid_brush().frozen(), nameof(grid_settings)); _selection_highlight = backing(nameof(selection_highlight), () => grid_settings.selection_highlight.to_brush().frozen(), nameof(grid_settings)); - _resources = new List { - (launch_settings_editor = new DialogCommand(create_settings_view)) - }; - // local methods - Window create_settings_view() { - var vm = new GridSettingsVM(owner_title, _bus, _orders_model, create_predicate_vm, create_column_predicate_vm, _create_settings_obj); - // need to refresh before launching the settings-view bc users can chanve some grid-column-settings properties directly from the grid (e.g. width, is_collapsed, etc.) - _grid_settings.set(grid_settings.with(columns.Select(c => c.create()))); - vm.load(_create_settings_obj(grid_settings, _predicate_animations_data)); - if (column_flags != null) { - foreach (var col in vm.columns) { - if (column_flags.TryGetValue(col.id, out GridColumnSettingsFeatureFlags f)) - col.apply_flags(f); - } - } - var window = new GridSettingsDialog { DataContext = vm }; - vm.committed += () => load_from(vm.get_result()); - vm.RequestClose += (s, e) => WindowUtilities.force_close(window); - return window; - } } - public void Dispose() { - Disposable.dispose(_resources); + public void Dispose() => Disposable.dispose(_notification_subs); - } public GridSettings grid_settings => _grid_settings.Value; public FontFamily font_family => _font_family.Value; @@ -99,10 +88,9 @@ namespace mbts.ui { public double font_size => _font_size.Value; public SolidColorBrush font_color => _font_color.Value; public SolidColorBrush selection_highlight => _selection_highlight.Value; - public IDialogCommand launch_settings_editor { get; } - public GridSettingsVM create_vm(GridSettings settings, IObservable title) { - var vm = new GridSettingsVM(title, _bus, _orders_model, _create_predicate_vm, _create_column_predicate_vm, _create_settings_obj, _column_flags.ToDictionary(kv => kv.Key, kv => kv.Value.flags)); + public GridSettingsVM create_vm(GridSettings settings, IObservable title) { + var vm = new GridSettingsVM(title, _bus, _orders_model, _predicate_data_factory, _notification_predicate_factory, _create_predicate_vm, _create_column_predicate_vm, _create_settings_obj, _column_flags.ToDictionary(kv => kv.Key, kv => kv.Value.flags)); vm.load(_create_settings_obj(settings, _predicate_animations_data)); return vm; } @@ -127,16 +115,16 @@ namespace mbts.ui { col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight); _predicate_animations_data = value.predicate_animations; _animation_defs.clear(); - if (_notification_service != null && _arg != null) { - foreach (var pa in _predicate_animations_data) { - var predicate = pa.predicate_builder.create_predicate(_arg); - foreach (var s in pa.sound_notifications) { - _notification_subs.Add(_notification_service.link(predicate, s)); - } - if (pa.predicate_builder is INotificationPredicateBuilder tpb && tpb.is_toast_enabled) { - _notification_subs.Add(_notification_service.link(tpb.create_notification_predicate(_arg))); - } + foreach (var pa in _predicate_animations_data) { + var predicate = _predicate_factory(pa.predicate_data); + if (predicate == null) + continue; + foreach (var s in pa.sound_notifications) { + _notification_subs.Add(_link_sound(predicate, s)); } + var notification_predicate = _notification_predicate_factory(pa.predicate_data); + if (notification_predicate != null) + _notification_subs.Add(_link_toast_notification(notification_predicate)); } // ** in the unfortunate event that we botch backwards compatability, and the columns don't bear a 1:1 relationship with the column-settings // don't add insult to injury by crashing ** diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs index 1666e0fc0..a7bc55036 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsVM.cs @@ -19,38 +19,38 @@ using CellAnimation = mbts.ui.CellAnimation; using FontFamily = System.Windows.Media.FontFamily; namespace mbts.spark { - interface IGridSettingsWithNotifications where TPredicateBuilder : IPredicateBuilder { + interface IGridSettingsWithNotifications { GridSettings general { get; } - IEnumerable> predicate_animations { get; } + IEnumerable> predicate_animations { get; } } - class GridSettingsWithNotifications : IEquatable> where TPredicateBuilder : IPredicateBuilder { + class GridSettingsWithNotifications : IEquatable> { public readonly GridSettings grid; - public readonly IEnumerable> predicate_animations_data; - public GridSettingsWithNotifications(GridSettings grid, IEnumerable> predicate_animations_data) { + public readonly IEnumerable> predicate_animations_data; + public GridSettingsWithNotifications(GridSettings grid, IEnumerable> predicate_animations_data) { this.grid = grid; this.predicate_animations_data = predicate_animations_data; } - public bool Equals(GridSettingsWithNotifications other) => + public bool Equals(GridSettingsWithNotifications other) => other != null && EqualityComparer.null_check_equals(grid, other.grid) && EqualityComparer.safe_sequence_equals(predicate_animations_data, other.predicate_animations_data); - public override bool Equals(object obj) => Equals(obj as GridSettingsWithNotifications); + public override bool Equals(object obj) => Equals(obj as GridSettingsWithNotifications); public override int GetHashCode() => EqualityComparer.aggregate_hash( EqualityComparer.safe_get_hash_code(grid), EqualityComparer.safe_aggregate_hash(predicate_animations_data)); } - partial class GridSettingsVM : DisposableViewModelBase, IRequestViewClose, IWindowSettingsVM, ITemplateSelectorKey - where TPredicateBuilder : IPredicateBuilder, new() - where TSettingsData :class, IGridSettingsWithNotifications { + partial class GridSettingsVM : DisposableViewModelBase, IRequestViewClose, IWindowSettingsVM, ITemplateSelectorKey + where TSettingsData :class, IGridSettingsWithNotifications { // - protected readonly Func> _create_predicate_vm; - protected readonly Func> _create_column_predicate_vm; - readonly Func>, TSettingsData> _create_settings_obj; + protected readonly Func> _create_predicate_vm; + protected readonly Func> _create_column_predicate_vm; + readonly Func _predicate_data_factory; + readonly Func>, TSettingsData> _create_settings_obj; readonly Property _current_column; readonly Property _font_family; readonly Property _font_weight; @@ -62,14 +62,17 @@ namespace mbts.spark { public GridSettingsVM( IObservable owner_title, IBus bus, OrdersModel orders_model, - Func> create_predicate_vm, - Func> create_column_predicate_vm, - Func>, TSettingsData> create_settings_obj, + Func predicate_data_factory, + Func> notification_predicate_factory, + Func> create_predicate_vm, + Func> create_column_predicate_vm, + Func>, TSettingsData> create_settings_obj, IReadOnlyDictionary column_flags = null) { // _owner_title = backing(nameof(owner_title), owner_title); this.bus = bus; _orders_model = orders_model; + _predicate_data_factory = predicate_data_factory; _create_predicate_vm = create_predicate_vm; _create_column_predicate_vm = create_column_predicate_vm; _create_settings_obj = create_settings_obj; @@ -82,7 +85,7 @@ namespace mbts.spark { _show_cell_predicate_animations = backing(nameof(show_cell_predicate_animations), true); _current_column = backing(nameof(current_column)); predicate_animations = new ObservableEditableCollection(() => - new PredicateRowAnimationVM(_create_predicate_vm()), true); + new PredicateRowAnimationVM(_create_predicate_vm(), _predicate_data_factory), true); predicate_animations.CollectionChanged += WPFHelper.create_collection_changed_cb(on_items_added: (_, __) => _show_predicate_animations.set(true)); } @@ -125,13 +128,13 @@ namespace mbts.spark { foreach (var c in columns) { var (settings, animations) = c.create(); col_settings.Add(settings); - foreach (IGrouping g in animations) + foreach (IGrouping g in animations) animation_map.AddOrUpdate(g.Key, p => animation_tuple(c: g), (p, t) => t.cell_animations.AddRange(g)); } return _create_settings_obj(new GridSettings(font_family.name(), font_size, font_weight, font_color.color.rgb_color(), selection_highlight.to_proto(), col_settings), - animation_map.Select(kv => PredicateAnimations.create_data(kv.Key, kv.Value.cell_animations, kv.Value.row_animations, kv.Value.sounds))); + animation_map.Select(kv => PredicateAnimations.create_data(kv.Key, kv.Value.cell_animations, kv.Value.row_animations, kv.Value.sounds))); // - (List row_animations, List sounds, List cell_animations) animation_tuple(IEnumerable r = null, IEnumerable s = null, IGrouping c = null) => + (List row_animations, List sounds, List cell_animations) animation_tuple(IEnumerable r = null, IEnumerable s = null, IGrouping c = null) => (r?.ToList() ?? new List(), s?.ToList() ?? new List(), c?.ToList() ?? new List()); } @@ -141,18 +144,18 @@ namespace mbts.spark { font_color.load_from(sd.general.font_color.rgb_solid_brush()); selection_highlight.load_from(sd.general.selection_highlight.to_brush()); _font_size.set(sd.general.font_size); - var col_animations = new Dictionary>>(); + var col_animations = new Dictionary>>(); predicate_animations.Clear(); foreach (var pa in sd.predicate_animations) { if (pa.row_animations.Count > 0 || pa.sound_notifications.Count > 0) { - var vm = new PredicateRowAnimationVM(_create_predicate_vm()); - vm.load_from((pa.predicate_builder, pa.row_animations, pa.sound_notifications)); + var vm = new PredicateRowAnimationVM(_create_predicate_vm(), _predicate_data_factory); + vm.load_from((pa.predicate_data, pa.row_animations, pa.sound_notifications)); predicate_animations.Add(vm); } foreach (var ca in pa.cell_animations) { col_animations.AddOrUpdate(ca.column_id, - col => new Dictionary> { { pa.predicate_builder, new List { ca } } }, - (col, d) => d.AddOrUpdate(pa.predicate_builder, p => new List { ca }, (p, l) => l.Add(ca))); + col => new Dictionary> { { pa.predicate_data, new List { ca } } }, + (col, d) => d.AddOrUpdate(pa.predicate_data, p => new List { ca }, (p, l) => l.Add(ca))); } } var curr_col_id = current_column?.id; @@ -171,11 +174,13 @@ namespace mbts.spark { _current_column.set(curr_column); } - public class PredicateRowAnimationVM : DisposableViewModelBase, IValueFactory<(TPredicateBuilder predicate, IEnumerable animations, IEnumerable sounds)> { + public class PredicateRowAnimationVM : DisposableViewModelBase, IValueFactory<(TPredicateData predicate, IEnumerable animations, IEnumerable sounds)> { readonly Property _show_animations/*, _play_sound*/; + readonly Func _predicate_state_factory; - public PredicateRowAnimationVM(IPropertyWrapperVM predicate) { + public PredicateRowAnimationVM(IPropertyWrapperVM predicate, Func predicate_state_factory) { this.predicate = predicate; + _predicate_state_factory = predicate_state_factory; _show_animations = backing(nameof(show_animations), true); //_play_sound = backing(nameof(play_sound), true); animations = new ObservableEditableCollection(() => { @@ -187,20 +192,20 @@ namespace mbts.spark { _dispose = predicate as IDisposable; } - public IPropertyWrapperVM predicate { get; } + public IPropertyWrapperVM predicate { get; } public ObservableEditableCollection animations { get; } public IEnumerable animation_types { get; } = EnumHelper.get_values_except(CellAnimation.AnimationTypeOneofCase.None); public bool show_animations { get => _show_animations.Value; set => _show_animations.set(value); } //public bool play_sound { get => _play_sound.Value; set => _play_sound.set(value); } public IPropertyWrapperVM sound { get; } = SoundAnimationVM.create_system_sound_vm(); - public (TPredicateBuilder predicate, IEnumerable animations, IEnumerable sounds) create() => - (predicate.create_assigned(), + public (TPredicateData predicate, IEnumerable animations, IEnumerable sounds) create() => + (predicate.create_assigned(_predicate_state_factory), animations.Select(a => a.create_assigned()), new[] { sound.create_assigned() }); //EnumerableExtensions.return_if(play_sound, () => sound.create_assigned())); - public void load_from((TPredicateBuilder predicate, IEnumerable animations, IEnumerable sounds) args) { + public void load_from((TPredicateData predicate, IEnumerable animations, IEnumerable sounds) args) { predicate.load_from(args.predicate); animations.SetItems(args.animations.Select(a => { var vm = new RowAnimationVM(); diff --git a/src/client/spark/view/Controls/DataGridEx/Filters/DataGridFilterHelper.cs b/src/client/spark/view/Controls/DataGridEx/Filters/DataGridFilterHelper.cs index 864026520..96308bbda 100644 --- a/src/client/spark/view/Controls/DataGridEx/Filters/DataGridFilterHelper.cs +++ b/src/client/spark/view/Controls/DataGridEx/Filters/DataGridFilterHelper.cs @@ -63,6 +63,7 @@ namespace mbts.spark.filters { TimeFilter = "TimeFilterTemplate", DiscreteValues = "DiscreteValuesTemplate", EnumValues = "EnumValuesTemplate", - Regex = "RegexTemplate"; + Regex = "RegexTemplate", + YesNo = "YesNoTemplate"; } } \ No newline at end of file diff --git a/src/client/spark/view/Controls/DataGridEx/Filters/Views/FilterTemplates.xaml b/src/client/spark/view/Controls/DataGridEx/Filters/Views/FilterTemplates.xaml index 925c3958a..26ff10f0a 100644 --- a/src/client/spark/view/Controls/DataGridEx/Filters/Views/FilterTemplates.xaml +++ b/src/client/spark/view/Controls/DataGridEx/Filters/Views/FilterTemplates.xaml @@ -146,6 +146,27 @@ /> + + + + + + + + + + + error_margin) { // 1 = task bar on left, so nudge right // -1 = task on right, so nuedge left nudge_direction = (task_bar_rect.Left == 0) ? 1 : -1; - window.Left = window.Left + nudge_direction * intersection.Width; + window.Left = source_window_rect.Left + nudge_direction * intersection.Width; } - if (intersection.Height < window.Height) { + if ((source_window_rect.Height - intersection.Height) > error_margin) { // 1 = task bar on top, so nudge down // -1 = task on bottom, so nuedge up nudge_direction = (task_bar_rect.Top == 0) ? 1 : -1; - window.Top = window.Top + nudge_direction * intersection.Height; - + window.Top = source_window_rect.Top + nudge_direction * intersection.Height; } - // update the rect w/ the new window position to see if we have to go another round - source_window_rect = new Rect((int)window.Left, (int)window.Top, (int)window.Width, (int)window.Height); - - } - } + source_window_rect = new Rect(window.Left, window.Top, window.ActualWidth, window.ActualHeight); + } + } } } } diff --git a/src/client/spark/view/Resources/Converters.xaml b/src/client/spark/view/Resources/Converters.xaml index 8c2d1da49..f31f2aef3 100644 --- a/src/client/spark/view/Resources/Converters.xaml +++ b/src/client/spark/view/Resources/Converters.xaml @@ -83,4 +83,7 @@ + + + diff --git a/src/client/spark/view/Spark/PAndL/PAndLVM.cs b/src/client/spark/view/Spark/PAndL/PAndLVM.cs index a5ca17a3a..a694a41e1 100644 --- a/src/client/spark/view/Spark/PAndL/PAndLVM.cs +++ b/src/client/spark/view/Spark/PAndL/PAndLVM.cs @@ -20,6 +20,7 @@ using mbts.ui.settings; namespace mbts.spark { class PAndLVM : DisposableViewModelBase { + public PAndLVM(IBus bus, PAndLModel model, PAndLStartupData startup_data, IWindowSettingsManager settings_manager) { _bus = bus; _model = model; @@ -42,6 +43,10 @@ namespace mbts.spark { if (p != null) { PnLCalculator calc = new PnLCalculator(p.state.Values, _selected_pnl_calc_type.Value); var summary_position_rows = calc.get_summary_position(); + // remove rows for which there is no net pos or no day pos + summary_position_rows = summary_position_rows.Where(r => + !(r.start_net_position == 0 && r.day_long_quantity == 0 && r.day_short_quantity == 0) + ); _pnl_data.sync_with(summary_position_rows); _last_pnl_update_time = DateTime.Now; } @@ -64,6 +69,11 @@ namespace mbts.spark { total_pnl_filter.load_state(fs.total_pnl); pnl_price_filter.load_state(fs.pnl_price); security_type_filter.load_state(fs.security_types); + has_day_trades_filter.load_state(fs.has_day_trades); + } else { + // this is debt that will have to be paid down at some point, similar to the pnl_calc_type thing above + // these should come from the default startup_data. + security_type_filter.load_state(new[] { SecurityType.Future }); } pnl_view.CollectionChanged += Pnl_view_CollectionChanged; @@ -77,6 +87,7 @@ namespace mbts.spark { add_col(Columns.DayLong, DefaultColumnHeaders.DayLong, r => r.day_long_quantity.ToString(), nameof(PnLSummaryRow.day_long_quantity), DefaultColumnWidths.PnL_Generic, day_long_quantity_filter, DataGridFilterKnownTemplates.UIntMinMax, HorizontalAlignment.Right); add_col(Columns.DayShort, DefaultColumnHeaders.DayShort, r => r.day_short_quantity.ToString(), nameof(PnLSummaryRow.day_short_quantity), DefaultColumnWidths.PnL_Generic, day_short_quantity_filter, DataGridFilterKnownTemplates.UIntMinMax, HorizontalAlignment.Right); add_col(Columns.DayPNL, DefaultColumnHeaders.DayPnL, r => r.day_pnl_text, nameof(PnLSummaryRow.day_pnl), 90, day_pnl_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right, r => r.day_pnl_background); + add_col(Columns.TradedToday, "Traded Today", r => r.has_day_trades_text, nameof(PnLSummaryRow.has_day_trades), 100, has_day_trades_filter, DataGridFilterKnownTemplates.YesNo, HorizontalAlignment.Center); add_col(Columns.TotalNetPos, DefaultColumnHeaders.TotalNetPos, r => r.total_net_position.ToString(), nameof(PnLSummaryRow.total_net_position), DefaultColumnWidths.Total_Net_Pos, total_net_position_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right); add_col(Columns.TotalPNL, DefaultColumnHeaders.TotalPnL, r => r.total_pnl_text, nameof(PnLSummaryRow.total_pnl), DefaultColumnWidths.PnL_Generic, total_pnl_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right, r => r.total_pnl_background); add_col(Columns.PNLPrice, DefaultColumnHeaders.PnLPrice, r => r.pnl_price_text, nameof(PnLSummaryRow.pnl_price), DefaultColumnWidths.PnL_Generic, pnl_price_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right); @@ -125,7 +136,8 @@ namespace mbts.spark { pnl_price_filter, weighted_average_buy_filter, weighted_average_sell_filter, - security_type_filter), + security_type_filter, + has_day_trades_filter), WorkLoop.Start("PAndL", _UPDATE_PERIOD, _calculate_pnl) ); } @@ -245,6 +257,7 @@ namespace mbts.spark { public IDataGridColumnPersistentFilter weighted_average_buy_filter { get; } = new DoubleMinMax(r => r.weighted_average_buy, nameof(PnLSummaryRow.weighted_average_buy)); public IDataGridColumnPersistentFilter weighted_average_sell_filter { get; } = new DoubleMinMax(r => r.weighted_average_sell, nameof(PnLSummaryRow.weighted_average_sell)); public IDataGridColumnPersistentFilter security_type_filter { get; } = DiscreteValuesFilterVM.Create(EnumHelper.get_values_except(SecurityType.Option, SecurityType.Stock, SecurityType.Synthetic).ToArray(), r => r.security_type, nameof(PnLSummaryRow.security_type)); + public IDataGridColumnPersistentFilter has_day_trades_filter { get; } = DiscreteValuesFilterVM.Create(new[] { true, false }, r => r.has_day_trades, nameof(PnLSummaryRow.has_day_trades)); public FilterStates get_filters_states() => new FilterStates { account_regex = account_filter.get_state(), @@ -259,7 +272,8 @@ namespace mbts.spark { total_net_pos = total_net_position_filter.get_state(), total_pnl = total_pnl_filter.get_state(), pnl_price = pnl_price_filter.get_state(), - security_types = security_type_filter.get_state() + security_types = security_type_filter.get_state(), + has_day_trades = has_day_trades_filter.get_state(), }; #endregion diff --git a/src/client/spark/view/Spark/PAndL/PAndLView.xaml.cs b/src/client/spark/view/Spark/PAndL/PAndLView.xaml.cs index 19871786a..04ceb59d0 100644 --- a/src/client/spark/view/Spark/PAndL/PAndLView.xaml.cs +++ b/src/client/spark/view/Spark/PAndL/PAndLView.xaml.cs @@ -3,7 +3,7 @@ using System.Windows.Controls; namespace mbts.spark { internal partial class PAndLView : UserControl { - public enum Columns { Account, Exchange, Symbol, Security, SecurityType, StartNetPos, StartPNL, DayLong, DayShort, DayPNL, TotalNetPos, TotalPNL, PNLPrice } + public enum Columns { Account, Exchange, Symbol, Security, SecurityType, StartNetPos, StartPNL, DayLong, DayShort, DayPNL, TotalNetPos, TotalPNL, PNLPrice, TradedToday } public PAndLView(PAndLVM vm) { InitializeComponent(); diff --git a/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs b/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs index 0b276cc26..fa9dc2ec8 100644 --- a/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs +++ b/src/client/spark/view/Spark/PAndL/PnLSummaryRow.cs @@ -184,6 +184,10 @@ namespace mbts.spark { public string weighted_average_buy_text => _weighted_average_buy.text; public double weighted_average_sell => _weighted_average_sell.value; public string weighted_average_sell_text => _weighted_average_sell.text; + // + public bool has_day_trades => day_long_quantity != 0 || day_short_quantity != 0; + public string has_day_trades_text => has_day_trades ? "Yes" : "No"; + public void raise_invalidated() => invalidated?.Invoke(); diff --git a/src/client/spark_api/Co2/MDConsumerHandle.cs b/src/client/spark_api/Co2/MDConsumerHandle.cs index 3f5c6502e..4a12f2f99 100644 --- a/src/client/spark_api/Co2/MDConsumerHandle.cs +++ b/src/client/spark_api/Co2/MDConsumerHandle.cs @@ -244,7 +244,7 @@ namespace mbts.co2 { } } - [StructLayout(LayoutKind.Sequential, Size = 376)] + [StructLayout(LayoutKind.Sequential, Size = 704)] internal struct ColdEntry { public int exchange_status; // Last trade diff --git a/src/client/spark_api/md/MarketDataClient.cs b/src/client/spark_api/md/MarketDataClient.cs index 87749fcee..3e5e0b4fb 100644 --- a/src/client/spark_api/md/MarketDataClient.cs +++ b/src/client/spark_api/md/MarketDataClient.cs @@ -189,7 +189,7 @@ namespace bts.md var sec = lookup(key); if (sec.HasValue) { - security_desc = sec.Value.glbx_desc(); + security_desc = sec.Value.security_desc(); return true; } return false; @@ -198,7 +198,7 @@ namespace bts.md public bool lookup_security_key_from_desc(string security_desc, out SecurityKey key) { key = 0; - var fnd = find(x => x.glbx_desc() == security_desc).TryFirst(); + var fnd = find(x => x.security_desc() == security_desc).TryFirst(); if (fnd.HasValue) { key = fnd.Value.security.Id; diff --git a/src/client/spark_api/security/SecurityFormatter.cs b/src/client/spark_api/security/SecurityFormatter.cs index 0a328cdf2..f67123fca 100644 --- a/src/client/spark_api/security/SecurityFormatter.cs +++ b/src/client/spark_api/security/SecurityFormatter.cs @@ -39,7 +39,7 @@ namespace bts.api { static string _format(SecurityImmutable? security) { switch (security?.ContractCase) { - case ContractOneofCase.Future: return format_future(security?.Symbol, security?.glbx_desc(), security.Value.Future); + case ContractOneofCase.Future: return format_future(security?.Symbol, security?.security_desc(), security.Value.Future); case ContractOneofCase.Spread: if (security?.HasGlbx == true) { // In case we ever bring it back, pretty printed spread names can be found here: diff --git a/src/client/spark_api/security/SecurityHelper.cs b/src/client/spark_api/security/SecurityHelper.cs index 7ef75b988..905d34846 100644 --- a/src/client/spark_api/security/SecurityHelper.cs +++ b/src/client/spark_api/security/SecurityHelper.cs @@ -19,7 +19,7 @@ namespace bts.api { foreach (var l in legs) { switch (l.Security.ContractCase) { case ContractOneofCase.Future: - yield return new FutureLeg(l.Security.Exchange, l.Security.Symbol, l.Security.glbx_desc(), l.Security.Future, qty * l.SignedQuantity()); + yield return new FutureLeg(l.Security.Exchange, l.Security.Symbol, l.Security.security_desc(), l.Security.Future, qty * l.SignedQuantity()); break; case ContractOneofCase.Spread: foreach (var fl in _get_flat_future_legs(l.Security.Spread.Legs, qty * l.SignedQuantity())) @@ -57,8 +57,18 @@ namespace bts.api { public static string DisplayExchange(this SecurityImmutable security) => security.ContractCase == ContractOneofCase.Synthetic ? $"[{string.Join(",", get_flat_future_legs(security).Select(flt => flt.exchange.ToString()).Distinct().OrderBy(e => e))}]" : security.Exchange.ToString(); - public static string glbx_desc(this SecurityImmutable security) => - security.HasGlbx ? security.Glbx.SecurityDesc ?? string.Empty : string.Empty; + public static string security_desc(this SecurityImmutable security) + { + if(security.HasGlbx) + return security.Glbx.SecurityDesc; + else if(security.HasIce) + return security.Ice.SecurityDesc; + else + { + Log.assert(false, "security_desc not implemented for exchange"); + return null; + } + } #endregion public static class Comparer { diff --git a/src/data_files/CMakeDeps.cmake b/src/data_files/CMakeDeps.cmake index db22eba31..c72de1cbb 100644 --- a/src/data_files/CMakeDeps.cmake +++ b/src/data_files/CMakeDeps.cmake @@ -1 +1 @@ -set(sources files/Onixs.BTS.lic;files/cert_secure_logon.txt;files/futures.coconut.xz;files/perf_trace/compiled.css;files/perf_trace/index.html;files/perf_trace/jquery-3.3.1.min.js;files/perf_trace/main.js;files/perf_trace/perf_log.sql;files/perf_trace/perf_trace_analysis.sql;files/perf_trace/plotly-latest.min.js) \ No newline at end of file +set(sources files/Onixs.BTS.lic;files/cert_secure_logon.txt;files/futures.coconut.xz;files/onixs_ice/ConnectivityConfiguration.APITest.xml;files/onixs_ice/ConnectivityConfiguration.PerfTest.xml;files/onixs_ice/ConnectivityConfiguration.Production.xml;files/perf_trace/compiled.css;files/perf_trace/index.html;files/perf_trace/jquery-3.3.1.min.js;files/perf_trace/main.js;files/perf_trace/perf_log.sql;files/perf_trace/perf_trace_analysis.sql;files/perf_trace/plotly-latest.min.js) \ No newline at end of file diff --git a/src/data_files/files/onixs_ice/ConnectivityConfiguration.APITest.xml b/src/data_files/files/onixs_ice/ConnectivityConfiguration.APITest.xml new file mode 100644 index 000000000..334c3c48f --- /dev/null +++ b/src/data_files/files/onixs_ice/ConnectivityConfiguration.APITest.xml @@ -0,0 +1,659 @@ + + + + + + + + 63.247.113.163 + 3000 + bluetrd-ps + Starts123 + N + Legacy + + + + 63.247.113.77 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.113.229 + 3000 + bluetrdl-ps + Starts123 + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Dutch TTF Gas Futures + German Natural Gas Futures + European Gas Spreads + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + Belgian Power Futures + Dutch Power Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + CIF US + Financial Environmental + European Power Spreads + TAQA + Belgian ZTP Gas Spot + Dutch TTF Gas Spot + Dutch TTF Gas Storage + European Gas Spot Spreads + Belgian ZTP Gas Futures + Belgian Gas Spreads + German Power Futures + Atlantic Coal Futures + Financial Olefins + Financial Monomers + Endex Spot Market Indices + Russell Cash Indices + Interest Rate Futures + Singapore Energy + Singapore Financials + Singapore Metals + Italian Natural Gas Futures + Italian Power Futures + World Cotton + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe STIRs + Liffe Bonds + Liffe Swapnotes + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Liffe Three Month Euro and EONIA + Eurodollar + Liffe Equity Derivatives - Non-US Based + Liffe Equity Derivatives - US Based + Liffe Index Options + Liffe Index Futures - US Restricted + Liffe Index Futures - Non-US Restricted + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + diff --git a/src/data_files/files/onixs_ice/ConnectivityConfiguration.PerfTest.xml b/src/data_files/files/onixs_ice/ConnectivityConfiguration.PerfTest.xml new file mode 100644 index 000000000..23680779e --- /dev/null +++ b/src/data_files/files/onixs_ice/ConnectivityConfiguration.PerfTest.xml @@ -0,0 +1,364 @@ + + + + + + + + + 63.247.113.214 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + Financial Environmental + Atlantic Coal Futures + Financial Olefins + Financial Monomers + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Eurodollar + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + diff --git a/src/data_files/files/onixs_ice/ConnectivityConfiguration.Production.xml b/src/data_files/files/onixs_ice/ConnectivityConfiguration.Production.xml new file mode 100644 index 000000000..796e1d195 --- /dev/null +++ b/src/data_files/files/onixs_ice/ConnectivityConfiguration.Production.xml @@ -0,0 +1,677 @@ + + + + + + + + + 63.247.112.185 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.112.190 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.125.185 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Dutch TTF Gas Futures + German Natural Gas Futures + European Gas Spreads + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + Belgian Power Futures + Dutch Power Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + CIF US + Financial Environmental + European Power Spreads + TAQA + Belgian ZTP Gas Spot + Dutch TTF Gas Spot + Dutch TTF Gas Storage + European Gas Spot Spreads + Belgian ZTP Gas Futures + Belgian Gas Spreads + German Power Futures + Atlantic Coal Futures + Financial Olefins + Financial Monomers + Russell Cash Indices + Interest Rate Futures + Italian Natural Gas Futures + Italian Power Futures + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe STIRs + Liffe Bonds + Liffe Swapnotes + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Liffe Three Month Euro and EONIA + Eurodollar + Liffe Equity Derivatives - Non-US Based + Liffe Equity Derivatives - US Based + Liffe Index Options + Liffe Index Futures - US Restricted + Liffe Index Futures - Non-US Restricted + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + \ No newline at end of file diff --git a/src/lib/CMakeDeps.cmake b/src/lib/CMakeDeps.cmake index 8bc562736..7330ed683 100644 --- a/src/lib/CMakeDeps.cmake +++ b/src/lib/CMakeDeps.cmake @@ -1 +1 @@ -set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metrics/system_metrics.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderBuilder.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServices.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/core/IOrderServices.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.cpp;orderman/limiter/ProductLimitNode.cpp;orderman/limiter/ProductLimitTree.cpp;orderman/limiter/SecurityLimitNode.cpp;orderman/limiter/SecurityLimitTree.cpp;orderman/limiter/tests/limit_tests.cpp;orderman/order_factory/DynamicOrderRegistry.cpp;orderman/order_factory/OrderFactory.cpp;orderman/order_router/OrderRouter.cpp;orderman/orderman_utils/fix_order_codec.cpp;orderman/orderman_utils/orderman_utils.cpp;orderman/orders/DynamicOrder.cpp;orderman/orders/IcebergOrder.cpp;orderman/orders/IcebergOrder2.cpp;orderman/orders/NativeOrder.cpp;orderman/orders/Order.cpp;orderman/orders/TimeBoxOrder.cpp;orderman/orders/TriggerOrder.cpp;orderman/orders/book_algos/BookAlgo.cpp;orderman/orders/book_algos/BookOrderBase.cpp;orderman/orders/book_algos/CoverOrder.cpp;orderman/orders/book_algos/JoinOrder.cpp;orderman/orders/book_algos/JoinOrder2.cpp;orderman/orders/book_algos/LeanOrder.cpp;orderman/orders/book_algos/OCOOrder.cpp;orderman/orders/book_algos/OffsetOrder.cpp;orderman/orders/book_algos/PricerOrder.cpp;orderman/orders/book_algos/TopOrder.cpp;orderman/orders/book_algos/TopOrder2.cpp;orderman/orders/spreader_orders/SpreaderOrder.cpp;orderman/orders/spreader_orders/spreader/LegFillState.cpp;orderman/orders/spreader_orders/spreader/LegPropertyData.cpp;orderman/orders/spreader_orders/spreader/QuoteLegPriceQuantityState.cpp;orderman/orders/spreader_orders/spreader/SingleFillHedger.cpp;orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp;orderman/orders/spreader_orders/spreader/SpreaderBookkeepingData.cpp;orderman/orders/spreader_orders/spreader/SpreaderChildOrderState.cpp;orderman/orders/spreader_orders/spreader/SpreaderLegData.cpp;orderman/orders/spreader_orders/spreader/SpreaderUtils.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderBuilder.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderServices.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderPreActivationOrderServices.cpp;orderman/orders/spreader_orders/spreader/hedger/HedgerManager.cpp;orderman/orders/spreader_orders/spreader/hedger/UnhedgedDelta.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckCancelledStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSet.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSetHistory.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteLegDriver.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckCancelledWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForIOCWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderEndStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderStartStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForCancelAllStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForInitialDataStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWorkingStateWorker.cpp;orderman/orders/spreader_orders/tests/spreader_tests.cpp;orderman/server/OrderServiceServer.cpp;orderman/tests/fat_wrapper_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/persistence_utils.cpp;persistence/tests/PersistenceServiceTests.cpp;plugin/SparkServices.cpp;plugin/plugin.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;tracing/PerfLog.cpp;tracing/bts_trace.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp) \ No newline at end of file +set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metrics/system_metrics.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderBuilder.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServices.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/core/IOrderServices.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.cpp;orderman/limiter/ProductLimitNode.cpp;orderman/limiter/ProductLimitTree.cpp;orderman/limiter/SecurityLimitNode.cpp;orderman/limiter/SecurityLimitTree.cpp;orderman/limiter/tests/limit_tests.cpp;orderman/order_factory/DynamicOrderRegistry.cpp;orderman/order_factory/OrderFactory.cpp;orderman/order_router/OrderRouter.cpp;orderman/orderman_utils/fix_order_codec.cpp;orderman/orderman_utils/orderman_utils.cpp;orderman/orders/DynamicOrder.cpp;orderman/orders/IcebergOrder.cpp;orderman/orders/IcebergOrder2.cpp;orderman/orders/NativeOrder.cpp;orderman/orders/Order.cpp;orderman/orders/TimeBoxOrder.cpp;orderman/orders/TriggerOrder.cpp;orderman/orders/book_algos/BookAlgo.cpp;orderman/orders/book_algos/BookOrderBase.cpp;orderman/orders/book_algos/CoverOrder.cpp;orderman/orders/book_algos/JoinOrder.cpp;orderman/orders/book_algos/JoinOrder2.cpp;orderman/orders/book_algos/LeanOrder.cpp;orderman/orders/book_algos/OCOOrder.cpp;orderman/orders/book_algos/OffsetOrder.cpp;orderman/orders/book_algos/PricerOrder.cpp;orderman/orders/book_algos/TopOrder.cpp;orderman/orders/book_algos/TopOrder2.cpp;orderman/orders/spreader_orders/SpreaderOrder.cpp;orderman/orders/spreader_orders/spreader/LegFillState.cpp;orderman/orders/spreader_orders/spreader/LegPropertyData.cpp;orderman/orders/spreader_orders/spreader/QuoteLegPriceQuantityState.cpp;orderman/orders/spreader_orders/spreader/SingleFillHedger.cpp;orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp;orderman/orders/spreader_orders/spreader/SpreaderBookkeepingData.cpp;orderman/orders/spreader_orders/spreader/SpreaderChildOrderState.cpp;orderman/orders/spreader_orders/spreader/SpreaderLegData.cpp;orderman/orders/spreader_orders/spreader/SpreaderUtils.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderBuilder.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderOrderServices.cpp;orderman/orders/spreader_orders/spreader/external_interfacing/SpreaderPreActivationOrderServices.cpp;orderman/orders/spreader_orders/spreader/hedger/HedgerManager.cpp;orderman/orders/spreader_orders/spreader/hedger/UnhedgedDelta.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckCancelledStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSet.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSetHistory.cpp;orderman/orders/spreader_orders/spreader/quoter/QuoteLegDriver.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckCancelledWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForIOCWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderEndStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderStartStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForCancelAllStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForInitialDataStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWorkingStateWorker.cpp;orderman/orders/spreader_orders/tests/spreader_tests.cpp;orderman/server/OrderServiceServer.cpp;orderman/tests/fat_wrapper_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/persistence_utils.cpp;persistence/tests/PersistenceServiceTests.cpp;plugin/SparkServices.cpp;plugin/plugin.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;tracing/PerfLog.cpp;tracing/bts_trace.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp) diff --git a/src/lib/CMakeDeps_win.cmake b/src/lib/CMakeDeps_win.cmake index 879f19a67..67cdb8a9f 100644 --- a/src/lib/CMakeDeps_win.cmake +++ b/src/lib/CMakeDeps_win.cmake @@ -1 +1 @@ -set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp) \ No newline at end of file +set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/ice/ICEUtils.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp) \ No newline at end of file diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 65064d4d2..2bc9cd150 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -141,4 +141,4 @@ if (WIN32) include(${CMAKE_SOURCE_DIR}/tools/vs_filters.cmake) endif() - \ No newline at end of file + diff --git a/src/lib/config/ConfigurationState.cpp b/src/lib/config/ConfigurationState.cpp index df1f97e64..dce50e8c6 100755 --- a/src/lib/config/ConfigurationState.cpp +++ b/src/lib/config/ConfigurationState.cpp @@ -40,7 +40,7 @@ #include "lib/config_proto_files.h" #include "lib/config_defaults.h" -using namespace std; +using namespace std; namespace bts { namespace config { diff --git a/src/lib/config/defaults/MarketData.conf b/src/lib/config/defaults/MarketData.conf index 967d94285..94b3ba277 100644 --- a/src/lib/config/defaults/MarketData.conf +++ b/src/lib/config/defaults/MarketData.conf @@ -12,6 +12,7 @@ MarketDataConfig { PlatformMap { value { glbx_platform: "PLATFORM_MDP3ONIXS" + ice_platform: "PLATFORM_ICEONIXS" } } @@ -37,6 +38,35 @@ CMEOptions { } } +ICEPublisherOptions { + value { + network_interface: "eth1" + } +} + +#to make this work in dev clone the operations repo +#go here: c:\\code\\bts\\operations\\ice\\ICE_iMpactMulticastFeed_GettingStarted-1_1_36\\bin\\easyTunnel> +#modify the easyTunnelProxy.properties file to replace +#tunnel.multicast.interface=10.96.18.37 with your local ip +#run easyTunnelProxy.bat BRENT-FI for Brent Full implied +#you should see ice data + +ICEOptions { + value { + channel { + name: "oil" #these names are arbitrary and are for debugging + market_type: 5 #ICE Futures Brent, IPE Brent Futures + market_type: 9 #ICE Futures WTI, ICE WTI Crude Futures + #udp_buffer_size: 33554432 #32mb + } + channel { + name: "juice" + market_type: 23 #ICE Futures US Agricultures, FCOJ A + } + ice_config_file: "ConnectivityConfiguration.APITest.xml" + } +} + MDBootDelayWindow { rule: "DeploymentType.type == 'dev'" value { @@ -56,4 +86,4 @@ MDBootDelayWindow { end: "14:10" } } -} \ No newline at end of file +} diff --git a/src/lib/config/defaults/Symbols.conf b/src/lib/config/defaults/Symbols.conf index e29ad43d0..147e5c917 100644 --- a/src/lib/config/defaults/Symbols.conf +++ b/src/lib/config/defaults/Symbols.conf @@ -1,37 +1,52 @@ - -SymbolList { - value { - symbol: "HE" - symbol: "LE" - symbol: "CL" - symbol: "RB" - symbol: "HO" - symbol: "BZ" - symbol: "NG" - symbol: "GC" - symbol: "SI" - symbol: "HG" - symbol: "ZW" - symbol: "ZC" - symbol: "ZS" - symbol: "ZM" - symbol: "ZL" - symbol: "ZO" - symbol: "ZR" - symbol: "ZB" - symbol: "ZN" - symbol: "ZF" - symbol: "ZT" - symbol: "UB" - } +SymbolLists +{ + value + { + list + { + key: "ICE" + + # symbol: "BRN" + # symbol: "WBS" + # symbol: "OJ" + } + list + { + key: "GLBX" + + symbol: "HE" + symbol: "LE" + symbol: "CL" + symbol: "RB" + symbol: "HO" + symbol: "BZ" + symbol: "NG" + symbol: "GC" + symbol: "SI" + symbol: "HG" + symbol: "ZW" + symbol: "ZC" + symbol: "ZS" + symbol: "ZM" + symbol: "ZL" + symbol: "ZO" + symbol: "ZR" + symbol: "ZB" + symbol: "ZN" + symbol: "ZF" + symbol: "ZT" + symbol: "UB" + symbol: "GE" + } + } } Symbols { rule: "DeploymentType.type == 'DEMO' and System.platform == 'windows'" value { sim { - future: @SymbolList.symbol - spread: @SymbolList.symbol + future: @SymbolLists.list[GLBX].symbol + spread: @SymbolLists.list[GLBX].symbol } } } @@ -40,8 +55,8 @@ Symbols { rule: "DeploymentType.type == 'PROD' and System.platform == 'windows'" value { glbx { - future: @SymbolList.symbol - spread: @SymbolList.symbol + future: @SymbolLists.list[GLBX].symbol + spread: @SymbolLists.list[GLBX].symbol } } } @@ -49,12 +64,16 @@ Symbols { Symbols { value { glbx { - future: @SymbolList.symbol - spread: @SymbolList.symbol + future: @SymbolLists.list[GLBX].symbol + spread: @SymbolLists.list[GLBX].symbol } sim { - future: @SymbolList.symbol - spread: @SymbolList.symbol + future: @SymbolLists.list[GLBX].symbol + spread: @SymbolLists.list[GLBX].symbol } + ice { + future: @SymbolLists.list[ICE].symbol + spread: @SymbolLists.list[ICE].symbol + } } } diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index c52377235..be967e9d4 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -13,6 +13,8 @@ message PlatformMap { // PLATFORM_MDP3ONIXS optional string glbx_platform = 1 [default = "PLATFORM_SIM"]; + // PLATFORM_ICEONIXS + optional string ice_platform = 2 [default = "PLATFORM_ICEONIXS"]; } // LOCAL TIME @@ -52,6 +54,14 @@ message PublisherOptions optional bool skip_options = 13 [default = true]; } +message ICEPublisherOptions +{ + optional string network_interface = 3 [default = "0.0.0.0"]; + // Supply either network_interface -or- network_interface_[a,b] + optional string network_interface_a = 30; + optional string network_interface_b = 31; +} + message PlatformConfig { required string platform = 1; @@ -125,6 +135,49 @@ message CMEOptions optional bool verbose_ticker = 7 [default=false]; } +// +// ICE Options +// +message ICEOptions +{ + enum OnixSLogMode { + Fatal = 0; + Error = 1; + Warning = 2; + Info = 3; + Trace = 4; + Debug = 5; + } + + //A channel is one onixs-ice thread + message ICEChannel { + required string name = 1; + repeated uint32 market_type = 2; + optional uint32 udp_buffer_size = 3 [default = 4194304]; //4mb + optional uint32 heartbeat_interval = 4 [default = 36000]; + optional uint32 sequence_gap_margin = 5 [default = 10000]; + optional uint32 gap_timeout_in_ms = 6 [default = 10000]; + + optional int32 snapshot_recovery_timeout_in_ms = 10 [default = -1]; + optional int32 maximum_number_of_snapshot_recovery_attempts = 11 [default = -1]; + optional int32 maximum_size_of_snapshot_message_queue = 12 [default = -1]; + optional int32 maximum_size_of_live_message_queue = 13 [default = 200000]; + + optional string processing_thread_affinity = 20 [default = ""]; + optional bool track_top_of_the_book_only = 30 [default = false]; + optional bool receive_product_definitions_only = 31 [default = false]; + optional uint32 max_multicast_message_block_size = 32 [default = 1400]; + optional string product_definition_cache_directory = 35 [default = ""]; + + optional OnixSLogMode onixs_log_mode = 40 [default = Warning]; + optional bool load_security_db = 41 [default = true]; + } + + optional string onixs_license = 1 [default = "{default}"]; + optional string ice_config_file = 2 [default = "ConnectivityConfiguration.Production.xml"]; + repeated ICEChannel channel = 3; +} + message RecordOptions { // optional string output_path = 2 [default = "/home/bts/md/today"]; optional bool enable_depth = 3 [default = false]; diff --git a/src/lib/config/protos/Symbols.proto b/src/lib/config/protos/Symbols.proto index bf52f670e..6d859c13f 100644 --- a/src/lib/config/protos/Symbols.proto +++ b/src/lib/config/protos/Symbols.proto @@ -19,4 +19,5 @@ message SecurityExchangeList { message Symbols { optional SecurityExchangeList glbx = 10; optional SecurityExchangeList sim = 20; + optional SecurityExchangeList ice = 30; } \ No newline at end of file diff --git a/src/lib/domain_model/Security.cpp b/src/lib/domain_model/Security.cpp index ea84b2c41..6f51a5d9d 100644 --- a/src/lib/domain_model/Security.cpp +++ b/src/lib/domain_model/Security.cpp @@ -24,6 +24,8 @@ std::string descriptor(api::Security const&sec) { if (sec.has_glbx()) return sec.glbx().security_desc(); + else if (sec.has_ice()) + return sec.ice().security_desc(); else return "No descriptor for non glbx exchange"; } diff --git a/src/lib/domain_model/Security.proto b/src/lib/domain_model/Security.proto index 2f517c5d8..9e16fd9b4 100644 --- a/src/lib/domain_model/Security.proto +++ b/src/lib/domain_model/Security.proto @@ -101,6 +101,17 @@ message CBOECFEExchangeData { int32 class_key = 30; } message ICEExchangeData { + int64 exchange_id = 10; + string security_desc = 15; //contractSymbol + int32 deal_display_factor = 20; + int32 settle_display_factor = 30; + + string market_description = 100; + string cleared_alias = 110; + string product_name = 120; + string hub_alias = 130; + string strip_name = 140; + string mic_code = 150; } message FutureContract { diff --git a/src/lib/md/Diag/ShmDumper.cpp b/src/lib/md/Diag/ShmDumper.cpp index a0b4272d0..d12f4c729 100644 --- a/src/lib/md/Diag/ShmDumper.cpp +++ b/src/lib/md/Diag/ShmDumper.cpp @@ -90,6 +90,13 @@ string dump_security(const FixedSecurity& security) { res << "'low_tick': " << security.low_tick << ", "; res << "'high_tick': " << security.high_tick << ", "; res << "'cpp': " << security.cash_per_point << ", "; + + res << "'market_description ': " << security.ice_market_description() << ", "; + res << "'cleared_alias ': " << security.ice_cleared_alias() << ", "; + res << "'product_description ': " << security.ice_product_name() << ", "; + res << "'hub_alias ': " << security.ice_hub_alias() << ", "; + res << "'strip_name': " << security.ice_strip_name() << ", "; + res << "'mic_code': " << security.mic_code() << ", "; switch(security.type) { case SECURITYTYPE_STOCK: break; diff --git a/src/lib/md/PlatformLoader.cpp b/src/lib/md/PlatformLoader.cpp index 717e8e88c..4188210f5 100644 --- a/src/lib/md/PlatformLoader.cpp +++ b/src/lib/md/PlatformLoader.cpp @@ -61,6 +61,10 @@ void PlatformLoader::run() { switch (_platform) { case PLATFORM_MDP3ONIXS: break; + case PLATFORM_MDP3EMUMBA: + break; + case PLATFORM_ICEONIXS: + break; default: bts_assert(false); break; @@ -86,8 +90,7 @@ void add_symbols_to_result( size_t get_system_md_symbols(api::Venue exchange, SecurityType type, std::set &result) { - bts_assert(config::system_symbols::Symbols::descriptor()->field_count() == - 2); + bts_assert(config::system_symbols::Symbols::descriptor()->field_count() == 3); { auto const &e = config::get().glbx(); if (exchange == api::VENUE_UNSET || exchange == api::VENUE_GLBX) { @@ -118,6 +121,28 @@ size_t get_system_md_symbols(api::Venue exchange, SecurityType type, } } } + + { + auto const &e = config::get().ice(); + if (exchange == api::VENUE_UNSET || exchange == api::VENUE_ICE) + { + if (type == api::SECURITYTYPE_FUTURE || type == api::SECURITYTYPE_UNSET) + add_symbols_to_result(e.future(), api::VENUE_ICE, api::SECURITYTYPE_FUTURE, &result); + if (type == api::SECURITYTYPE_OPTION || type == api::SECURITYTYPE_UNSET) + add_symbols_to_result(e.option(), api::VENUE_ICE, api::SECURITYTYPE_OPTION, &result); + if (type == api::SECURITYTYPE_SPREAD || type == api::SECURITYTYPE_UNSET) + add_symbols_to_result(e.spread(), api::VENUE_ICE, api::SECURITYTYPE_SPREAD, &result); + } + if (exchange == api::VENUE_BTS || exchange == api::VENUE_UNSET) + { + std::set all_symbols; + all_symbols.insert(e.future().begin(), e.future().end()); + all_symbols.insert(e.option().begin(), e.option().end()); + all_symbols.insert(e.spread().begin(), e.spread().end()); + for (const auto &symbol : all_symbols) + result.insert(UserSymbol(symbol, api::VENUE_BTS, api::SECURITYTYPE_SYNTHETIC)); + } + } { auto const &e = config::get().sim(); @@ -181,10 +206,15 @@ std::set get_system_md_symbols() { extern "C" BTS_EXPORT Platform platform_for_exchange(Venue v) { const auto &pmap = config::get(); co2::Platform platform; - if (v == VENUE_SIM) return PLATFORM_SIM; - if (co2::Platform_Parse(pmap.glbx_platform(), &platform)) { - return platform; - } + if (v == VENUE_SIM) + return PLATFORM_SIM; + if (v == VENUE_ICE && co2::Platform_Parse(pmap.ice_platform(), &platform)) + return platform; + + //md2_tests.cpp depends on this fall through to yield SIM as the GLBX platform + if (co2::Platform_Parse(pmap.glbx_platform(), &platform)) + return platform; + return PLATFORM_UNSET; } diff --git a/src/lib/md/Shm/FixedSecurity.cpp b/src/lib/md/Shm/FixedSecurity.cpp index 7f7f78787..a159e291a 100644 --- a/src/lib/md/Shm/FixedSecurity.cpp +++ b/src/lib/md/Shm/FixedSecurity.cpp @@ -31,6 +31,8 @@ FixedSecurity::FixedSecurity() : cme_main_fraction(0), cme_sub_fraction(0), cme_price_display_format(0), + ice_deal_display_factor(0), + ice_settle_display_factor(0), _symbol(), _cfi_code(), _security_desc(), @@ -41,6 +43,13 @@ FixedSecurity::FixedSecurity() : memset(_cfi_code, 0, BTS_ARRAYSIZE(_cfi_code)); memset(_security_desc, 0, BTS_ARRAYSIZE(_security_desc)); memset(_platform_id, 0, BTS_ARRAYSIZE(_platform_id)); + + memset(_ice_market_description, 0, BTS_ARRAYSIZE(_ice_market_description)); + memset(_ice_cleared_alias, 0, BTS_ARRAYSIZE(_ice_cleared_alias)); + memset(_ice_product_name, 0, BTS_ARRAYSIZE(_ice_product_name)); + memset(_ice_hub_alias, 0, BTS_ARRAYSIZE(_ice_hub_alias)); + memset(_ice_strip_name, 0, BTS_ARRAYSIZE(_ice_strip_name)); + memset(_mic_code, 0, BTS_ARRAYSIZE(_mic_code)); } FixedSecurity::~FixedSecurity(){} @@ -169,6 +178,19 @@ void convert_security(const FixedSecurity& source, Security* presult) { dest.mutable_glbx()->set_cme_symbol(source.alt_symbol()); if (source.cme_market_segment_id != 0) dest.mutable_glbx()->set_market_segment_id(source.cme_market_segment_id); break; + case Venue::VENUE_ICE: + dest.mutable_ice()->set_exchange_id(source.numeric_id); + dest.mutable_ice()->set_security_desc(source.security_desc()); + dest.mutable_ice()->set_deal_display_factor(source.ice_deal_display_factor); + dest.mutable_ice()->set_settle_display_factor(source.ice_settle_display_factor); + + dest.mutable_ice()->set_market_description(source.ice_market_description()); + dest.mutable_ice()->set_cleared_alias(source.ice_cleared_alias()); + dest.mutable_ice()->set_product_name(source.ice_product_name()); + dest.mutable_ice()->set_hub_alias(source.ice_hub_alias()); + dest.mutable_ice()->set_strip_name(source.ice_strip_name()); + dest.mutable_ice()->set_mic_code(source.mic_code()); + break; case Venue::VENUE_BTS: break; default: @@ -257,7 +279,7 @@ uint64_t exchange_id(const Security& security) { case Security::ExchangeDataCase::kCboe: return security.cboe().exchange_id(); case Security::ExchangeDataCase::kGlbx: return security.glbx().exchange_id(); case Security::ExchangeDataCase::kCfe: return security.cfe().exchange_id(); - case Security::ExchangeDataCase::kIce: bts_assert(false); + case Security::ExchangeDataCase::kIce: return security.ice().exchange_id(); // Debatable whether this should be an error or not. // If is possible that we might create a spread with no exchange in the future // and if we did this would be a runtime error. @@ -288,7 +310,18 @@ void convert_security(const Security& src, FixedSecurity& dest, bool set_securit dest.cboe_class_key = src.cfe().class_key(); break; case Security::ExchangeDataCase::kIce: - bts_assert_d(false); + dest.numeric_id = src.ice().exchange_id(); + dest.security_desc(src.ice().security_desc()); + dest.ice_deal_display_factor = src.ice().deal_display_factor(); + dest.ice_settle_display_factor = src.ice().settle_display_factor(); + + dest.ice_market_description(src.ice().market_description()); + dest.ice_cleared_alias(src.ice().cleared_alias()); + dest.ice_product_name(src.ice().product_name()); + dest.ice_hub_alias(src.ice().hub_alias()); + dest.ice_strip_name(src.ice().strip_name()); + dest.mic_code(src.ice().mic_code()); + break; case Security::ExchangeDataCase::EXCHANGEDATA_NOT_SET: break; } diff --git a/src/lib/md/Shm/FixedSecurity.h b/src/lib/md/Shm/FixedSecurity.h index 0ad9e4ffa..853db1308 100644 --- a/src/lib/md/Shm/FixedSecurity.h +++ b/src/lib/md/Shm/FixedSecurity.h @@ -59,13 +59,29 @@ public: uint8_t cme_main_fraction; uint8_t cme_sub_fraction; uint8_t cme_price_display_format; + int8_t ice_deal_display_factor; + int8_t ice_settle_display_factor; + + STRING_PROPERTY(ice_market_description); + STRING_PROPERTY(ice_cleared_alias); + STRING_PROPERTY(ice_product_name); + STRING_PROPERTY(ice_hub_alias); + STRING_PROPERTY(ice_strip_name); + STRING_PROPERTY(mic_code); private: char _symbol[16]; // CME defines this as a char[6] but I'm padding char _cfi_code[8]; // CME defines this as char[6] - char _security_desc[32]; // cme security desc FIX=107 + char _security_desc[32]; // cme security desc FIX=107 //ice wants this to be 35 char _alt_symbol[16]; // "cme symbol" or alternate symbol char _platform_id[64]; + + char _ice_market_description[120]; + char _ice_cleared_alias[15]; + char _ice_product_name[62]; + char _ice_hub_alias[80]; + char _ice_strip_name[39]; + char _mic_code[4]; }; class FixedStockSecurity : public FixedSecurity { @@ -171,6 +187,7 @@ private: }; // Stack allocate a FixedSpreadSecurity with a high number of legs then memcpy the right size to shared memory +typedef FixedSpreadSecurity<2> FixedSpreadSecurityXS; typedef FixedSpreadSecurity<16> FixedSpreadSecurityS; typedef FixedSpreadSecurity<128> FixedSpreadSecurityL; typedef FixedSpreadSecurity<512> FixedSpreadSecurityXL; diff --git a/src/lib/md/cme/MDP3Utils.cpp b/src/lib/md/cme/MDP3Utils.cpp index 3e027653d..ae3ac82cd 100644 --- a/src/lib/md/cme/MDP3Utils.cpp +++ b/src/lib/md/cme/MDP3Utils.cpp @@ -163,5 +163,5 @@ const vector parse_channels(const vector& symbols) { return result; } -}}//namespace +}} //namespace #endif \ No newline at end of file diff --git a/src/lib/md/ice/ConnectivityConfiguration.APITest.xml b/src/lib/md/ice/ConnectivityConfiguration.APITest.xml new file mode 100644 index 000000000..4cb6546b7 --- /dev/null +++ b/src/lib/md/ice/ConnectivityConfiguration.APITest.xml @@ -0,0 +1,659 @@ + + + + + + + + 63.247.113.163 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.113.77 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.113.229 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Dutch TTF Gas Futures + German Natural Gas Futures + European Gas Spreads + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + Belgian Power Futures + Dutch Power Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + CIF US + Financial Environmental + European Power Spreads + TAQA + Belgian ZTP Gas Spot + Dutch TTF Gas Spot + Dutch TTF Gas Storage + European Gas Spot Spreads + Belgian ZTP Gas Futures + Belgian Gas Spreads + German Power Futures + Atlantic Coal Futures + Financial Olefins + Financial Monomers + Endex Spot Market Indices + Russell Cash Indices + Interest Rate Futures + Singapore Energy + Singapore Financials + Singapore Metals + Italian Natural Gas Futures + Italian Power Futures + World Cotton + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe STIRs + Liffe Bonds + Liffe Swapnotes + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Liffe Three Month Euro and EONIA + Eurodollar + Liffe Equity Derivatives - Non-US Based + Liffe Equity Derivatives - US Based + Liffe Index Options + Liffe Index Futures - US Restricted + Liffe Index Futures - Non-US Restricted + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + diff --git a/src/lib/md/ice/ConnectivityConfiguration.PerfTest.xml b/src/lib/md/ice/ConnectivityConfiguration.PerfTest.xml new file mode 100644 index 000000000..23680779e --- /dev/null +++ b/src/lib/md/ice/ConnectivityConfiguration.PerfTest.xml @@ -0,0 +1,364 @@ + + + + + + + + + 63.247.113.214 + 3000 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + Financial Environmental + Atlantic Coal Futures + Financial Olefins + Financial Monomers + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Eurodollar + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + diff --git a/src/lib/md/ice/ConnectivityConfiguration.Production.xml b/src/lib/md/ice/ConnectivityConfiguration.Production.xml new file mode 100644 index 000000000..796e1d195 --- /dev/null +++ b/src/lib/md/ice/ConnectivityConfiguration.Production.xml @@ -0,0 +1,677 @@ + + + + + + + + + 63.247.112.185 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.112.190 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 63.247.125.185 + 80 + Value from ICE Support + Value from ICE Support + N + Legacy + + + + 16 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Financial Gas + Financial Power + Oil + IPE Natural Gas Futures + IPE Gas Oil Futures + IPE Brent Futures + IPE UK Electricity Futures Peak + IPE UK Electricity Futures Base + ICE WTI Crude Futures + gC Newcastle Coal Futures + ICE Brent-WTI Futures Spread + IPE-ECX European Emissions + ICE Heating Oil Futures + ICE Heating Oil/WTI Futures Crack + ICE NYH (RBOB) Gasoline Futures + ICE NYH (RBOB) Gasoline/WTI Futures Crack + ICE Rotterdam Coal Futures + ICE Richards Bay Coal Futures + ICE Rotterdam/Richards Bay Coal Futures Spread + Cocoa + Coffee C + Cotton No 2 + FCOJ A + Sugar No 11 + Heat Rate Spread + US Dollar Index + ICE Middle East Sour Crude Futures + ICE Brent/Middle East Crude Futures Spread + ICE WTI/Middle East Crude Futures Spread + Canadian Oilseeds + Canadian Grains + ICE ECX CER Futures + Foreign Exchange + Financial Index Data + Sugar No 16 + ECX EUA/CER Futures Spread + Henry Hub + Dutch TTF Gas Futures + German Natural Gas Futures + European Gas Spreads + Canadian Financial Gas + NGX Canadian Physical Crude + US Coal Futures + FOB Indo sub-bit Coal Futures + Heating Oil/Brent Futures Crack + NYH (RBOB) Gasoline/Brent Futures Crack + NYH (RBOB) Gasoline/Heating Oil Spread + Physical Environmental + Heating Oil/LS Gasoil Futures Spread + LS Gasoil/Brent Futures Crack + NYH (RBOB) Gasoline/LS Gasoil Futures Spread + ECX EUAA Futures + ECX CER/EUAA Futures Spread + ECX EUAA/EUA Futures Spread + Soybean + Wheat + Corn + CFR South China Coal Futures + Belgian Power Futures + Dutch Power Futures + gC Newcastle/FOB Indo sub-bit Coal Futures Spread + Richards Bay/gC Newcastle Coal Futures Spread + CIF US + Financial Environmental + European Power Spreads + TAQA + Belgian ZTP Gas Spot + Dutch TTF Gas Spot + Dutch TTF Gas Storage + European Gas Spot Spreads + Belgian ZTP Gas Futures + Belgian Gas Spreads + German Power Futures + Atlantic Coal Futures + Financial Olefins + Financial Monomers + Russell Cash Indices + Interest Rate Futures + Italian Natural Gas Futures + Italian Power Futures + ICE Rotterdam/Newcastle Coal Futures Spread + IFUS ICE Indices + Liffe STIRs + Liffe Bonds + Liffe Swapnotes + Liffe Commodities + Metals + IFUS Equity Indices + GCF Repo + Liffe Three Month Euro and EONIA + Eurodollar + Liffe Equity Derivatives - Non-US Based + Liffe Equity Derivatives - US Based + Liffe Index Options + Liffe Index Futures - US Restricted + Liffe Index Futures - Non-US Restricted + NGX Physical Gas + NGX Financial Power + Financial NGL + Olefins/Polymers + + + \ No newline at end of file diff --git a/src/lib/md/ice/ICEUtils.cpp b/src/lib/md/ice/ICEUtils.cpp new file mode 100644 index 000000000..d25fb696a --- /dev/null +++ b/src/lib/md/ice/ICEUtils.cpp @@ -0,0 +1,126 @@ +#ifndef _WIN32 +#include "ICEUtils.h" + +#include "lib/config/config.h" +#include "lib/utils/datetime.h" +#include "lib/utils/bts_chrono.h" +#include "lib/utils/download.h" +#include "lib/logging/logging.h" +#include "lib/md/get_symbols.h" + +#include "lib/config/protos/MarketData.pb.h" +#include "lib/config/protos/system.pb.h" + +#include +#include + + +using namespace std; +using namespace bts::api; + +namespace bts { +namespace md { +namespace ice { + +std::string ICEChannel::to_string() const +{ + std::string mt = name; + for(const auto& x : market_types) + mt += " " + x; + return mt; +} + +//We are sort of punting on symbols here because there is no symbol -> channel mapping supplied by ice +//therefore we must 1) enumerate the channels we want in config, and smash them together with the list of +//symbols we care about. This has the unfortunate side effect of not knowing what channel should heartbeat what symbol +//but Eric says this is ok +const vector parse_ice_channels(const vector& symbols) +{ + vector result; + const auto& ice_options = config::get(); + for(const auto& x : ice_options.channel()) + { + md::ice::ICEChannel chan; + chan.name = x.name(); + chan.symbols.insert(symbols.begin(), symbols.end()); + for(const auto& xx : x.market_type()) + chan.market_types.push_back(xx); + result.push_back(chan); + } + return result; +} + + +string ice_data_path() { + auto p = config::get().data_path() + "onixs_ice/"; +#ifdef _WIN32 + // OnixS requires win32 paths to look like Win32 paths - everyone else in the world is ok with '/' + os::normalize_path(p, '\\'); +#else + os::normalize_path(p); +#endif + return p; +} +const string ice_config_file() { return config::get().ice_config_file(); } +const string ice_config_path() { return ice_data_path() + "/" + ice_config_file(); } + +const std::string ice_log_path() {return log:: log_path().string() + "/onix_ice";} + +bool ice_check_file_exists_with_instructions(const string& filename, const string& url, bool log) { + // if (!boost::filesystem::exists(filename)) { + // download_file(url.c_str(), filename.c_str()); + // } + if (!boost::filesystem::exists(filename)) { + if (log) { + LOG(md,Error, + "File {} is not present on this system. " + "Please download it from the ICE web site. " + "I will wait until the file is present.\n$ curl {} > {} ", + filename, url, filename); + } + return false; + } + return true; +} + +// For exponential backoff on logging this return true if x is a power of 2 or 0 +bool is_pow_two_or_0(uint32_t x) { return (x & (~x + 1)) == x; } + +void await_ice_config() { + std::string config_url; + + if (config::get().type() != "dev") { + config_url = "https://drive.google.com/open?id=13_eyF2pKtn3F7chgsa_75ftUdf7emMbp"; + } + else { + config_url = "https://community.theice.com/docs/DOC-19989"; + } + + boost::filesystem::create_directories(ice_data_path()); + boost::filesystem::create_directories(ice_log_path()); + + // Check config is present and give instructions for downloading it if not + // If the file is not present log an error and wait a second. Continue to log the error ever power of 2 seconds until the file appears or the process is killed. + auto configpath = ice_config_path(); + uint32_t count = 0; + while(!ice_check_file_exists_with_instructions(configpath, config_url, is_pow_two_or_0(count))) { + ++count; + std::this_thread::sleep_for(1s); + } + // If we waited for someone to download the file give it a second to be finished downloading + if (count > 0) { + std::this_thread::sleep_for(1s); + } +} + + +const std::vector get_configured_ice_channels() { + std::vector symbols; + // Get all ice symbols + get_system_md_symbols(api::VENUE_ICE, api::SECURITYTYPE_UNSET, &symbols); + return parse_ice_channels(symbols); +} + + +}}} //namespace +#endif \ No newline at end of file diff --git a/src/lib/md/ice/ICEUtils.h b/src/lib/md/ice/ICEUtils.h new file mode 100644 index 000000000..5e0df291e --- /dev/null +++ b/src/lib/md/ice/ICEUtils.h @@ -0,0 +1,29 @@ +#pragma once + +#include "lib/md/coconut2.h" +#include +#include +#include + +namespace bts { +namespace md { +namespace ice { + +struct ICEChannel +{ + std::string name; + std::vector market_types; + std::set symbols; + std::string to_string() const; +}; + +void await_ice_config(); +const std::vector get_configured_ice_channels(); +const std::vector parse_ice_channels(const std::vector& symbols); + +const std::string ice_config_path(); +const std::string ice_log_path(); + + +}}} //namespace + diff --git a/src/lib/md/protos/co2.proto b/src/lib/md/protos/co2.proto index b05794f9c..8d5355be6 100644 --- a/src/lib/md/protos/co2.proto +++ b/src/lib/md/protos/co2.proto @@ -11,6 +11,7 @@ enum Platform { PLATFORM_MDP3ONIXS = 10; PLATFORM_CELOXICA = 13; PLATFORM_MDP3EMUMBA = 14; + PLATFORM_ICEONIXS = 15; } enum TradingStatus { diff --git a/src/lib/md/relay/QueryServer.cpp b/src/lib/md/relay/QueryServer.cpp index e8331308b..7b409662f 100644 --- a/src/lib/md/relay/QueryServer.cpp +++ b/src/lib/md/relay/QueryServer.cpp @@ -376,6 +376,14 @@ public: google::protobuf::MapPair v(h.handle.key(), security.glbx().security_desc()); x->insert(v); } + else if (security.ExchangeData_case() == Security::kIce) { + google::protobuf::MapPair v(h.handle.key(), security.ice().security_desc()); + x->insert(v); + } + else + { + LOG(md,Error, "Invalid ExchangeData_case {}", security.ExchangeData_case()); + } } } } diff --git a/src/lib/orderman/orders/spreader_orders/spreader/hedger/HedgerManager.h b/src/lib/orderman/orders/spreader_orders/spreader/hedger/HedgerManager.h index bc6b7e676..c54821ba5 100644 --- a/src/lib/orderman/orders/spreader_orders/spreader/hedger/HedgerManager.h +++ b/src/lib/orderman/orders/spreader_orders/spreader/hedger/HedgerManager.h @@ -33,7 +33,7 @@ public: for (auto& h : _hedgers) if(h.is_free()) return h; - LOG(OrderMan, Error, "HedgerManager::get_hedger allocating new hedger {} ", + LOG(OrderMan, Info, "HedgerManager::get_hedger allocating new hedger {} ", _hedgers.size()); _hedgers.emplace_back(_spreader_manager, _leg_property_data, diff --git a/src/lib/utils/init_spark_lib.cpp b/src/lib/utils/init_spark_lib.cpp index d9dc6fab9..452936018 100644 --- a/src/lib/utils/init_spark_lib.cpp +++ b/src/lib/utils/init_spark_lib.cpp @@ -17,6 +17,7 @@ void init_spark_lib() void finit_spark_lib() { + LOG(Gen, Info, "finit_spark_lib"); if (poller) { delete poller; } diff --git a/src/server/sparkd/CMakeDeps.cmake b/src/server/sparkd/CMakeDeps.cmake index ff557cbbe..a4aceb09a 100644 --- a/src/server/sparkd/CMakeDeps.cmake +++ b/src/server/sparkd/CMakeDeps.cmake @@ -1 +1 @@ -set(sources algo/AlgoDefinitionServiceServer.cpp;algo/AlgoServiceServer.cpp;cmds/AdminReport.cpp;cmds/AutoCert.cpp;cmds/Benchmark.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/Help.cpp;cmds/Md.cpp;cmds/PrintHedgeOrders.cpp;cmds/QuickTest.cpp;cmds/Run.cpp;cmds/RunSim.cpp;cmds/Span.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;cmds/Web.cpp;dspark/mirage/quick_queue/quick_queue.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/book/Book.cpp;exchange_sim/book/ExchangeSim.proto;exchange_sim/book/Order.cpp;exchange_sim/book/OrderMatcher.cpp;exchange_sim/book/book_transform.cpp;exchange_sim/tests/test_book_transform.cpp;http/ApiGateway.cpp;http/WebServer.cpp;main.cpp;md/ChannelVolume.cpp;md/MarketDataAuxiliaryServiceServer.cpp;md/VolumeAtPriceState.cpp;md/platforms/celoxica/CXListener.cpp;md/platforms/celoxica/CXMain.cpp;md/platforms/celoxica/tests/cx_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;position/IMarginObserver.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/PositionServiceCore.cpp;position/PositionServiceServer.cpp;position/tests/PositionTests.cpp;support/ErrorReportService.cpp;support/ShellLatencyServer.cpp;user/AdminServiceServer.cpp;user/AuthServiceServer.cpp;user/tests/admin_service_tests.cpp) \ No newline at end of file +set(sources algo/AlgoDefinitionServiceServer.cpp;algo/AlgoServiceServer.cpp;cmds/AdminReport.cpp;cmds/AutoCert.cpp;cmds/Benchmark.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/Help.cpp;cmds/Md.cpp;cmds/PrintHedgeOrders.cpp;cmds/QuickTest.cpp;cmds/Run.cpp;cmds/RunSim.cpp;cmds/Span.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;cmds/Web.cpp;dspark/mirage/quick_queue/quick_queue.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/book/Book.cpp;exchange_sim/book/ExchangeSim.proto;exchange_sim/book/Order.cpp;exchange_sim/book/OrderMatcher.cpp;exchange_sim/book/book_transform.cpp;exchange_sim/tests/test_book_transform.cpp;http/ApiGateway.cpp;http/WebServer.cpp;main.cpp;md/ChannelVolume.cpp;md/MarketDataAuxiliaryServiceServer.cpp;md/VolumeAtPriceState.cpp;md/platforms/IMDPlatform.cpp;md/platforms/celoxica/CXListener.cpp;md/platforms/celoxica/CXMain.cpp;md/platforms/celoxica/tests/cx_tests.cpp;md/platforms/ice_onixs/ICEListener.cpp;md/platforms/ice_onixs/ICEMain.cpp;md/platforms/ice_onixs/tests/ice_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;position/IMarginObserver.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/PositionServiceCore.cpp;position/PositionServiceServer.cpp;position/tests/PositionTests.cpp;support/ErrorReportService.cpp;support/ShellLatencyServer.cpp;user/AdminServiceServer.cpp;user/AuthServiceServer.cpp;user/tests/admin_service_tests.cpp) \ No newline at end of file diff --git a/src/server/sparkd/CMakeLists.txt b/src/server/sparkd/CMakeLists.txt index 2213ae62c..802ffd19b 100644 --- a/src/server/sparkd/CMakeLists.txt +++ b/src/server/sparkd/CMakeLists.txt @@ -26,6 +26,8 @@ target_link_libraries( sparkd cryptopp tbb onixs-cmemdh-all-4.8.0 + OnixS.IceImpactMulticastPriceFeedHandlerCpp + ACE quickfix benchmark lttng-ust diff --git a/src/server/sparkd/exchange_sim/ExchangeSim.cpp b/src/server/sparkd/exchange_sim/ExchangeSim.cpp index d457d53d5..a60118485 100644 --- a/src/server/sparkd/exchange_sim/ExchangeSim.cpp +++ b/src/server/sparkd/exchange_sim/ExchangeSim.cpp @@ -107,11 +107,14 @@ struct MDPlayer : md::IRelayWriter obs.on_depth(*sec_ptr, bids, asks, nullptr, nullptr); } - if (cr.has_misc()) { - if (cr.misc().has_settlement()) { - const auto& s = cr.misc().settlement(); - obs.on_settlement(*sec_ptr, { s.mantissa(), (int8_t)s.exponent() }); - } + if (cr.has_misc()) { + const auto& s = cr.misc(); + obs.on_high(*sec_ptr, s.session_high()); + obs.on_low(*sec_ptr, s.session_low()); + obs.on_open(*sec_ptr, s.open_price()); + obs.on_close(*sec_ptr, s.close_price()); + if (cr.misc().has_settlement()) + obs.on_settlement(*sec_ptr, { s.settlement().mantissa(), (int8_t)s.settlement().exponent() }); } } } diff --git a/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp b/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp index cf426fd65..9be135a9a 100644 --- a/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp +++ b/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp @@ -500,10 +500,11 @@ void ExchangeSimApplication::update_md(std::string const &sec_desc) { for (auto &t : new_trades) handle.add_trade( utils::TimeStamp::now(), - md::PriceSize_from_double<7>(t.price.value() * price_factor, - t.quantity.value()), + md::PriceSize_from_double(t.price.value() * price_factor,t.quantity.value()), datetime::ll_now(), - co2::AGGRESSOR_SIDE_NONE); + t.bid_aggressor ? co2::AGGRESSOR_SIDE_BUY + : ( t.ask_aggressor ? co2::AGGRESSOR_SIDE_SELL + : co2::AGGRESSOR_SIDE_NONE) ); } } @@ -557,6 +558,42 @@ void ExchangeSimApplication::on_settlement(md::Security const& sec, md::IntPrice } } +void ExchangeSimApplication::on_high(md::Security const& sec, md::Price price) { + auto sec_desc = get_sim_sec_desc(sec); + auto iter = me->md_producer_handles.find(sec_desc); + if (iter != me->md_producer_handles.end()) { + auto &handle = iter->second; + handle.update_session_high(utils::TimeStamp::now(), price); + } +} + +void ExchangeSimApplication::on_low(md::Security const& sec, md::Price price) { + auto sec_desc = get_sim_sec_desc(sec); + auto iter = me->md_producer_handles.find(sec_desc); + if (iter != me->md_producer_handles.end()) { + auto &handle = iter->second; + handle.update_session_low(utils::TimeStamp::now(), price); + } +} + +void ExchangeSimApplication::on_open(md::Security const& sec, md::Price price) { + auto sec_desc = get_sim_sec_desc(sec); + auto iter = me->md_producer_handles.find(sec_desc); + if (iter != me->md_producer_handles.end()) { + auto &handle = iter->second; + handle.update_opening(utils::TimeStamp::now(), price, datetime::today()); + } +} + +void ExchangeSimApplication::on_close(md::Security const& sec, md::Price price) { + auto sec_desc = get_sim_sec_desc(sec); + auto iter = me->md_producer_handles.find(sec_desc); + if (iter != me->md_producer_handles.end()) { + auto &handle = iter->second; + handle.update_closing(utils::TimeStamp::now(), price, datetime::today()); + } +} + void ExchangeSimApplication::on_depth( md::Security const &sec, md::PriceSize bids[md::COCONUT_MAX_DEPTH], diff --git a/src/server/sparkd/exchange_sim/ExchangeSimApplication.h b/src/server/sparkd/exchange_sim/ExchangeSimApplication.h index 90bfa7edf..5261df51f 100644 --- a/src/server/sparkd/exchange_sim/ExchangeSimApplication.h +++ b/src/server/sparkd/exchange_sim/ExchangeSimApplication.h @@ -100,7 +100,11 @@ public: void persist_book(OrderBook const &b); void on_new_security(md::Security const&) override; - void on_settlement(md::Security const&, md::IntPrice) override; + void on_high(md::Security const& sec, md::Price price) override; + void on_low(md::Security const& sec, md::Price price) override; + void on_open(md::Security const& sec, md::Price price) override; + void on_close(md::Security const& sec, md::Price price) override; + void on_settlement(md::Security const&, md::IntPrice) override; void on_depth(md::Security const&s, md::PriceSize bids[md::COCONUT_MAX_DEPTH], md::PriceSize asks[md::COCONUT_MAX_DEPTH], diff --git a/src/server/sparkd/exchange_sim/IMDPlayerObserver.h b/src/server/sparkd/exchange_sim/IMDPlayerObserver.h index b2e194b34..9708d2e75 100644 --- a/src/server/sparkd/exchange_sim/IMDPlayerObserver.h +++ b/src/server/sparkd/exchange_sim/IMDPlayerObserver.h @@ -9,7 +9,11 @@ namespace sim { struct IMDPlayerObserver { virtual void on_new_security(md::Security const&) = 0; - virtual void on_settlement(const md::Security&, md::IntPrice) = 0; + virtual void on_high(const md::Security&, md::Price) = 0; + virtual void on_low(const md::Security&, md::Price) = 0; + virtual void on_open(const md::Security&, md::Price) = 0; + virtual void on_close(const md::Security&, md::Price) = 0; + virtual void on_settlement(const md::Security&, md::IntPrice) = 0; virtual void on_depth(md::Security const&s, md::PriceSize bids[md::COCONUT_MAX_DEPTH], md::PriceSize asks[md::COCONUT_MAX_DEPTH], diff --git a/src/server/sparkd/exchange_sim/book/OrderMatcher.cpp b/src/server/sparkd/exchange_sim/book/OrderMatcher.cpp index a4a5c0977..03681b315 100644 --- a/src/server/sparkd/exchange_sim/book/OrderMatcher.cpp +++ b/src/server/sparkd/exchange_sim/book/OrderMatcher.cpp @@ -195,12 +195,18 @@ void OrderMatcher::match(std::vector *out) { void OrderMatcher::match(Order *bid, Order *ask) { Price price(0); - + bool bid_aggressor = false, ask_aggressor = false; if (utils::pb::greater(bid->last_update_time(), ask->last_update_time())) + { price = Price(ask->price()); + bid_aggressor = true; + } else + { price = Price(bid->price()); - + if(utils::pb::smaller(bid->last_update_time(), ask->last_update_time())) + ask_aggressor = true; + } Quantity quantity; if (bid->open_quantity() > ask->open_quantity()) @@ -208,7 +214,7 @@ void OrderMatcher::match(Order *bid, Order *ask) { else quantity = Quantity(bid->open_quantity()); - me->pending_trades.push_back(Trade{price, quantity}); + me->pending_trades.push_back(Trade{price, quantity, bid_aggressor, ask_aggressor}); execute(bid, price, quantity); execute(ask, price, quantity); } diff --git a/src/server/sparkd/exchange_sim/book/OrderMatcher.h b/src/server/sparkd/exchange_sim/book/OrderMatcher.h index 352afc33a..5c8a93d57 100644 --- a/src/server/sparkd/exchange_sim/book/OrderMatcher.h +++ b/src/server/sparkd/exchange_sim/book/OrderMatcher.h @@ -38,7 +38,8 @@ class OrderMatcher { struct Trade { Price price; - Quantity quantity; + Quantity quantity; + bool bid_aggressor, ask_aggressor; }; std::vector get_new_trades(); std::tuple size() const; diff --git a/src/server/sparkd/md/platforms/IMDPlatform.cpp b/src/server/sparkd/md/platforms/IMDPlatform.cpp new file mode 100644 index 000000000..3c0949e1d --- /dev/null +++ b/src/server/sparkd/md/platforms/IMDPlatform.cpp @@ -0,0 +1,8 @@ +#include "IMDPlatform.h" + +namespace bts { +namespace md { + +void IMDPlatform::send_heartbeats() {} + +}} \ No newline at end of file diff --git a/src/server/sparkd/md/platforms/IMDPlatform.h b/src/server/sparkd/md/platforms/IMDPlatform.h new file mode 100644 index 000000000..df4840f30 --- /dev/null +++ b/src/server/sparkd/md/platforms/IMDPlatform.h @@ -0,0 +1,12 @@ +#pragma once + +namespace bts { +namespace md { + +class IMDPlatform +{ +public: + virtual void send_heartbeats(); +}; + +}} \ No newline at end of file diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp new file mode 100644 index 000000000..df13de9bb --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -0,0 +1,393 @@ +#include "ICEListener.h" +#include "lib/utils/datetime.h" +#include +#include "lib/utils/helper_macros.h" +#include "lib/config/protos/MarketData.pb.h" +#include "lib/md/protos/co2.pb.h" + +using namespace std; +using namespace bts::co2; +using namespace bts::md::ice; + +namespace bts { +namespace md { +namespace ice { + +template <> +double double_of_price(const onixs_ice::Rational& price, int8_t display_factor) +{ + UNUSED(display_factor); + double dbl = price.convertTo(); + return dbl; +} + + +ICEListener::ICEListener(ICESecurityIndex& index, MDProducer& producer, const std::vector channels) : + _index(index), + _producer(producer), + _symbol_filter(), + _channels(channels), + _concurrency_monitor(0) +{ +} + +ICEListener::~ICEListener() {} + +std::string ICEListener::parse_contract_symbol(const std::string& sym) +{ + const auto&& res = sym.substr(0, sym.find(' ')); + return res; +} + +// +//State change +void ICEListener::onHandlerStateChange(const onixs_ice::HandlerStateChange& ) +{ + //TODO +} + +void ICEListener::onMarketStateChange(const onixs_ice::MarketStateChange& , const onixs_ice::MessageInfo& ) +{ + //TODO +} + +// +// Warnings/Errors +void ICEListener::onError(const onixs_ice::Error& error) +{ + std::string error_desc(error.description()); + tracepoint (bts_trace,trace_order,(char*) "onError", 0, (uint16_t) 0, 0); + LOG(md,Warn, "OnixS ICE Error: {} - {}", error.toString(), error_desc ); +} +void ICEListener::onFeedError(onixs_ice::FeedId feedid, onixs_ice::ErrorCode code, const std::string& desc) +{ + tracepoint (bts_trace,trace_order,(char*) "onFeedError", 0, (uint16_t) 0, 0); + LOG(md,Warn, "OnixS ICE FeedError: {} - {}", feedid, desc, code); +} +void ICEListener::onWarning(const onixs_ice::Warning& warning) +{ + tracepoint (bts_trace,trace_order,(char*) "onWarning", 0, (uint16_t) 0, 0); + LOG(md,Warn, "OnixS ICE Warn: {} - {}", warning.toString(), std::string(warning.description()) ); +} + +// +// Security discovery +void ICEListener::onFuturesProductDefinition(const onixs_ice::FuturesProductDefinition& msg, bool& is_interested) +{ + tracepoint (bts_trace,trace_order,(char*) "onFuturesProductDefinition", 0, (uint16_t) 0, 0); + if(msg.isSpread) + on_future_strip(msg, is_interested); + else + on_future(msg, is_interested); +} + +void ICEListener::onNewExpiry(const onixs_ice::NewExpiry& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) +{ + tracepoint (bts_trace,trace_order,(char*) "onNewExpiry", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); + on_future(msg, is_interested); +} + +void ICEListener::onFuturesStrategyDefinition(const onixs_ice::FuturesStrategyDefinition& def, bool& is_interested) +{ + tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", 0, (uint16_t) 0, 0); + //TODO need to find out how to produce data for testing + //on_uds_future_spread(def, is_interested); + UNUSED(def); + UNUSED(is_interested); +} +//This is only for UDS +void ICEListener::onNewFuturesStrategyDefinition(const onixs_ice::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) +{ + tracepoint (bts_trace,trace_order,(char*) "onFuturesStrategyDefinition", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); + //TODO need to find out how to produce data for testing + //on_uds_future_spread(msg, is_interested); + UNUSED(msg); + UNUSED(is_interested); +} + +void ICEListener::onOptionsProductDefinition(const onixs_ice::OptionsProductDefinition& msg, bool& is_interested) +{ + UNUSED(msg); + UNUSED(is_interested); +} +void ICEListener::onNewOptionsMarketDefinition(const onixs_ice::NewOptionsMarketDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) +{ + UNUSED(msg); + UNUSED(is_interested); + UNUSED(msg_info); +} +void ICEListener::onOptionsStrategyDefinition(const onixs_ice::OptionsStrategyDefinition& msg, bool& is_interested) +{ + UNUSED(msg); + UNUSED(is_interested); +} +void ICEListener::onNewOptionsStrategyDefinition(const onixs_ice::NewOptionsStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) +{ + UNUSED(msg); + UNUSED(is_interested); + UNUSED(msg_info); +} + +// +// Gap Recovery -- This is not necessary if we subscribe to the onOrderBookUpdated callback, they handle the breaks transparently +void ICEListener::onMarketSnapshot(const onixs_ice::MarketSnapshot& msg, const onixs_ice::MessageInfo& msg_info) +{ + UNUSED(msg); + UNUSED(msg_info); +} + +void ICEListener::onMarketSnapshotOrder(const onixs_ice::MarketSnapshotOrder& msg, const onixs_ice::MessageInfo& msg_info) +{ + UNUSED(msg); + UNUSED(msg_info); +} + +void ICEListener::onMarketSnapshotPriceLevel(const onixs_ice::MarketSnapshotPriceLevel& msg, const onixs_ice::MessageInfo& msg_info) +{ + UNUSED(msg); + UNUSED(msg_info); +} + +// +// Book +void ICEListener::onOrderBookUpdated(const onixs_ice::OrderBook& onixs_book, const onixs_ice::MessageInfo& msg_info) +{ + tracepoint (bts_trace,trace_order,(char*) "onBookUpdate", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); + + auto data = _index.get_security(onixs_book.marketId()); + if (data == nullptr) + return; + bts_assert(data->id == onixs_book.marketId()); + auto display_factor = data->handle.security().display_factor; + + // Overwrite all entries every time + size_t bids_size = onixs_book.bids().size(); + size_t asks_size = onixs_book.offers().size(); + if (!data->handle.has_depth()) + { + bids_size = std::min(bids_size, size_t { 1 }); + asks_size = std::min(asks_size, size_t { 1 }); + } + std::array dbids; dbids.fill(NO_MARKET); + std::array ibids; ibids.fill(NO_MARKET); + std::array dasks; dasks.fill(NO_MARKET); + std::array iasks; iasks.fill(NO_MARKET); + for (size_t x = 0; x < bids_size; ++x) + { + auto& bid = onixs_book.bids()[x]; + if(x < COCONUT_MAX_DEPTH) + dbids[x] = pricesize_of_price_size(bid.price, display_factor, bid.quantity - bid.impliedQuantity); + if(x < COCONUT_MAX_IMPLIED_DEPTH) + ibids[x] = pricesize_of_price_size(bid.price, display_factor, bid.impliedQuantity); + } + for (size_t x = 0; x < asks_size; ++x) + { + auto& ask = onixs_book.offers()[x]; + if(x < COCONUT_MAX_DEPTH) + dasks[x] = pricesize_of_price_size(ask.price, display_factor, ask.quantity - ask.impliedQuantity); + if(x < COCONUT_MAX_IMPLIED_DEPTH) + iasks[x] = pricesize_of_price_size(ask.price, display_factor, ask.impliedQuantity); + } + data->handle.update_books(TimeStamp::now(), dbids, dasks, ibids, iasks, (uint32_t) msg_info.sequenceNumber); +} + +// +// Trades +AggressorSide map_aggressor(onixs_ice::AggressorSide::Enum agside) +{ + switch(agside) { + default: + case onixs_ice::AggressorSide::NoAggressor: + return AGGRESSOR_SIDE_NONE; + case onixs_ice::AggressorSide::Buy: + return AGGRESSOR_SIDE_BUY; + case onixs_ice::AggressorSide::Sell: + return AGGRESSOR_SIDE_SELL; + } +} + +void on_trade(ICESecurityData* data, const onixs_ice::Price& price, int size, onixs_ice::AggressorSide::Enum agside, const onixs_ice::DateTime& onixs_date) +{ + auto ts = utils::TimeStamp::now(); + PriceSize ps = pricesize_of_price_size(price, data->handle.security().display_factor, size); + auto date = ll_of_timestamp(onixs_date); + data->handle.add_trade(ts, ps, date, map_aggressor(agside), size); +} + +void ICEListener::onTrade(const onixs_ice::Trade& msg, const onixs_ice::MessageInfo& msg_info) +{ + tracepoint (bts_trace,trace_order,(char*) "onTrade", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); + auto* data = _index.get_security(msg.marketId); + if (data != NULL) + { + bts_assert(data->id == msg.marketId); + auto size = msg.quantity; + auto price = msg.price; + onixs_ice::AggressorSide::Enum agside = msg.aggressorSide; + on_trade(data, price, size, agside, msg.transactDateTime); + } +} + +// +// RFQ +void ICEListener::onRfq(const onixs_ice::Rfq& msg, const onixs_ice::MessageInfo& msg_info) +{ + tracepoint (bts_trace,trace_order,(char*) "onRfq", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); + auto* data = _index.get_security(msg.marketId); + if (data != nullptr) + { + bts_assert(data->id == msg.marketId); + auto ts = utils::TimeStamp::now(); + co2::QuoteRequestMessage message; + message.set_key(data->handle.key()); + + auto time = ll_of_timestamp(msg.messageTimestamp); + message.set_time(time); + + long long rfqid = msg.rfqSystemId; + message.set_request_id(std::to_string(rfqid)); + + //https://ref.onixs.biz/cpp-ice-impact-handler-guide/struct_onix_s_1_1_i_c_e_1_1i_mpact_1_1_market_data_1_1_side.html#a8150b7776c2a1749101acf22e868d091 + switch(msg.side) + { + case ' ': + message.set_side(co2::QuoteRequestMessage::UNDEFINED); + break; + case '1': + message.set_side(co2::QuoteRequestMessage::BUY); + break; + case '2': + message.set_side(co2::QuoteRequestMessage::SELL); + break; + } + message.set_size(msg.quantity); + data->handle.add_rfq(ts, message); + } +} + +// +// Misc +void ICEListener::onSettlementPrice(const onixs_ice::SettlementPrice& msg, const onixs_ice::MessageInfo& msg_info) +{ + tracepoint (bts_trace,trace_order,(char*) "onSettlementPrice", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); + auto* data = _index.get_security(msg.marketId); + if (data != nullptr) + { + bts_assert(data->id == msg.marketId); + onixs_ice::Price price = msg.settlementPrice; + onixs_ice::DateTime time = msg.dateTime; + auto display_factor = data->handle.security().display_factor; + data->handle.update_settlement(utils::TimeStamp::now(), convert_price(price, display_factor), date_of_timestamp(time)); + } +} + +void ICEListener::onOpenInterest(const onixs_ice::OpenInterest &msg, const onixs_ice::MessageInfo &msg_info) +{ + UNUSED(msg); + UNUSED(msg_info); +} + +void ICEListener::onOpenPrice(const onixs_ice::OpenPrice& msg, const onixs_ice::MessageInfo& msg_info) +{ + tracepoint (bts_trace,trace_order,(char*) "onOpenPrice", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); + auto* data = _index.get_security(msg.marketId); + if (data != nullptr) + { + bts_assert(data->id == msg.marketId); + onixs_ice::Price price = msg.openPrice; + onixs_ice::DateTime time = msg.dateTime; + auto display_factor = data->handle.security().display_factor; + data->handle.update_opening( utils::TimeStamp::now(), double_of_price(price, display_factor), date_of_timestamp(time)); + } +} + +void ICEListener::onClosePrice(const onixs_ice::ClosePrice& msg, const onixs_ice::MessageInfo& msg_info) +{ + tracepoint (bts_trace,trace_order,(char*) "onClosePrice", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); + auto* data = _index.get_security(msg.marketId); + if (data != nullptr) + { + bts_assert(data->id == msg.marketId); + onixs_ice::Price price = msg.closePrice; + onixs_ice::DateTime time = msg.dateTime; + auto display_factor = data->handle.security().display_factor; + data->handle.update_closing( utils::TimeStamp::now(), double_of_price(price, display_factor), date_of_timestamp(time)); + } +} + +void ICEListener::onEndOfDayMarketSummary(const onixs_ice::EndOfDayMarketSummary& msg, const onixs_ice::MessageInfo& msg_info) +{ + tracepoint (bts_trace,trace_order,(char*) "onEndOfDayMarketSummary", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); + auto* data = _index.get_security(msg.marketId); + if (data != nullptr) + { + bts_assert(data->id == msg.marketId); + onixs_ice::DateTime time = msg.dateTime; + auto display_factor = data->handle.security().display_factor; + data->handle.update_opening( utils::TimeStamp::now(), double_of_price(msg.openingPrice, display_factor), date_of_timestamp(time) ); + data->handle.update_session_high( utils::TimeStamp::now(), double_of_price(msg.high, display_factor) ); + data->handle.update_session_low( utils::TimeStamp::now(), double_of_price(msg.low, display_factor) ); + data->handle.update_settlement( utils::TimeStamp::now(), convert_price(msg.settlementPrice, display_factor), date_of_timestamp(time) ); + } +} + +// +// Feed +void ICEListener::onMulticastMessageBlockBegin(onixs_ice::FeedId feedId, const onixs_ice::MessageInfo& msg_info) +{ + UNUSED(feedId); + tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockBegin", (uint32_t)msg_info.sequenceNumber, (uint16_t) msg_info.sequenceNumber, 0); +} + +void ICEListener::onMulticastMessageBlockEnd(onixs_ice::FeedId feedId, const onixs_ice::MarketIds& marketIds) +{ + UNUSED(feedId); + UNUSED(marketIds); + tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockEnd.begin", 0, (uint16_t) 0, 0); + tracepoint (bts_trace,trace_order,(char*) "onMulticastMessageBlockEnd.end", 0, (uint16_t) 0, 0); +} + +void ICEListener::onFeedStarted(onixs_ice::FeedId, const onixs_ice::MarketIds&) +{} + +void ICEListener::onFeedStopped(onixs_ice::FeedId) +{} + +void ICEListener::onSessionNumberChange(onixs_ice::FeedId , short , short ) +{} + + +// +// Non-onixs calls +void ICEListener::add_filter_symbol(const std::string& symbol) +{ + _symbol_filter.insert(symbol); +} + +void ICEListener::heartbeat() +{ + for (auto& c : _channels) { c.heartbeat(); } +} + +// +// Private functions +void ICEListener::add_security(const FixedSecurity& security) +{ + // Set up the shared memory for this security + auto handle = _producer.add_security(security); + bts_assert(security.numeric_id != 0); + // Add it to the index so it can receive messages + _index.add_security(security.numeric_id, handle); +} + +void ICEListener::update_all_status(CoconutSecurityStatus status) +{ + _index.walk_security_list([=](ICESecurityData& data) + { + data.handle.set_status(status); + }); +} + +}}} //namespace + + diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h new file mode 100644 index 000000000..25eacf3aa --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListener.h @@ -0,0 +1,239 @@ +#pragma once + +#include "lib/utils/bts_no_copy.h" +#include "lib/md/coconut2.h" +#include "ICESecurityIndex.h" +#include "lib/tracing/bts_trace.h" + +#include "ICEListenerHelpers.h" +#include "onixs.h" + +#include +#include +#include +#include +#include + +namespace bts { +namespace md { +namespace ice { + +class ICEListener : + public onixs_ice::ExchangeListener, //One Thread + public onixs_ice::HandlerStateChangeListener, //One thread + public onixs_ice::OrderBookUpdateListener, //One thread //TODO? + public onixs_ice::FeedListener, //Multi thread + public onixs_ice::ErrorListener, //Multi thread + public onixs_ice::WarningListener //Multi thread + +{ + typedef uint32_t BookType; + static constexpr BookType book_type_direct=1; + static constexpr BookType book_type_implied=2; + static constexpr BookType book_type_both=(book_type_direct|book_type_implied); + +public: + ICEListener(ICESecurityIndex& index, MDProducer&, const std::vector); + virtual ~ICEListener(); + + // + //State change + void onHandlerStateChange(const onixs_ice::HandlerStateChange& change) override; + void onMarketStateChange(const onixs_ice::MarketStateChange& msg, const onixs_ice::MessageInfo& msgInfo) override; + + // Warnings/Errors/Info + void onError(const onixs_ice::Error&) override; + void onFeedError(onixs_ice::FeedId feedid, onixs_ice::ErrorCode code, const std::string& desc) override; + void onWarning(const onixs_ice::Warning& warning) override; + + // + // Security discovery + void onFuturesProductDefinition(const onixs_ice::FuturesProductDefinition& def, bool& is_interested) override; + void process_strip(int stripid); + + void onNewExpiry(const onixs_ice::NewExpiry& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) override; + void onFuturesStrategyDefinition(const onixs_ice::FuturesStrategyDefinition& def, bool& is_interested) override; + void onNewFuturesStrategyDefinition(const onixs_ice::NewFuturesStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) override; + + void onOptionsProductDefinition(const onixs_ice::OptionsProductDefinition& def, bool& is_interested) override; + void onNewOptionsMarketDefinition(const onixs_ice::NewOptionsMarketDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) override; + void onOptionsStrategyDefinition(const onixs_ice::OptionsStrategyDefinition& def, bool& is_interested) override; + void onNewOptionsStrategyDefinition(const onixs_ice::NewOptionsStrategyDefinition& msg, bool& is_interested, const onixs_ice::MessageInfo& msg_info) override; + + // + // Gap Recovery + void onMarketSnapshot(const onixs_ice::MarketSnapshot& msg, const onixs_ice::MessageInfo& msgInfo) override; + void onMarketSnapshotOrder(const onixs_ice::MarketSnapshotOrder& msg, const onixs_ice::MessageInfo& msgInfo) override; + void onMarketSnapshotPriceLevel(const onixs_ice::MarketSnapshotPriceLevel& msg, const onixs_ice::MessageInfo& msgInfo) override; + + // + // Book + void onOrderBookUpdated(const onixs_ice::OrderBook& book, const onixs_ice::MessageInfo& msgInfo) override; + + // + // Trades + void onTrade (const onixs_ice::Trade& msg, const onixs_ice::MessageInfo& msgInfo) override; + + // + // RFQ + void onRfq (const onixs_ice::Rfq& msg, const onixs_ice::MessageInfo& msgInfo) override; + + // + // Misc + void onSettlementPrice(const onixs_ice::SettlementPrice& msg, const onixs_ice::MessageInfo& msgInfo) override; + void onOpenInterest(const onixs_ice::OpenInterest &msg, const onixs_ice::MessageInfo &msgInfo) override; + void onOpenPrice(const onixs_ice::OpenPrice& msg, const onixs_ice::MessageInfo& msgInfo) override; + void onClosePrice(const onixs_ice::ClosePrice& msg, const onixs_ice::MessageInfo& msgInfo) override; + void onEndOfDayMarketSummary(const onixs_ice::EndOfDayMarketSummary& msg, const onixs_ice::MessageInfo& msgInfo) override; + + // Feed + void onMulticastMessageBlockBegin(onixs_ice::FeedId feedId, const onixs_ice::MessageInfo& msgInfo) override; + void onMulticastMessageBlockEnd(onixs_ice::FeedId feedId, const onixs_ice::MarketIds& marketIds) override; + void onFeedStarted(onixs_ice::FeedId feedId, const onixs_ice::MarketIds& ids) override; + void onFeedStopped(onixs_ice::FeedId feedId) override; + void onSessionNumberChange(onixs_ice::FeedId feedId, short oldSessionNumber, short newSessionNumber) override; + + // + // Discover securities + void add_filter_symbol(const std::string& symbol); + void heartbeat(); + + // Add a new security to the index + void add_security(const FixedSecurity& security); +private: + template + void set_security_common(const Definition& def, FixedSecurity& fsec); + template + void on_future(const Definition& def, bool& is_interested); + template + void on_uds_future_spread(const Definition& def, bool& is_interested); + template + void on_future_strip(const Definition& def, bool& is_interested); + template + void on_book(const TBook& onixs_book, BookType booktype); + +private: + enum SecurityFilterAction { ADD, SKIP, DELETE }; + + std::string parse_contract_symbol(const std::string& sym); + + template + SecurityFilterAction filter_security(int exchange_id, const Definition& def) + { + if (_index.has_security(exchange_id)) + return SKIP; + // if(_symbol_filter.count("*") > 0) + // return ADD; + return _symbol_filter.count( parse_contract_symbol(def.contractSymbol) ) > 0 ? ADD : SKIP; + } + void flush_books(); + void update_all_status(co2::CoconutSecurityStatus status); + + ICESecurityIndex& _index; + MDProducer& _producer; + std::set _symbol_filter; + std::vector _channels; + std::atomic _concurrency_monitor; +}; + +template +void ICEListener::set_security_common(const Definition& def, FixedSecurity& fsec) +{ + fsec.numeric_id = def.marketId; + std::string sym = parse_contract_symbol(def.contractSymbol); + fsec.symbol( sym ); + //fsec.security_desc(def.marketDesc); + fsec.security_desc(def.contractSymbol); + fsec.exchange = api::Venue::VENUE_ICE; + fsec.display_factor = (int8_t)(def.orderPriceDenominator - '0'); + fsec.ice_deal_display_factor = (int8_t)(def.dealPriceDenominator - '0'); + fsec.ice_settle_display_factor = (int8_t)(def.settlePriceDenominator - '0'); + double min_tick = double_of_price(def.incrementPrice, fsec.display_factor); + fsec.low_tick = fsec.high_tick = min_tick; + fsec.price_break = 0.; + + fsec.ice_market_description(def.marketDesc); + fsec.ice_cleared_alias(def.clearedAlias); + fsec.ice_product_name(def.productName); + fsec.ice_hub_alias(def.hubAlias); + fsec.ice_strip_name(def.stripName); + fsec.mic_code(def.micCode); +} + +template +void ICEListener::on_future(const Definition& def, bool& is_interested) +{ + is_interested = false; + auto exchange_id = def.marketId; + if (filter_security(exchange_id, def) != ADD) return; + + FixedFutureSecurity fsec; + set_security_common(def, fsec); + //fsec.cash_per_point = double_of_price(def.tickValue, fsec.display_factor); + + fsec.expiration_year = def.maturityYear; + fsec.expiration_month = def.maturityMonth; + fsec.expiration_day = def.maturityDay; + add_security(fsec); + is_interested = true; +} + +template +void ICEListener::on_uds_future_spread(const Definition& def, bool& is_interested) +{ + is_interested = false; + auto exchange_id = def.marketId; + if (filter_security(exchange_id, def) != ADD) return; + // // Filter out any already expired spreads + // auto expiration = date_of_maturity(sec); + // if (expiration < datetime::today()) return; + + FixedSpreadSecurityL fsec; + set_security_common(def, fsec); + fsec.alt_symbol(def.strategySymbol); + + const auto& legs = def.legs; + fsec.set_leg_count(legs.size()); + for(size_t x = 0; x < fsec.leg_count(); ++x) + { + const auto& leg = legs[x]; + if(leg.ratioPriceNumerator) + fsec.legs[x].leg_price = double_of_price(leg.ratioPriceNumerator.value(), leg.ratioPriceDenominator.value()); + + if(leg.ratioQtyNumerator && leg.ratioQtyDenominator) + fsec.legs[x].leg_delta = double_of_price(leg.ratioQtyNumerator.value(), leg.ratioQtyDenominator.value()); + + fsec.legs[x].leg_quantity = leg.ratio; + fsec.legs[x].leg_side = leg.side == onixs_ice::Side::Bid ? api::SIDE_BUY : api::SIDE_SELL; + fsec.legs[x].exchange_key = ExchangeKey(leg.marketId); + fsec.legs[x].key = invalid_security_key; + } + add_security(fsec); + is_interested = true; +} + + +template +void ICEListener::on_future_strip(const FutureDefinition& def, bool& is_interested) +{ + is_interested = false; + auto exchange_id = def.marketId; + if (filter_security(exchange_id, def) != ADD) return; + + FixedSpreadSecurityXS fsec; + set_security_common(def, fsec); + fsec.alt_symbol(def.stripName); + + fsec.set_leg_count(2); + for(size_t x = 0; x < fsec.leg_count(); ++x) + { + fsec.legs[x].leg_quantity = 1.0; + fsec.legs[x].leg_side = (x == 0) ? api::SIDE_BUY : api::SIDE_SELL; + fsec.legs[x].exchange_key = ExchangeKey((x == 0) ? def.primaryMarketId : def.secondaryMarketId); + fsec.legs[x].key = invalid_security_key; + } + add_security(fsec); + is_interested = true; +} + +}}} //namespace diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h new file mode 100644 index 000000000..7efa7b049 --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEListenerHelpers.h @@ -0,0 +1,55 @@ +#pragma once + +#include "lib/utils/bts_assert.h" +#include "lib/utils/helper_macros.h" +#include "lib/md/ice/ICEUtils.h" +#include "lib/md/coconut2.h" + +#include "onixs.h" + +#include +#include +#include + +namespace bts { +namespace md { +namespace ice { + +template +double double_of_price(const OnixPrice& price, int8_t display_factor) +{ + double dbl = price / pow10(display_factor); + return dbl; +} + +template +IntPrice convert_price(const OnixsPrice& price, int8_t display_factor) +{ + double dbl = double_of_price(price, display_factor); + const int PRECISION = 7; //TODO config::get().connection() case ICE + auto intpx = md::IntPrice_from_double(dbl); + return intpx; +} + +template +inline PriceSize pricesize_of_price_size(const OnixsPrice& price, int8_t display_factor, Size size) +{ + auto intpx = convert_price(price, display_factor); + PriceSize result({intpx.mantissa(), (int8_t)(intpx.exponent())}, size); + return result; +} + +inline datetime::LLDateTime ll_of_timestamp(const onixs_ice::DateTime& dt) +{ + return datetime::ll_from_unix_epoch_ms(dt); +} + +inline datetime::Date date_of_timestamp(const onixs_ice::DateTime& dt) +{ + auto ll = ll_of_timestamp(dt); + return datetime::ll_to_date(ll); +} + + + +}}} //namespace \ No newline at end of file diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp new file mode 100644 index 000000000..c44ad0d3a --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -0,0 +1,237 @@ +#include "ICEMain.h" + +#include "lib/md/ice/ICEUtils.h" +#include "lib/config/config.h" +#include "lib/md/coconut2.h" +#include "lib/md/SecurityDB.h" +#include "lib/os/os.h" +#include "lib/utils/helper_macros.h" +#include "lib/utils/Dispatcher.h" +#include "lib/utils/proto_helper.h" +#include "lib/utils/bts_chrono.h" +#include "lib/md/protos/co2.pb.h" + +#include "lib/config/protos/MarketData.pb.h" +#include "lib/config/protos/system.pb.h" +#include "lib/utils/thread_manager.h" + + +#include +#include +#include + +void recursive_copy(const boost::filesystem::path &src, const boost::filesystem::path &dst) +{ + if (boost::filesystem::exists(dst)) + throw std::runtime_error(dst.generic_string() + " exists"); + if (boost::filesystem::is_directory(src)) + { + boost::filesystem::create_directories(dst); + for (boost::filesystem::directory_entry& item : boost::filesystem::directory_iterator(src)) + recursive_copy(item.path(), dst/item.path().filename()); + } + else if (boost::filesystem::is_regular_file(src)) + boost::filesystem::copy(src, dst); + else + throw std::runtime_error(dst.generic_string() + " not dir or file"); +} + +using namespace std; +using namespace bts::co2; +using std::size_t; + +namespace bts { +namespace md { +namespace ice { + +ICEMain::ICEMain() : + _index(), + _recorder ({ utils::Dispatcher::current(), [=](ExchangeKey k) { return SecurityKey(_index.get_key(k.value())); } }), + _producer(PLATFORM_ICEONIXS, _recorder ), + _handlers(), + _listeners() +{ +} + +ICEMain::~ICEMain() {} + +const ICEOptions::ICEChannel channel_settings_for(const ICEChannel& channel) +{ + const auto& config = config::get(); + for (const auto& ch : config.channel()) + { + if(ch.name() == channel.name) + return ch; + } + return ICEOptions::ICEChannel(); +} + + +onixs_ice::MarketSubscriptions market_subcription_for_channel(const ICEChannel& chan) +{ + onixs_ice::MarketSubscriptions subs; + for(const auto& x : chan.market_types) + { + //onixs_ice::MarketSubType::NonImplied + onixs_ice::MarketSubscription futures(x, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::Futures, onixs_ice::BookDepth::FOD); + onixs_ice::MarketSubscription spreads(x, onixs_ice::MarketSubType::FullImplied, onixs_ice::SecurityType::UdsFuturesMarkets, onixs_ice::BookDepth::FOD); + subs.push_back(futures); + subs.push_back(spreads); + } + return subs; +} + + +void ICEMain::start(std::vector& symbols) +{ + // License path and config file + auto license_location = os::bts_data_path() + "/licenses/"; + if (!boost::filesystem::is_directory(license_location)) + { + auto license_path =os::sparkd_wd() + "/data_files/Onixs.BTS.lic" ; + boost::filesystem::create_directories(license_location); + boost::filesystem::copy_file(license_path,license_location+"/Onixs.BTS.lic"); + } + auto ice_conf_location = os::bts_data_path() + "/onixs_ice/"; + if (!boost::filesystem::is_directory(ice_conf_location)) + { + auto conf_path = os::sparkd_wd() + "/data_files/onixs_ice/" ; + recursive_copy(boost::filesystem::path(conf_path), boost::filesystem::path(ice_conf_location)); + } + + await_ice_config(); + const auto& channels = parse_ice_channels(symbols); + for (const auto& channel : channels) + { + unique_ptr phandler = prepare_handler(channel); + _listeners.push_back(prepare_listener(*phandler, channel)); + _handlers.push_back(std::make_pair(channel, move(phandler))); + + std::stringstream symstr; + for (const auto& sym : channel.symbols) + symstr << sym.symbol() << "-" << SecurityType_Name(sym.type()) << " "; + LOG(md,Info, "ICE: Initialized channel {} ({})", channel.to_string(), symstr.str()); + } + + for (auto& pair : _handlers) + { + LOG(md,Info, "ICE: Init Handler {}", pair.first.to_string()); + sleep_for(16s); + onixs_ice::MarketSubscriptions subs = market_subcription_for_channel(pair.first); + pair.second->start(subs); + } + LOG(md,Info, "** ICE Publisher started **"); +} + +void ICEMain::send_heartbeats() +{ + for (const auto& listener: _listeners) + listener->heartbeat(); +} + +// // +// Initialize HandlerSettings and allocate the channel Handler +unique_ptr ICEMain::prepare_handler(const ICEChannel& channel) +{ + const auto& ice_options = config::get(); + auto license = ice_options.onixs_license(); + if (license == "{default}") + license = os::bts_data_path() + "/licenses/"; + + const auto& options = channel_settings_for(channel); + LOG(md,Info,"Loaded channel options for channel {}:\n{}", channel.to_string(), options.DebugString()); + + onixs_ice::HandlerSettings settings; + settings.licenseDirectory = license; + // + // Logging + settings.logLevel = (onixs_ice::LogLevels::Enum) options.onixs_log_mode(); + settings.logDirectory = ice_log_path(); + + // + // Config file + settings.connectivityConfiguration = ice_config_path(); + + // + // Network settings + const auto& pub_options = config::get(); + if (pub_options.has_network_interface()) + settings.networkInterface = pub_options.network_interface(); + else + { + std::string inter; + if (pub_options.has_network_interface_a() && !pub_options.has_network_interface_b()) + inter = pub_options.network_interface_a(); + if (!pub_options.has_network_interface_a() && pub_options.has_network_interface_b()) + inter = pub_options.network_interface_b(); + if (pub_options.has_network_interface_a() && pub_options.has_network_interface_b()) + inter = pub_options.network_interface_b() + ":" + pub_options.network_interface_b(); + settings.networkInterface = inter; + } + settings.udpBufferSize = options.udp_buffer_size(); + settings.heartbeatInterval = options.heartbeat_interval(); + settings.sequenceGapMargin = options.sequence_gap_margin(); + settings.gapTimeoutInMilliseconds = options.gap_timeout_in_ms(); + + // + // Snapshot recovery options + settings.snapshotRecoveryOptions.snapshotRecoveryTimeoutInMilliseconds = options.snapshot_recovery_timeout_in_ms(); + settings.snapshotRecoveryOptions.maximumNumberOfSnaphotRecoveryAttempts = options.maximum_number_of_snapshot_recovery_attempts(); + settings.snapshotRecoveryOptions.maximumSizeOfSnapshotMessageQueue = options.maximum_size_of_snapshot_message_queue(); + settings.snapshotRecoveryOptions.maximumSizeOfLiveMessageQueue = options.maximum_size_of_live_message_queue(); + + // + // Misc settings + if(options.processing_thread_affinity() != "" ) + settings.processingThreadAffinity = onixs_ice::ThreadAffinity::deserialize(options.processing_thread_affinity()); + // if(options.has_track_top_of_the_book_only() + // settings.trackTopOfTheBookOnly = options.track_top_of_the_book_only(); + if(options.has_receive_product_definitions_only()) + settings.receiveProductDefinitionsOnly = options.receive_product_definitions_only(); + if(options.has_max_multicast_message_block_size() && options.max_multicast_message_block_size() > 0) + settings.maxMulticastMessageBlockSize = options.max_multicast_message_block_size(); + if(options.product_definition_cache_directory() != "" ) + settings.productDefinitionCacheDirectory = options.product_definition_cache_directory(); + + // + // return feed handler + try + { + auto handler = unique_ptr(new onixs_ice::Handler(settings)); + return handler; + } + catch (std::exception& e) { + LOG(md,Error,"ONIXSERROR{}", std::string(e.what())); + throw; + } +} + +// +// Create a listener for this channel and register callbacks +unique_ptr ICEMain::prepare_listener(onixs_ice::Handler& handler, const ICEChannel& channel) +{ + // We need to get a handler to the producer channels so we can produce heartbeats + vector producer_channels; + for (auto& symbol : channel.symbols) + { + producer_channels.push_back(_producer.get_channel(symbol.symbol().c_str(), symbol.type(), symbol.exchange())); + } + + const auto& options = channel_settings_for(channel); + unique_ptr listener(new ICEListener(_index, _producer, /*_settlement_recorder,*/ producer_channels)); + for (auto& symbol : channel.symbols) + listener->add_filter_symbol(symbol.symbol()); + + handler.registerExchangeListener(listener.get()); + handler.registerFeedListener(listener.get()); + handler.registerOrderBookUpdateListener(listener.get()); + handler.registerErrorListener(listener.get()); + handler.registerWarningListener(listener.get()); + handler.registerHandlerStateChangeListener(listener.get()); + + return listener; +} + + +}}} //namespace + diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h new file mode 100644 index 000000000..ec6f1dfb8 --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.h @@ -0,0 +1,51 @@ +#pragma once + +#include "lib/utils/bts_no_copy.h" +#include "lib/md/coconut2.h" +#include "ICEListener.h" +#include "ICESecurityIndex.h" +#include "server/sparkd/md/platforms/IMDPlatform.h" +#include "onixs.h" + +#include +#include +#include + +namespace bts { +namespace md { +namespace ice { + +// void run_onixs_ice_server(UserSymbol* sym, size_t symcount); + +struct ICEChannel; + +/* + * The ICE provider is very simple + * Control starts in ICEMain which gets a list of all the symbols we need and starts the onixs handlers + * There is a single listener for all callbacks which maps the exchange id to the MDProducerHandle and writes + * the data to it. + */ +class ICEMain : public IMDPlatform +{ +public: + ICEMain(); + ~ICEMain(); + + void start(std::vector&); + void send_heartbeats() override; + + std::unique_ptr prepare_handler(const ICEChannel& channel); + std::unique_ptr prepare_listener(onixs_ice::Handler& handler, const ICEChannel& channel); + +private: + BTS_NO_COPY(ICEMain); + + ICESecurityIndex _index; + SecurityIDRecorder _recorder; + MDProducer _producer; + std::vector< std::pair> > _handlers; + std::vector< std::unique_ptr > _listeners; +}; + +}}} //namespace + diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h b/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h new file mode 100644 index 000000000..50a138485 --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/ICESecurityIndex.h @@ -0,0 +1,19 @@ +#pragma once + +#include "lib/md/SecurityIndex.h" +#include + +namespace bts { +namespace md { + +struct ICESecurityData +{ + ICESecurityData(uint32_t id, MDProducerHandle& h) : id(id), handle(h) {} + int id; // exchange id + MDProducerHandle handle; +}; + +typedef ConcurrentSecurityIndex ICESecurityIndex; + +}}//namespace + diff --git a/src/server/sparkd/md/platforms/ice_onixs/onixs.h b/src/server/sparkd/md/platforms/ice_onixs/onixs.h new file mode 100644 index 000000000..bafa3f5e2 --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/onixs.h @@ -0,0 +1,7 @@ +#pragma once +#include + +// namespace onixs = OnixS::CME::MDH; +namespace onixs_ice { + using namespace OnixS::ICE::iMpact::MarketData; +} \ No newline at end of file diff --git a/src/server/sparkd/md/platforms/ice_onixs/tests/ice_tests.cpp b/src/server/sparkd/md/platforms/ice_onixs/tests/ice_tests.cpp new file mode 100644 index 000000000..0358d1741 --- /dev/null +++ b/src/server/sparkd/md/platforms/ice_onixs/tests/ice_tests.cpp @@ -0,0 +1,210 @@ +// #include "catch/catch.hpp" + +// #include "lib/config/config.h" +// #include "lib/config/protos/MarketData.pb.h" + +// #include +// #include +// #include +// #include + +// #include "../MDP3Utils.h" +// #include "../onixs.h" + +// using namespace bts::md; +// using namespace std; + + +// namespace bts { +// namespace md { + +// map create_feed_engine_settings(const std::vector& channels); +// const CMEOptions::CMEChannel channel_settings_for(const string& id); + +// namespace test { + +// vector test_channels(int count, ...) { +// // Doing this the C way because I still haven't updated VS +// vector result; +// va_list ap; +// va_start(ap, count); +// for (int x = 0; x < count; ++x) { +// const char* val = va_arg(ap, char*); +// CMEChannel temp; +// temp.id = val; +// result.push_back(temp); +// } +// va_end(ap); +// return result; +// } + + +// TEST_CASE("mdp3_tests","[md]") { +// SECTION("test_defaults") { +// config::internal::initialize_for_test("CMEOptions {}"); + +// vector channels = test_channels(1, "310"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); + +// channels = test_channels(2, "310", "311"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); + +// channels = test_channels(4, "310", "311", "400", "412"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); + +// REQUIRE(!channel_settings_for("310").has_feed_engine()); +// REQUIRE(!channel_settings_for("311").has_feed_engine()); +// REQUIRE(!channel_settings_for("315").has_feed_engine()); +// } + +// SECTION("test_segregate_futures") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " feed_engine {\n" +// " name: 'default'\n" +// " }\n" +// " feed_engine {\n" +// " name: 'futures'\n" +// " num_threads: 4\n" +// " }\n" +// " # Futures\n" +// " channel {\n" +// " id: '310'\n" +// " id: '312'\n" +// " feed_engine: 'futures'\n" +// " }\n" +// " # Options\n" +// " channel {\n" +// " id: '311'\n" +// " id: '313'\n" +// " id: '315'\n" +// " feed_engine: 'default'\n" +// " }\n" +// " }\n" +// "}"); + +// vector channels = test_channels(1, "310"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result.begin()->first == "futures"); +// REQUIRE(result.begin()->second.threadsCount() == 4); + +// channels = test_channels(1, "311"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result.begin()->first == "default"); +// REQUIRE(result.begin()->second.threadsCount() == 1); + +// channels = test_channels(2, "311", "310"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 2); +// REQUIRE(result["default"].threadsCount() == 1); +// REQUIRE(result["futures"].threadsCount() == 4); + +// // Test channels not listed in config +// channels = test_channels(2, "317", "318"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); +// } + +// SECTION("test_no_default") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " feed_engine {\n" +// " name: 'futures'\n" +// " num_threads: 4\n" +// " }\n" +// " # any channel not listed will use the default feed engine\n" +// " # Futures\n" +// " channel {\n" +// " id: '310'\n" +// " id: '312'\n" +// " feed_engine: 'futures'\n" +// " }\n" +// " # Options\n" +// " channel {\n" +// " id: '311'\n" +// " id: '313'\n" +// " id: '315'\n" +// " use_tcp_replay: false\n" +// " }\n" +// " }\n" +// "}"); + +// vector channels = test_channels(1, "310"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result.begin()->first == "futures"); +// REQUIRE(result.begin()->second.threadsCount() == 4); + +// channels = test_channels(1, "311"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); + +// channels = test_channels(2, "311", "310"); +// result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// REQUIRE(result["futures"].threadsCount() == 4); + + +// REQUIRE(channel_settings_for("310").use_tcp_replay() == true); +// REQUIRE(channel_settings_for("311").use_tcp_replay() == false); +// REQUIRE(channel_settings_for("315").use_tcp_replay() == false); +// } + +// SECTION("test_one_thread_each") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " channel {\n" +// " id: '*'\n" +// " }\n" +// " }\n" +// "}\n"); + +// vector channels = test_channels(1, "310", "311"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 0); + +// const auto& settings = channel_settings_for("311"); +// REQUIRE(!settings.has_feed_engine()); +// } + +// SECTION("test_common_futures_thread") { +// config::internal::initialize_for_test( +// "CMEOptions {\n" +// " value {\n" +// " feed_engine {\n" +// " name: 'futures'\n" +// " num_threads: 4\n" +// " }\n" +// " channel {\n" +// " id: '310'\n" +// " feed_engine: 'futures'\n" +// " udp_socket_buffer_size: 1234\n" +// " }\n" +// " channel {\n" +// " id: '*'\n" +// " }\n" +// " }\n" +// "}\n"); + +// vector channels = test_channels(6, "310", "311", "315", "100", "10", "42"); +// auto result = create_feed_engine_settings(channels); +// REQUIRE(result.size() == 1); +// result = create_feed_engine_settings(test_channels(1, "315")); +// REQUIRE(result.size() == 0); + +// REQUIRE(!channel_settings_for("311").has_feed_engine()); +// REQUIRE(channel_settings_for("310").has_feed_engine()); +// REQUIRE(channel_settings_for("310").udp_socket_buffer_size() == 1234); +// REQUIRE(channel_settings_for("311").has_udp_socket_buffer_size() == false); +// } +// } + +// }}}//namespace diff --git a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp index 7c0db2832..0ea409588 100644 --- a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp +++ b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp @@ -130,7 +130,7 @@ onixs::SessionSettings session_settings_for_channel(const string& channel_id) { return settings; } -void MDP3Main::run(std::vector& symbols) { +void MDP3Main::start(std::vector& symbols) { await_cme_config(); initialize(); const auto& channels = parse_channels(symbols); @@ -148,30 +148,19 @@ void MDP3Main::run(std::vector& symbols) { onixs::SessionSettings settings = session_settings_for_channel(pair.first); pair.second->start(settings); } + LOG(md,Info, "** CME MDP3 Publisher started **"); +} - // - // Timers - - auto& disp = utils::Dispatcher::current(); - +void MDP3Main::send_heartbeats() { + for (const auto& listener: _listeners) + listener->heartbeat(); + // utils::DispatcherTimer settlement_timer(disp, 100, [&]() { // _settlement_recorder.do_work(); // }); - // settlement_timer.start(); - - utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() { - for (const auto& listener: _listeners) { - listener->heartbeat(); - } - }); - heartbeat_timer.start(); - - LOG(md,Info, "** CME MDP3 Publisher started **"); - - disp.run(); + // settlement_timer.start(); } - void MDP3Main::initialize() { const auto& options = config::get(); auto license_location = os::bts_data_path() + "/licenses/"; diff --git a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.h b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.h index 4eb1fbf62..974d01bc8 100644 --- a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.h +++ b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.h @@ -4,6 +4,7 @@ #include "lib/md/coconut2.h" #include "MDP3Listener.h" #include "CMESecurityIndex.h" +#include "server/sparkd/md/platforms/IMDPlatform.h" #include "onixs.h" #include @@ -23,13 +24,15 @@ struct CMEChannel; * There is a single listener for all callbacks which maps the exchange id to the MDProducerHandle and writes * the data to it. */ -class MDP3Main +class MDP3Main : public IMDPlatform { public: MDP3Main(); ~MDP3Main(); - void run(std::vector&); + void start(std::vector&); + void send_heartbeats() override; + void initialize(); std::unique_ptr prepare_handler(const std::string& channel); std::unique_ptr prepare_listener(onixs::Handler& handler, const CMEChannel& channel); diff --git a/src/server/sparkd/md/run_md.cpp b/src/server/sparkd/md/run_md.cpp index 56e2c2762..89994f057 100644 --- a/src/server/sparkd/md/run_md.cpp +++ b/src/server/sparkd/md/run_md.cpp @@ -11,6 +11,8 @@ #include "lib/md/Diag/MDPeriodicDumper.h" #include "lib/md/cme/MDP3Utils.h" #include "platforms/mdp3_onixs/MDP3Main.h" +#include "platforms/ice_onixs/ICEMain.h" +#include "platforms/IMDPlatform.h" #include "lib/md/SecurityDB.h" #include "server/sparkd/exchange_sim/ExchangeSim.h" #include "lib/utils/thread_manager.h" @@ -19,6 +21,7 @@ #include #include #include +#include #include using namespace bts; @@ -65,12 +68,41 @@ void run_replay() { replay_recording(file, naggle_ms, fallback_path); } -void run_onixs() { +void run_onixs() +{ + std::vector> platforms; // get all glbx symbols - std::vector symbols; - get_system_md_symbols(api::VENUE_GLBX, api::SECURITYTYPE_UNSET, &symbols); - MDP3Main main; - main.run(symbols); + std::vector cme_symbols; + get_system_md_symbols(api::VENUE_GLBX, api::SECURITYTYPE_UNSET, &cme_symbols); + if(cme_symbols.size() > 0) + { + MDP3Main* main = new MDP3Main(); + std::shared_ptr ptr(main); + main->start(cme_symbols); + platforms.push_back(ptr); + } + + std::vector ice_symbols; + get_system_md_symbols(api::VENUE_ICE, api::SECURITYTYPE_UNSET, &ice_symbols); + if(ice_symbols.size() > 0) + { + ice::ICEMain* imain = new ice::ICEMain(); + std::shared_ptr ptr(imain); + imain->start(ice_symbols); + platforms.push_back(ptr); + } + + // + // Timers + auto& disp = utils::Dispatcher::current(); + utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() + { + for (auto& p: platforms) + p->send_heartbeats(); + }); + heartbeat_timer.start(); + + disp.run(); } void run_cleanup() {