Algo Popups open by default
This commit is contained in:
1 parent
500a8094d5
commit
99621eecb6
5 files changed
+37
-10
No files matched your search
@@ -25,6 +25,8 @@ namespace bts.shell {
|
||||
readonly OrdersModel _orders_model;
|
||||
readonly MarketDataAuxiliaryModel _md_auxiliary_model;
|
||||
readonly int _max_ladders_open;
|
||||
readonly int _thread_count = Configuration.get<bts.config.toggles.LaddersOnThreads>().enabled ? Environment.ProcessorCount : 1;
|
||||
|
||||
IReadOnlyDictionary<uint, SecurityMD> _securities = new Dictionary<uint, SecurityMD>();
|
||||
|
||||
public LadderWindowFactory(IShellModule owner, IBus bus, IWindowManager wm, UserSettingsHub settings_hub, OrdersModel orders_model, MarketDataAuxiliaryModel md_auxiliary_model)
|
||||
@@ -36,6 +38,14 @@ namespace bts.shell {
|
||||
_md_auxiliary_model = md_auxiliary_model;
|
||||
var knobs = Configuration.get<bts.config.LadderKnobs>();
|
||||
_max_ladders_open = (int)(knobs.max_open_ladders);
|
||||
#if DEBUG
|
||||
string thread_count_arg = Environment.GetCommandLineArgs()
|
||||
.Select(a => a.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
.Where(a => a.Length == 2 && a[0].iequals("ladderthreads"))
|
||||
.FirstOrDefault()?[1];
|
||||
if (thread_count_arg != null)
|
||||
_thread_count = int.TryParse(thread_count_arg, out int i) ? Math.Max(i, 1) : Environment.ProcessorCount;
|
||||
#endif
|
||||
_security_timeout = TimeSpan.FromSeconds(Math.Max(15, knobs.security_timeout_secs));
|
||||
_dispose = Disposable.Create(
|
||||
bus.subscribe(SparkTags.SecuritiesTag).Subscribe(s => _securities = s),
|
||||
@@ -57,7 +67,6 @@ namespace bts.shell {
|
||||
|
||||
int _ladder_count = 0;
|
||||
IShellWindow create_ladder_window(SecurityMD md, LadderSettings state_settings) {
|
||||
var id = Interlocked.Increment(ref _ladder_count) % Environment.ProcessorCount;
|
||||
var view = new Lazy<UIElement>(() => {
|
||||
var model = new LadderModel(md, _orders_model, _md_auxiliary_model);
|
||||
var settings_manager = new WindowSettingsManager<LadderSettings>(
|
||||
@@ -67,7 +76,7 @@ namespace bts.shell {
|
||||
var vm = new LadderVM(_bus, model, settings_manager);
|
||||
return new LadderView(vm);
|
||||
});
|
||||
string thread = Configuration.get<bts.config.toggles.LaddersOnThreads>().enabled ? $"Ladder{id:00}" : "";
|
||||
string thread = _thread_count > 1 ? $"Ladder{Interlocked.Increment(ref _ladder_count) % _thread_count:00}" : "";
|
||||
return ShellWindow.create(
|
||||
module, md.security.ToString(), _window_type, view,
|
||||
(v,s) => save(_get_state(((LadderView)v).vm), s),
|
||||
|
||||
@@ -117,8 +117,14 @@ namespace mbts.spark {
|
||||
public SecurityImmutable? security => security_md?.security ?? (SecurityImmutable?)null;
|
||||
public ContractSpecificationImmutable spec => security.spec_or_default();
|
||||
|
||||
public ICollection<IOrderTypeVM> child_order_types => _child_order_choices ?? (_child_order_choices =
|
||||
ObservableAutoWrapper.Create(_order_types, ot => create(ot.key.type, ot.key.name, ot.display_name, model, _security_md_source)));
|
||||
public ICollection<IOrderTypeVM> child_order_types => _child_order_choices ?? (_child_order_choices =
|
||||
ObservableAutoWrapper.Create(_order_types, ot => {
|
||||
var ovm = create(ot.key.type, ot.key.name, ot.display_name, model, _security_md_source);
|
||||
ovm.init();
|
||||
if (ovm.has_editable_properties)
|
||||
ovm.editable_properties_open = true;
|
||||
return ovm;
|
||||
}));
|
||||
|
||||
public IOrderTypeVM child_order {
|
||||
get {
|
||||
|
||||
@@ -5,6 +5,7 @@ using mbts.ui.controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark {
|
||||
static partial class OrderTypeVMFactory {
|
||||
@@ -93,17 +94,27 @@ namespace mbts.spark {
|
||||
_owner._template.Changed -= _order_template_changed;
|
||||
}
|
||||
|
||||
static SyntheticEditorVM _mk_vm(OrdersModel model, SpreaderOrderDefinitionImmutable def) =>
|
||||
new SyntheticEditorVM(model.spreader, def.Security, def.ExecutionStrategy, model.security_has_working_orders(def.Security.Id));
|
||||
|
||||
static DialogSkirtItem _mk_save_item(ICommand commit) =>
|
||||
new DialogSkirtItem("Save Strategy", commit);
|
||||
|
||||
void _init() {
|
||||
if (_vm == null && _owner.template.HasValue) {
|
||||
var def = _owner.template.Value;
|
||||
_vm = new SyntheticEditorVM(_owner.model.spreader, def.Security, def.ExecutionStrategy, _owner.model.security_has_working_orders(def.Security.Id));
|
||||
_save_strategy_item = new DialogSkirtItem("Save Strategy", _vm.commit);
|
||||
_vm = _mk_vm(_owner.model, _owner.template.Value);
|
||||
_save_strategy_item = _mk_save_item(_vm.commit);
|
||||
}
|
||||
}
|
||||
|
||||
void _order_template_changed(SpreaderOrderDefinitionImmutable? oldval, SpreaderOrderDefinitionImmutable? newval) {
|
||||
if (_vm != null && newval.HasValue)
|
||||
_vm.set_synthetic(newval.Value.Security, newval.Value.ExecutionStrategy);
|
||||
if (newval.HasValue) {
|
||||
if (_vm == null) {
|
||||
_vm = _mk_vm(_owner.model, newval.Value);
|
||||
_save_strategy_item = _mk_save_item(_vm.commit);
|
||||
_owner.RaisePropertyChanged(nameof(strategy_editor), nameof(skirt_items));
|
||||
} else _vm.set_synthetic(newval.Value.Security, newval.Value.ExecutionStrategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace mbts.spark {
|
||||
|
||||
private class StopLimitOrderVM : OrderTypeVMBase<StopLimitOrderDefinition>, IDisposable {
|
||||
UserProperty<double> _stop_price;
|
||||
InlineStopLimitOrderProperties _inline_props;
|
||||
InlineStopLimitOrderProperties _inline_props = new InlineStopLimitOrderProperties(() => new InlineUserProperty<double>(double.NaN));
|
||||
IDisposable _dispose;
|
||||
|
||||
internal StopLimitOrderVM(OrdersModel model, IObservable<SecurityMD> security_md_source, string id, string display_name)
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
<ResourceDictionary Source="/view/Controls/DataGridEx/Filters/Views/DoubleMinMaxFilterControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/DataGridEx/Filters/Views/DiscreteValuesFilterControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/DataGridEx/Filters/Views/TimeFilterControl.xaml"/>
|
||||
<ResourceDictionary Source="/Modules/Spreader/ExecutionStrategyEditor.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<!-- Override xp/win7 style themes with Win8 style flat for certain controls -->
|
||||
|
||||
Reference in new issue
Block a user