SPARK-1545 Spreader sniper mode

This commit is contained in:
John Colvin committed 2018-08-23 00:37:35 -04:00
1 parent 637a6cb094
commit 162c192963
5 files changed
+48

No files matched your search

@@ -257,6 +257,7 @@
Background="Transparent"
Padding="{Binding section_count, Converter={StaticResource RowHeaderGroupIndentConverter}}"
Content="{Binding display_name}"
FontWeight="{Binding font_weight, FallbackValue={u:FontWeight Normal}}"
SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
Visibility="{Binding
HeadersVisibility,
@@ -0,0 +1,38 @@
using bts.shell;
using bts.spark;
using mbts.collections.extensions;
using mbts.ui.spark;
using System.Collections.Generic;
using System.Windows;
namespace mbts.spark {
partial class SyntheticEditorVM {
class QuoteHiddenModel : RowModelBase<bool>, IHaveFontParams {
IDictionary<uint, bool> _value_store = new Dictionary<uint, bool>();
public override string display_name { get; } = "Hidden";
public override ParameterSection[] section_path { get; } = new[] { Sections.Quote };
public FontWeight font_weight => FontWeights.SemiBold;
public void apply_value(LegSpreaderParamsTuple leg_tup) =>
leg_tup.leg_params.QuoteParams.QuoteHidden = _value_from_store(leg_tup) ? new QuoteHidden() : null;
public override bool get_value(LegSpreaderParamsTuple leg_tup) =>
_get_throttle(leg_tup) != null;
public override void set_value(LegSpreaderParamsTuple leg_tup, bool value) {
_value_store[leg_tup.SecurityKey] = value;
leg_tup.leg_params.QuoteParams.QuoteHidden = value ? new QuoteHidden() : null;
}
protected override bool _get_enabled(LegSpreaderParamsTuple leg_tup) =>
_get_throttle(leg_tup) != null;
QuoteHidden _get_throttle(LegSpreaderParamsTuple leg_tup) =>
leg_tup.leg_params.QuoteParams.QuoteHidden;
bool _value_from_store(LegSpreaderParamsTuple leg_tup) =>
_value_store.GetValueOrDefault(leg_tup.SecurityKey, _ => false);
}
}
}
@@ -4,6 +4,7 @@ using mbts.utils;
using System;
using System.Collections.Generic;
using System.Reactive.Subjects;
using System.Windows;
namespace mbts.spark {
partial class SyntheticEditorVM {
@@ -33,6 +34,10 @@ namespace mbts.spark {
Type data_type { get; }
bool enabled { get; }
}
internal interface IHaveFontParams {
FontWeight font_weight { get; }
}
abstract class RowModelBase<T> : ViewModelBase, IRowModel {
readonly Dictionary<uint, ReplaySubject<bool>> _enabled_store = new Dictionary<uint, ReplaySubject<bool>>();
@@ -7,6 +7,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
namespace mbts.spark {
partial class SyntheticEditorVM {
@@ -26,6 +27,7 @@ namespace mbts.spark {
for (int i = 0; i < section_count; i++)
section_path[i].level = i;
read_only = model.read_only;
font_weight = model is IHaveFontParams fps ? fps.font_weight : FontWeights.Normal;
_has_errors = backing(nameof(has_errors), false);
_cells = ObservantDictionary.Create(legs, l => l.leg.Security, model.create_cell, EqualityComparer.Create<Security, uint>(s => s.Id));
_cells.ValueDestroyed += c => (c as IDisposable)?.Dispose();
@@ -33,6 +35,7 @@ namespace mbts.spark {
}
public string display_name { get; }
public FontWeight font_weight { get; }
public ParameterSection[] section_path { get; }
public int section_count => section_path.Length;
public bool read_only { get; }
@@ -201,6 +201,7 @@ namespace mbts.spark {
_price_mult_model,
new IsQuoteModel(),
new HedgeRatioModel(),
new QuoteHiddenModel(),
new QuoteThrottleEnabledModel(quote_throttle_inside_ticks, quote_throttle_outside_ticks),
quote_throttle_inside_ticks,
quote_throttle_outside_ticks,