Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a561ff3aae | ||
|
|
3eeab708d2 | ||
|
|
082056ea3f | ||
|
|
e9f3e92f82 | ||
|
|
152c79a4a9 | ||
|
|
db877c859b |
No files matched your search
@@ -25,7 +25,7 @@ namespace bts.ui {
|
||||
public AboutDaemon(IBus bus, [Import("username")]string username, IBrowserWindowManager browser) {
|
||||
_user = username;
|
||||
_browser = browser;
|
||||
_dispose = bus.subscribe(SparkTags.About).ObserveOnDispatcher().Subscribe(_ => show_about());
|
||||
_dispose = bus.subscribe(SparkTags.About).OnDispatcher().Subscribe(_ => show_about());
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace bts {
|
||||
public DeleteSyntheticDaemon(IBus bus, OrdersModel orders_model) {
|
||||
_orders_model = orders_model;
|
||||
_dispose = bus.subscribe(SparkTags.SyntheticDeleteTag)
|
||||
.ObserveOnDispatcher()
|
||||
.OnDispatcher()
|
||||
.Subscribe(_delete_synthetic);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using mbts.ui;
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
using System.Windows;
|
||||
|
||||
namespace bts.spark
|
||||
@@ -22,18 +22,21 @@ namespace bts.spark
|
||||
public ErrorReporter(ErrorReportService svc, IBus bus, [Import("username")] string username) {
|
||||
_svc = svc;
|
||||
_username = username;
|
||||
_dispose = bus.subscribe(SparkTags.Support).ObserveOnDispatcher().Subscribe(msg => show_support_window(msg, "Report a problem"));
|
||||
_dispose = bus.subscribe(SparkTags.Support).OnDispatcher().Subscribe(msg => show_support_window(msg, "Report a problem"));
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Disposable.dispose(ref _dispose);
|
||||
}
|
||||
|
||||
public async Task report_error(string message, string title = null, MessageBoxImage? image = null) {
|
||||
var result = await BTSMessageBox.ShowAsync(message, title = "Error", BTSMessageBoxButtons.OK | BTSMessageBoxButtons.Support, image ?? MessageBoxImage.Error);
|
||||
if (result == BTSMessageBoxButtons.Support) {
|
||||
show_support_window(message, title);
|
||||
}
|
||||
public void report_error(string message, string title = null, MessageBoxImage? image = null) {
|
||||
// Error reports are likely to arrive the api thread (which is not an STA thread)
|
||||
Application.Current.Dispatcher.BeginInvoke(async () => {
|
||||
var result = await BTSMessageBox.ShowAsync(message, title = "Error", BTSMessageBoxButtons.OK | BTSMessageBoxButtons.Support, image ?? MessageBoxImage.Error);
|
||||
if (result == BTSMessageBoxButtons.Support) {
|
||||
show_support_window(message, title);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void show_support_window(string message, string title) {
|
||||
@@ -70,11 +73,11 @@ namespace bts.spark
|
||||
return (get_successful_rv(result.value), string.Empty);
|
||||
else {
|
||||
string error_msg = template.fmt(error);
|
||||
error_reporter.report_error(error_msg).ignore();
|
||||
error_reporter.report_error(error_msg);
|
||||
return (get_unsuccessful_rv(), error_msg);
|
||||
}
|
||||
} else {
|
||||
error_reporter.report_error(result.error_message).ignore();
|
||||
error_reporter.report_error(result.error_message);
|
||||
return (get_unsuccessful_rv(), result.error_message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ namespace bts.shell {
|
||||
_model = model;
|
||||
_error_reporter = error_reporter;
|
||||
_dispose = Disposable.Create(
|
||||
model.on_orders.ObserveOnDispatcher().Subscribe(o => _orders = o),
|
||||
bus.subscribe(SparkTags.SecuritiesTag).ObserveOnDispatcher().Subscribe(m =>_md_map = m),
|
||||
bus.subscribe(SparkTags.ShowOrderTicketFromSecurityTag).ObserveOnDispatcher().Subscribe(_show_order_ticket),
|
||||
bus.subscribe(SparkTags.ShowOrderTicketTag).ObserveOnDispatcher().Subscribe(_show_order_ticket),
|
||||
bus.subscribe(SparkTags.ShowModifyOrderTag).ObserveOnDispatcher().Subscribe(_show_modify_order)
|
||||
model.on_orders.OnDispatcher().Subscribe(o => _orders = o),
|
||||
bus.subscribe(SparkTags.SecuritiesTag).OnDispatcher().Subscribe(m =>_md_map = m),
|
||||
bus.subscribe(SparkTags.ShowOrderTicketFromSecurityTag).OnDispatcher().Subscribe(_show_order_ticket),
|
||||
bus.subscribe(SparkTags.ShowOrderTicketTag).OnDispatcher().Subscribe(_show_order_ticket),
|
||||
bus.subscribe(SparkTags.ShowModifyOrderTag).OnDispatcher().Subscribe(_show_modify_order)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace bts {
|
||||
public SecurityPickerDaemon(IBus bus) {
|
||||
_bus = bus;
|
||||
_dispose = Disposable.Create(
|
||||
bus.subscribe(SparkTags.ShowPickOne).ObserveOnDispatcher().Subscribe(show_pick_one),
|
||||
bus.subscribe(SparkTags.FilterPickOne).ObserveOnDispatcher().Subscribe(show_filtered_pick_one),
|
||||
bus.subscribe(SparkTags.ShowPickMultiple).ObserveOnDispatcher().Subscribe(show_pick_multiple),
|
||||
bus.subscribe(SparkTags.ShowAndEditPickMultiple).ObserveOnDispatcher().Subscribe(show_and_edit_pick_multiple)
|
||||
bus.subscribe(SparkTags.ShowPickOne).OnDispatcher().Subscribe(show_pick_one),
|
||||
bus.subscribe(SparkTags.FilterPickOne).OnDispatcher().Subscribe(show_filtered_pick_one),
|
||||
bus.subscribe(SparkTags.ShowPickMultiple).OnDispatcher().Subscribe(show_pick_multiple),
|
||||
bus.subscribe(SparkTags.ShowAndEditPickMultiple).OnDispatcher().Subscribe(show_and_edit_pick_multiple)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,11 +78,11 @@ namespace mbts.spark {
|
||||
_animation.AnimationsChanged += on_animations_changed;
|
||||
void on_animations_changed() => RaisePropertyChanged(nameof(animations));
|
||||
_dispose = Disposable.Create(
|
||||
_orders_model.on_security_orders(security.Id).ObserveOnDispatcher().Subscribe(_on_orders),
|
||||
_position.ObserveOnDispatcher().Subscribe(v => _animation.animate_position(v.newval > v.oldval)),
|
||||
_inside_bids.ObserveOnDispatcher().Subscribe(v => _animation.animate_working_bids_inside(v.newval)),
|
||||
_inside_asks.ObserveOnDispatcher().Subscribe(v => _animation.animate_working_asks_inside(v.newval)),
|
||||
_day_change.ObserveOnDispatcher().Subscribe(v => _animation.animate_day_change(v.newval > v.oldval)),
|
||||
_orders_model.on_security_orders(security.Id).OnDispatcher().Subscribe(_on_orders),
|
||||
_position.OnDispatcher().Subscribe(v => _animation.animate_position(v.newval > v.oldval)),
|
||||
_inside_bids.OnDispatcher().Subscribe(v => _animation.animate_working_bids_inside(v.newval)),
|
||||
_inside_asks.OnDispatcher().Subscribe(v => _animation.animate_working_asks_inside(v.newval)),
|
||||
_day_change.OnDispatcher().Subscribe(v => _animation.animate_day_change(v.newval > v.oldval)),
|
||||
Disposable.Create(() => _animation.AnimationsChanged -= on_animations_changed)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace mbts.spark {
|
||||
}
|
||||
//
|
||||
_resources.AddRange(
|
||||
state.ObserveOnDispatcher().Subscribe(s => {
|
||||
state.OnDispatcher().Subscribe(s => {
|
||||
using (rows_view.DeferRefresh()) {
|
||||
rows_view.SetSortingCriteria(s.sorting_criteria);
|
||||
var filters = s.filters;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace mbts.spark {
|
||||
SparkCommands.ShowTimeAndSales.complete(_vm.selected_securities_observable(), _ => true, secs => secs.Count > 0 ? new SecurityCriteria(secs) : _state.security_criteria),
|
||||
SparkCommands.ShowSyntheticCreate.complete(_vm.selected_securities_observable(), secs => secs.Count > 0 && secs.Count < 3, secs => new SecurityCriteria(secs))
|
||||
};
|
||||
_subscriptions = _bus.subscribe(update_securities_tag).ObserveOnDispatcher().Subscribe(c =>
|
||||
_subscriptions = _bus.subscribe(update_securities_tag).OnDispatcher().Subscribe(c =>
|
||||
_state_changed?.Invoke(_state = new MarketViewWindowFactory.StartupData(c, _vm.rows_view.GetSortingCriteria(), _vm.get_filter_states())));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace bts.shell {
|
||||
public MarketViewWindowFactory(MarketShellModule module, IBus bus, OrdersModel orders_model) : base(module, "MarketView") {
|
||||
_bus = bus;
|
||||
_orders_model = orders_model;
|
||||
_dispose = bus.subscribe(SparkTags.ShowMarketViewTag).ObserveOnDispatcher().Subscribe(_show);
|
||||
_dispose = bus.subscribe(SparkTags.ShowMarketViewTag).OnDispatcher().Subscribe(_show);
|
||||
}
|
||||
|
||||
public override Task<IShellWindow> load(StartupData state) =>
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace mbts.spark {
|
||||
_vm = new SingleValuePump<TimeAndSalesVM>();
|
||||
var update_securities_tag = new SparkTags.SparkTag<SecurityCriteria>("TimeAndSales Callback");
|
||||
var update_securities_cmd = SparkCommand.create("Update Time and Sales", Icon, update_securities_tag);
|
||||
var current_smd_source = _vm.observable.SelectMany(vm => vm.current_security_md_observable(_bus)).ObserveOnDispatcher();
|
||||
var selected_secs_source = _vm.observable.SelectMany(vm => vm.selected_securities_observable()).ObserveOnDispatcher();
|
||||
var current_smd_source = _vm.observable.SelectMany(vm => vm.current_security_md_observable(_bus)).OnDispatcher();
|
||||
var selected_secs_source = _vm.observable.SelectMany(vm => vm.selected_securities_observable()).OnDispatcher();
|
||||
_commands = new SparkCommand[] {
|
||||
SparkCommand.create("Change Securities", Icons.Admin, SparkTags.ShowAndEditPickMultiple, () => (update_securities_cmd, _state.security_criteria)),
|
||||
SparkCommands.ShowLadder.complete(current_smd_source, md => md.HasValue, ObjectHelper.ValueOrDefault),
|
||||
@@ -56,7 +56,7 @@ namespace mbts.spark {
|
||||
SparkCommands.ShowFills.complete(selected_secs_source, always_true, get_fills_startup_data),
|
||||
SparkCommands.ShowMarketView.complete(selected_secs_source, always_true, secs => secs.Count > 0 ? new SecurityCriteria(secs) : _state.security_criteria)
|
||||
};
|
||||
_subscriptions = _bus.subscribe(update_securities_tag).ObserveOnDispatcher().Subscribe(update_criteria);
|
||||
_subscriptions = _bus.subscribe(update_securities_tag).OnDispatcher().Subscribe(update_criteria);
|
||||
_initialize();
|
||||
|
||||
bool always_true<T>(T _) => true;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace bts.shell {
|
||||
|
||||
_dispose = Disposable.Create(
|
||||
bus.subscribe(SparkTags.SecuritiesTag).Subscribe(s => _securities = s),
|
||||
bus.subscribe(SparkTags.ShowTimeAndSalesTag).ObserveOnDispatcher().Subscribe(show)
|
||||
bus.subscribe(SparkTags.ShowTimeAndSalesTag).OnDispatcher().Subscribe(show)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,9 +98,9 @@ namespace bts.shell {
|
||||
void IInitializable.initialize() {
|
||||
Disposable.dispose(ref _dispose);
|
||||
_dispose = Disposable.Create(
|
||||
_bus.subscribe(SparkTags.ShowSyntheticCreateTag).ObserveOnDispatcher().Subscribe(_show_synthetic_create),
|
||||
_bus.subscribe(SparkTags.ShowSyntheticStrategyTag).ObserveOnDispatcher().Subscribe(_show_synthetic_strategy),
|
||||
_bus.subscribe(SparkTags.ShowSyntheticCloneTag).ObserveOnDispatcher().Subscribe(_show_synthetic_clone)
|
||||
_bus.subscribe(SparkTags.ShowSyntheticCreateTag).OnDispatcher().Subscribe(_show_synthetic_create),
|
||||
_bus.subscribe(SparkTags.ShowSyntheticStrategyTag).OnDispatcher().Subscribe(_show_synthetic_strategy),
|
||||
_bus.subscribe(SparkTags.ShowSyntheticCloneTag).OnDispatcher().Subscribe(_show_synthetic_clone)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace bts.shell {
|
||||
public SyntheticManagementWindowFactory(SpreaderShellModule module, IBus bus, OrdersModel orders_model) : base(module, "SyntheticManagement") {
|
||||
_bus = bus;
|
||||
_orders_model = orders_model;
|
||||
_dispose = bus.subscribe(SparkTags.ShowSyntheticManagementTag).ObserveOnDispatcher().Subscribe(show);
|
||||
_dispose = bus.subscribe(SparkTags.ShowSyntheticManagementTag).OnDispatcher().Subscribe(show);
|
||||
}
|
||||
|
||||
public override Task<IShellWindow> load(StartupData state) =>
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace mbts.spark {
|
||||
readonly Property<bool> _enabled;
|
||||
|
||||
protected CellBase(IRowModel model, LegSpreaderParamsTuple leg_tup) =>
|
||||
_enabled = backing(nameof(enabled), model.observe_enabled(leg_tup).ObserveOnDispatcher());
|
||||
_enabled = backing(nameof(enabled), model.observe_enabled(leg_tup).OnDispatcher());
|
||||
|
||||
public bool enabled => _enabled.Value;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace mbts.spark {
|
||||
: base(model, leg_tup) {
|
||||
_model = model;
|
||||
_leg_tup = leg_tup;
|
||||
_override_value_sub = model.observe_override_value(leg_tup).ObserveOnDispatcher().Subscribe(v => {
|
||||
_override_value_sub = model.observe_override_value(leg_tup).OnDispatcher().Subscribe(v => {
|
||||
value = v;
|
||||
RaisePropertyChanged(nameof(value));
|
||||
});
|
||||
|
||||
@@ -44,10 +44,10 @@ namespace mbts.spark {
|
||||
_tick_factors = TickUtils.get_regional_ticks(synthetic.ContractSpec).low_tick;
|
||||
title = $"Edit '{synthetic.Synthetic.Name}'";
|
||||
icon = Icons.ModifySynthetic;
|
||||
_has_working_orders = backing(nameof(has_working_orders), security_has_working_orders.ObserveOnDispatcher());
|
||||
_has_working_orders = backing(nameof(has_working_orders), security_has_working_orders.OnDispatcher());
|
||||
var commit = new ObservantAsyncCommand(commit_async);
|
||||
_resources.Add(security_has_working_orders.Select(v => !v).ObserveOnDispatcher().Subscribe(commit));
|
||||
_resources.Add(_has_working_orders.ObserveOnDispatcher().Subscribe(vals => {
|
||||
_resources.Add(security_has_working_orders.Select(v => !v).OnDispatcher().Subscribe(commit));
|
||||
_resources.Add(_has_working_orders.OnDispatcher().Subscribe(vals => {
|
||||
if (vals.newval)
|
||||
set_error(nameof(has_working_orders), "Security has working orders");
|
||||
else clear_error(nameof(has_working_orders));
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace mbts.spark {
|
||||
.Select(t => (uint)(t.state
|
||||
.Where(kv => kv.Value.is_active())
|
||||
.Count())
|
||||
).ObserveOnDispatcher());
|
||||
).OnDispatcher());
|
||||
name = security.Synthetic.Name;
|
||||
n_legs = security.Synthetic.Legs.Count();
|
||||
description = SecurityFormatter.format_contract_legs(security.Synthetic.Legs);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace bts.shell
|
||||
}
|
||||
|
||||
public void thread_init() {
|
||||
_dispose = _message_src.ObserveOnDispatcher().Subscribe(_messages.AddLog);
|
||||
_dispose = _message_src.OnDispatcher().Subscribe(_messages.AddLog);
|
||||
_content =
|
||||
new LogViewer {
|
||||
ItemsSource = _messages,
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace bts.shell {
|
||||
public HelpShellModule(IBus bus, IBrowserWindowManager browser) {
|
||||
_awf = new ActivityWindowFactory(this, bus);
|
||||
_dispose = Disposable.Create(
|
||||
bus.subscribe(SparkTags.ShowUri).ObserveOnDispatcher().Subscribe(u => browser.Pages.Add(u))
|
||||
bus.subscribe(SparkTags.ShowUri).OnDispatcher().Subscribe(u => browser.Pages.Add(u))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace bts.shell {
|
||||
: base(module, "Fills") {
|
||||
_bus = bus;
|
||||
_orders_model = orders_model;
|
||||
_dispose = bus.subscribe(SparkTags.ShowFillsTag).ObserveOnDispatcher().Subscribe(show);
|
||||
_dispose = bus.subscribe(SparkTags.ShowFillsTag).OnDispatcher().Subscribe(show);
|
||||
}
|
||||
|
||||
public override Task<IShellWindow> load(StartupData state) =>
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace bts.shell {
|
||||
_max_ladders_open = (int)(window_props?.ladder?.max_total_open ?? 75);
|
||||
_dispose = Disposable.Create(
|
||||
bus.subscribe(SparkTags.SecuritiesTag).Subscribe(s => _securities = s),
|
||||
bus.subscribe(SparkTags.ShowLadderTag).ObserveOnDispatcher().Subscribe(s => show_windows(new[] { s })),
|
||||
bus.subscribe(SparkTags.ShowLaddersTag).ObserveOnDispatcher().Subscribe(show_windows)
|
||||
bus.subscribe(SparkTags.ShowLadderTag).OnDispatcher().Subscribe(s => show_windows(new[] { s })),
|
||||
bus.subscribe(SparkTags.ShowLaddersTag).OnDispatcher().Subscribe(show_windows)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace bts.shell {
|
||||
_bus = bus;
|
||||
_model = model;
|
||||
|
||||
_dispose = bus.subscribe(SparkTags.ShowOrderBookTag).ObserveOnDispatcher().Subscribe(show);
|
||||
_dispose = bus.subscribe(SparkTags.ShowOrderBookTag).OnDispatcher().Subscribe(show);
|
||||
}
|
||||
|
||||
public override Task<IShellWindow> load(OrderBookStartupData state) {
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace bts.shell {
|
||||
_bus = bus;
|
||||
_model = model;
|
||||
|
||||
_dispose = bus.subscribe(SparkTags.ShowPAndLTag).ObserveOnDispatcher().Subscribe(show);
|
||||
_dispose = bus.subscribe(SparkTags.ShowPAndLTag).OnDispatcher().Subscribe(show);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace mbts.spark {
|
||||
var security_source = security_md_source.Select(smd => smd.security);
|
||||
//
|
||||
_security = backing(nameof(security), security_source, SecurityDataHelper.Defaults.SecurityImmutable);
|
||||
properties_vm = new OrderPropertiesEditorVM(model, security_source.ObserveOnDispatcher(), order_source.Select(ot => new InlineOrderProperties(model, ot.order.Def)));
|
||||
properties_vm = new OrderPropertiesEditorVM(model, security_source.OnDispatcher(), order_source.Select(ot => new InlineOrderProperties(model, ot.order.Def)));
|
||||
_price = backing(nameof(price), double.NaN);
|
||||
size_calculator = new CalculatorLogic(null, calculator_buttons);
|
||||
_current_price = backing(nameof(current_price), order_source.Select(ort => ort.order.State.Price));
|
||||
@@ -83,15 +83,15 @@ namespace mbts.spark {
|
||||
size_calculator,
|
||||
properties_vm,
|
||||
bbo = new BBOVM(security_md_source),
|
||||
order_source.ObserveOnDispatcher().Subscribe(ort => {
|
||||
order_source.OnDispatcher().Subscribe(ort => {
|
||||
key = ort.order.Key;
|
||||
if (DoubleHelper.IsNaNOrInfinity(price))
|
||||
price = ort.order.State.Price;
|
||||
if (!size_calculator.value.HasValue || !size_calculator.value_setter_called)
|
||||
size_calculator.bypass_value_setter(ort.order.State.Quantity);
|
||||
}),
|
||||
Observable.Merge(_price_dirty, _size_dirty, _account_dirty, _time_in_force_dirty, _order_type_dirty).ObserveOnDispatcher().Subscribe(_ => RaisePropertyChanged(nameof(dirty_items_text))),
|
||||
_price_dirty.observe_current(true).CombineLatest(_size_dirty.observe_current(true), (pd, sd) => pd || sd).DistinctUntilChanged().ObserveOnDispatcher().Subscribe(modify_order));
|
||||
Observable.Merge(_price_dirty, _size_dirty, _account_dirty, _time_in_force_dirty, _order_type_dirty).OnDispatcher().Subscribe(_ => RaisePropertyChanged(nameof(dirty_items_text))),
|
||||
_price_dirty.observe_current(true).CombineLatest(_size_dirty.observe_current(true), (pd, sd) => pd || sd).DistinctUntilChanged().OnDispatcher().Subscribe(modify_order));
|
||||
this.modify_order = modify_order;
|
||||
set_price_command = new DelegateCommand<double>(_price.set);
|
||||
}
|
||||
|
||||
@@ -46,15 +46,15 @@ namespace mbts.spark {
|
||||
return _subject.Subscribe(observer);
|
||||
});
|
||||
_dispose = Disposable.Create(
|
||||
securities.ObserveOnDispatcher().Subscribe(s => {
|
||||
securities.OnDispatcher().Subscribe(s => {
|
||||
state.update_securities(s);
|
||||
_subject.OnNext(state.last_update);
|
||||
}),
|
||||
orders.ObserveOnDispatcher().Subscribe(o => {
|
||||
orders.OnDispatcher().Subscribe(o => {
|
||||
state.update_orders(o);
|
||||
_subject.OnNext(state.last_update);
|
||||
}),
|
||||
fills.ObserveOnDispatcher().Subscribe(f => {
|
||||
fills.OnDispatcher().Subscribe(f => {
|
||||
state.update_fills(f);
|
||||
_subject.OnNext(state.last_update);
|
||||
}));
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace mbts.spark {
|
||||
set_price_command = new DelegateCommand<double>(set_price);
|
||||
_dispose = Disposable.Create(
|
||||
size_calculator = new CalculatorLogic(0, calculator_buttons),
|
||||
props_source.ObserveOnDispatcher().Subscribe(p => on_props(p.price, p.size))
|
||||
props_source.OnDispatcher().Subscribe(p => on_props(p.price, p.size))
|
||||
);
|
||||
|
||||
void on_props(InlineUserProperty<double> price_prop, InlineUserProperty<uint> size_prop) {
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace mbts.spark {
|
||||
|
||||
public OrderPropertiesEditorVM(OrdersModel model, IObservable<SecurityImmutable> security_source, IObservable<InlineOrderProperties> order_properties) {
|
||||
_model = model;
|
||||
_security = backing(nameof(security), security_source.ObserveOnDispatcher(), SecurityDataHelper.Defaults.SecurityImmutable);
|
||||
_security = backing(nameof(security), security_source.OnDispatcher(), SecurityDataHelper.Defaults.SecurityImmutable);
|
||||
// guarentee that "this.security" will always be set before observers are notified
|
||||
// this is important bc some observers will reference "this.security" in their callbacks
|
||||
// - namely the [SelectorProperty]order_type's "get_default" function,
|
||||
|
||||
@@ -44,9 +44,9 @@ namespace mbts.spark {
|
||||
: base(model) {
|
||||
_security_source = security_source;
|
||||
_dispose = Disposable.Create(
|
||||
security_source.ObserveOnDispatcher()
|
||||
security_source.OnDispatcher()
|
||||
.Subscribe(s => _security = s),
|
||||
inline_properties.ObserveOnDispatcher()
|
||||
inline_properties.OnDispatcher()
|
||||
.Subscribe(p => {
|
||||
if (_order_types.Count == 0 || p.child_order_types.force_override) {
|
||||
_order_types.SetItems(p.child_order_types.value);
|
||||
|
||||
@@ -88,9 +88,9 @@ namespace mbts.spark
|
||||
{
|
||||
_security_source = security_source;
|
||||
_dispose = Disposable.Create(
|
||||
security_source.ObserveOnDispatcher()
|
||||
security_source.OnDispatcher()
|
||||
.Subscribe(s => _security = s),
|
||||
inline_properties.ObserveOnDispatcher()
|
||||
inline_properties.OnDispatcher()
|
||||
.Subscribe(p => {
|
||||
if (_order_types.Count == 0 || p.child_order_types.force_override)
|
||||
{
|
||||
|
||||
@@ -55,9 +55,9 @@ namespace mbts.spark
|
||||
{
|
||||
_security_source = security_source;
|
||||
_dispose = Disposable.Create(
|
||||
security_source.ObserveOnDispatcher()
|
||||
security_source.OnDispatcher()
|
||||
.Subscribe(s => _security = s),
|
||||
inline_properties.ObserveOnDispatcher()
|
||||
inline_properties.OnDispatcher()
|
||||
.Subscribe(p => {
|
||||
if (_order_types.Count == 0 || p.child_order_types.force_override)
|
||||
{
|
||||
|
||||
@@ -31,10 +31,10 @@ namespace mbts.spark {
|
||||
_strategy_editor_wrapper = new StrategyEditorWrapper(this);
|
||||
_dispose = Disposable.Create(
|
||||
_strategy_editor_wrapper,
|
||||
_template.ObserveOnDispatcher().Subscribe(vals => {
|
||||
_template.OnDispatcher().Subscribe(vals => {
|
||||
_validate();
|
||||
}),
|
||||
order_template_source.ObserveOnDispatcher().Subscribe(prop => {
|
||||
order_template_source.OnDispatcher().Subscribe(prop => {
|
||||
if (prop.force_override || (!template.HasValue && prop.has_value)) {
|
||||
_template.Value = prop.value;
|
||||
_validate();
|
||||
|
||||
@@ -64,9 +64,9 @@ namespace mbts.spark
|
||||
{
|
||||
_security_source = security_source;
|
||||
_dispose = Disposable.Create(
|
||||
security_source.ObserveOnDispatcher()
|
||||
security_source.OnDispatcher()
|
||||
.Subscribe(s => _security = s),
|
||||
inline_properties.ObserveOnDispatcher()
|
||||
inline_properties.OnDispatcher()
|
||||
.Subscribe(p => {
|
||||
if (_order_types.Count == 0 || p.child_order_types.force_override)
|
||||
{
|
||||
|
||||
@@ -50,9 +50,9 @@ namespace mbts.spark {
|
||||
: base(model) {
|
||||
_security_source = security_source;
|
||||
_dispose = Disposable.Create(
|
||||
security_source.ObserveOnDispatcher()
|
||||
security_source.OnDispatcher()
|
||||
.Subscribe(s => _security = s),
|
||||
inline_properties.ObserveOnDispatcher()
|
||||
inline_properties.OnDispatcher()
|
||||
.Subscribe(p => {
|
||||
if (_order_types.Count == 0 || p.child_order_types.force_override) {
|
||||
_order_types.SetItems(p.child_order_types.value);
|
||||
|
||||
@@ -87,9 +87,9 @@ namespace mbts.spark
|
||||
{
|
||||
_security_source = security_source;
|
||||
_dispose = Disposable.Create(
|
||||
security_source.ObserveOnDispatcher()
|
||||
security_source.OnDispatcher()
|
||||
.Subscribe(s => _security = s),
|
||||
inline_properties.ObserveOnDispatcher()
|
||||
inline_properties.OnDispatcher()
|
||||
.Subscribe(p =>
|
||||
{
|
||||
if (_order_types.Count == 0 || p.child_order_types.force_override)
|
||||
|
||||
@@ -175,8 +175,8 @@ namespace bts.spark
|
||||
public SparkCommandParamObserver(string title, ImageSource icon, ITag<T> tag, IObservable<T> parameter, IObservable<bool> can_execute) : base(title, icon) {
|
||||
_tag = tag;
|
||||
_subs = Disposable.Create(
|
||||
parameter.ObserveOnDispatcher().Subscribe(p => _parameter = p),
|
||||
can_execute.ObserveOnDispatcher().Subscribe(ce => {
|
||||
parameter.OnDispatcher().Subscribe(p => _parameter = p),
|
||||
can_execute.OnDispatcher().Subscribe(ce => {
|
||||
_can_execute = ce;
|
||||
raiseCanExecuteChanged();
|
||||
})
|
||||
|
||||
@@ -345,6 +345,17 @@ namespace System.Reactive.Linq
|
||||
|
||||
public static async Task<(TResult result, bool success)> FirstAsyncTask<T, TResult>(this IObservable<T> source, Func<T, bool> predicate, Func<T, TResult> selector, TimeSpan timeout) where T : class =>
|
||||
await source.Where(predicate).Select(val => (selector(val), true)).Merge(Observable.Return((default(TResult), false)).Delay(timeout)).FirstAsync();
|
||||
|
||||
// This is placed here to intentionally make ObserveOnDispatcher ambiguous with the one provided by Rx
|
||||
public static IObservable<T> ObserveOnDispatcher<T>(this IObservable<T> source) {
|
||||
throw new InvalidOperationException("This method can starve the UI of input messages. Please use OnDispatcher() instead");
|
||||
}
|
||||
|
||||
public static IObservable<T> OnDispatcher<T>(this IObservable<T> source) {
|
||||
return DispatcherObservable.ObserveOnDispatcher(source, DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -471,7 +471,7 @@ namespace mbts.ui.shell
|
||||
protected Property<T> backing<T, TData>(string name, IObservable<TData> source, Func<TData, T> select, T default_value = default) {
|
||||
if (_observable_properties == null) _observable_properties = new List<IDisposable>();
|
||||
var prop = new ObservablePropertySink<T>(this, name, default_value);
|
||||
_observable_properties.Add(source.ObserveOnDispatcher().Subscribe(d => prop.set(select(d))));
|
||||
_observable_properties.Add(source.OnDispatcher().Subscribe(d => prop.set(select(d))));
|
||||
return prop;
|
||||
}
|
||||
|
||||
@@ -526,8 +526,8 @@ namespace mbts.ui.shell
|
||||
protected SelectorProperty<T> backing<T>(string name, IObservable<IEnumerable<T>> items, IObservable<InlineUserProperty<T>> desired_item, Func<T> select_default, Func<T, T, bool> items_match, IReadOnlyList<PropertyValidation<T>> validation_steps) {
|
||||
if (_observable_properties == null) _observable_properties = new List<IDisposable>();
|
||||
var prop = new SelectorProperty<T>(this, name, select_default, items_match, validation_steps);
|
||||
_observable_properties.Add(items.ObserveOnDispatcher().Subscribe(prop));
|
||||
_observable_properties.Add(desired_item.ObserveOnDispatcher().Subscribe(prop));
|
||||
_observable_properties.Add(items.OnDispatcher().Subscribe(prop));
|
||||
_observable_properties.Add(desired_item.OnDispatcher().Subscribe(prop));
|
||||
return prop;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace mbts.ui.controls {
|
||||
Disposable.dispose(ref timer._trigger_sub);
|
||||
IObservable<object> newval = args.NewValue as IObservable<object>;
|
||||
if (newval != null) {
|
||||
timer._trigger_sub = newval.ObserveOnDispatcher().Subscribe(timer.start);
|
||||
timer._trigger_sub = newval.OnDispatcher().Subscribe(timer.start);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace mbts.spark.filters {
|
||||
IComparer<TValue> comparer = null
|
||||
) : this(get_row_val, get_state, load_state, prop_name, equality_comparer, comparer) {
|
||||
//
|
||||
_items_sub = items.ObserveOnDispatcher().Subscribe(new_items => {
|
||||
_items_sub = items.OnDispatcher().Subscribe(new_items => {
|
||||
_items_set.SetItems(new_items.Concat(_selected_items_set));
|
||||
_unsorted_items.sync_with(_items_set);
|
||||
});
|
||||
@@ -131,7 +131,7 @@ namespace mbts.spark.filters {
|
||||
IComparer<TValue> comparer = null
|
||||
) : this(get_row_val, get_state, load_state, prop_name, equality_comparer, comparer) {
|
||||
//
|
||||
_items_sub = items.ObserveOnDispatcher().Subscribe(update => {
|
||||
_items_sub = items.OnDispatcher().Subscribe(update => {
|
||||
foreach (var v in update.added)
|
||||
_items_set.Add(v);
|
||||
foreach (var v in update.removed.Except(_selected_items_set))
|
||||
@@ -182,7 +182,7 @@ namespace mbts.spark.filters {
|
||||
|
||||
protected override void _load_state_internal(TState state) {
|
||||
Disposable.dispose(ref _desired_items_sub);
|
||||
_desired_items_sub = _load_state(state).ObserveOnDispatcher().Subscribe(_on_desired_item);
|
||||
_desired_items_sub = _load_state(state).OnDispatcher().Subscribe(_on_desired_item);
|
||||
}
|
||||
|
||||
protected override void _apply() {
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace mbts.ui
|
||||
|
||||
private void _subscribe() {
|
||||
Disposable.dispose(ref _sub);
|
||||
_sub = _source.ObserveOnDispatcher().Subscribe(_on_data);
|
||||
_sub = _source.OnDispatcher().Subscribe(_on_data);
|
||||
}
|
||||
private void _on_data(T data) { Target.SetValue(_target_property, _last_value = data); }
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace mbts.ui.shell {
|
||||
_window_settings = settings;
|
||||
_window_factory = factory;
|
||||
_undo = undo;
|
||||
_dispose = bus.subscribe(SparkTags.ShowWindow).ObserveOnDispatcher().Subscribe(w => add(w).ignore());
|
||||
_dispose = bus.subscribe(SparkTags.ShowWindow).OnDispatcher().Subscribe(w => add(w).ignore());
|
||||
}
|
||||
|
||||
#region Window creation
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace mbts.spark
|
||||
{
|
||||
internal class ContractPickerModel : ViewModelBase {
|
||||
|
||||
private const string dot = "•";
|
||||
private const string dot = "•";
|
||||
|
||||
public ContractPickerModel(IBus bus, bool edit_mode, SecurityCriteria existing_criteria, SecurityCriteria world_view_filter = null) {
|
||||
_bus = bus;
|
||||
@@ -38,7 +38,7 @@ namespace mbts.spark
|
||||
_world_view_filter = world_view_filter;
|
||||
securities_view = CollectionViewSource.GetDefaultView(securities);
|
||||
(securities_view as ListCollectionView).CustomSort = new SecuritySorter();
|
||||
_subs.Add(_bus.subscribe(SecuritiesTag).ObserveOnDispatcher().Subscribe(on_securities_changed));
|
||||
_subs.Add(_bus.subscribe(SecuritiesTag).OnDispatcher().Subscribe(on_securities_changed));
|
||||
|
||||
add_criteria_command = new DelegateCommand(
|
||||
execute: _ => {
|
||||
|
||||
@@ -340,7 +340,7 @@ namespace mbts.spark {
|
||||
_price_comparer = Comparer<double>.Create((x, y) => security.ContractSpec.tick_equals(x, y) ? 0 : y.CompareTo(x));
|
||||
_price_dirty = true;
|
||||
_vm.on_tick += _tick;
|
||||
_settings_sub = _vm.settings.ObserveOnDispatcher().Subscribe(_settings_updated);
|
||||
_settings_sub = _vm.settings.OnDispatcher().Subscribe(_settings_updated);
|
||||
_tick_sub = Disposable.Create(() => _vm.on_tick -= _tick);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,9 +89,9 @@ namespace mbts.spark {
|
||||
}
|
||||
var darker = BTSColor.darken2(color.R, color.G, color.B, 0.75);
|
||||
Color dark = new Color() { A = 255, R = darker.r, G = darker.g, B = darker.b };
|
||||
var completion = _parent_and_child_not_sharing_slot().Sum(order => OrderUtils.filled(order)) / _parent_and_child_not_sharing_slot().Sum(order => OrderUtils.quantity(order));
|
||||
background = mkbrush(color, _colorbg, completion);
|
||||
hoverbackground = mkbrush(dark, _darkbg, completion);
|
||||
//var completion = _parent_and_child_not_sharing_slot().Sum(order => OrderUtils.filled(order)) / _parent_and_child_not_sharing_slot().Sum(order => OrderUtils.quantity(order));
|
||||
background = _color_bg_brush; //mkbrush(color, _colorbg, 0);
|
||||
hoverbackground = mkbrush(dark, _darkbg, 0);
|
||||
border = new SolidColorBrush(color);
|
||||
filled = _parent_and_child_not_sharing_slot().Select(order => OrderUtils.filled(order)).Sum();
|
||||
working_quantity = _parent_and_child_not_sharing_slot().Select(order => order.working_quantity()).Sum();
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace mbts.spark {
|
||||
_ask_background = brush_prop(nameof(ask_background), s => s.ask_column.background.rgb_brush());
|
||||
_ask_foreground = brush_prop(nameof(ask_foreground), s => s.ask_column.foreground.rgb_brush());
|
||||
Property<Brush> brush_prop(string name, Func<LadderSettings, Brush> get_brush) =>
|
||||
backing(name, settings_manager.subscribe_current().ObserveOnDispatcher(), get_brush);
|
||||
backing(name, settings_manager.subscribe_current().OnDispatcher(), get_brush);
|
||||
//
|
||||
send_order_command = new DelegateCommand<(double price, Side? side, bool size_from_alternate)>(send_order);
|
||||
cancel_command = new AsyncCommand<LadderModel.CancelType>(_model.cancel_orders, true);
|
||||
@@ -69,8 +69,8 @@ namespace mbts.spark {
|
||||
settings_command,
|
||||
order_properties_vm = new OrderPropertiesEditorVM(model.order_gateway, Observable.Return(security), _settings_manager.subscribe_current().Select(s => new InlineOrderProperties(model.order_gateway, s))),
|
||||
size_calculator = new CalculatorLogic(0, _settings_manager.subscribe_current().Select(s => s.calculator_buttons)),
|
||||
bus.subscribe(SparkTags.LogActivity).ObserveOnDispatcher().Subscribe(status_update),
|
||||
model.order_gateway.working_orders.ObserveOnDispatcher().Subscribe(working => {
|
||||
bus.subscribe(SparkTags.LogActivity).OnDispatcher().Subscribe(status_update),
|
||||
model.order_gateway.working_orders.OnDispatcher().Subscribe(working => {
|
||||
// Here we manage N orders to 1 price slot in the ladder
|
||||
|
||||
Dictionary<double, HashSet<uint>> orders_used_in_this_update = new Dictionary<double, HashSet<uint>>();
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace mbts.spark {
|
||||
_model = model;
|
||||
var pnl = model.on_pnl_data
|
||||
.Sample(_POSITION_UPDATE_PERIOD)
|
||||
.ObserveOnDispatcher()
|
||||
.OnDispatcher()
|
||||
.Subscribe(p => {
|
||||
if (p != null) {
|
||||
PnLCalculator calc = new PnLCalculator(p);
|
||||
|
||||
@@ -68,8 +68,8 @@ namespace mbts.spark {
|
||||
IReadOnlyDictionary<uint, SecurityMD> security_dict = new Dictionary<uint, SecurityMD>();
|
||||
|
||||
_dispose = Disposable.Create(
|
||||
bus.subscribe(SparkTags.SecuritiesTag).ObserveOnDispatcher().Subscribe(on_securities),
|
||||
model.on_orders.ObserveOnDispatcher().Subscribe(on_orders),
|
||||
bus.subscribe(SparkTags.SecuritiesTag).OnDispatcher().Subscribe(on_securities),
|
||||
model.on_orders.OnDispatcher().Subscribe(on_orders),
|
||||
columns);
|
||||
|
||||
void on_orders(TableUpdate<OrderRecordImmutable, uint> table) {
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace mbts.spark {
|
||||
}
|
||||
return orders_and_securities;
|
||||
})
|
||||
.ObserveOnDispatcher()
|
||||
.OnDispatcher()
|
||||
.Subscribe(order_security_pairs => {
|
||||
using (_visible_orders.defer_refresh())
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace mbts.spark {
|
||||
readonly Property<ushort> _bid_size, _ask_size;
|
||||
|
||||
public BBOVM(IObservable<SecurityMD> security_md)
|
||||
: this(security_md.Select(smd => smd.security).ObserveOnDispatcher(), new SecurityMDPump(security_md.Select(smd => smd.md))) { }
|
||||
: this(security_md.Select(smd => smd.security).OnDispatcher(), new SecurityMDPump(security_md.Select(smd => smd.md))) { }
|
||||
|
||||
public BBOVM(IObservable<SecurityImmutable> security, ISecurityMDPump md_pump) {
|
||||
_security = backing(nameof(security), security, SecurityDataHelper.Defaults.SecurityImmutable);
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace mbts.spark.utilities
|
||||
private class ColumnContainer : IDisposable {
|
||||
public ColumnContainer(TColumn column, IObservable<bool> is_selected, GridRowViewModelBase<TColumn> owner) {
|
||||
this.column = column;
|
||||
_dispose = is_selected.ObserveOnDispatcher().Subscribe(selected => {
|
||||
_dispose = is_selected.OnDispatcher().Subscribe(selected => {
|
||||
if (selected) owner._selected_columns.Add(column);
|
||||
else owner._selected_columns.Remove(column);
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace mbts.spark.utilities {
|
||||
_account_map = new Dictionary<string, uint>();
|
||||
|
||||
var admin_data_sequence = _admin_model.on_admin_data
|
||||
.ObserveOnDispatcher()
|
||||
.OnDispatcher()
|
||||
.Subscribe(admin_data => {
|
||||
List<string> account_names = new List<string>();
|
||||
List<string> user_names = new List<string>();
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace mbts.ui.utility {
|
||||
IDisposable _sub;
|
||||
|
||||
public AnonymousRXCollection(IObservable<TData> source, Action<IRXCollection<T>, TData> on_data) =>
|
||||
_sub = source.ObserveOnDispatcher().Subscribe(d => on_data(this, d));
|
||||
_sub = source.OnDispatcher().Subscribe(d => on_data(this, d));
|
||||
|
||||
public void Dispose() => Disposable.dispose(ref _sub);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace mbts.ui.utility {
|
||||
|
||||
internal TableUpdateCollection(IObservable<TableUpdate<T, TKey>> source, Func<T, bool> collection_filter) {
|
||||
_collection_filter = collection_filter;
|
||||
_sub = source.ObserveOnDispatcher().Subscribe(u => {
|
||||
_sub = source.OnDispatcher().Subscribe(u => {
|
||||
_raw_state = u.state;
|
||||
foreach (T val in u.removed.Where(_collection_filter)) Remove(val);
|
||||
foreach (T val in u.added.Where(_collection_filter)) Add(val);
|
||||
@@ -96,7 +96,7 @@ namespace mbts.ui.utility {
|
||||
|
||||
internal TableUpdateTransformCollection(IObservable<ITableUpdateTransform<T, TKey>> source, Func<T, bool> collection_filter) {
|
||||
_collection_filter = collection_filter;
|
||||
_sub = source.ObserveOnDispatcher().Subscribe(u => {
|
||||
_sub = source.OnDispatcher().Subscribe(u => {
|
||||
_raw_state = u.state;
|
||||
foreach (T val in u.removed.Where(_collection_filter)) Remove(val);
|
||||
foreach (T val in u.added.Where(_collection_filter)) Add(val);
|
||||
@@ -111,7 +111,7 @@ namespace mbts.ui.utility {
|
||||
IDisposable _sub;
|
||||
|
||||
internal IncrementalUpdateCollection(IObservable<IIncrementalUpdate<T, TKey>> source) {
|
||||
_sub = source.ObserveOnDispatcher().Subscribe(u => {
|
||||
_sub = source.OnDispatcher().Subscribe(u => {
|
||||
foreach (T val in u.removed.Values)
|
||||
Remove(val);
|
||||
foreach (T val in u.added.Values)
|
||||
|
||||
@@ -191,12 +191,7 @@ void ConfigurationState::initialize_builtins()
|
||||
}
|
||||
|
||||
// Version string
|
||||
std::string install_path = os::get_install_path();
|
||||
std::string app_version_file = install_path + "/edge.version";
|
||||
if (!boost::filesystem::exists(app_version_file))
|
||||
{
|
||||
app_version_file = install_path + "/blue2.version";
|
||||
}
|
||||
std::string app_version_file = os::get_install_path() + "/spark.version";
|
||||
if (boost::filesystem::exists(app_version_file))
|
||||
{
|
||||
std::ifstream input(app_version_file.c_str(), std::ifstream::in);
|
||||
|
||||
Reference in new issue
Block a user