add OrderTicket.close_on_send config toggle
This commit is contained in:
1 parent
9bbc73b48c
commit
7baa7ca8a1
3 files changed
+21
-7
No files matched your search
@@ -3,6 +3,7 @@ using bts.api.core;
|
||||
using bts.api.orderman;
|
||||
using bts.spark;
|
||||
using mbts;
|
||||
using mbts.config;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
using mbts.ui.spark;
|
||||
@@ -10,9 +11,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using LadderSettings = mbts.spark.LadderSettings;
|
||||
|
||||
@@ -22,15 +21,20 @@ namespace bts.shell {
|
||||
readonly IBus _bus;
|
||||
readonly OrdersModel _model;
|
||||
readonly ErrorReporter _error_reporter;
|
||||
readonly bool _close_on_send;
|
||||
IReadOnlyDictionary<uint, SecurityMD> _md_map;
|
||||
TableUpdate<(SecurityImmutable? sec, OrderRecordImmutable order), uint> _orders;
|
||||
IDisposable _dispose;
|
||||
|
||||
[ImportingConstructor]
|
||||
public OrderTicketDaemon(IBus bus, OrdersModel model, ErrorReporter error_reporter) {
|
||||
public OrderTicketDaemon(IBus bus, OrdersModel model, ErrorReporter error_reporter)
|
||||
: this(bus, model, error_reporter, Configuration.get<bts.config.OrderTicketOptions>().close_on_send) { }
|
||||
|
||||
public OrderTicketDaemon(IBus bus, OrdersModel model, ErrorReporter error_reporter, bool close_on_send) {
|
||||
_bus = bus;
|
||||
_model = model;
|
||||
_error_reporter = error_reporter;
|
||||
_close_on_send = close_on_send;
|
||||
_dispose = Disposable.Create(
|
||||
model.on_orders.OnDispatcher().Subscribe(o => _orders = o),
|
||||
bus.subscribe(SparkTags.SecuritiesTag).OnDispatcher().Subscribe(m =>_md_map = m),
|
||||
@@ -58,14 +62,18 @@ namespace bts.shell {
|
||||
void _show_order_ticket(SecurityMD smd) =>
|
||||
_show_order_window(new OrderTicket {
|
||||
DataContext = new NewOrderTicketVM(_model, smd,
|
||||
Observable.Return(LadderSettings.Default))
|
||||
Observable.Return(LadderSettings.Default)) {
|
||||
close_on_send = _close_on_send
|
||||
}
|
||||
});
|
||||
|
||||
void _show_order_ticket((OrderDefinitionImmutable def, double price, uint size) ops) {
|
||||
if (_md_map.TryGetValue(ops.def.SecurityKey, out SecurityMD smd))
|
||||
_show_order_window(new OrderTicket {
|
||||
DataContext = new NewOrderTicketVM(_model, smd, ops.def, ops.price, ops.size,
|
||||
Observable.Return(LadderSettings.Default.calculator_buttons))
|
||||
Observable.Return(LadderSettings.Default.calculator_buttons)) {
|
||||
close_on_send = _close_on_send
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -89,4 +97,4 @@ namespace bts.shell {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,8 @@ namespace mbts.spark {
|
||||
bool price_valid = _validate_price(), size_valid = size_calculator.validate();
|
||||
if (price_valid && size_valid && !HasErrors && !properties_vm.HasErrors) {
|
||||
model.send_order(security, properties_vm.create(side), price, size_calculator.value.Value).ignore();
|
||||
RequestClose?.Invoke(this, new EventArgs());
|
||||
if (close_on_send)
|
||||
RequestClose?.Invoke(this, new EventArgs());
|
||||
}
|
||||
});
|
||||
set_price_command = new DelegateCommand<double>(set_price);
|
||||
@@ -84,6 +85,7 @@ namespace mbts.spark {
|
||||
public CalculatorLogic size_calculator { get; }
|
||||
public OrderPropertiesEditorVM properties_vm { get; }
|
||||
public BBOVM bbo { get; }
|
||||
public bool close_on_send { get; set; }
|
||||
public ICommand send_order { get; }
|
||||
public ICommand set_price_command { get; }
|
||||
|
||||
|
||||
@@ -78,6 +78,10 @@ message OrderBookOptions {
|
||||
optional double status_color_opacity_when_selected = 2 [default = 0.35];
|
||||
}
|
||||
|
||||
message OrderTicketOptions {
|
||||
optional bool close_on_send = 1 [default = true];
|
||||
}
|
||||
|
||||
message OrderAlerts {
|
||||
// when the client sees an order for the first time,
|
||||
// this time period is used to determine if the order is actually new,
|
||||
|
||||
Reference in new issue
Block a user