diff --git a/.vscode/launch.json b/.vscode/launch.json index 0fdb97700..dd627c595 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -75,10 +75,10 @@ "name": "SparkVM Launch", "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": ["run"], "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/doc/dev/dev_process.md b/doc/dev/dev_process.md index 2d7445a1f..b3736db48 100644 --- a/doc/dev/dev_process.md +++ b/doc/dev/dev_process.md @@ -1,11 +1,10 @@ # The BTS Development Process # -## The Big Picture ## - -Our development work is organized in projects. A project is an effort -to specifiy, develop and validate a related set of additions to our -Spark platform. A project can be assigned to one more developers and a -developer might concurrently be assigned to multiple +## Projects ## +Our development work is organized in projects. A project is a +non-trivial effort to specify, develop and validate a related set of +additions to our Spark platform. A project can be assigned to one more +developers and a developer might concurrently be assigned to multiple projects. Projects typically start out with specification work, proceed to implementation and finish with validation efforts. At any given time there will be multiple projects being worked on @@ -14,16 +13,16 @@ are merged into the product and deployed to customers. ## The Details ## Typically project ideas come from sales interactions, opposition -research and customer feedback, alltough on occasion development or -operational requirements will also suggest potentially valuable +research and customer feedback, all tough on occasion development or +operational requirements can also suggest valuable project ideas. Whatever the source of a project idea the final decision of which projects to pursue is always done by management. Once a project idea has been selected for implementation the corresponding project -will go through several phases: inception, specification, development -and merge. We detail each of these phases below. +will go through several phases: inception, specification, development, +validation and merge. -* Inception. In this phase we create the infrastructure for the -project. Typically this means selecting a team, creating a project +* Inception. In this phase the infrastructure for the project is +created. Typically this means selecting a team, creating a project case in Jira (that is a case assigned to the team@bluetradesys.com Jira user) and possibly creating a new branch for the project. This phase is mostly mechanical and the responsibility of Pedro. @@ -32,11 +31,11 @@ phase is mostly mechanical and the responsibility of Pedro. ill-considered idea project idea into a concrete, implementable specification that attempts to maximize the value/cost ratio of the project. It is hard to exaggerate the impact of a this phase on the -rest of the project. *Nothing* has more impact on our ability to -quickly deliver value to customers than good specification -work. Specification typically take the form of shared google docs, -using a mix of text and UI mockups to capture both user requirements -and suggested implementation strategies. Taha is responsible for this +rest of the project. *Nothing* has more impact on BTS's ability to +quickly deliver value to customers than good specification work. A +specification typically takes the form of a shared google docs using +a mix of text and UI mock-ups to capture both user requirements and +suggested implementation strategies. Taha and Kevin are responsible for this phase. * Development. Once a specification is complete, a team of developers @@ -44,24 +43,26 @@ will use a project specific branch to implement the specification. Periodically, typically once a week, progress on the project is assessed by Pedro, possibly with the help of others. This assessment takes the form of code reviews, demos, or just one-on-one -conversations. To ensure development does not go off on sub-optimal -tangents, developers are expected to continuously merge master into -the project branch as well as encouraged to create Pull Requests (PRs) -early in the project implementation, so that their work is kept -visible and integrated with that of the rest of the group. During the +conversations. To ensure development does not go off on tangents, +developers are expected to continuously merge master into the project +branch as well as encouraged to create Pull Requests (PRs) early in +the project implementation, so that their work is kept visible and +integrated with that of the rest of the group. During the implementation phase developers should reach out to Pedro for UI -reviews, architecture and design concerns as well as specification -trade off concerns. +reviews, architecture and design questions and specification trade off +concerns. -* Verification. Once code is complete think carefully about the best way -to verify that it is good before it goes to production. We don't have a -dedicated QA cycle to flush out bugs so it's important that a change be -fully tested before it's marked "Ready to Merge." For any non-trivial -change consider enlisting a 'test buddy' to help review the code and -think of test cases that you may not have considered. Stability from -release to release is especially critical right now as we develop a -reputation in the futures world. - - Code Reviews +* Verification. Once code is complete it is the project's team job to +think carefully about the best way to verify that the work is solid +enough to go to production. We do not have a dedicated QA cycle to +flush out bugs so it is important for changes to be fully tested +before being marked ready to merge (RTM). For any non-trivial change +project teams should enlist a 'test buddy' from outside the team to +help review the code and think of test cases that they may not have +considered. Stability from release to release is especially critical +right now as we develop a reputation in the futures +world. Additionally, project teams are encouraged to make liberal use +of other testing techniques such as - Unit tests - System tests - Manual tests @@ -70,7 +71,7 @@ reputation in the futures world. that includes Pedro should be created (unless, as mentioned above, an early PR was already created in the development phase). Whether the PR already existed or not, its description should be changed to start -with the "Ready To Merge" statement. This marks the project as ready +with the RTM (Ready To Merge) acronym. This marks the project as ready to be merged into master. Once a week, typically on Mondays, Pedro will go through every PR marked as "Ready To Merge", build it, check it out and if everything looks good merge it to master. At the end of @@ -79,6 +80,3 @@ number. This version will be go through some additional testing by Brian and will then be deployed by Karl and Pete to customers throughout the rest of the week. -## Tools ## - * Pre-Merge checklist - * Code Review tutorial diff --git a/doc/user/docs/release_notes.md b/doc/user/docs/release_notes.md index 722258b98..a2048387b 100644 --- a/doc/user/docs/release_notes.md +++ b/doc/user/docs/release_notes.md @@ -1,5 +1,24 @@ # Release Notes +## 1.4.11 +### New Features + - Floating Order Book + - The floating order book provides a quick view of orders occupying a price level in the ladder + - Launch the Floating Order Book by middle-clicking a ladder badge + - Cancel orders by clicking on the red X in the Cancel column + - Quantity and Price modification + - Clicking on a row will select it, providing the option for changing your price and quantity + - Enter in a new value or use the up/down buttons to set a desired value + - Press the green checkbox to finalize your change and update the order +### SDK + - Improved SDK documentation and usability +### User Interface Improvements + - The following spreader quoting parameters have been deprecated: + - Hidden parameter + - Price Type setting of the Conditional parameter +### Bug Fixes + - Fixed a limit enforcement problem that could lead to 0 sized orders being sent to the exchange + ## 1.4.10 ### Bug Fixes - Removed duplicate entries in performance log diff --git a/externals b/externals index 5570689de..c0941c565 160000 --- a/externals +++ b/externals @@ -1 +1 @@ -Subproject commit 5570689de27947a1573aa82e8f0e13000234f639 +Subproject commit c0941c5650a2a136cb036960d009fb8a16fb1165 diff --git a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs index 093d9f4d9..23a2db725 100644 --- a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs +++ b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs @@ -205,7 +205,7 @@ namespace mbts.spark { //new EnableHedgeModel(), //TAHA_SPREADER new HedgeRatioModel(), //new MinLeanQtyModel(), //TAHA_SPREADER - new QuoteHiddenModel(), + //new QuoteHiddenModel(), new MarketDataTypeModel(), new MarketDataCalculationModel(), new QuoteThrottleEnabledModel(quote_throttle_inside_ticks, quote_throttle_outside_ticks), @@ -213,7 +213,7 @@ namespace mbts.spark { quote_throttle_outside_ticks, new ConditionalQuoteEnabledModel(conditional_quoting_ticks, conditional_quoting_price_type), conditional_quoting_ticks, - conditional_quoting_price_type, + //conditional_quoting_price_type, //new QuoteInsideMarketThrottleEnabledModel(quote_inside_market_throttle_ticks, quote_inside_market_throttle_min_move), //quote_inside_market_throttle_ticks, //quote_inside_market_throttle_min_move, diff --git a/src/client/spark/Modules/Trading/OrderBook/MiniOrderBook/MiniOrderBookView.xaml b/src/client/spark/Modules/Trading/OrderBook/MiniOrderBook/MiniOrderBookView.xaml new file mode 100644 index 000000000..627a2da4b --- /dev/null +++ b/src/client/spark/Modules/Trading/OrderBook/MiniOrderBook/MiniOrderBookView.xaml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/client/spark/Modules/Trading/OrderBook/MiniOrderBook/MiniOrderBookView.xaml.cs b/src/client/spark/Modules/Trading/OrderBook/MiniOrderBook/MiniOrderBookView.xaml.cs new file mode 100644 index 000000000..20f5a46d5 --- /dev/null +++ b/src/client/spark/Modules/Trading/OrderBook/MiniOrderBook/MiniOrderBookView.xaml.cs @@ -0,0 +1,26 @@ +using mbts.ui.controls; +using System.Windows.Controls; + +namespace mbts.spark { + internal partial class MiniOrderBookView : UserControl { + // IMPORTANT: these enums are stored as strings in the general-purpose GridColumnSettings proto, and are used to ID THE COLUMNS! + // Do NOT RENAME them! However, if you must, be sure to write an IShellWindowMigrationRule or something to account for backwards compatability. + public enum Columns { Security, Symbol, Time, LastChange, User, Account, Exchange, TimeInForce, OrderType, SubType, Side, Size, Price, Filled, AvgFilled, LastPrice, Status, LastMessage, SecurityKey, OrderKey, ParentKey, Cancel, EditableQty, EditablePrice } + public const string + SubTypeFilterTemplateKey = "SubTypeFilterTemplate", + ExpandCollapseToggleStyleKey = "ExpandCollapseToggleStyle", + RowStyleKey = "RowStyle", + RowTemplateKey = "RowTemplateKey", + CVRowStyleKey = "CVRowStyle", + CVRowTemplateKey = "CVRowTemplateKey"; + + public MiniOrderBookView(OrderBookVM vm) { + InitializeComponent(); + DataContext = vm; + } + } + + class MiniOrderBookRowView : DIYGrid.HighPerformanceRow { + public MiniOrderBookRowView() : base() { } + } +} \ No newline at end of file diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs index 209416179..b189c0c0c 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookColumns.cs @@ -194,6 +194,10 @@ namespace mbts.spark { // quantity Add(qty_column = new SizeColumn( new UIntMinMax(ort => ort.order.quantity(), nameof(OrderBookRowVM.quantity)))); + // edit quantity column + // not usually part of the main order book, but it's useful to add it + // rather than debugging the popup window + //Add(edit_qty_column = new EditableQtyColumn()); // filled quantity Add(filled_qty_column = new FilledColumn( new UIntMinMax(ort => ort.order.filled(), nameof(OrderBookRowVM.filled_quantity)))); @@ -209,6 +213,10 @@ namespace mbts.spark { nameof(OrderBookRowVM.price)), DataGridFilterKnownTemplates.DoubleMinMax, _wrap_comparer(r => r.price))); + // edit price column + // not usually part of the main order book, but it's useful to add it + // rather than debugging the popup window + //Add(edit_price_column = new OrderBookVM.EditablePriceColumn()); // avg filled price Add(avg_price_column = new SimpleTextColumn( Columns.AvgFilled, @@ -291,6 +299,7 @@ namespace mbts.spark { public event Action filter_changed; + public CancelColumn cancel_column { get; } public SecurityColumn security_column { get; } public SimpleTextColumn symbol_column { get; } public SimpleTextColumn time_created_column { get; } @@ -303,7 +312,9 @@ namespace mbts.spark { public SimpleTextColumn sub_type_column { get; } public SideColumn side_column { get; } public SizeColumn qty_column { get; } + public EditableQtyColumn edit_qty_column { get; } public SimpleTextColumn price_column { get; } + public EditablePriceColumn edit_price_column { get; } public FilledColumn filled_qty_column { get; } public SimpleTextColumn last_price_column { get; } public SimpleTextColumn avg_price_column { get; } @@ -509,7 +520,7 @@ namespace mbts.spark { : base(key, header, get_text, sort_prop, width, filter, filter_template, comparer) { } public void draw(OrderBookRowVM row, DrawingContext dc, ColumnGeometry position, double row_height) => - CellRender.draw_text(dc, _get_glyph_context(row), font_size, _get_text(row), position, RowHeight, + CellRender.draw_text(dc, _get_glyph_context(row), font_size, _get_text(row), position, row_height, font_brush, null, horizontal_alignment, VerticalAlignment.Center, DefaultCellPadding); } @@ -519,7 +530,7 @@ namespace mbts.spark { : base(Columns.Side, "B/S", r => r.side.ToString(), nameof(OrderBookRowVM.side), DefaultColumnWidths.Side, filter, DataGridFilterKnownTemplates.EnumValues, _wrap_comparer(r => r.side)) { } public void draw(OrderBookRowVM row, DrawingContext dc, ColumnGeometry position, double row_height) => - CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.side.ToString(), position, RowHeight, + CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.side.ToString(), position, row_height, RenderUtils.get_side_brush(row), null, horizontal_alignment, VerticalAlignment.Center, DefaultCellPadding); } @@ -530,7 +541,7 @@ namespace mbts.spark { } public void draw(OrderBookRowVM row, DrawingContext dc, ColumnGeometry position, double row_height) => - CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.quantity.ToString(), position, RowHeight, + CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.quantity.ToString(), position, row_height, RenderUtils.get_side_brush(row), null, horizontal_alignment, VerticalAlignment.Center, DefaultCellPadding); } @@ -541,7 +552,7 @@ namespace mbts.spark { } public void draw(OrderBookRowVM row, DrawingContext dc, ColumnGeometry position, double row_height) => - CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.filled_quantity.ToString(), position, RowHeight, + CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.filled_quantity.ToString(), position, row_height, RenderUtils.get_side_brush(row), null, horizontal_alignment, VerticalAlignment.Center, DefaultCellPadding); } @@ -640,6 +651,8 @@ namespace mbts.spark { grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.Children.Add(toggle_button); grid.Children.Add(security_view); + grid.HorizontalAlignment = HorizontalAlignment.Center; + grid.VerticalAlignment = VerticalAlignment.Center; // var border = new Border { Child = grid }; CellRender.set_background_animation_bindings(border, nameof(OrderBookRowVM.security)); @@ -651,6 +664,88 @@ namespace mbts.spark { base.OnSortDirectionChanged(new_value); } } + + public class CancelColumn : FrameworkElementColumnBase { + readonly BindingBase _command_binding; + + public CancelColumn(string command_property) : base(Columns.Cancel) { + id = key.ToString(); + Header = DefaultColumnHeaders.Cancel; + _command_binding = new Binding(command_property); + } + + public override FrameworkElement view_factory() { + var grid = new Grid() { + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + var l1 = new System.Windows.Shapes.Line() { + StrokeThickness = 1, + Stroke = Brushes.White, + X1 = 0.5, + Y1 = 0.5, + X2 = 7, + Y2 = 7 + }; + var l2 = new System.Windows.Shapes.Line() { + StrokeThickness = 1, + Stroke = Brushes.White, + X1 = 0.5, + Y1 = 7, + X2 = 7, + Y2 = 0.5 + }; + grid.Children.Add(l1); + grid.Children.Add(l2); + + var button = new Button() { + Content = grid, + Background = Brushes.Red, + Foreground = Brushes.White, + Margin = new Thickness(2), + VerticalAlignment = VerticalAlignment.Center, + Height = 14, + Width = 14 + }; + + button.SetBinding(Button.CommandProperty, _command_binding); + return button; + } + } + + public class EditableQtyColumn:FrameworkElementColumnBase { + + public EditableQtyColumn() : base(Columns.EditableQty) { + id = key.ToString(); + Header = "Qty"; + Width = 64; + } + + public override FrameworkElement view_factory() { + var tick_up_down = new TickUpDownNullableUIntCommit(); + tick_up_down.SetBinding(TickUpDownNullableUIntCommit.SourceValueProperty, nameof(OrderBookRowVM.prospective_quantity)); + tick_up_down.SetBinding(TickUpDownNullableUIntCommit.OnCommitProperty, nameof(OrderBookRowVM.modify_order_quantity)); + return tick_up_down; + } + } + + public class EditablePriceColumn : FrameworkElementColumnBase { + + public EditablePriceColumn() : base(Columns.EditablePrice) { + id = key.ToString(); + Header = "Price"; + Width = 96; + } + + public override FrameworkElement view_factory() { + var price_up_down = new PriceEntryCommitControl(); + price_up_down.SetBinding(PriceEntryCommitControl.SourceValueProperty, nameof(OrderBookRowVM.prospective_price)); + price_up_down.SetBinding(PriceEntryCommitControl.SourceContractSpecProperty, nameof(OrderBookRowVM.contract_spec)); + price_up_down.SetBinding(PriceEntryCommitControl.OnCommitProperty, nameof(OrderBookRowVM.modify_order_price)); + return price_up_down; + } + } + #endregion static class RenderUtils { diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs index dc41be7ac..3327e1f49 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookRowVM.cs @@ -6,6 +6,9 @@ using mbts.ui; using mbts.ui.controls; using mbts.ui.shell; using System; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; using System.Windows.Input; namespace mbts.spark { @@ -13,16 +16,35 @@ namespace mbts.spark { const string _unknown_security_price_format_string = "0.#########"; const int _unknown_security_price_num_fractional_digits = 9; readonly OrderBookVM _owner; - IRaiseCanExecuteChangedCommand _show_order_modify_cmd, _toggle_expanded_cmd; - bool _is_parent, _is_expanded; + IRaiseCanExecuteChangedCommand _show_order_modify_cmd, _toggle_expanded_cmd, _cancel_cmd, _modify_order_quantity, _modify_order_price; + bool _is_parent, _is_expanded, _is_selected; int _depth_level; SecurityImmutable? _security => order_tuple.security; - - public OrderBookRowVM(OrderBookVM owner, OrderSecurity order_tuple) { + + // for mini-ob + uint _prospective_quantity; + double _prospective_price; + + + public OrderBookRowVM(OrderBookVM owner, OrderSecurity order_tuple, bool is_expanded) { _owner = owner; this.order_tuple = order_tuple; is_visible = !is_child; + _is_expanded = is_expanded; + prospective_quantity = this.quantity; + prospective_price = this.price; + this.invalidated += OrderBookRowVM_invalidated; + } + + private void OrderBookRowVM_invalidated() { + modify_order_quantity?.TryRaiseCanExecuteChanged(); + modify_order_price?.TryRaiseCanExecuteChanged(); + } + + protected override void Dispose(bool disposing) { + this.invalidated -= OrderBookRowVM_invalidated; + base.Dispose(disposing); } public event Action invalidated; @@ -35,6 +57,7 @@ namespace mbts.spark { public uint parent_order_key => order.ParentKey; public uint security_key => order.security_key(); public SecurityImmutable? security => _security; + public ContractSpecificationImmutable? contract_spec => security.spec_or_default(); public string security_text => security.display_name(); public Venue exchange => _security.exchange_or_default(); public string symbol => _security.symbol_or_default(); @@ -73,6 +96,29 @@ namespace mbts.spark { } } public int depth_level { get => _depth_level; set => Set(ref _depth_level, value); } + public bool is_selected { + get => _is_selected; + set => Set(ref _is_selected, value); + } + public uint prospective_quantity { + get => _prospective_quantity; + set { + if (Set(ref _prospective_quantity, value)) { + RaisePropertyChanged(nameof(is_qty_dirty)); + } + } + } + public double prospective_price { + get => _prospective_price; + set { + if (Set(ref _prospective_price, value)) { + RaisePropertyChanged(nameof(is_price_dirty)); + } + } + } + public bool is_qty_dirty => this.prospective_quantity != this.quantity; + public bool is_price_dirty => this.prospective_price != this.price; + // Commands public ICommand toggle_command => _toggle_expanded_cmd ?? ( _toggle_expanded_cmd = new DelegateCommand(() => is_expanded = !is_expanded)); @@ -80,6 +126,27 @@ namespace mbts.spark { ICommand DIYGrid.IActionableRowVM.default_command => _show_order_modify_cmd ?? (_show_order_modify_cmd = new DelegateCommand(() => _owner.show_order_modify(this), () => status == OrderStatus.Working)); + public ICommand cancel_command => _cancel_cmd ?? + (_cancel_cmd = new DelegateCommand(() => _owner.cancel_order(this), () => status == OrderStatus.Working)); + + public ICommand modify_order_quantity => _modify_order_quantity ?? + (_modify_order_quantity = new DelegateCommand( + (desired_quantity) => _owner.modify_order_quantity(this, (uint)desired_quantity), + (desired_quantity) => + (desired_quantity != null && this.status == OrderStatus.Working && (uint)desired_quantity != this.quantity) + || is_qty_dirty + ) + ); + + public ICommand modify_order_price => _modify_order_price ?? + (_modify_order_price = new DelegateCommand( + (desired_price) => _owner.modify_order_price(this, (double)desired_price), + (desired_price) => + (desired_price != null && this.status == OrderStatus.Working && (double)desired_price != this.price) + || is_price_dirty + ) + ); + // These fns present a way for the orderbook to avoid noisy, intermittent collection changes during "Expand/Collapse All" ops, // when incremental changes are ignored in favor of a full reset, after 'is_expanded' is updated for all rows. internal void expand_internal() => Set(ref _is_expanded, true); @@ -104,6 +171,14 @@ namespace mbts.spark { // however, the order-type and security cells DO use databindings - if these cells have changed, the PropertyChanged event must be raised regardless of whether or not invalidated is raised if (old_order.order_type() != order.order_type()) RaisePropertyChanged(nameof(order_type), nameof(order_metadata)); + if (old_order.quantity() != order.quantity()) { + RaisePropertyChanged(nameof(quantity)); + RaisePropertyChanged(nameof(is_qty_dirty)); + } + if (old_order.price() != order.price()) { + RaisePropertyChanged(nameof(price)); + RaisePropertyChanged(nameof(is_price_dirty)); + } if (!had_security && _security.HasValue) { RaisePropertyChanged(nameof(security), nameof(security_text)); // need to raise invalidated to refresh the price cells (the security.ContractSpec determines how they are formatted - Ticks!) diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs index 534bf0a02..8e5f9d480 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookVM.cs @@ -15,6 +15,7 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; using System.Reactive.Linq; +using System.Threading.Tasks; using System.Windows.Controls; using System.Windows.Input; using static bts.shell.OrderBookWindowFactory; @@ -38,36 +39,47 @@ namespace mbts.spark { readonly IWindowSettingsManager _settings_manager; readonly List _resources; OrderBookStartupData _state; + bool _is_row_collection_populated; - public OrderBookVM(IObservable owner_title, IBus bus, INotificationService notification_service, OrdersModel model, IWindowSettingsManager settings_manager) { + public OrderBookVM(IObservable owner_title, IBus bus, INotificationService notification_service, OrdersModel model, IWindowSettingsManager settings_manager, bool rows_are_initially_expanded = false) { _bus = bus; _model = model; _settings_manager = settings_manager; - _columns = new OrderBookColumnCollection(bus, model, - model.on_order_securities.Select(x => (x.added.Values, x.removed.Values))); - _row_collection = new OrderBookRowCollection(ort => new OrderBookRowVM(this, ort), _columns.get_sorting_data().comparer) { filter = _columns.get_filter() }; + _columns = new OrderBookColumnCollection(bus, model, model.on_order_securities.Select(x => (x.added.Values, x.removed.Values))); + // we use an ObservableAppendCollection b/c the mini-ob needs a cancel column at the front + columns = new ObservableAppendCollection(_columns); + _row_collection = new OrderBookRowCollection(ort => new OrderBookRowVM(this, ort, rows_are_initially_expanded), _columns.get_sorting_data().comparer) { filter = _columns.get_filter() }; + _row_collection.CollectionChanged += _row_collection_CollectionChanged; _current_row = backing(nameof(current_row)); _columns.filter_changed += on_filter_changed; collapse_all_rows_command = new DelegateCommand(_row_collection.collapse_all); expand_all_rows_command = new DelegateCommand(_row_collection.expand_all); - grid_settings_manager = _create_grid_settings_manager(owner_title, bus, notification_service, model, rows, columns); + grid_settings_manager = _create_grid_settings_manager(owner_title, bus, notification_service, model, rows, core_columns); _resources = new List { model.on_orders.OnDispatcher().Subscribe(_row_collection.update), - settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager), grid_settings_manager, Disposable.Create(() => { _columns.filter_changed -= on_filter_changed; + _row_collection.CollectionChanged -= _row_collection_CollectionChanged; Disposable.dispose(_row_collection); }), _columns }; + if (settings_manager != null) { + _resources.Add(settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager)); + } void on_filter_changed() => _row_collection.filter = _columns.get_filter(); } + private void _row_collection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { + is_row_collection_populated = _row_collection.Count != 0; + } + public event Action selected_order_changed; public event Action OnDisposed; - public ObservableCollection columns => _columns; + public ObservableAppendCollection columns { get; } + public ObservableCollection core_columns => _columns; public ObservableCollection rows => _row_collection; public OrderBookRowVM current_row { get => _current_row.Value; set => _current_row.Value = value ?? _selected_rows.FirstOrDefault(); } public OrderRecordImmutable? current_order => current_row?.order; @@ -76,7 +88,23 @@ namespace mbts.spark { public ICommand collapse_all_rows_command { get; } public ICommand expand_all_rows_command { get; } + public bool is_row_collection_populated { + get => _is_row_collection_populated; + set => Set(ref _is_row_collection_populated, value); + } + public void row_selection_changed(SelectionChangedEventArgs e) { + if (e.RemovedItems != null) { + foreach (var row_vm in e.RemovedItems.Cast()) { + row_vm.is_selected = false; + } + } + if (e.AddedItems != null) { + foreach (var row_vm in e.AddedItems.Cast()) { + row_vm.is_selected = true; + } + } + RowSelectionHelper.apply_changes(_selected_rows, e); selected_order_changed?.Invoke(current_order); } @@ -137,6 +165,15 @@ namespace mbts.spark { internal void show_order_modify(OrderBookRowVM row) => _bus.post(SparkTags.ShowModifyOrderTag, row.order_key); + internal void cancel_order(OrderBookRowVM row) => + _bus.post(SparkTags.CancelOrders, new List { row.order_key }); + + internal void modify_order_quantity(OrderBookRowVM row, uint size) => + _bus.post(SparkTags.UpdateOrder, (row.order_key, row.price, size)); + + internal void modify_order_price(OrderBookRowVM row, double price) => + _bus.post(SparkTags.UpdateOrder, (row.order_key, price, row.quantity)); + internal void on_expanded_changed(OrderBookRowVM row) { using (_row_collection.defer_refresh(true)) { if (row.is_expanded) { @@ -193,7 +230,8 @@ namespace mbts.spark { 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.data_cache, col_settings_flags); + (notification_service == null) ? null : notification_service.data_cache, + col_settings_flags); } static OrderRecordTuplePredicate.PredicateTypeOneofCase _corresponding_predicate_type(Columns col) { diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookView.xaml.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookView.xaml.cs index a497b3cbe..8fb0a43c9 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookView.xaml.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookView.xaml.cs @@ -5,7 +5,7 @@ namespace mbts.spark { internal partial class OrderBookView : UserControl { // IMPORTANT: these enums are stored as strings in the general-purpose GridColumnSettings proto, and are used to ID THE COLUMNS! // Do NOT RENAME them! However, if you must, be sure to write an IShellWindowMigrationRule or something to account for backwards compatability. - public enum Columns { Security, Symbol, Time, LastChange, User, Account, Exchange, TimeInForce, OrderType, SubType, Side, Size, Price, Filled, AvgFilled, LastPrice, Status, LastMessage, SecurityKey, OrderKey, ParentKey } + public enum Columns { Security, Symbol, Time, LastChange, User, Account, Exchange, TimeInForce, OrderType, SubType, Side, Size, Price, Filled, AvgFilled, LastPrice, Status, LastMessage, SecurityKey, OrderKey, ParentKey, Cancel, EditableQty, EditablePrice } public const string SubTypeFilterTemplateKey = "SubTypeFilterTemplate", ExpandCollapseToggleStyleKey = "ExpandCollapseToggleStyle", @@ -14,8 +14,6 @@ namespace mbts.spark { CVRowStyleKey = "CVRowStyle", CVRowTemplateKey = "CVRowTemplateKey"; - public const double RowHeight = 17; - public OrderBookView(OrderBookVM vm) { InitializeComponent(); DataContext = vm; @@ -23,6 +21,6 @@ namespace mbts.spark { } class OrderBookRowView : DIYGrid.HighPerformanceRow { - public OrderBookRowView() : base(OrderBookView.RowHeight) { } + public OrderBookRowView() : base() { } } } \ No newline at end of file diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs index 8b0efabb6..e41e416f3 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindow.cs @@ -131,7 +131,7 @@ namespace mbts.spark { return _vm.grid_settings_manager.create_vm( // we need to get the most up to date GridSettings when launching b/c users may // have changed some settings on the grid directly, like column widths. - s.general.with(_vm.columns.Select(c => c.create())), + s.general.with(_vm.core_columns.Select(c => c.create())), this.observe_title() ); } diff --git a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs index 52c632be9..2ef366ef4 100644 --- a/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs +++ b/src/client/spark/Modules/Trading/OrderBook/OrderBookWindowFactory.cs @@ -90,6 +90,8 @@ namespace bts.shell { public static OrderBookGridSettings DefaultGrid => new OrderBookGridSettings(_default_general_grid); static GridSettings _default_general_grid => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.sorting_criterion); + public static GridSettings default_mini_grid => GridSettings.Default.with(DefaultColumns.mini, DefaultColumns.sorting_criterion); + static class DefaultColumns { public static GridColumnSettings security => new GridColumnSettings(Columns.Security.ToString(), DIYGrid.DefaultColumnHeaders.Security, width: DIYGrid.DefaultColumnWidths.Security); @@ -145,7 +147,23 @@ namespace bts.shell { yield return parent_key; } } - } + + private static HashSet _mini_mode_columns_to_hide = new HashSet { + time_created, exchange, sub_type, quantity, price, avg_price, last_price, status, last_message, security_key, order_key, parent_key + }; + + public static IEnumerable mini { + get { + foreach (var col_setting in all) { + if (_mini_mode_columns_to_hide.Contains(col_setting)) { + yield return col_setting.with(is_visible: false); + } else { + yield return col_setting; + } + } + } + } + } } [ProtoContract] diff --git a/src/client/spark/Spark.csproj b/src/client/spark/Spark.csproj index f3579dcd9..c6eb7e982 100644 --- a/src/client/spark/Spark.csproj +++ b/src/client/spark/Spark.csproj @@ -31,7 +31,7 @@ - + @@ -54,6 +54,7 @@ + @@ -71,11 +72,20 @@ + + Code + Code + + MSBuild:Compile + + + MSBuild:Compile + MSBuild:Compile diff --git a/src/client/spark/view/Controls/Badge.cs b/src/client/spark/view/Controls/Badge.cs index 6e5ec4f96..239403381 100644 --- a/src/client/spark/view/Controls/Badge.cs +++ b/src/client/spark/view/Controls/Badge.cs @@ -9,6 +9,7 @@ using System.Globalization; using System.Linq; using System.Windows; using System.Windows.Controls; +using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Media; using FontFamily = System.Windows.Media.FontFamily; @@ -38,6 +39,7 @@ namespace mbts.ui.controls { CustomOrderDefinition.CustomOneofCase _parent_algo_type; (Point p1, Point p2, Point p3) _current_triangle_vertices; StreamGeometry _triangle_geometry; + Popup _popup; static Badge() { @@ -181,6 +183,7 @@ namespace mbts.ui.controls { _has_multiple_orders_at_level = HasMultipleOrdersAtLevel; _is_hedge_order = IsHedgeOrder; _gcr.glyph_context = GlyphContext.create(FontFamily, FontWeight); + _popup = Popup; } public static readonly DependencyProperty TextLinesProperty = @@ -264,6 +267,19 @@ namespace mbts.ui.controls { (b, v) => b._is_hedge_order = v, false); + public Popup Popup { + get { return (Popup)GetValue(PopupProperty); } + set { SetValue(PopupProperty, value); } + } + + public static readonly DependencyProperty PopupProperty = + WPFHelper.create_dp( + nameof(Popup), + FrameworkPropertyMetadataOptions.AffectsRender, + (b, v) => b._popup = v, + null); + + protected override Size ArrangeOverride(Size finalSize) => finalSize; protected override Size MeasureOverride(Size availableSize) { diff --git a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs index 3edb17e7d..02ff43b49 100644 --- a/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs +++ b/src/client/spark/view/Controls/DIYGrid/Columns/ColumnBase.cs @@ -97,7 +97,8 @@ namespace mbts.ui.controls { DayPnL = "Day PnL", TotalNetPos = "Total Net Pos", TotalPnL = "Total PnL", - PnLPrice = "PnL Price"; + PnLPrice = "PnL Price", + Cancel = "Cancel"; } public interface IKeyedColumn { diff --git a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs index 50bd4cb93..93c209fd4 100644 --- a/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs +++ b/src/client/spark/view/Controls/DIYGrid/DIYGrid.cs @@ -139,6 +139,7 @@ namespace mbts.ui.controls { public static readonly Thickness DefaultCellPadding = new Thickness(4, 2, 4, 2), AnimatableCellPadding = new Thickness(8, 2, 4, 2); + public static readonly Visibility DefaultRowsHorizontalScrollBarVisibility = Visibility.Visible; #region RoutedCommands public static readonly RoutedCommand SortCommand = new RoutedCommand(), DefaultRowCommand = new RoutedCommand(); @@ -695,6 +696,14 @@ namespace mbts.ui.controls { public static readonly DependencyProperty SelectionModeProperty = ListBox.SelectionModeProperty.AddOwner(typeof(DIYGrid)); + public Visibility RowsHorizontalScrollBarVisibility { + get { return (Visibility)GetValue(RowsHorizontalScrollBarVisibilityProperty); } + set { SetValue(RowsHorizontalScrollBarVisibilityProperty, value); } + } + + public static readonly DependencyProperty RowsHorizontalScrollBarVisibilityProperty = DependencyProperty.Register( + nameof(RowsHorizontalScrollBarVisibility), typeof(Visibility), typeof(DIYGrid), new PropertyMetadata(DefaultRowsHorizontalScrollBarVisibility)); + #endregion // Internal Methods diff --git a/src/client/spark/view/Controls/DIYGrid/DIYGridResources.xaml b/src/client/spark/view/Controls/DIYGrid/DIYGridResources.xaml index 4cd01bcb9..c52a305d3 100644 --- a/src/client/spark/view/Controls/DIYGrid/DIYGridResources.xaml +++ b/src/client/spark/view/Controls/DIYGrid/DIYGridResources.xaml @@ -335,7 +335,7 @@ - + diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs index e6ed6953f..cce3f9388 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridColumnSettings.cs @@ -1,4 +1,5 @@ using bts.proto; +using bts.utils; using ProtoBuf; using System; using System.ComponentModel; @@ -18,7 +19,7 @@ namespace mbts.ui.settings { } [ProtoContract] - class GridColumnSettings { + class GridColumnSettings : IEquatable { const bool _default_is_visible = true, _default_is_collapsed = false; @@ -103,5 +104,43 @@ namespace mbts.ui.settings { width ?? this.width, horizontal_alignment ?? this.horizontal_alignment, horizontal_offset ?? this.horizontal_offset); + + public bool Equals(GridColumnSettings other) => + other != null && + id == other.id && + display_name == other.display_name && + is_visible == other.is_visible && + is_collapsed == other.is_collapsed && + font_weight_override.Equals(other.font_weight_override) && + font_color_override.Equals(other.font_color_override) && + width == other.width && + horizontal_alignment == other.horizontal_alignment && + horizontal_offset == other.horizontal_offset && + display_name == other.display_name; + + public override bool Equals(object obj) => + Equals(obj as GridColumnSettings); + + public override int GetHashCode() => + EqualityComparer.aggregate_hash( + id.GetHashCode(), + display_name.GetHashCode(), + is_visible.GetHashCode(), + is_collapsed.GetHashCode(), + font_weight_override.GetHashCode(), + font_color_override.GetHashCode(), + width.GetHashCode(), + horizontal_alignment.GetHashCode(), + horizontal_offset.GetHashCode(), + display_name.GetHashCode() + ); + + public override string ToString() { + return $"id: {id} display_name: {display_name}"; + } + + + } + } \ No newline at end of file diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs index 5d5e60b52..b3c153195 100644 --- a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs +++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsManager.cs @@ -127,13 +127,15 @@ 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(); - 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))); + 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))); + } } } // ** in the unfortunate event that we botch backwards compatability, and the columns don't bear a 1:1 relationship with the column-settings diff --git a/src/client/spark/view/Controls/TickUpDown/PriceEntryCommitControl.xaml b/src/client/spark/view/Controls/TickUpDown/PriceEntryCommitControl.xaml new file mode 100644 index 000000000..23efd25ff --- /dev/null +++ b/src/client/spark/view/Controls/TickUpDown/PriceEntryCommitControl.xaml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/client/spark/view/Controls/TickUpDown/PriceEntryCommitControl.xaml.cs b/src/client/spark/view/Controls/TickUpDown/PriceEntryCommitControl.xaml.cs new file mode 100644 index 000000000..d2373ffd3 --- /dev/null +++ b/src/client/spark/view/Controls/TickUpDown/PriceEntryCommitControl.xaml.cs @@ -0,0 +1,73 @@ +using bts.api; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace mbts.ui.controls { + /// + /// Interaction logic for PriceEntryCommitControl.xaml + /// + public partial class PriceEntryCommitControl : UserControl { + + + public static readonly DependencyProperty SourceValueProperty = + DependencyProperty.Register("SourceValue", + typeof(double), + typeof(PriceEntryCommitControl), + new FrameworkPropertyMetadata { + BindsTwoWayByDefault = true, + PropertyChangedCallback = source_value_changed + } + ); + + public double SourceValue { + get => (double)GetValue(SourceValueProperty); + set => SetValue(SourceValueProperty, value); + } + private static void source_value_changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { + if (d is PriceEntryCommitControl _instance_of_me) { + _instance_of_me.Dispatcher.BeginInvoke( + (Action)(() => _instance_of_me.OnCommit?.TryRaiseCanExecuteChanged()) + ); + } + } + + public static readonly DependencyProperty SourceContractSpecProperty = + DependencyProperty.Register("SourceContractSpec", typeof(ContractSpecificationImmutable?), typeof(PriceEntryCommitControl)); + public ContractSpecificationImmutable? SourceContractSpec { + get => (ContractSpecificationImmutable?)GetValue(SourceContractSpecProperty); + set => SetValue(SourceContractSpecProperty, value); + } + + // public static readonly DependencyProperty PriceTextProperty = + //DependencyProperty.Register("PricText", typeof(string), typeof(PriceEntryCommitControl)); + // public string PriceText { + // get => (string)GetValue(PriceTextProperty); + // set => SetValue(PriceTextProperty, value); + // } + + public static readonly DependencyProperty OnCommitProperty = + DependencyProperty.Register("OnCommit", typeof(ICommand), typeof(PriceEntryCommitControl)); + public ICommand OnCommit { + get => (ICommand)GetValue(OnCommitProperty); + set => SetValue(OnCommitProperty, value); + } + + public PriceEntryCommitControl() { + InitializeComponent(); + } + + } +} diff --git a/src/client/spark/view/Controls/TickUpDown/TickUpDownNullableUIntCommit.xaml b/src/client/spark/view/Controls/TickUpDown/TickUpDownNullableUIntCommit.xaml new file mode 100644 index 000000000..4d2b93056 --- /dev/null +++ b/src/client/spark/view/Controls/TickUpDown/TickUpDownNullableUIntCommit.xaml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/client/spark/view/Controls/TickUpDown/TickUpDownNullableUIntCommit.xaml.cs b/src/client/spark/view/Controls/TickUpDown/TickUpDownNullableUIntCommit.xaml.cs new file mode 100644 index 000000000..50008743d --- /dev/null +++ b/src/client/spark/view/Controls/TickUpDown/TickUpDownNullableUIntCommit.xaml.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace mbts.ui.controls { + /// + /// Interaction logic for TickUpDownNullableUIntCommit.xaml + /// + public partial class TickUpDownNullableUIntCommit : UserControl { + + + public static readonly DependencyProperty SourceValueProperty = + DependencyProperty.Register("SourceValue", + typeof(uint?), + typeof(TickUpDownNullableUIntCommit), + new FrameworkPropertyMetadata { + BindsTwoWayByDefault = true, + PropertyChangedCallback = source_value_changed + } + ); + + private static void source_value_changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { + if (d is TickUpDownNullableUIntCommit _instance_of_me) { + _instance_of_me.Dispatcher.BeginInvoke( + (Action)(() => _instance_of_me.OnCommit?.TryRaiseCanExecuteChanged()) + ); + } + } + + public uint? SourceValue { + get => GetValue(SourceValueProperty) as uint?; + set => SetValue(SourceValueProperty, value); + } + + public static readonly DependencyProperty OnCommitProperty = + DependencyProperty.Register("OnCommit", typeof(ICommand), typeof(TickUpDownNullableUIntCommit)); + public ICommand OnCommit { + get => (ICommand)GetValue(OnCommitProperty); + set => SetValue(OnCommitProperty, value); + } + + public TickUpDownNullableUIntCommit() { + InitializeComponent(); + } + + } +} diff --git a/src/client/spark/view/Spark/Ladder/LadderOrderVM.cs b/src/client/spark/view/Spark/Ladder/LadderOrderVM.cs index 73dcf147b..048c236ce 100644 --- a/src/client/spark/view/Spark/Ladder/LadderOrderVM.cs +++ b/src/client/spark/view/Spark/Ladder/LadderOrderVM.cs @@ -37,7 +37,7 @@ namespace mbts.spark { readonly Property _foreground, _background, _hoverbackground, _border, _parent_algo_type_brush; readonly Property _is_exchange_order, _has_multiple_orders_at_same_level, _is_hedge_order; readonly Property _parent_algo_type; - readonly Property _summary, _description; + readonly Property _summary; IObservable _bs; LadderSettings.BadgeStyle _current_badge_style; int _n_active_price_change_ops = 0; @@ -63,7 +63,6 @@ namespace mbts.spark { _hoverbackground = backing(nameof(hoverbackground), _color_bg_brush); _border = backing(nameof(border), _color_bg_brush); _summary = backing(nameof(summary), string.Empty); - _description = backing(nameof(description), string.Empty); _is_exchange_order = backing(nameof(is_exchange_order), false); _has_multiple_orders_at_same_level = backing(nameof(has_multiple_orders_at_same_level), false); _is_hedge_order = backing(nameof(is_hedge_order), false); @@ -75,6 +74,7 @@ namespace mbts.spark { Brush get_foreground(LadderSettings s) => s.orders_column.foreground.rgb_brush(); // add_order(o); + _dispose = Disposable.Create( _bs.Subscribe(badge => { _current_badge_style = badge; @@ -122,7 +122,6 @@ namespace mbts.spark { if (_orders.Any()) { summary = _orders.Values.Select(order => order.short_description(_parent.security.ContractSpec)).Aggregate((s1, s2) => $"{s1}{Environment.NewLine}{Environment.NewLine}{s2}"); - description = _orders.Values.Select(order => order.full_description(_parent.security)).Aggregate((s1, s2) => $"{s1}{Environment.NewLine}{Environment.NewLine}{s2}"); } _set_badge_text(); @@ -185,11 +184,10 @@ namespace mbts.spark { public Brush hoverbackground { get => _hoverbackground.Value; private set => _hoverbackground.Value = value; } public Brush border { get => _border.Value; private set => _border.Value = value; } public string summary { get => _summary.Value; private set => _summary.Value = value; } - public string description { get => _description.Value; private set => _description.Value = value; } public bool is_exchange_order { get => _is_exchange_order.Value; private set => _is_exchange_order.Value = value; } public bool has_multiple_orders_at_same_level { get => _has_multiple_orders_at_same_level.Value; private set => _has_multiple_orders_at_same_level.Value = value; } public bool is_hedge_order { get => _is_hedge_order.Value; private set => _is_hedge_order.Value = value; } - public Brush parent_algo_type_brush { get => _parent_algo_type_brush.Value; private set => _parent_algo_type_brush.Value = value; } + public Brush parent_algo_type_brush { get => _parent_algo_type_brush.Value; private set => _parent_algo_type_brush.Value = value; } // the setter is public so that the LadderVM can set this field public CustomOrderDefinition.CustomOneofCase parent_algo_type { get => _parent_algo_type.Value; set => _parent_algo_type.Value = value; } @@ -224,6 +222,56 @@ namespace mbts.spark { } } + public OrderBookVM create_orderbook_vm() { + // We are returning a new OrderBookVM each time b/c after + // successive launches of the mini-ob from the same badge, we get an exception + // System.InvalidOperationException: Sharing GridViewColumn among multiple GridViewColumnCollections or adding the same GridViewColumn into one GridViewColumnCollection more than once is not allowed. + // I checked with Eric and he guesses that what is happening is that the Popup is throwing away the grid, but the binding doesn't remove the columns from that grid + // + // I think returning a new OrderbookVM is okay at the moment since this Popup window will not be saving any state at this time + var price_filter = new filters.DoubleMinMaxState(); + price_filter.minimum.value = real_price; + price_filter.maximum.value = real_price; + + var obvm = new OrderBookVM(null, _parent.bus, null, _parent.model.order_gateway, null, true); + var state = new bts.shell.OrderBookWindowFactory.OrderBookStartupData( + new bts.shell.OrderBookWindowFactory.FilterStates { + security_criteria = new SecurityCriteria(_parent.security), + price = price_filter, + statuses = new[] { OrderStatus.Working } + }, + bts.shell.OrderBookWindowFactory.OrderBookStartupData.default_mini_grid, + use_defaults: false + ); + // NOTE: + // we might need the ObservableAppend to InsertAt + // if these EditXXX ever support settings. + // insert the cancel column + obvm.columns.Insert(0, new OrderBookVM.CancelColumn(nameof(OrderBookRowVM.cancel_command))); + var qty_col = obvm.columns.FirstOrDefault(x => x.id == OrderBookView.Columns.Size.ToString()); + var qty_index = obvm.columns.indexOf(qty_col); + if (qty_index > -1) { + // insert the edit column in the same position that the hidden column occupies + var existing_editqty_col = obvm.columns.FirstOrDefault(x => x.id == OrderBookView.Columns.EditableQty.ToString()); + var existing_editqty_index = obvm.columns.indexOf(existing_editqty_col); + if (existing_editqty_index == -1) { + obvm.columns.Insert(qty_index, new OrderBookVM.EditableQtyColumn()); + } + } + var price_col = obvm.columns.FirstOrDefault(x => x.id == OrderBookView.Columns.Price.ToString()); + var price_index = obvm.columns.indexOf(price_col); + if (price_index > -1) { + var existing_editprice_col = obvm.columns.FirstOrDefault(x => x.id == OrderBookView.Columns.EditablePrice.ToString()); + var existing_editprice_index = obvm.columns.indexOf(existing_editprice_col); + if (existing_editprice_index == -1) { + // insert the edit price column immediately after the edit qty + obvm.columns.Insert(qty_index + 1, new OrderBookVM.EditablePriceColumn()); + } + } + obvm.load_from(state); + return obvm; + } + public override string ToString() { return $"Price: {this.price} Order Count: {this.orders.Count()}"; } diff --git a/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs b/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs index 46b776e68..8ff34f733 100644 --- a/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs +++ b/src/client/spark/view/Spark/Ladder/LadderOrdersHost.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -91,15 +92,26 @@ namespace mbts.spark { order.PropertyChanged += _order_PropertyChanged; // get the stackpanel it belongs in Panel panel = get_panel(price); + //var coords = GetAbsolutePlacement(panel, true); // insert Badge and wire up DataContext if (panel != null) { - panel.Children.Add(mkbadge(order)); + panel.Children.Add(mkbadge(order, panel)); } } //else { //Log.Ui.warn($"Failed to add order ({order.id}): order already in {nameof(LadderGridHost)}'s {nameof(_orders)}."); //} } + public static Rect GetAbsolutePlacement(FrameworkElement element, bool relativeToScreen = false) { + var absolutePos = element.PointToScreen(new System.Windows.Point(0, 0)); + if (relativeToScreen) { + return new Rect(absolutePos.X, absolutePos.Y, element.ActualWidth, element.ActualHeight); + } + var posMW = Application.Current.MainWindow.PointToScreen(new System.Windows.Point(0, 0)); + absolutePos = new System.Windows.Point(absolutePos.X - posMW.X, absolutePos.Y - posMW.Y); + return new Rect(absolutePos.X, absolutePos.Y, element.ActualWidth, element.ActualHeight); + } + void _order_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(LadderOrderVM.price)) { var order = (LadderOrderVM)sender; @@ -108,35 +120,38 @@ namespace mbts.spark { } } - Badge mkbadge(LadderOrderVM order) { + Badge mkbadge(LadderOrderVM order, UIElement popup_placement_target) { Badge b = new Badge(); b.DataContext = order; // Hook up the style from xaml b.Style = this.TryFindResource(typeof(Badge)) as Style; - b.MouseUp += (s, e) => { + b.MouseUp += async (s, e) => { var curr_order = b.DataContext as LadderOrderVM; if (e.ChangedButton == MouseButton.Middle) { - b.ContextMenu.DataContext = b.DataContext; - b.ContextMenu.IsOpen = true; - // close context menu after command executed - if (curr_order != null) { - Action command_executed = null; - command_executed = () => { - try { - b.ContextMenu.IsOpen = false; - curr_order.command_executed -= command_executed; - } catch (Exception ex) { - Log.Ui.warn($"Error in {typeof(LadderGridHost)}'s {typeof(Badge)} {nameof(LadderOrderVM.command_executed)} local handler: {ex}"); - } - }; - curr_order.command_executed += command_executed; - } + // create the new popup window in here + var obvm = order.create_orderbook_vm(); + await Task.Delay(100); // Wait for obvm to load rows collection before showing UI to avoid a flash + var view = new MiniOrderBookView(obvm); + var popup = new System.Windows.Controls.Primitives.Popup { + // we only keep the obvm around assigned to the DataContext so that we can + // properly Dispose of it later when the popup is closed. + DataContext = obvm, + Child = view, + StaysOpen = false, + PlacementTarget = popup_placement_target, + Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom, + VerticalOffset = 5 + }; + popup.SetBinding(System.Windows.Controls.Primitives.Popup.IsOpenProperty, + nameof(OrderBookVM.is_row_collection_populated) + ); + popup.Closed += (sender, event_args) => (popup.DataContext as IDisposable)?.Dispose(); + b.Popup = popup; } else if (e.ChangedButton == MouseButton.Left) { if (curr_order?.cancel_command?.CanExecute(null) == true) curr_order.cancel_command.Execute(null); } }; - b.ContextMenuOpening += (s, e) => e.Handled = true; return b; } diff --git a/src/client/spark/view/Spark/Ladder/LadderView.xaml b/src/client/spark/view/Spark/Ladder/LadderView.xaml index 65b738d80..360855cba 100644 --- a/src/client/spark/view/Spark/Ladder/LadderView.xaml +++ b/src/client/spark/view/Spark/Ladder/LadderView.xaml @@ -533,29 +533,12 @@ - - - - - - - - - - - - - - - - - diff --git a/src/client/spark_api/spark_api.csproj b/src/client/spark_api/spark_api.csproj index 5a555f48a..a0d60f3e1 100644 --- a/src/client/spark_api/spark_api.csproj +++ b/src/client/spark_api/spark_api.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/client/spark_excel/spark_excel.csproj b/src/client/spark_excel/spark_excel.csproj index 37fe13f5a..4aa21a9c4 100644 --- a/src/client/spark_excel/spark_excel.csproj +++ b/src/client/spark_excel/spark_excel.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/client/spark_sdk/spark_sdk.csproj b/src/client/spark_sdk/spark_sdk.csproj index bf27ddb55..26ff14c6c 100644 --- a/src/client/spark_sdk/spark_sdk.csproj +++ b/src/client/spark_sdk/spark_sdk.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/client/spark_test/System/LimitsTests.cs b/src/client/spark_test/System/LimitsTests.cs index a37f6bce1..b517765bd 100644 --- a/src/client/spark_test/System/LimitsTests.cs +++ b/src/client/spark_test/System/LimitsTests.cs @@ -12,6 +12,7 @@ using bts.test; using bts.api.orderman; using mbts; using mbts.tests; +using bts.co2; namespace bts.tests { @@ -36,6 +37,39 @@ namespace bts.tests Disposable.dispose(ref _context); } + async Task> all_futures(string symbol) { + var request = new MDRequest() { + Host = "system_test", + Channels = { + new SecurityChannel() { + Time = 0, + Flags = 0, + Type = SecurityType.Future, + Exchange = Venue.Sim, + Symbol = symbol, + TradeCursor = 0, + RfqCursor = 0 + } + } + }; + + var relay = _context.locate(); + await Task.Delay(100); + var result = await relay.requestmd_async(request); + + List securities = new List(); + if (result.success) { + foreach (var ch in result.value.Channels) { + foreach (var update in ch.Updates) { + if (update.Security != null) { + securities.Add(new SecurityImmutable(update.Security)); + } + } + } + } + return securities; + } + [Test] public async Task test_clip_limits() { //Get and set limit values from the admin service @@ -53,9 +87,9 @@ namespace bts.tests //create Orders Here - bts.md.MarketDataClient mdc = new bts.md.MarketDataClient(); - - SecurityImmutable? sec = await mdc.find_security_async(y => y.Symbol == test_symbol && y.Exchange == Venue.Sim); + var all = await all_futures(test_symbol); + SecurityImmutable? sec = all.FirstOrDefault(); + Assert.IsTrue(sec.HasValue); uint under_limit_order_key; uint over_limit_order_key; diff --git a/src/client/spark_test/spark_test.csproj b/src/client/spark_test/spark_test.csproj index 1c755b687..8a6c94761 100644 --- a/src/client/spark_test/spark_test.csproj +++ b/src/client/spark_test/spark_test.csproj @@ -1,7 +1,7 @@ - net471 + netstandard2.0 x64 x64 diff --git a/src/client/sparkcmd/Program.cs b/src/client/sparkcmd/Program.cs index 1feb68ecb..790308e27 100644 --- a/src/client/sparkcmd/Program.cs +++ b/src/client/sparkcmd/Program.cs @@ -8,10 +8,10 @@ using System.Linq; namespace sparkcmd { class Program { - static void Main(string[] args) { + static int Main(string[] args) { + mbts.config.Configuration.initialize(); var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program)); - ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out); - return; + return ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out); } } } \ No newline at end of file diff --git a/src/client/sparkcmd/sparkcmd.csproj b/src/client/sparkcmd/sparkcmd.csproj index 31c2efcd9..9046c4610 100644 --- a/src/client/sparkcmd/sparkcmd.csproj +++ b/src/client/sparkcmd/sparkcmd.csproj @@ -2,8 +2,7 @@ Exe - net471 - + net471;netcoreapp2.1 win7-x64;ubuntu.16.04-x64 Blue Trading Systems Blue Trading Systems @@ -18,7 +17,7 @@ - + diff --git a/src/data_files/copy_data_files.sh b/src/data_files/copy_data_files.sh index fb7479549..b3b880d74 100644 --- a/src/data_files/copy_data_files.sh +++ b/src/data_files/copy_data_files.sh @@ -3,3 +3,10 @@ rm -rf $1 mkdir $1 cp -r $2/files/* $1 + +for filename in $1/*; do + if [[ $filename == *.xz ]]; then + echo Decompressing $filename + unxz $filename + fi +done diff --git a/src/data_files/files/futures.coconut.xz b/src/data_files/files/futures.coconut.xz new file mode 100644 index 000000000..79f80a12d Binary files /dev/null and b/src/data_files/files/futures.coconut.xz differ diff --git a/src/lib/CMakeDeps.cmake b/src/lib/CMakeDeps.cmake index af8ee127c..be983b91a 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/services/AdminService.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/MDRecoverableConsumer.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/services/AdminService.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/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.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/OrderServicesData.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/orders/DynamicOrder.cpp;orderman/orders/IcebergOrder.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/CoverOrder.cpp;orderman/orders/book_algos/JoinOrder.cpp;orderman/orders/book_algos/LeanOrder.cpp;orderman/orders/book_algos/OffsetOrder.cpp;orderman/orders/book_algos/TickOrder.cpp;orderman/orders/book_algos/TopOrder.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/QuoterWorkingStat \ No newline at end of file diff --git a/src/lib/CMakeDeps_win.cmake b/src/lib/CMakeDeps_win.cmake new file mode 100644 index 000000000..afd768425 --- /dev/null +++ b/src/lib/CMakeDeps_win.cmake @@ -0,0 +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/services/AdminService.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/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.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 diff --git a/src/lib/config/ConfigValueQueue.cpp b/src/lib/config/ConfigValueQueue.cpp index 1195eac08..2d65a5ee8 100755 --- a/src/lib/config/ConfigValueQueue.cpp +++ b/src/lib/config/ConfigValueQueue.cpp @@ -14,6 +14,7 @@ namespace internal { using namespace ::google::protobuf; using namespace bts::expression; using namespace bts::util::proto; +using std::vector; ConfigValueQueue::ConfigValueQueue(IPropertyEvaluator& evaluator) : _eval(evaluator), diff --git a/src/lib/config/protos/MarketData.proto b/src/lib/config/protos/MarketData.proto index 17924a6a1..08b397958 100755 --- a/src/lib/config/protos/MarketData.proto +++ b/src/lib/config/protos/MarketData.proto @@ -124,14 +124,14 @@ message RecordOptions { // Replay options // message ReplayOptions { - optional string host = 1 [default = "mdreplay"]; - optional string base_path = 2 [default = "/spark"]; - optional string file_name = 3 [default = "futures.coconut"]; + optional string url = 1 [default = "http://mdreplay.bluetradesys.local/spark/futures.coconut"]; // 2.0 = double speed, 0.5 = half speed optional double speed = 11 [default = 1.0]; optional bool interactive = 12 [default = false]; + + optional string fallback = 20 [default ="data_files/futures.coconut"]; } message RelayOptions { diff --git a/src/lib/config/text_format/text_format.cpp b/src/lib/config/text_format/text_format.cpp index 99f352cbf..cc942c036 100755 --- a/src/lib/config/text_format/text_format.cpp +++ b/src/lib/config/text_format/text_format.cpp @@ -50,6 +50,7 @@ #include #include #include +using std::vector; #include "text_format.h" diff --git a/src/lib/md/relay/RelayRecorder.cpp b/src/lib/md/relay/RelayRecorder.cpp index 6b6d3f020..d2a094b52 100644 --- a/src/lib/md/relay/RelayRecorder.cpp +++ b/src/lib/md/relay/RelayRecorder.cpp @@ -183,23 +183,46 @@ void replay_url(const std::string& url, IRelayWriter& writer, int32_t naggle_ms) auto filename = url.substr(last_slash+1); filename = os::sparkdata_path("data/replay/") + filename; utils::download_file_if_newer(host, path, filename); - replay_file(filename, writer, naggle_ms, true); + if (boost::filesystem::exists(filename)) { + replay_file(filename, writer, naggle_ms, true); + } +} + +void replay_url_with_fallback(const std::string& url, IRelayWriter& writer, int32_t naggle_ms) { + // loops forever + replay_url(url, writer, naggle_ms); + // If it returns it means it failed to download or play cached + const auto fallback = config::get().fallback(); + if (boost::filesystem::exists(fallback)) { + replay_file(fallback, writer, naggle_ms); + } + } shared_ptr mkrelayproducer(bool shared); + /*this is the public one*/ -void replay_recording(const string& filename, int32_t naggle_ms) { +void replay_recording(const string& filename, int32_t naggle_ms, const std::string fallback) { auto writer = mkrelayproducer(true); if (config::get().interactive()) { naggle_ms = -1; } + // Try relay_url/replay_file + // If it fails resort to the fallback location + if (filename.find("http://") == 0) { + // loops forever replay_url(filename, *writer, naggle_ms); } - else { + else if (boost::filesystem::exists(filename)) { + // loops forever replay_file(filename, *writer, naggle_ms); } + // try fallback + if (boost::filesystem::exists(fallback)) { + replay_file(fallback, *writer, naggle_ms); + } } void print_recording(const string& filename) { ConsoleReplayWriter writer; diff --git a/src/lib/md/relay/RelayRecorder.h b/src/lib/md/relay/RelayRecorder.h index fbcd53617..d70dd4757 100644 --- a/src/lib/md/relay/RelayRecorder.h +++ b/src/lib/md/relay/RelayRecorder.h @@ -28,8 +28,9 @@ void record_everything(std::string path, std::string filename); void print_recording(const std::string&); void unprint_recording(const std::string& src, const std::string& dest); void trace_recording(const std::string& file, security_key key); -void replay_recording(const std::string&, int32_t delay_ms); +void replay_recording(const std::string&, int32_t delay_ms, const std::string fallback=""); void replay_url(const std::string& url, IRelayWriter& writer, int32_t naggle_ms); +void replay_url_with_fallback(const std::string& url, IRelayWriter& writer, int32_t naggle_ms); void replay_file(const std::string& filename, IRelayWriter& writer, int32_t naggle_ms, bool loop=false); }}//namespace diff --git a/src/lib/orderman/orders/NativeOrder.cpp b/src/lib/orderman/orders/NativeOrder.cpp index 9ff30477d..4085a3b81 100644 --- a/src/lib/orderman/orders/NativeOrder.cpp +++ b/src/lib/orderman/orders/NativeOrder.cpp @@ -276,7 +276,7 @@ void NativeOrder::on_init_from_exe_report( NativeOrder::~NativeOrder() {} -void NativeOrder::_on_activate(Price p, Quantity q, +bool NativeOrder::_on_activate(Price p, Quantity q, bts::orderman::OrderServices &services, trace::CorID const &trace) { auto scoped_log = @@ -300,7 +300,7 @@ void NativeOrder::_on_activate(Price p, Quantity q, "Dropping order {}", key().value()); transition(ORDER_STATUS_REJECTED_BY_SPARK, "Exchange gateway is down"); - return; + return false; } // can we trade? @@ -316,7 +316,7 @@ void NativeOrder::_on_activate(Price p, Quantity q, transition(ORDER_STATUS_REJECTED_BY_SPARK, fmt::format("Unauthorized order: {}", lqr.error_msg)); - return; + return false; } // can we trade this security, with this size? @@ -333,7 +333,7 @@ void NativeOrder::_on_activate(Price p, Quantity q, transition(ORDER_STATUS_REJECTED_BY_SPARK, fmt::format("Order would breach limit: {}", lqr.error_msg)); - return; + return false; } // are we under the messaging threshold? @@ -344,7 +344,7 @@ void NativeOrder::_on_activate(Price p, Quantity q, key().value()); transition(ORDER_STATUS_REJECTED_BY_SPARK, "Messaging threshold breached"); - return; + return false; } // if we are here we are good. @@ -383,21 +383,22 @@ void NativeOrder::_on_activate(Price p, Quantity q, auto const &ts = services.get_time_str(); me->create_transact_time_bm = encoding.overwrite( me->create_transact_time_bm, &ts.value()[0], ts.value().size()); + return true; } -void NativeOrder::warm_up_activate(OrderServicesData&data, OrderServices& services) { +void NativeOrder::warm_up_activate(OrderServicesData &data, + OrderServices &services) { bts_assert(!me->services); me->services = &services; - init_order_services(data,services); - _on_activate(Price(0),Quantity(0),services, trace::CorID{}); + init_order_services(data, services); + _on_activate(Price(0), Quantity(0), services, trace::CorID{}); - me->services->unsubscribe_from_exe_report( - *me->session_services,me->exe_report_sid); - me->services->unsubscribe_from_cancel_reject( - *me->session_services,me->cancel_reject_sid); - me->services->unsubscribe_from_gateway_status( - *me->session_services); - me->services = nullptr; + me->services->unsubscribe_from_exe_report(*me->session_services, + me->exe_report_sid); + me->services->unsubscribe_from_cancel_reject(*me->session_services, + me->cancel_reject_sid); + me->services->unsubscribe_from_gateway_status(*me->session_services); + me->services = nullptr; } void NativeOrder::on_activate(Price p, Quantity q, @@ -408,22 +409,22 @@ void NativeOrder::on_activate(Price p, Quantity q, switch (me->state.status()) { - case ORDER_STATUS_INACTIVE: { + case ORDER_STATUS_INACTIVE: // this is a brand new order + if (_on_activate(p, q, services, trace)) { + me->services->queue_fix(*me->session_services, + jetfix::MessageTypes::NewOrderSingle, + me->create_encoding, trace); - _on_activate(p,q,services,trace); - me->services->queue_fix(*me->session_services, - jetfix::MessageTypes::NewOrderSingle, - me->create_encoding, trace); + me->services->governor(*me->session_services).record_sent(); + me->state.set_status(ORDER_STATUS_PENDING_WORKING); - me->services->governor(*me->session_services).record_sent(); - me->state.set_status(ORDER_STATUS_PENDING_WORKING); - - LOG(OrderMan, Info, "Sent new order with key {} to gateway", - key().value()); - // early return so we skip the expensive report_state() call - return; - } + LOG(OrderMan, Info, "Sent new order with key {} to gateway", + key().value()); + // early return so we skip the expensive report_state() call + return; + } + break; // all cases below are for orders recovered from disk case ORDER_STATUS_WORKING: diff --git a/src/lib/orderman/orders/NativeOrder.h b/src/lib/orderman/orders/NativeOrder.h index b2fc6f87f..16f1a8d18 100644 --- a/src/lib/orderman/orders/NativeOrder.h +++ b/src/lib/orderman/orders/NativeOrder.h @@ -39,7 +39,7 @@ protected: struct PImpl; std::unique_ptr me; - void _on_activate(Price, Quantity, bts::orderman::OrderServices &, + bool _on_activate(Price, Quantity, bts::orderman::OrderServices &, trace::CorID const &); void on_exe_report(const NewExecutionReportEvent &); void on_cancel_reject(const CancelRejectEvent &); diff --git a/src/lib/os/os.cpp b/src/lib/os/os.cpp index f7f087633..d16966dcd 100755 --- a/src/lib/os/os.cpp +++ b/src/lib/os/os.cpp @@ -544,7 +544,6 @@ uint64_t tick_count() { #endif } -#ifdef _WIN32 std::vector g_cmd_args; bool g_cmd_args_set; @@ -559,14 +558,13 @@ extern "C" BTS_EXPORT void provide_command_line(const char **argv, int argc) { g_cmd_args_set = true; } } -#endif std::vector get_command_line() { -#ifdef _WIN32 if (g_cmd_args_set) { // return cached copy return g_cmd_args; } +#ifdef _WIN32 for (int index = 0; index < __argc; index++) { if (__argv != nullptr) { g_cmd_args.push_back(__argv[index]); diff --git a/src/lib/utils/HTTPStream.cpp b/src/lib/utils/HTTPStream.cpp index e594fa41f..76dbf50bb 100755 --- a/src/lib/utils/HTTPStream.cpp +++ b/src/lib/utils/HTTPStream.cpp @@ -65,6 +65,7 @@ HTTPStream::HTTPStream(const std::string& host, const std::string& path, const s HTTPStream::~HTTPStream() { } +// returns true if file was downloaded bool download_file_if_newer(const string& host, const string& path, const string& destination) { struct stat st = boost::initialized_value; stat(destination.c_str(), &st); diff --git a/src/sdk/README.md b/src/sdk/README.md index 47356faec..d6fdaed69 100644 --- a/src/sdk/README.md +++ b/src/sdk/README.md @@ -62,10 +62,25 @@ run ```build_examples.sh``` to make sure you can build the examples, this will p $ cd ~/spark_sdk/examples $ ./build_examples.sh ``` +### Server Layout +* Spark servers reside on a port, usually 8000, but your production instance could be on a different $PORT + +##### SDK Package Layout +* The sdk puts logs in ``~/sparkdata/data/logging/log`` +* The sdk package has binaries in ``spark_skd/lib`` +* Put plugins in ``spark_sdk/lib/plugins/`` for debugging + +##### Production layout +* Production Logs are in ``~/$PORT/sparkdata/data/logging/log`` on the host +* Production binaries are in ``/sparkbin`` inside the docker container +* Production algo plugins should go into the ``/sparkbin/plugins`` directory + +### Recorded market data +* If you want to see prices, before you start sparkd, you'll have to extract the futures.coconut.tar.gz found at the root of the sdk repo and place futures.coconut in ``~/sparkdata/data/replay/`` ## Debugging -Copy the order_plugin_example.so to ```spark_sdk/lib/plugins/``` and start the sparkd server process inside gdb +Copy the order_plugin_example.so to ``spark_sdk/lib/plugins/`` and start the sparkd server process inside gdb ``` $ cp -f order_plugin_example.so ~/spark_sdk/lib/plugins/ $ cd ~/spark_sdk/lib @@ -87,24 +102,31 @@ $ cp -f order_plugin_example.so ~/spark_sdk/lib/plugins/ $ cd ~/spark_sdk/lib $ ./sparkd run ``` + + ## Connect to Admin (Risk) UI to set limits or add users + * Browse to http://location:$PORT + * Login as bts, no password + * Add or manage user trading and market data permissions by clicking the Users icon on the left side + * Add or manage accounts and risk limits by clicking on the Accounts icon on the left side + +## Other interesting web accessible things + +* When you have a running server you can: + * Browse to http://location/$PORT/config to check configuration overrides + * Browse to http://location:$PORT/perf_trace to see socket to socket latencies + * Send us an email for help: api_support@bluetradesys.com + ## Connect Spark windows client * To start a spark client, use the -ConfigServer parameter to point at this new server ``` -> spark.exe -ConfigServer http://location/8000/config +> spark.exe -ConfigServer http://location:$PORT/config ``` Or create a file called spark.conf at %APPDATA%\bts\conf\ that contains: ``` -include: "http://location:8000/config/" +include: "http://location:$PORT/config/" ``` - -## Notes - -* When you have a running server you can: - * Browse to http://location/8000 to set risk limits and create users - * Browse to http://location/8000/config to check configuration overrides - * Browse to http://location/8000/perf_trace to see socket to socket latencies - * Send us an email for help: api_support@bluetradesys.com - - + + ## Download the Spark windows client + * Download the bts installer here: diff --git a/src/server/sparkd/exchange_sim/ExchangeSim.cpp b/src/server/sparkd/exchange_sim/ExchangeSim.cpp index 0dda72a44..d457d53d5 100644 --- a/src/server/sparkd/exchange_sim/ExchangeSim.cpp +++ b/src/server/sparkd/exchange_sim/ExchangeSim.cpp @@ -148,7 +148,7 @@ int start_exchange_sim() switch(conf.source_case()) { case config::ExchangeSim::SOURCE_NOT_SET: case config::ExchangeSim::kReplayUrl: - md::replay_url(conf.replay_url(), + md::replay_url_with_fallback(conf.replay_url(), player, config::get().naggle_ms()); break; diff --git a/src/server/sparkd/md/run_md.cpp b/src/server/sparkd/md/run_md.cpp index b21fd137a..6bb2a2ef5 100644 --- a/src/server/sparkd/md/run_md.cpp +++ b/src/server/sparkd/md/run_md.cpp @@ -58,9 +58,11 @@ void clean_dir(const std::string base_path) { } void run_replay() { - auto naggle_ms = config::get().naggle_ms(); - auto file = "http://mdreplay.bluetradesys.local/spark/futures.coconut"; - replay_recording(file, naggle_ms); + auto naggle_ms = config::get().naggle_ms(); + const auto& options = config::get(); + auto file = options.url(); + auto fallback_path = options.fallback(); + replay_recording(file, naggle_ms, fallback_path); } void run_onixs() { diff --git a/tools/jenkinsbuild.cmd b/tools/jenkinsbuild.cmd index debcee509..a6f345831 100644 --- a/tools/jenkinsbuild.cmd +++ b/tools/jenkinsbuild.cmd @@ -13,6 +13,11 @@ IF %ERRORLEVEL% NEQ 0 GOTO :ERROR_AND_END msbuild /m /p:debugtype=portable /p:platform=x64 /clp:verbosity=minimal /clp:summary spark_client.sln /p:Configuration=release IF %ERRORLEVEL% NEQ 0 GOTO :ERROR_AND_END +:: build netcore +cd src\client\sparkcmd +dotnet publish -f netcoreapp2.1 -c release +IF %ERRORLEVEL% NEQ 0 GOTO :ERROR_AND_END + GOTO :END :ERROR_AND_END diff --git a/tools/safe_dep_glob.cmake b/tools/safe_dep_glob.cmake index e4a8e28e4..3b8dc2255 100644 --- a/tools/safe_dep_glob.cmake +++ b/tools/safe_dep_glob.cmake @@ -16,7 +16,12 @@ endfunction(update_file) # the list of dependencies in it - this file should be treated as part of # CMakeLists.txt (source controlled, etc.). function(update_deps_file deps) + if (WIN32) + set(deps_file "CMakeDeps_win.cmake") + else () set(deps_file "CMakeDeps.cmake") + endif() + # Normalize the list so it's the same on every machine list(REMOVE_DUPLICATES deps) list(SORT deps)