diff --git a/doc/user/content/release_notes/_index.md b/doc/user/content/release_notes/_index.md index e8266d576..ae480724c 100644 --- a/doc/user/content/release_notes/_index.md +++ b/doc/user/content/release_notes/_index.md @@ -4,6 +4,10 @@ weight = 3 sort_by = "weight" insert_anchor_links = "right" +++ +## 2.7.2 +### User Visible Changes + - Changed the login dialog to avoid leaking workspace names from other users. + ## 2.7.1 ### User Visible Changes - Fixed some issues with the Cover algo, where in some circumstances diff --git a/src/client/spark/view/Shell/Login/LoginView.xaml b/src/client/spark/view/Shell/Login/LoginView.xaml index 61ab1e961..741efc3fb 100644 --- a/src/client/spark/view/Shell/Login/LoginView.xaml +++ b/src/client/spark/view/Shell/Login/LoginView.xaml @@ -1,143 +1,265 @@ - - - - - - - - + + + + + + + + + + + + 40 + 10 + 22 + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + - - - - - - - - - - + + Load last workspace + - + + + + + + + \ No newline at end of file diff --git a/src/client/spark/view/Shell/Login/LoginView.xaml.cs b/src/client/spark/view/Shell/Login/LoginView.xaml.cs index 8a763e43a..974f3c5ba 100644 --- a/src/client/spark/view/Shell/Login/LoginView.xaml.cs +++ b/src/client/spark/view/Shell/Login/LoginView.xaml.cs @@ -1,15 +1,43 @@ -using System; +using bts; +using mbts.ui.converters; +using mbts.ui.native; +using mbts.utils; +using System; using System.Linq; using System.Windows; +using System.Windows.Data; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media.Imaging; -using mbts.ui.native; -using bts; namespace mbts.ui.shell { - public partial class LoginView : Window - { + public partial class LoginView : Window { + public enum LoginStatus { + Initializing, + Ready, + Error, + Rejected, + LoggingIn + } + + public static IValueConverter WorkspaceVisualStateConverter => + ValueConverter.create(workspace => + !string.IsNullOrEmpty(workspace) && workspace != LoginViewModel.NEW_WORKSPACE_NAME ? + VisualStateNames.Workspace.Active : + VisualStateNames.Workspace.Inactive); + + public static IValueConverter LoginStatusVisualStateConverter => + ValueConverter.create(status => { + switch (status) { + case LoginStatus.Initializing: return VisualStateNames.LoginStatus.Initializing; + case LoginStatus.Ready: return VisualStateNames.LoginStatus.Ready; + case LoginStatus.LoggingIn: return VisualStateNames.LoginStatus.Loading; + case LoginStatus.Rejected: return VisualStateNames.LoginStatus.Rejected; + case LoginStatus.Error: return VisualStateNames.LoginStatus.Error; + default: throw ExceptionBuilder.Argument.unexpected_case(status, nameof(status)); + } + }); + public LoginView(LoginViewModel model) { this.DataContext = model; if (model is IRequestViewClose) { @@ -65,6 +93,24 @@ namespace mbts.ui.shell { return IntPtr.Zero; } - } + public static class VisualStateNames { + public static class LoginStatus { + public const string GroupName = nameof(LoginStatus); + public static readonly string + Initializing = $"{GroupName}{nameof(Initializing)}", + Ready = $"{GroupName}{nameof(Ready)}", + Loading = $"{GroupName}{nameof(Loading)}", + Rejected = $"{GroupName}{nameof(Rejected)}", + Error = $"{GroupName}{nameof(Error)}"; + } -} + public static class Workspace { + public const string GroupName = nameof(Workspace); + + public static readonly string + Active = $"{GroupName}{VisualStates.Active}", + Inactive = $"{GroupName}{VisualStates.Inactive}"; + } + } + } +} \ No newline at end of file diff --git a/src/client/spark/view/Shell/Login/LoginViewModel.cs b/src/client/spark/view/Shell/Login/LoginViewModel.cs index 15e8dc229..608b79009 100644 --- a/src/client/spark/view/Shell/Login/LoginViewModel.cs +++ b/src/client/spark/view/Shell/Login/LoginViewModel.cs @@ -2,16 +2,15 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Threading; +using LoginStatus = mbts.ui.shell.LoginView.LoginStatus; -namespace mbts.ui.shell -{ +namespace mbts.ui.shell { public class LoginViewModel : ViewModelBase, IRequestViewClose { + public const string NEW_WORKSPACE_NAME = "New workspace..."; private LoginModel _model; private Dispatcher _dispatcher; public LoginViewModel(LoginModel model, Dispatcher disp) { @@ -42,7 +41,7 @@ namespace mbts.ui.shell void _model_Ready() { _dispatcher.BeginInvoke(() => { if (!_model.HasFatalError) { - this.VisualState = "LoginState"; + login_status = LoginStatus.Ready; load_username(); if (!string.IsNullOrEmpty(_name)) KnownUsers.Add(_name); @@ -50,16 +49,21 @@ namespace mbts.ui.shell } else { ErrorMessage = _model.ErrorMessage; - VisualState = "ErrorState"; + login_status = LoginStatus.Error; } }); } - private string _vstate = "Normal"; - public string VisualState { get { return _vstate; } set { _vstate = value; RaisePropertyChanged("VisualState"); } } + LoginStatus _login_status; + public LoginStatus login_status { get => _login_status; private set => Set(ref _login_status, value); } /// should only contain the user-name of the last login (if none exists, it should be empty). public ObservableCollection KnownUsers { get; } = new ObservableCollection(); + bool _resume_workspace = true; + public bool resume_workspace { + get => _resume_workspace; + set => Set(ref _resume_workspace, value); + } private string _name; public string Name { get { return _name; } @@ -82,7 +86,7 @@ namespace mbts.ui.shell public string SelectedWorkspace { get; set; } private async void update_workspaces(string name) { Workspaces.Clear(); - Workspaces.Add("New workspace..."); + Workspaces.Add(NEW_WORKSPACE_NAME); SelectedWorkspace = Workspaces.First(); if (_model.try_get_user(name, out var user)) { var to_add = await _model.workspaces_for(user); @@ -136,15 +140,13 @@ namespace mbts.ui.shell private async void OnLogin(object arg) { save_selection(); - string selected_workspace = SelectedWorkspace; - if (selected_workspace == "New workspace...") { - selected_workspace = null; - } + string selected_workspace = _resume_workspace && SelectedWorkspace != NEW_WORKSPACE_NAME ? + SelectedWorkspace : null; var result = await _model.do_login(Name, selected_workspace, Password); - if (result.success) { VisualState = "Loading"; } + if (result.success) { login_status = LoginStatus.LoggingIn; } if (!result.success && !string.IsNullOrEmpty(result.reason)) { WarningMessage = result.reason; - VisualState = "BadPassword"; + login_status = LoginStatus.Rejected; } else if (!string.IsNullOrEmpty(result.reason)) { // Login was successful but we have a message for the user diff --git a/src/client/spark/view/Utility/StateManager.cs b/src/client/spark/view/Utility/StateManager.cs index ddcd63094..3537c894e 100644 --- a/src/client/spark/view/Utility/StateManager.cs +++ b/src/client/spark/view/Utility/StateManager.cs @@ -253,15 +253,18 @@ namespace mbts.ui { sd.StateChanged += on_state_changed; return Disposable.Create(() => sd.StateChanged -= on_state_changed); void on_state_changed(string oldval, string newval) => transition(newval); - async void transition(string state) { + void transition(string state) { version++; if (target.IsLoaded) StateManager.GoToState(target, state); else { int v = version; - await target.LoadedAsync(); - if (v == version) - StateManager.GoToState(target, state); + target.Loaded += on_loaded; + void on_loaded(object sender, RoutedEventArgs e) { + target.Loaded -= on_loaded; + if (v == version) + StateManager.GoToState(target, state); + } } } }); diff --git a/testing/manual/algo_operations/Top_cover_TEST.txt b/testing/manual/algo_operations/Top_cover_TEST.txt index 57f6f2afa..a603a2c3f 100644 --- a/testing/manual/algo_operations/Top_cover_TEST.txt +++ b/testing/manual/algo_operations/Top_cover_TEST.txt @@ -1,3 +1,14 @@ +This needs sim market data **not** to be merged with replay (or +cert), so we can create our own markets. Use the following key to set +market data up: + +ExchangeSim { + value { + merge_with_md: false + forward_implied: false + } +} + Algo Studio lets you combine algos together and save it as an order type: To test this, we will create a common algo combination and test to make sure it's working as desired. @@ -6,42 +17,32 @@ To test this, we will create a common algo combination and test to make sure it' Let's start by creating the Algo: Launch Algo Studio -Click on top right icon to "add algo" +Click on top left icon to "add algo" Give it a name, call it T_C and give the abbrev a title of T_C as well. Create a Top with Cover, so the very top algos with be a "top" (top thresh 10) and it's child will be a cover (Hedge Ticks 2) Leave both Hedge and Child as limits of the child -Use a very liquid market with recorded data to test, I suggest something like ES or CL. - On the ladder, go to settings, then algo favorites and click add and choose your T_C algo. This will display it on the ladder for quick deployment -click on algo, then enter an order on the best bid +1.) Create a 20 lot bid/ask market 1 tick apart. +2.) Place a 5 lot T_C (top cover algo) buy order on the best bid market. +3.) Place another 5 lot buy limit order on the best bid +4.) Place a 25 lot sell limit order on the best bid, filling the orders placed in 1 and 2 +5.) Verify that the cover order was deployed. -wait until it fills, once fills, it should submit the cover order 2 ticks above the price you got filled at. - -try this with a sell order following the same procedure. +Repeat steps 1 through 5 with a sell order. Additionally, we will add a "lean" into the mix as the child of the cover. -go back to your algo studio, and change the hedge of the cover to be that of lean. - -What will happen is once the cover order is submitted, it will include the lean logic on that cover order. Meaning, it'll lean into the market and cross once the cross thresh is reach. - -Set the parameters to a cross thresh of 10, max chase ticks 0 and on toward no change - -save the algo, and send an order and wait for it to be filled. - -Once filled, it will remain working until the market flips, which means it ticks up a level. Once it flips and there is 1 remaining, the order should cross. - - - - - - +Go back to your algo studio, and change the hedge of the cover to be that of lean. +What will happen is once the cover order is submitted, it will include the lean logic on that cover order. +Set the parameters to a cross thresh of 10, max chase ticks 0 and on toward no change. +Save the algo, and repeat steps 1 through 5 again. +This time the hedge should get filled immediately, as it will lean into the market that we just reduced below it's threshold size. \ No newline at end of file