diff --git a/src/client/spark/view/Shell/Settings/Global/GlobalAlertsDialog.xaml b/src/client/spark/view/Shell/Settings/Global/GlobalAlertsDialog.xaml
new file mode 100644
index 000000000..0f11993d2
--- /dev/null
+++ b/src/client/spark/view/Shell/Settings/Global/GlobalAlertsDialog.xaml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/client/spark/view/Shell/Settings/Global/GlobalAlertsDialog.xaml.cs b/src/client/spark/view/Shell/Settings/Global/GlobalAlertsDialog.xaml.cs
new file mode 100644
index 000000000..103f46713
--- /dev/null
+++ b/src/client/spark/view/Shell/Settings/Global/GlobalAlertsDialog.xaml.cs
@@ -0,0 +1,14 @@
+using mbts.ui.utility;
+using System.Windows;
+
+namespace mbts.ui.spark {
+ ///
+ /// Interaction logic for GlobalAlertsDialog.xaml
+ ///
+ partial class GlobalAlertsDialog : Window {
+ public GlobalAlertsDialog() {
+ InitializeComponent();
+ WindowUtilities.listen_for_close_requests(this);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Shell/Settings/Global/GlobalAlertsView.xaml b/src/client/spark/view/Shell/Settings/Global/GlobalAlertsView.xaml
new file mode 100644
index 000000000..cf518ce2e
--- /dev/null
+++ b/src/client/spark/view/Shell/Settings/Global/GlobalAlertsView.xaml
@@ -0,0 +1,246 @@
+
+
+
+
+
+
+
+ 130
+ 210
+ 100
+ 163
+ 10,8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ (N/A)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Click to Add Alert
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/client/spark/view/Shell/Settings/Global/GlobalAlertsView.xaml.cs b/src/client/spark/view/Shell/Settings/Global/GlobalAlertsView.xaml.cs
new file mode 100644
index 000000000..842c585f3
--- /dev/null
+++ b/src/client/spark/view/Shell/Settings/Global/GlobalAlertsView.xaml.cs
@@ -0,0 +1,41 @@
+using mbts.ui.controls;
+using mbts.ui.converters;
+using mbts.ui.utilities;
+using System.Windows.Controls;
+using System.Windows.Data;
+
+namespace mbts.ui.spark {
+ ///
+ /// Interaction logic for ShellSettingsDialog.xaml
+ ///
+ partial class GlobalAlertsView : UserControl {
+ public static readonly IValueConverter
+ DoublePredicateTypeDisplayNameConverter = ValueConverter.create(t => {
+ switch (t) {
+ case DoublePredicate.PredicateTypeOneofCase.InsideRange: return "Between";
+ case DoublePredicate.PredicateTypeOneofCase.OutsideRange: return "Not Between";
+ case DoublePredicate.PredicateTypeOneofCase.None: return "(None)";
+ default: return DisplayNameHelper.camel_to_title_case(t.ToString());
+ }
+ });
+
+ public GlobalAlertsView() =>
+ InitializeComponent();
+
+ public enum Columns {
+ None = 0,
+ Delete,
+ IsEnabled,
+ Security,
+ Price,
+ Quantity,
+ Side,
+ Sound
+ }
+ }
+
+ class GlobalAlertsColumn : DIYGrid.ColumnBase {
+ protected override void on_key_initialized(GlobalAlertsView.Columns key) =>
+ id = key.ToString();
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Shell/Settings/Global/VM/GlobalAlertsVM.cs b/src/client/spark/view/Shell/Settings/Global/VM/GlobalAlertsVM.cs
new file mode 100644
index 000000000..711225e0f
--- /dev/null
+++ b/src/client/spark/view/Shell/Settings/Global/VM/GlobalAlertsVM.cs
@@ -0,0 +1,44 @@
+using mbts.spark;
+using mbts.ui.shell;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Input;
+
+namespace mbts.ui.spark {
+ class GlobalAlertsVM : ViewModelBase, IValueFactory, IRequestViewClose {
+ IReadOnlyDictionary _security_map = DictionaryHelper.empty();
+
+ public GlobalAlertsVM() {
+ ok_cmd = new DelegateCommand(() => {
+ apply();
+ RequestClose?.Invoke(this, EventArgs.Empty);
+ });
+ apply_cmd = new DelegateCommand(apply);
+ void apply() =>
+ request_commit?.Invoke();
+ }
+
+ public event Action request_commit;
+ public event EventHandler RequestClose;
+
+ public TradeAlertsVM trade_alerts { get; } = new TradeAlertsVM();
+ public ICommand apply_cmd { get; }
+ public ICommand ok_cmd { get; }
+
+ public IReadOnlyDictionary security_map {
+ get => _security_map;
+ set {
+ _security_map = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ public GlobalAlertSettings create() =>
+ new GlobalAlertSettings(trade_alerts.create().ToArray());
+
+ public void load_from(GlobalAlertSettings value) {
+ trade_alerts.load_from(value.trade_alerts);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Shell/Settings/Global/VM/SoundNotificationVM.cs b/src/client/spark/view/Shell/Settings/Global/VM/SoundNotificationVM.cs
new file mode 100644
index 000000000..58f31d864
--- /dev/null
+++ b/src/client/spark/view/Shell/Settings/Global/VM/SoundNotificationVM.cs
@@ -0,0 +1,28 @@
+using bts.shell;
+using mbts.ui.shell;
+using mbts.ui.utility;
+using System.Collections.Generic;
+
+namespace mbts.spark {
+ class SoundNotificationVM : DisposableViewModelBase {
+ SoundNotification.SystemSound _system_sound;
+
+ public SoundNotificationVM() {
+ }
+
+ public SoundNotification.SystemSound system_sound { get => _system_sound; set => Set(ref _system_sound, value); }
+ public IReadOnlyList system_sound_options => EnumHelper.get_values();
+
+ public SoundNotification create() =>
+ new SoundNotification {
+ system_sound = system_sound
+ };
+
+ public void load_from(SoundNotification value) {
+ switch (value.sound_type_case) {
+ case SoundNotification.SoundTypeOneofCase.System: system_sound = value.system_sound.Value; break;
+ case SoundNotification.SoundTypeOneofCase.Uri: /*todo*/ break;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Shell/Settings/Global/VM/TradeAlertPredicateVM.cs b/src/client/spark/view/Shell/Settings/Global/VM/TradeAlertPredicateVM.cs
new file mode 100644
index 000000000..84074aa42
--- /dev/null
+++ b/src/client/spark/view/Shell/Settings/Global/VM/TradeAlertPredicateVM.cs
@@ -0,0 +1,39 @@
+using bts.api;
+using mbts.spark;
+using mbts.ui.shell;
+using mbts.ui.utility;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace mbts.ui.spark {
+ class TradeAlertPredicateVM : ViewModelBase, IValueFactory {
+ SecurityCriteria _security_criteria;
+ Side _side;
+
+ public SecurityCriteria security_criteria { get => _security_criteria; set => Set(ref _security_criteria, value); }
+ public DoublePredicateVM price { get; } = new DoublePredicateVM();
+ public DoublePredicateVM quantity { get; } = new DoublePredicateVM();
+ public Side side { get => _side; set => Set(ref _side, value); }
+ public IEnumerable side_options {
+ get {
+ yield return Side.Buy;
+ yield return Side.Sell;
+ yield return Side.Buy | Side.Sell;
+ }
+ }
+
+ public void load_from(TradeAlertPredicate value) {
+ security_criteria = value.security_criteria;
+ quantity.load_from(value.quantity);
+ price.load_from(value.price);
+ side = value.side.Aggregate(Side.Undefined, (flags, s) => flags | s);
+ }
+
+ public TradeAlertPredicate create() =>
+ new TradeAlertPredicate(
+ security_criteria,
+ quantity.create(),
+ price.create(),
+ EnumHelper.split_flags(side).ToArray());
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Shell/Settings/Global/VM/TradeAlertVM.cs b/src/client/spark/view/Shell/Settings/Global/VM/TradeAlertVM.cs
new file mode 100644
index 000000000..506f14cf9
--- /dev/null
+++ b/src/client/spark/view/Shell/Settings/Global/VM/TradeAlertVM.cs
@@ -0,0 +1,24 @@
+using mbts.spark;
+using mbts.ui.shell;
+
+namespace mbts.ui.spark {
+ class TradeAlertVM : ViewModelBase, IValueFactory {
+ bool _is_enabled;
+
+ public TradeAlertPredicateVM predicate { get; } = new TradeAlertPredicateVM();
+ public SoundNotificationVM sound { get; } = new SoundNotificationVM();
+ public bool is_enabled { get => _is_enabled; set => Set(ref _is_enabled, value); }
+
+ public TradeAlert create() =>
+ new TradeAlert(
+ predicate.create(),
+ sound.create(),
+ is_enabled);
+
+ public void load_from(TradeAlert value) {
+ predicate.load_from(value.predicate);
+ sound.load_from(value.sound);
+ is_enabled = value.is_enabled;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Shell/Settings/Global/VM/TradeAlertsVM.cs b/src/client/spark/view/Shell/Settings/Global/VM/TradeAlertsVM.cs
new file mode 100644
index 000000000..3e4dff11f
--- /dev/null
+++ b/src/client/spark/view/Shell/Settings/Global/VM/TradeAlertsVM.cs
@@ -0,0 +1,41 @@
+using bts.api;
+using bts.shell;
+using mbts.spark;
+using mbts.ui.shell;
+using mbts.utils;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows.Input;
+
+namespace mbts.ui.spark {
+ class TradeAlertsVM : ViewModelBase, IValueFactory> {
+ public TradeAlertsVM() {
+ add_alert_cmd = new DelegateCommand(() => {
+ var a = new TradeAlertVM();
+ a.load_from(_default_alert());
+ alerts.Add(a);
+ });
+ delete_alert_cmd = new DelegateCommand(a => alerts.Remove(a));
+ }
+
+ public ObservableCollection alerts { get; } = new ObservableCollection();
+
+ public ICommand add_alert_cmd { get; }
+ public ICommand delete_alert_cmd { get; }
+
+ public IReadOnlyList create() =>
+ alerts.Select(a => a.create()).ToList();
+
+ public void load_from(IReadOnlyList value) =>
+ alerts.sync_with_models(value);
+
+ static TradeAlert _default_alert() =>
+ new TradeAlert(
+ new TradeAlertPredicate(side: new[] { Side.Buy, Side.Sell }),
+ new SoundNotification {
+ system_sound = SoundNotification.SystemSound.BellCounter
+ },
+ true);
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Shell/Settings/Global/VM/TradeSoundsVM.cs b/src/client/spark/view/Shell/Settings/Global/VM/TradeSoundsVM.cs
new file mode 100644
index 000000000..9e8523813
--- /dev/null
+++ b/src/client/spark/view/Shell/Settings/Global/VM/TradeSoundsVM.cs
@@ -0,0 +1,24 @@
+using bts.collections;
+using bts.utils;
+using mbts.collections;
+using mbts.persist;
+using mbts.ui;
+using mbts.ui.controls;
+using mbts.ui.shell;
+using mbts.ui.spark;
+using mbts.ui.utility;
+using mbts.utils;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Reactive.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace mbts.spark {
+ class TradeSoundsVM : DisposableViewModelBase {
+
+ }
+}
\ No newline at end of file