Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82a2ba4a86 | ||
|
|
ccbe20eb57 | ||
|
|
70a2feb92a | ||
|
|
6aeba4f599 | ||
|
|
523f02b4c2 | ||
|
|
edb4ed02c9 | ||
|
|
96da8e3276 | ||
|
|
c056bfcf7a | ||
|
|
2ddf1a1762 | ||
|
|
8a9ddfded7 | ||
|
|
a83f97e1ef | ||
|
|
3630bf5b9a | ||
|
|
c7ea6c4ca4 | ||
|
|
1ffda9c413 | ||
|
|
1ca5ed4520 | ||
|
|
8115f9df74 | ||
|
|
306cbaa837 | ||
|
|
efa31059d9 | ||
|
|
73089634f9 | ||
|
|
a84e5e3460 | ||
|
|
4d53bfb3f0 | ||
|
|
717391afb3 | ||
|
|
38e0d40364 | ||
|
|
7053c2ee03 | ||
|
|
cdde730fc5 | ||
|
|
95b0119d22 | ||
|
|
07a965a3e0 | ||
|
|
eba153e289 | ||
|
|
fc5238c56f | ||
|
|
bc367b9f56 | ||
|
|
ba07041c26 | ||
|
|
d3101b1cd8 | ||
|
|
3a9a86020b | ||
|
|
6c93208e11 | ||
|
|
bf1ca4e5fa | ||
|
|
3f9e64016b | ||
|
|
c672967caf | ||
|
|
1e0dac0fbc | ||
|
|
aec8de54bd | ||
|
|
a960093cf6 | ||
|
|
4601e49106 | ||
|
|
7e65db38cf | ||
|
|
d70bd63659 | ||
|
|
246f9240e7 | ||
|
|
a8ebb9cdcb | ||
|
|
bdb2d6cf9e | ||
|
|
1966c8e0c6 | ||
|
|
a418f47d1c | ||
|
|
df516fbd2d | ||
|
|
b8e298c524 | ||
|
|
02d1badf0d |
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
The shortcut icon will appear on your desktop like below:
|
||||
|
||||

|
||||

|
||||
|
||||
Simply double click or single click and hit enter to launch the
|
||||
login screen:
|
||||
|
||||
@@ -198,7 +198,7 @@
|
||||
|
||||

|
||||
|
||||
- Tick
|
||||
- Lean
|
||||
|
||||
- This is a specialized algo order which allows the user to
|
||||
essentially watch the opposite-inside market size and cross when
|
||||
@@ -207,16 +207,9 @@
|
||||
buying into the asks. This is often referred to as “paying up” as
|
||||
well
|
||||
|
||||

|
||||

|
||||
|
||||
- Lean
|
||||
|
||||
- This is a specialized algo order which allows the user to enter an
|
||||
order which will watch the opposite-inside market size and cross
|
||||
when that size goes below the threshold defined in the
|
||||
parameters
|
||||
|
||||

|
||||
|
||||
- Join
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 11 KiB |
@@ -62,7 +62,7 @@ namespace bts.perf {
|
||||
if (response.Status == IPStatus.Success) {
|
||||
_current_missed_ping_count = 0;
|
||||
if (response.RoundtripTime > config.logging_milliseconds_threshold) {
|
||||
Log.Ui.warn($"Ping response not recieved in a timely manner:\n" +
|
||||
Log.Ui.warn($"Ping response not received in a timely manner:\n" +
|
||||
$"\tAddress:\t{response.Address}\n" +
|
||||
$"\tRoundTrip:\t{response.RoundtripTime} ms");
|
||||
}
|
||||
|
||||
@@ -48,14 +48,12 @@
|
||||
</c:DIYGrid>
|
||||
<StatusBar Grid.Row="1" DockPanel.Dock="Bottom">
|
||||
<StatusBarItem HorizontalAlignment="Right">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="Securities: "/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding ElementName=_grid, Path=Rows.Count}"/>
|
||||
</Grid>
|
||||
<TextBlock>
|
||||
<Run Text="Securities:"/>
|
||||
<Run Text="{Binding ElementName=_grid, Path=Rows.Count, Mode=OneWay}" />
|
||||
<Run Text="of"/>
|
||||
<Run Text="{Binding rows_view.SourceCollection.Count, Mode=OneWay}" />
|
||||
</TextBlock>
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace mbts.spark {
|
||||
var update_securities_cmd = SparkCommands.change_securities_callback(_window_type_display_name);
|
||||
_commands = new List<SparkCommand> {
|
||||
SparkCommands.ShowLadders.complete(_vm.selected_security_mds_observable(), smds => smds.Count > 0),
|
||||
SparkCommands.ShowOrderTicketFromSecurity.complete(_vm.current_security_md, md => md.HasValue, ObjectHelper.ValueOrDefault),
|
||||
SparkCommands.ShowOrderTicketFromSecurity.complete(_vm.current_security_md, md => md.HasValue, ConvertUtils.ValueOrDefault),
|
||||
SparkCommands.ShowFills.complete(_vm.selected_securities_observable(), _ => true,
|
||||
secs => new FillsWindowFactory.StartupData(new FillsWindowFactory.FilterStates {
|
||||
security = secs.Count > 0 ? new SecurityCriteria(secs) : _state.security_criteria
|
||||
|
||||
@@ -49,13 +49,7 @@
|
||||
</c:DIYGrid>
|
||||
<StatusBar Grid.Row="1" DockPanel.Dock="Bottom">
|
||||
<StatusBarItem HorizontalAlignment="Right">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text=" "/>
|
||||
</Grid>
|
||||
<TextBlock Text=" "/>
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
|
||||
@@ -62,8 +62,8 @@ namespace mbts.spark {
|
||||
var current_smd_source = connectable_builder.create(vm => vm.current_security_md_observable(_bus)).OnDispatcher();
|
||||
var selected_secs_source = connectable_builder.create(vm => vm.selected_securities_observable()).OnDispatcher();
|
||||
_commands = new SparkCommand[] {
|
||||
SparkCommands.ShowLadder.complete(current_smd_source, md => md.HasValue, ObjectHelper.ValueOrDefault),
|
||||
SparkCommands.ShowOrderTicketFromSecurity.complete(current_smd_source, md => md.HasValue, ObjectHelper.ValueOrDefault),
|
||||
SparkCommands.ShowLadder.complete(current_smd_source, md => md.HasValue, ConvertUtils.ValueOrDefault),
|
||||
SparkCommands.ShowOrderTicketFromSecurity.complete(current_smd_source, md => md.HasValue, ConvertUtils.ValueOrDefault),
|
||||
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),
|
||||
SparkCommands.change_securities_command(() => (update_securities_cmd, _state.security_criteria)),
|
||||
|
||||
@@ -46,14 +46,12 @@
|
||||
</c:DIYGrid>
|
||||
<StatusBar Grid.Row="1" DockPanel.Dock="Bottom">
|
||||
<StatusBarItem HorizontalAlignment="Right">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="Synthetics: "/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding ElementName=_grid, Path=Rows.Count}"/>
|
||||
</Grid>
|
||||
<TextBlock>
|
||||
<Run Text="Synthetics:"/>
|
||||
<Run Text="{Binding ElementName=_grid, Path=Rows.Count, Mode=OneWay}" />
|
||||
<Run Text="of"/>
|
||||
<Run Text="{Binding rows_view.SourceCollection.Count, Mode=OneWay}" />
|
||||
</TextBlock>
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace mbts.spark {
|
||||
current_row_connectable_builder.create(observe_row_strategy),
|
||||
rs => rs.HasValue, select_row_strategy_tuple
|
||||
), SparkCommands.ShowLadder.complete(
|
||||
vm_connectable_builder.create(vm => vm.current_security_md), md => md.HasValue, ObjectHelper.ValueOrDefault
|
||||
vm_connectable_builder.create(vm => vm.current_security_md), md => md.HasValue, ConvertUtils.ValueOrDefault
|
||||
), SparkCommands.ShowOrders.complete(() => new OrderBookWindowFactory.OrderBookStartupData {
|
||||
filters = new OrderBookWindowFactory.FilterStates {
|
||||
security_criteria = new SecurityCriteria(_vm.value.row_vms.Select(r => r.security))
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using bts.utils;
|
||||
using mbts.spark.utilities;
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.spark;
|
||||
@@ -110,7 +109,7 @@ namespace mbts.spark {
|
||||
_validate_leg_count();
|
||||
};
|
||||
|
||||
async Task commit_async(){
|
||||
async Task commit_async() {
|
||||
RequestUpdate?.Invoke();
|
||||
bool valid = true;
|
||||
if (string.IsNullOrWhiteSpace(name)) {
|
||||
@@ -125,8 +124,7 @@ namespace mbts.spark {
|
||||
valid = false;
|
||||
}
|
||||
if (valid) {
|
||||
_synthetic.Synthetic.Legs.Clear();
|
||||
_synthetic.Synthetic.Legs.AddRange(leg_tuples.Select(l => l.leg).OrderBy(l => l.Security, SecurityHelper.Comparer.Instance));
|
||||
_synthetic.Synthetic.Legs.SetItems(leg_tuples.Select(l => l.leg));
|
||||
_synthetic.Symbol = _deduce_symbol(_synthetic);
|
||||
double tick_frac = _tick_factors.tick_unit / _tick_factors.tick_base;
|
||||
_synthetic.ContractSpec.LowTick = tick_frac;
|
||||
@@ -296,7 +294,6 @@ namespace mbts.spark {
|
||||
|
||||
static IEnumerable<LegSpreaderParamsTuple> _get_legs(Security synthetic, ExecutionStrategyImmutable strategy) =>
|
||||
synthetic.Synthetic.Legs
|
||||
.OrderBy(l => l.Security, SecurityHelper.Comparer.Instance)
|
||||
.Select(l => new LegSpreaderParamsTuple(l, strategy.LegParamsMap[l.Security.Id].Clone()));
|
||||
|
||||
void _close_new_leg_popup() {
|
||||
@@ -339,4 +336,4 @@ namespace mbts.spark {
|
||||
else clear_error(nameof(leg_count));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,14 +49,12 @@
|
||||
</c:DIYGrid>
|
||||
<StatusBar Grid.Row="1" DockPanel.Dock="Bottom">
|
||||
<StatusBarItem HorizontalAlignment="Right">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="Fills: "/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding ElementName=_grid, Path=Rows.Count}"/>
|
||||
</Grid>
|
||||
<TextBlock>
|
||||
<Run Text="Fills:"/>
|
||||
<Run Text="{Binding ElementName=_grid, Path=Rows.Count, Mode=OneWay}" />
|
||||
<Run Text="of"/>
|
||||
<Run Text="{Binding rows_view.SourceCollection.Count, Mode=OneWay}" />
|
||||
</TextBlock>
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
|
||||
@@ -423,7 +423,8 @@ namespace mbts.spark {
|
||||
base.InsertItem(index, item);
|
||||
} catch {
|
||||
_unhook(col);
|
||||
} finally { }
|
||||
throw;
|
||||
}
|
||||
} else {
|
||||
Log.Ui.warn($"{nameof(OrderBookColumnCollection)} added a column that is not of type {nameof(ICVOrderBookColumn)}");
|
||||
base.InsertItem(index, item);
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace mbts.spark {
|
||||
if (old_order.order_type() != order.order_type())
|
||||
RaisePropertyChanged(nameof(order_type), nameof(order_metadata));
|
||||
if (!had_security && _security_md.HasValue) {
|
||||
RaisePropertyChanged(nameof(security));
|
||||
RaisePropertyChanged(nameof(security), nameof(security_text));
|
||||
// need to raise invalidated to refresh the price cells (the security.ContractSpec determines how they are formatted - Ticks!)
|
||||
invalidate = true;
|
||||
}
|
||||
|
||||
@@ -155,18 +155,12 @@
|
||||
</c:DIYGrid>
|
||||
<StatusBar Grid.Row="1" DockPanel.Dock="Bottom">
|
||||
<StatusBarItem HorizontalAlignment="Right">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="Orders: "/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding ElementName=_grid, Path=Rows.Count}"/>
|
||||
<TextBlock Grid.Column="2" Text=" of "/>
|
||||
<TextBlock Grid.Column="3" Text="{Binding rows_view.SourceCollection.Count}"/>
|
||||
</Grid>
|
||||
<TextBlock>
|
||||
<Run Text="Orders:"/>
|
||||
<Run Text="{Binding rows.Count, Mode=OneWay}" />
|
||||
<Run Text="of"/>
|
||||
<Run Text="{Binding rows.total_row_count, Mode=OneWay}" />
|
||||
</TextBlock>
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace mbts.spark {
|
||||
// data cache
|
||||
readonly Dictionary<uint, OrderRecordTuple> _state = new Dictionary<uint, OrderRecordTuple>();
|
||||
readonly SetMap<uint, uint> _security_orders = new SetMap<uint, uint>();
|
||||
readonly IDictionary<uint, SecurityMD> _security_md_cache = new Dictionary<uint, SecurityMD>(0);
|
||||
IReadOnlyDictionary<uint, OrderRecordImmutable> _orders_cache = new Dictionary<uint, OrderRecordImmutable>(0);
|
||||
IReadOnlyDictionary<uint, SecurityMD> _security_md_cache = new Dictionary<uint, SecurityMD>(0);
|
||||
IDisposable _dispose;
|
||||
|
||||
public OrderRecordTupleSource(IObservable<IReadOnlyDictionary<uint, SecurityMD>> securities, IObservable<TableUpdate<OrderRecordImmutable, uint>> orders) =>
|
||||
@@ -92,11 +92,14 @@ namespace mbts.spark {
|
||||
Dictionary<uint, OrderRecordTuple> added = new Dictionary<uint, OrderRecordTuple>(), removed = new Dictionary<uint, OrderRecordTuple>();
|
||||
Dictionary<uint, SecurityMD> added_securities = new Dictionary<uint, SecurityMD>(), removed_securities = new Dictionary<uint, SecurityMD>();
|
||||
_security_md_cache.Keys.difference(securities.Keys, out IEnumerable<uint> added_keys, out IEnumerable<uint> removed_keys);
|
||||
/// Warning: <see cref="_security_md_cache"/> must NOT be reassigned with <see cref="securities"/>; the latter is always the same object.
|
||||
/// This would mean that the <see cref="GlobalExtensions.difference{T}(IEnumerable{T}, IEnumerable{T}, out IEnumerable{T}, out IEnumerable{T})"/>
|
||||
/// call above would literally be calculating the difference between the keys of the same dictionary!
|
||||
foreach (var k in removed_keys) {
|
||||
if (_security_orders.try_lookup(k, out ISet<uint> order_keys)) {
|
||||
removed_securities.Add(k, _security_md_cache[k]);
|
||||
IEnumerable<OrderRecordImmutable> orders = order_keys.Select(fk => _orders_cache[fk]);
|
||||
SecurityMD old_sec_md = _security_md_cache[k];
|
||||
removed_securities.Add(k, old_sec_md);
|
||||
IEnumerable<OrderRecordImmutable> orders = order_keys.Select(fk => _orders_cache[fk]);
|
||||
foreach (OrderRecordImmutable order in orders) {
|
||||
OrderRecordTuple old_ft = new OrderRecordTuple(order, old_sec_md);
|
||||
removed.Add(old_ft.order.Key, old_ft);
|
||||
@@ -104,12 +107,13 @@ namespace mbts.spark {
|
||||
added.Add(new_ft.order.Key, new_ft);
|
||||
}
|
||||
}
|
||||
_security_md_cache.Remove(k);
|
||||
}
|
||||
foreach (var k in added_keys) {
|
||||
SecurityMD new_sec_md = securities[k];
|
||||
if (_security_orders.try_lookup(k, out ISet<uint> order_keys)) {
|
||||
added_securities.Add(k, securities[k]);
|
||||
added_securities.Add(k, new_sec_md);
|
||||
IEnumerable<OrderRecordImmutable> orders = order_keys.Select(fk => _orders_cache[fk]);
|
||||
SecurityMD new_sec_md = securities[k];
|
||||
foreach (OrderRecordImmutable order in orders) {
|
||||
OrderRecordTuple old_ft = new OrderRecordTuple(order, null);
|
||||
removed.Add(old_ft.order.Key, old_ft);
|
||||
@@ -117,8 +121,8 @@ namespace mbts.spark {
|
||||
added.Add(new_ft.order.Key, new_ft);
|
||||
}
|
||||
}
|
||||
_security_md_cache.Add(k, new_sec_md);
|
||||
}
|
||||
_security_md_cache = securities;
|
||||
_apply_changes(added, removed, added_securities, removed_securities);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace mbts.ui {
|
||||
public bool CanExecute(object parameter) {
|
||||
if (!allow_concurrent_executions && _n_executing > 0)
|
||||
return false;
|
||||
else return _can_execute(ObjectHelper.try_convert<T>(parameter));
|
||||
else return _can_execute(ConvertUtils.try_convert<T>(parameter));
|
||||
}
|
||||
|
||||
public async Task Execute(object parameter) {
|
||||
@@ -51,7 +51,7 @@ namespace mbts.ui {
|
||||
if (!allow_concurrent_executions)
|
||||
RaiseCanExecuteChanged();
|
||||
}
|
||||
await _execute(ObjectHelper.try_convert<T>(parameter));
|
||||
await _execute(ConvertUtils.try_convert<T>(parameter));
|
||||
if (--_n_executing == 0) {
|
||||
_raise_is_executing_changed();
|
||||
if (!allow_concurrent_executions)
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace mbts.ui
|
||||
if (_can_execute == null)
|
||||
return true;
|
||||
else
|
||||
return _can_execute(ObjectHelper.try_convert<T>(parameter));
|
||||
return _can_execute(ConvertUtils.try_convert<T>(parameter));
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public void Execute(object parameter) =>
|
||||
_execute(ObjectHelper.try_convert<T>(parameter));
|
||||
_execute(ConvertUtils.try_convert<T>(parameter));
|
||||
}
|
||||
|
||||
public class DelegateCommand : DelegateCommand<object> {
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace mbts.ui {
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public bool CanExecute(object parameter) => _can_execute;
|
||||
public void Execute(object parameter) => _execute(ObjectHelper.try_convert<T>(parameter));
|
||||
public void Execute(object parameter) => _execute(ConvertUtils.try_convert<T>(parameter));
|
||||
|
||||
public void OnCompleted() { }
|
||||
public void OnError(Exception error) { }
|
||||
|
||||
@@ -364,7 +364,7 @@ namespace System.Collections.Generic {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses <see cref="ObjectHelper.try_convert{TResult}(object)"/> to convert the elements of an <see cref="IEnumerable"/> to the specified type.
|
||||
/// Uses <see cref="ConvertUtils.try_convert{TResult}(object)"/> to convert the elements of an <see cref="IEnumerable"/> to the specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResult">The type to convert the elements of source to.</typeparam>
|
||||
/// <param name="source">The <see cref="IEnumerable"/> that contains the elements to be cast to type <typeparamref name="TResult"/></param>
|
||||
@@ -373,7 +373,7 @@ namespace System.Collections.Generic {
|
||||
public static IEnumerable<TResult> convert<TResult>(this IEnumerable source) {
|
||||
ExceptionAssert.Argument.NotNull(source, nameof(source));
|
||||
foreach (object obj in source)
|
||||
yield return ObjectHelper.try_convert<TResult>(obj);
|
||||
yield return ConvertUtils.try_convert<TResult>(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,12 +131,6 @@ namespace mbts
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int safe_compare<T>(this T a, T b, Func<T, T, int> compare) =>
|
||||
a == null ? (b == null ? 0 : -1) : (b == null ? 1 : compare(a, b));
|
||||
|
||||
public static int safe_compare<T>(this T a, T b) where T : IComparable<T> =>
|
||||
a == null ? (b == null ? 0 : -1) : (b == null ? 1 : a.CompareTo(b));
|
||||
|
||||
public static bool safe_equals<T>(this T a, T b, Func<T, T, bool> equals) =>
|
||||
a == null ? b == null : b != null && equals(a, b);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using bts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace mbts.utils {
|
||||
|
||||
@@ -32,8 +32,11 @@ namespace mbts.utils {
|
||||
// need to lock bc simultaneous callbacks on diff threads could generate 2 subscriptions at once,
|
||||
// only 1 of which would get disposed in the next callback.
|
||||
Disposable.dispose(ref _current_key_sub);
|
||||
if (!_is_disposed)
|
||||
_current_key_sub = _selector(key)?.Subscribe(_value_subject);
|
||||
if (!_is_disposed) {
|
||||
// IMPORTANT: do NOT subscribe _value_subject directly to the inner sequences. Subscribe with a callback delegate instead (e.g. _value_subject.OnNext).
|
||||
// Reason: If a sequence 'completes' while _value_subject's subscription is active, it will enter a 'Terminated' state, and forever cease notifying observers of subsequent updates.
|
||||
_current_key_sub = _selector(key)?.Subscribe(_value_subject.OnNext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ namespace mbts.ui.controls {
|
||||
|
||||
class BadgeTextLinesConverter : IMultiValueConverter {
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) {
|
||||
if (ObjectHelper.try_convert_args(values, out Side side, out uint quantity, out uint filled, out mbts.spark.LadderSettings.BadgeStyle style))
|
||||
if (ConvertUtils.try_convert_args(values, out Side side, out uint quantity, out uint filled, out mbts.spark.LadderSettings.BadgeStyle style))
|
||||
return BadgeRender.format(side, quantity, filled, style);
|
||||
else return new string[0];
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace mbts.ui.controls.color_picker {
|
||||
public DataTemplate EditableTemplate { get; set; }
|
||||
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) {
|
||||
if (ObjectHelper.try_convert_args(values, out ColorPaletteVM vm, out bool is_selected)) {
|
||||
if (ConvertUtils.try_convert_args(values, out ColorPaletteVM vm, out bool is_selected)) {
|
||||
if (vm.can_user_edit && is_selected)
|
||||
return EditableTemplate;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace mbts.ui.controls.color_picker {
|
||||
|
||||
class NamedColorItemToolTipConverter : IMultiValueConverter {
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) =>
|
||||
ObjectHelper.try_convert_args(values, out string name, out bool can_user_edit) ?
|
||||
ConvertUtils.try_convert_args(values, out string name, out bool can_user_edit) ?
|
||||
$"{name} (Alt + Click for info{(can_user_edit ? ", Ctrl + Click to assign" : string.Empty)})" :
|
||||
string.Empty;
|
||||
|
||||
|
||||
@@ -109,6 +109,6 @@ namespace mbts.spark.filters {
|
||||
protected virtual void _validate() { }
|
||||
|
||||
bool IDataGridColumnFilter.filter(object row) =>
|
||||
filter(ObjectHelper.try_convert<TRow>(row));
|
||||
filter(ConvertUtils.try_convert<TRow>(row));
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,6 @@ namespace mbts.spark.filters {
|
||||
|
||||
|
||||
bool IDataGridColumnFilter.filter(object row) =>
|
||||
filter(ObjectHelper.try_convert<TRow>(row));
|
||||
filter(ConvertUtils.try_convert<TRow>(row));
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
Content="Apply"
|
||||
CommandParameter="{TemplateBinding ApplyCommandParameter}"
|
||||
Command="{TemplateBinding ApplyCommand}"
|
||||
CommandTarget="{TemplateBinding ApplyCommandTarget}"
|
||||
IsDefault="True"
|
||||
Focusable="False"
|
||||
Style="{StaticResource CommonButton}"
|
||||
|
||||
@@ -24,6 +24,11 @@ namespace mbts.ui.spark {
|
||||
public object ApplyCommandParameter { get => GetValue(ApplyCommandParameterProperty); set => SetValue(ApplyCommandParameterProperty, value); }
|
||||
#endregion
|
||||
|
||||
#region ApplyCommandTarget
|
||||
public static readonly DependencyProperty ApplyCommandTargetProperty = WPFHelper.create_dp<IInputElement, FilterContentControl>(nameof(ApplyCommandTarget));
|
||||
public IInputElement ApplyCommandTarget { get => GetValue(ApplyCommandTargetProperty) as IInputElement; set => SetValue(ApplyCommandTargetProperty, value); }
|
||||
#endregion
|
||||
|
||||
#region ClearCommand
|
||||
public static readonly DependencyProperty ClearCommandProperty = DependencyProperty.Register(
|
||||
nameof(ClearCommand), typeof(ICommand), typeof(FilterContentControl));
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
<usp:FilterContentControl
|
||||
ApplyCommandParameter="{Binding}"
|
||||
ApplyCommand="{x:Static c:DataGridFilterProperties.CommitCommand}"
|
||||
ApplyCommandTarget="{Binding ElementName=Filter}"
|
||||
ClearCommandParameter="{Binding}"
|
||||
ClearCommand="{x:Static c:DataGridFilterProperties.ClearCommand}"
|
||||
>
|
||||
@@ -115,6 +116,9 @@
|
||||
Begin="{Binding begin}"
|
||||
End="{Binding end}"
|
||||
>
|
||||
<c:TimeFilterControl.CommandBindings>
|
||||
<CommandBinding Command="{x:Static c:DataGridFilterProperties.CommitCommand}" Executed="{x:Static c:TimeFilterControl.CommitExecuted}"/>
|
||||
</c:TimeFilterControl.CommandBindings>
|
||||
<u:Behavior.BindingUpdateGroups>
|
||||
<u:BindingUpdateGroupCollection>
|
||||
<u:BindingUpdateGroup Source="{Binding DataContext, Source={u:DirectReference Filter}}" Target="{Binding Source={u:DirectReference Filter}}">
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.ui.controls {
|
||||
@@ -14,6 +15,18 @@ namespace mbts.ui.controls {
|
||||
/// Interaction logic for TimeFilterControl.xaml
|
||||
/// </summary>
|
||||
public class TimeFilterControl : Control {
|
||||
public static readonly ExecutedRoutedEventHandler CommitExecuted = (s, e) => {
|
||||
if (s is TimeFilterControl tfc) {
|
||||
tfc.get_template_child<DateTimePicker>(_begin_dtp_name)?.flush_pending_changes();
|
||||
tfc.get_template_child<DateTimePicker>(_end_dtp_name)?.flush_pending_changes();
|
||||
(e.Parameter as IDataGridColumnFilter)?.apply.TryExecuteIfCan(null);
|
||||
e.Handled = true;
|
||||
}
|
||||
};
|
||||
const string
|
||||
_begin_dtp_name = "PART_Begin_DateTimePicker",
|
||||
_end_dtp_name = "PART_End_DateTimePicker";
|
||||
|
||||
static TimeFilterControl() =>
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(TimeFilterControl), new FrameworkPropertyMetadata(typeof(TimeFilterControl)));
|
||||
|
||||
@@ -45,17 +58,17 @@ namespace mbts.ui.controls {
|
||||
var clear_begin_time = this.assert_template_child<Hyperlink>("ClearBeginLink");
|
||||
var clear_end_time = this.assert_template_child<Hyperlink>("ClearEndLink");
|
||||
var set_last_hour = this.assert_template_child<Hyperlink>("SetLastHourLink");
|
||||
clear_begin_time.Command = new DelegateCommand(() => Begin = default);
|
||||
clear_end_time.Command = new DelegateCommand(() => End = default);
|
||||
set_last_hour.Command = new DelegateCommand(() => Begin = TimeTextTuple.FromDateTime(DateTime.Now.AddHours(-1)));
|
||||
clear_begin_time.Command = new DelegateCommand(() => SetCurrentValue(BeginProperty, default(TimeTextTuple)));
|
||||
clear_end_time.Command = new DelegateCommand(() => SetCurrentValue(EndProperty, default(TimeTextTuple)));
|
||||
set_last_hour.Command = new DelegateCommand(() => SetCurrentValue(BeginProperty, TimeTextTuple.FromDateTime(DateTime.Now.AddHours(-1))));
|
||||
}
|
||||
|
||||
class TimeFilterErrorAdorner : NotifyDataErrorAdorner<TimeFilterControl, ITimeFilterVM>, IDisposable {
|
||||
readonly ChildProperty<DateTimePicker> _begin_picker, _end_picker;
|
||||
|
||||
public TimeFilterErrorAdorner(TimeFilterControl view) : base(view) {
|
||||
_begin_picker = child_property<DateTimePicker>("PART_Begin_DateTimePicker");
|
||||
_end_picker = child_property<DateTimePicker>("PART_End_DateTimePicker");
|
||||
_begin_picker = child_property<DateTimePicker>(_begin_dtp_name);
|
||||
_end_picker = child_property<DateTimePicker>(_end_dtp_name);
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext drawing_context) {
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace mbts.ui.controls
|
||||
protected DataGridExRow() { }
|
||||
|
||||
public abstract object get_cell(TColKey col_key);
|
||||
public object get_cell(object col_key) { return get_cell(ObjectHelper.try_convert<TColKey>(col_key)); }
|
||||
public object get_cell(object col_key) { return get_cell(ConvertUtils.try_convert<TColKey>(col_key)); }
|
||||
|
||||
|
||||
}
|
||||
@@ -60,6 +60,6 @@ namespace mbts.ui.controls
|
||||
public abstract class DataGridExCell<TData> : ViewModelBase, IDataGridExCell<TData>, IDataGridExCell
|
||||
{
|
||||
public abstract void update(TData data);
|
||||
public void update(object data) { update(ObjectHelper.try_convert<TData>(data)); }
|
||||
public void update(object data) { update(ConvertUtils.try_convert<TData>(data)); }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using mbts.ui.utility;
|
||||
using mbts.ui.utility.text;
|
||||
using mbts.utils;
|
||||
using bts.utils;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
@@ -77,7 +77,7 @@ namespace mbts.ui.controls {
|
||||
|
||||
class FontFamilySupportsWeightConverter : IMultiValueConverter {
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) {
|
||||
if (ObjectHelper.try_convert_args(values, out FontFamily ff, out FontWeight fw))
|
||||
if (ConvertUtils.try_convert_args(values, out FontFamily ff, out FontWeight fw))
|
||||
return TextUtils.available_weights(ff).Contains(fw);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using mbts.utils;
|
||||
using bts.utils;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<cv:KeyValue Key="{x:Null}" Value="{u:Visibility Visible}"/>
|
||||
</cv:ValueMap>
|
||||
|
||||
<ControlTemplate x:Key="HoverButtonOverlayTemplate2" TargetType="c:TickUpDown">
|
||||
<ControlTemplate x:Key="HoverButtonOverlayTemplate" TargetType="c:TickUpDown">
|
||||
<Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
@@ -86,8 +86,8 @@
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="38"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<c:TickUpDown x:Name="PART_time_tick" HorizontalAlignment="Stretch" EnableArrowKeyTick="False" Template="{StaticResource HoverButtonOverlayTemplate2}">
|
||||
<TextBox x:Name="PART_time_text" Height="20" u:TextBoxBehavior.EnableArrowKeyTraverse="True" u:Behavior.DisablePaste="True">
|
||||
<c:TickUpDown x:Name="PART_time_tick" HorizontalAlignment="Stretch" EnableArrowKeyTick="False" Template="{StaticResource HoverButtonOverlayTemplate}">
|
||||
<TextBox x:Name="PART_time_text" u:TextBoxBehavior.CommitOnEnter="True" Height="20" u:TextBoxBehavior.EnableArrowKeyTraverse="True" u:Behavior.DisablePaste="True">
|
||||
<TextBox.InputBindings>
|
||||
<KeyBinding Key="Up" Command="{x:Static c:DateTimePicker.TickTimeComponentCommand}" CommandParameter="{u:Int 1}"/>
|
||||
<KeyBinding Key="Down" Command="{x:Static c:DateTimePicker.TickTimeComponentCommand}" CommandParameter="{u:Int -1}"/>
|
||||
@@ -95,15 +95,15 @@
|
||||
</TextBox.InputBindings>
|
||||
</TextBox>
|
||||
</c:TickUpDown>
|
||||
<c:TickUpDown x:Name="PART_month_tick" Margin="2,0,0,0" Grid.Column="1" Template="{StaticResource HoverButtonOverlayTemplate2}">
|
||||
<c:TickUpDown x:Name="PART_month_tick" Margin="2,0,0,0" Grid.Column="1" Template="{StaticResource HoverButtonOverlayTemplate}">
|
||||
<TextBox x:Name="PART_month_text" Height="20" u:TextBoxBehavior.EnableArrowKeyTraverse="True" u:Behavior.DisablePaste="True"/>
|
||||
</c:TickUpDown>
|
||||
<TextBlock Grid.Column="2" Margin="2,0">/</TextBlock>
|
||||
<c:TickUpDown x:Name="PART_day_tick" Grid.Column="3" Template="{StaticResource HoverButtonOverlayTemplate2}">
|
||||
<c:TickUpDown x:Name="PART_day_tick" Grid.Column="3" Template="{StaticResource HoverButtonOverlayTemplate}">
|
||||
<TextBox x:Name="PART_day_text" Height="20" u:TextBoxBehavior.EnableArrowKeyTraverse="True" u:Behavior.DisablePaste="True"/>
|
||||
</c:TickUpDown>
|
||||
<TextBlock Grid.Column="4" Margin="2,0">/</TextBlock>
|
||||
<c:TickUpDown x:Name="PART_year_tick" Grid.Column="5" Template="{StaticResource HoverButtonOverlayTemplate2}">
|
||||
<c:TickUpDown x:Name="PART_year_tick" Grid.Column="5" Template="{StaticResource HoverButtonOverlayTemplate}">
|
||||
<TextBox x:Name="PART_year_text" Height="20" u:TextBoxBehavior.EnableArrowKeyTraverse="True" u:Behavior.DisablePaste="True"/>
|
||||
</c:TickUpDown>
|
||||
<TextBlock Grid.Column="0" Text="hh:mm tt" Style="{StaticResource TextPromptStyle}" Visibility="{Binding Text, ElementName=PART_time_text, Converter={StaticResource NullOrEmptyVisibilityConverter}}"/>
|
||||
|
||||
@@ -18,6 +18,11 @@ namespace mbts.ui.controls {
|
||||
public static readonly RoutedCommand TickTimeComponentCommand = new RoutedCommand();
|
||||
|
||||
DTPController _controller;
|
||||
TextBox
|
||||
_month_text,
|
||||
_day_text,
|
||||
_year_text,
|
||||
_time_text;
|
||||
bool _suspend_notify_vm;
|
||||
|
||||
static DateTimePicker() =>
|
||||
@@ -34,18 +39,25 @@ namespace mbts.ui.controls {
|
||||
|
||||
IList<IDisposable> _hooks = new List<IDisposable>();
|
||||
|
||||
public void flush_pending_changes() {
|
||||
_month_text?.GetBindingExpression(TextBox.TextProperty)?.UpdateSource();
|
||||
_day_text?.GetBindingExpression(TextBox.TextProperty)?.UpdateSource();
|
||||
_year_text?.GetBindingExpression(TextBox.TextProperty)?.UpdateSource();
|
||||
_time_text?.GetBindingExpression(TextBox.TextProperty)?.UpdateSource();
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate() {
|
||||
var month = this.assert_template_child<TickUpDown>("PART_month_tick");
|
||||
var month_text = this.assert_template_child<TextBox>("PART_month_text");
|
||||
_month_text = this.assert_template_child<TextBox>("PART_month_text");
|
||||
var day = this.assert_template_child<TickUpDown>("PART_day_tick");
|
||||
var day_text = this.assert_template_child<TextBox>("PART_day_text");
|
||||
_day_text = this.assert_template_child<TextBox>("PART_day_text");
|
||||
var year = this.assert_template_child<TickUpDown>("PART_year_tick");
|
||||
var year_text = this.assert_template_child<TextBox>("PART_year_text");
|
||||
_year_text = this.assert_template_child<TextBox>("PART_year_text");
|
||||
var time = this.assert_template_child<TickUpDown>("PART_time_tick");
|
||||
var time_text = this.assert_template_child<TextBox>("PART_time_text");
|
||||
_time_text = this.assert_template_child<TextBox>("PART_time_text");
|
||||
|
||||
if (_controller != null) _controller.PropertyChanged -= _vm_PropertyChanged;
|
||||
_controller = new DTPController(time_text);
|
||||
_controller = new DTPController(_time_text);
|
||||
_controller.result = TimeTuple;
|
||||
_controller.PropertyChanged += _vm_PropertyChanged;
|
||||
time.CommandBindings.Add(new CommandBinding(TickTimeComponentCommand, (s, e) => {
|
||||
@@ -53,53 +65,52 @@ namespace mbts.ui.controls {
|
||||
}));
|
||||
time.CommandBindings.Add(new CommandBinding(TextBoxBehavior.SelectAllCommand, TextBoxBehavior.SelectAllCommandExecutedHandler));
|
||||
|
||||
const int delay = 500;
|
||||
time.SetBinding(TickUpDown.TickCommandProperty, new Binding("tick_time") { Source = _controller });
|
||||
time.TickUpParameter = 1;
|
||||
time.TickDownParameter = -1;
|
||||
time.TickUpAltParameter = 60;
|
||||
time.TickDownAltParameter = -60;
|
||||
time_text.SetBinding(TextBox.TextProperty, new Binding("time_text") { Source = _controller, Delay = delay, ValidatesOnExceptions = true });
|
||||
_hooks.Add(time_text.SubscribePreviewTextInput((s, e) => {
|
||||
string preview = time_text.PeekText(e);
|
||||
_time_text.SetBinding(TextBox.TextProperty, new Binding("time_text") { Source = _controller, ValidatesOnExceptions = true });
|
||||
_hooks.Add(_time_text.SubscribePreviewTextInput((s, e) => {
|
||||
string preview = _time_text.PeekText(e);
|
||||
if (RegexFilters.Time.StandardTimeOptionalSeconds.IsMatch(preview)) {
|
||||
_controller.use_military_time = false;
|
||||
} else if (RegexFilters.Time.MilitaryTimeOptionalSeconds.IsMatch(preview)) {
|
||||
_controller.use_military_time = true;
|
||||
} else {
|
||||
e.Handled = true;
|
||||
e.Handled = !RegexFilters.Time.FlexibleTime.IsMatch(preview);
|
||||
}
|
||||
}));
|
||||
|
||||
month.SetBinding(TickUpDown.TickCommandProperty, new Binding("tick_month") { Source = _controller });
|
||||
month.TickUpParameter = 1;
|
||||
month.TickDownParameter = -1;
|
||||
month_text.SetBinding(TextBox.TextProperty, new Binding("month_text") { Source = _controller, Delay = delay });
|
||||
_hooks.Add(month_text.SubscribePreviewTextInput((s, e) =>
|
||||
e.Handled = !RegexFilters.Time.MonthAbbrev.IsMatch(month_text.PeekText(e))
|
||||
_month_text.SetBinding(TextBox.TextProperty, new Binding("month_text") { Source = _controller });
|
||||
_hooks.Add(_month_text.SubscribePreviewTextInput((s, e) =>
|
||||
e.Handled = !RegexFilters.Time.MonthAbbrev.IsMatch(_month_text.PeekText(e))
|
||||
));
|
||||
|
||||
day.SetBinding(TickUpDown.TickCommandProperty, new Binding("tick_day") { Source = _controller });
|
||||
day.TickUpParameter = 1;
|
||||
day.TickDownParameter = -1;
|
||||
day_text.SetBinding(TextBox.TextProperty, new Binding("day_text") { Source = _controller, Delay = delay });
|
||||
_hooks.Add(day_text.SubscribePreviewTextInput((s, e) =>
|
||||
e.Handled = !RegexFilters.Time.DaysInMonth.IsMatch(day_text.PeekText(e))
|
||||
_day_text.SetBinding(TextBox.TextProperty, new Binding("day_text") { Source = _controller });
|
||||
_hooks.Add(_day_text.SubscribePreviewTextInput((s, e) =>
|
||||
e.Handled = !RegexFilters.Time.DaysInMonth.IsMatch(_day_text.PeekText(e))
|
||||
));
|
||||
|
||||
year.SetBinding(TickUpDown.TickCommandProperty, new Binding("tick_year") { Source = _controller });
|
||||
year.TickUpParameter = 1;
|
||||
year.TickDownParameter = -1;
|
||||
year_text.SetBinding(TextBox.TextProperty, new Binding("year_text") { Source = _controller, Delay = delay });
|
||||
_hooks.Add(year_text.SubscribePreviewTextInput((s, e) =>
|
||||
e.Handled = !RegexFilters.Time.Year.IsMatch(year_text.PeekText(e))
|
||||
_year_text.SetBinding(TextBox.TextProperty, new Binding("year_text") { Source = _controller });
|
||||
_hooks.Add(_year_text.SubscribePreviewTextInput((s, e) =>
|
||||
e.Handled = !RegexFilters.Time.Year.IsMatch(_year_text.PeekText(e))
|
||||
));
|
||||
}
|
||||
|
||||
void _vm_PropertyChanged(object sender, PropertyChangedEventArgs e) {
|
||||
if (e.PropertyName == nameof(DTPController.result)) {
|
||||
_suspend_notify_vm = true;
|
||||
TimeTuple = _controller.result;
|
||||
SetCurrentValue(TimeTupleProperty, _controller.result);
|
||||
_suspend_notify_vm = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace mbts.ui.converters {
|
||||
private readonly Func<TIn, TOut> _convert;
|
||||
private readonly Func<TOut, TIn> _convert_back;
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return _convert(ObjectHelper.try_convert<TIn>(value)); }
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return _convert_back(ObjectHelper.try_convert<TOut>(value)); }
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return _convert(ConvertUtils.try_convert<TIn>(value)); }
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return _convert_back(ConvertUtils.try_convert<TOut>(value)); }
|
||||
}
|
||||
|
||||
public class AnonymousMultiValueConverter<TIn1, TIn2, TOut> : IMultiValueConverter {
|
||||
@@ -49,7 +49,7 @@ namespace mbts.ui.converters {
|
||||
public TOut ErrorValue { get; set; }
|
||||
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) =>
|
||||
ObjectHelper.try_convert_args(values, out TIn1 a, out TIn2 b) ? _convert(a, b) : ErrorValue;
|
||||
ConvertUtils.try_convert_args(values, out TIn1 a, out TIn2 b) ? _convert(a, b) : ErrorValue;
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||
}
|
||||
@@ -62,7 +62,7 @@ namespace mbts.ui.converters {
|
||||
public TOut ErrorValue { get; set; }
|
||||
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) =>
|
||||
ObjectHelper.try_convert_args(values, out TIn1 a, out TIn2 b, out TIn3 c) ? _convert(a, b, c) : ErrorValue;
|
||||
ConvertUtils.try_convert_args(values, out TIn1 a, out TIn2 b, out TIn3 c) ? _convert(a, b, c) : ErrorValue;
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using mbts.utils;
|
||||
using bts.utils;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
@@ -19,7 +19,7 @@ namespace mbts.ui.converters
|
||||
}
|
||||
|
||||
public class DynamicValueEquals<T> : DynamicValueEquals {
|
||||
protected override bool ValuesEqual(object x, object y) { return ObjectHelper.try_convert(x, out T tx) && ObjectHelper.try_convert(y, out T ty) && ValuesEqual(tx, ty); }
|
||||
protected override bool ValuesEqual(object x, object y) { return ConvertUtils.try_convert(x, out T tx) && ConvertUtils.try_convert(y, out T ty) && ValuesEqual(tx, ty); }
|
||||
protected virtual bool ValuesEqual(T x, T y) { return CompareUtils.NullCheckEquals(x, y); }
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace mbts.ui.converters
|
||||
}
|
||||
|
||||
public class StaticValueEqualsConverter<T> : StaticValueEqualsConverter {
|
||||
protected override bool ValueEquals(object value) { return ObjectHelper.try_convert(value, out T result) && ValueEquals(result); }
|
||||
protected override bool ValueEquals(object value) { return ConvertUtils.try_convert(value, out T result) && ValueEquals(result); }
|
||||
protected virtual bool ValueEquals(T value) { return base.ValueEquals(value); }
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace mbts.ui
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public bool CanExecute(object parameter) {
|
||||
return !_is_executing && (_can_execute == null || _can_execute(ObjectHelper.try_convert<T>(parameter)));
|
||||
return !_is_executing && (_can_execute == null || _can_execute(ConvertUtils.try_convert<T>(parameter)));
|
||||
}
|
||||
|
||||
public void RaiseCanExecuteChanged() {
|
||||
@@ -45,7 +45,7 @@ namespace mbts.ui
|
||||
_is_executing = true;
|
||||
RaiseCanExecuteChanged();
|
||||
try {
|
||||
var w = await _factory(ObjectHelper.try_convert<T>(parameter));
|
||||
var w = await _factory(ConvertUtils.try_convert<T>(parameter));
|
||||
if (w != null) {
|
||||
if (_off_x.HasValue && _off_y.HasValue)
|
||||
w.move_to_mouse(_off_x.Value, _off_x.Value);
|
||||
|
||||
@@ -28,12 +28,12 @@ namespace mbts.ui
|
||||
private IDisposable _dialog;
|
||||
public Predicate<T> can_execute { get; set; }
|
||||
|
||||
public bool CanExecute(object parameter) { return can_execute == null ? true : can_execute(ObjectHelper.try_convert<T>(parameter)); }
|
||||
public bool CanExecute(object parameter) { return can_execute == null ? true : can_execute(ConvertUtils.try_convert<T>(parameter)); }
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public void Execute(object parameter) {
|
||||
Disposable.dispose(ref _dialog);
|
||||
Window w = _factory(ObjectHelper.try_convert<T>(parameter));
|
||||
Window w = _factory(ConvertUtils.try_convert<T>(parameter));
|
||||
if (w != null) {
|
||||
if (_try_dispose_vm_on_close) {
|
||||
w.Closed += (s, e) => {
|
||||
|
||||
@@ -101,10 +101,10 @@ namespace mbts.ui {
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public bool CanExecute(object parameter) => _can_execute(ObjectHelper.try_convert<TParam>(parameter));
|
||||
public bool CanExecute(object parameter) => _can_execute(ConvertUtils.try_convert<TParam>(parameter));
|
||||
public void Execute(object parameter) {
|
||||
_safe_close_dialog();
|
||||
TParam tparam = ObjectHelper.try_convert<TParam>(parameter);
|
||||
TParam tparam = ConvertUtils.try_convert<TParam>(parameter);
|
||||
_dialog = _dialog_factory(tparam);
|
||||
if (_dialog.ShowDialog() == DialogResult.OK)
|
||||
_commit(tparam, _dialog.FileName);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace mbts.ui {
|
||||
|
||||
public static T get_template_child<T>(this Control control, string name) {
|
||||
object obj = get_template_child(control, name);
|
||||
return ObjectHelper.try_convert<T>(obj);
|
||||
return ConvertUtils.try_convert<T>(obj);
|
||||
}
|
||||
|
||||
public static bool try_get_template_child(this Control control, string name, out object result) {
|
||||
@@ -40,7 +40,7 @@ namespace mbts.ui {
|
||||
|
||||
public static bool try_get_template_child<T>(this Control control, string name, out T result) {
|
||||
if (try_get_template_child(control, name, out object obj))
|
||||
return ObjectHelper.try_convert(obj, out result);
|
||||
return ConvertUtils.try_convert(obj, out result);
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace mbts.ui.shell
|
||||
{
|
||||
public class WorkspaceViewModel : ViewModelBase
|
||||
{
|
||||
private const string INITIAL_VISUAL_STATE = "Normal";
|
||||
|
||||
WorkspacesModel _parent;
|
||||
public WorkspaceViewModel(WorkspacesModel parent, string name, WorkspaceDefinition definition) {
|
||||
_parent = parent;
|
||||
@@ -22,8 +24,23 @@ namespace mbts.ui.shell
|
||||
get { return Icons.Window; }
|
||||
}
|
||||
|
||||
private string _vstate = "Normal";
|
||||
public string VisualState { get { return _vstate; } set { _vstate = value; RaisePropertyChanged("VisualState"); } }
|
||||
private string _vstate = INITIAL_VISUAL_STATE;
|
||||
public string VisualState {
|
||||
get {
|
||||
// this unconventional getter acts as a reset after the VisualStateManager has played
|
||||
// i.e. if we overwrite a workspace then save, then close the window, when we open the
|
||||
// window back up, we'll see item animate b/c it has never been reset from the animate
|
||||
// state. This is necessary b/c the lifetime of Workspaces is not tied to the lifetime
|
||||
// of the View, rather it lives in the Model and is only instantiated on startup via MEF
|
||||
var return_val = _vstate;
|
||||
_vstate = INITIAL_VISUAL_STATE;
|
||||
return return_val;
|
||||
}
|
||||
set {
|
||||
_vstate = value;
|
||||
RaisePropertyChanged("VisualState");
|
||||
}
|
||||
}
|
||||
|
||||
internal WorkspaceDefinition Definition { get; private set; }
|
||||
|
||||
|
||||
@@ -45,13 +45,13 @@ namespace mbts.ui.shell
|
||||
{
|
||||
clear_error("SaveName");
|
||||
}
|
||||
var save_candidate_already_exists = Workspaces.Any(x => x.Name == SaveName);
|
||||
var save_candidate_already_exists = Workspaces.Any(x => x.Name.Replace(WorkspacesModel.SHARED_MONIKER, string.Empty) == SaveName && x.IsShared == IsPublicWorkspace);
|
||||
// Save
|
||||
_work_model.save_workspace(SaveName, ispublic: IsPublicWorkspace);
|
||||
|
||||
// if we just overwrote something, have the vm reflect it
|
||||
if (save_candidate_already_exists)
|
||||
Workspaces.Where(x => x.Name == SaveName).ForEach(x => x.VisualState = "Overridden");
|
||||
Workspaces.Where(x => x.Name.Replace(WorkspacesModel.SHARED_MONIKER, string.Empty) == SaveName && x.IsShared == IsPublicWorkspace).ForEach(x => x.VisualState = "Overridden");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace mbts.ui.shell
|
||||
{
|
||||
internal const string WORKSPACE_NAMESPACE = "workspace";
|
||||
internal const string ACTIVE_WORKSPACE_PREFIX = "Where I left off on ";
|
||||
public const string SHARED_MONIKER = " (shared)";
|
||||
public static string ACTIVE_WORKSPACE_NAME { get { return ACTIVE_WORKSPACE_PREFIX + Environment.MachineName; } }
|
||||
|
||||
private ISettingsCollector _settings_collector;
|
||||
@@ -178,7 +179,7 @@ namespace mbts.ui.shell
|
||||
public void save_workspace(string name, bool persist=true, bool ispublic=false) {
|
||||
WorkspaceDefinition workspace = get_workspace();
|
||||
workspace.is_shared = ispublic;
|
||||
if (ispublic) { name += " (shared)"; }
|
||||
if (ispublic) { name += SHARED_MONIKER; }
|
||||
|
||||
// Remove the old one if a workspace by this name exists already
|
||||
var old = Workspaces.SingleOrDefault(w => w.Name == name && ispublic == w.IsShared);
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace mbts.spark {
|
||||
Comparer<double>.Create(_compare_unit);
|
||||
|
||||
public static IComparer<TickFactors> base_unit_comparer =>
|
||||
Comparer<TickFactors>.Create(utils.CompareUtils.safe_comparison<TickFactors>(compare_base_unit));
|
||||
Comparer<TickFactors>.Create(bts.utils.CompareUtils.safe_comparison<TickFactors>(compare_base_unit));
|
||||
|
||||
public static int compare_base_unit(TickFactors a, TickFactors b) {
|
||||
int comp = _compare_base(a.tick_base, b.tick_base);
|
||||
|
||||
@@ -853,11 +853,11 @@ namespace mbts.spark {
|
||||
LadderSettings _settings => _owner._settings;
|
||||
|
||||
public void refresh() {
|
||||
bid_dirty = ObjectHelper.update_value_type(ref _bid, _settings.bid_break_line.show ? _owner._get_bid_market_break() : double.NaN);
|
||||
ask_dirty = ObjectHelper.update_value_type(ref _ask, _settings.ask_break_line.show ? _owner._get_ask_market_break() : double.NaN);
|
||||
mid_dirty = ObjectHelper.update_value_type(ref _mid, _settings.mid_break_line.show ? _owner._get_mid_market_break() : double.NaN);
|
||||
session_low_dirty = ObjectHelper.update_value_type(ref _session_low, (_settings.session_low_line.show || _settings.session_range_fill.show) ? _owner._get_session_low() : double.NaN);
|
||||
session_high_dirty = ObjectHelper.update_value_type(ref _session_high, (_settings.session_high_line.show || _settings.session_range_fill.show) ? _owner._get_session_high() : double.NaN);
|
||||
bid_dirty = ConvertUtils.update_value_type(ref _bid, _settings.bid_break_line.show ? _owner._get_bid_market_break() : double.NaN);
|
||||
ask_dirty = ConvertUtils.update_value_type(ref _ask, _settings.ask_break_line.show ? _owner._get_ask_market_break() : double.NaN);
|
||||
mid_dirty = ConvertUtils.update_value_type(ref _mid, _settings.mid_break_line.show ? _owner._get_mid_market_break() : double.NaN);
|
||||
session_low_dirty = ConvertUtils.update_value_type(ref _session_low, (_settings.session_low_line.show || _settings.session_range_fill.show) ? _owner._get_session_low() : double.NaN);
|
||||
session_high_dirty = ConvertUtils.update_value_type(ref _session_high, (_settings.session_high_line.show || _settings.session_range_fill.show) ? _owner._get_session_high() : double.NaN);
|
||||
if (session_low_dirty)
|
||||
_low_index = null;
|
||||
if (session_high_dirty)
|
||||
@@ -871,7 +871,7 @@ namespace mbts.spark {
|
||||
else new_origin = mid;
|
||||
if (double.IsNaN(new_origin))
|
||||
new_origin = _owner._get_bid_market_break();
|
||||
origin_dirty = ObjectHelper.update_value_type(ref _origin, new_origin);
|
||||
origin_dirty = ConvertUtils.update_value_type(ref _origin, new_origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +144,7 @@ namespace mbts.ui.utility.text {
|
||||
StandardTimeOptionalSeconds = new Regex(@"^((\d?|0\d|1[0-2])|((\d|0\d|1[0-2])(:?|(:([0-5]?|[0-5]\d(( ?|( ([aApP]?|[aApP][mM])))(:?|(: ?)|(: [aApP]?[mM]?)|(:[0-5]?\d? ?[aApP]?[mM]?))|:([0-5]?|([0-5]\d( ?|( ([aApP]?|([aApP][mM]))))))))))))$"),
|
||||
MilitaryTime = new Regex(@"^(([0-1]?[0-9])|(2?[0-3]?))(:?|:([0-5]?|[0-5][0-9]?))$"),
|
||||
MilitaryTimeOptionalSeconds = new Regex(@"^((\d?|[0-1]\d|2[0-3])|((\d|[0-1]\d|2[0-3])(:?|(:([0-5]?|[0-5]\d(:?|:([0-5]?|[0-5]\d)))))))$"),
|
||||
FlexibleTime = new Regex(@"^[0-9:aApPmM ]*$"),
|
||||
DaysInMonth = new Regex(@"^([0-9]?|[0-2][0-9]|3[0-1])?$"),
|
||||
MonthAbbrev = new Regex(@"^(?i)(a(ug?|pr?)?|d(e|ec)?|f(e?b)?|j(an?|u[nl]?)?|m(a[ry]?)?|(o(ct?)?)|s(ep?)?|n(ov?)?)?$"),
|
||||
Year = new Regex(@"^\d{0,4}$"),
|
||||
|
||||
@@ -259,13 +259,13 @@ namespace mbts.ui {
|
||||
}
|
||||
|
||||
public static PropertyChangedCallback prop_changed_callback<TValue, TOwner>(PropertyChangedCallback<TValue, TOwner> callback) =>
|
||||
(d, e) => callback(ObjectHelper.try_convert<TOwner>(d), ObjectHelper.try_convert<TValue>(e.OldValue), ObjectHelper.try_convert<TValue>(e.NewValue));
|
||||
(d, e) => callback(ConvertUtils.try_convert<TOwner>(d), ConvertUtils.try_convert<TValue>(e.OldValue), ConvertUtils.try_convert<TValue>(e.NewValue));
|
||||
|
||||
public static PropertyChangedCallback prop_changed_callback<TValue, TOwner>(Action<TOwner, TValue> callback) =>
|
||||
(d, e) => callback(ObjectHelper.try_convert<TOwner>(d), ObjectHelper.try_convert<TValue>(e.NewValue));
|
||||
(d, e) => callback(ConvertUtils.try_convert<TOwner>(d), ConvertUtils.try_convert<TValue>(e.NewValue));
|
||||
|
||||
public static CoerceValueCallback coerce_value_callback<TValue, TOwner>(Func<TOwner, TValue, TValue> coerce_value) =>
|
||||
(d, obj) => coerce_value(ObjectHelper.try_convert<TOwner>(d), ObjectHelper.try_convert<TValue>(obj));
|
||||
(d, obj) => coerce_value(ConvertUtils.try_convert<TOwner>(d), ConvertUtils.try_convert<TValue>(obj));
|
||||
|
||||
public static double control_base_width(Thickness border_thickness, Thickness padding) =>
|
||||
border_thickness.Left + padding.Left + padding.Right + border_thickness.Right;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -57,8 +58,23 @@ namespace bts.collections {
|
||||
_replace(node, item);
|
||||
return false;
|
||||
} else {
|
||||
node = _init_node(item);
|
||||
_insert_node(node);
|
||||
if (_nursery.TryPopValue(k, out SortedList<Node> children)) {
|
||||
// remove orphans from _tree (orphan-nodes must reside in the main _tree until parents arrive)
|
||||
foreach (var n in children)
|
||||
_tree.Remove(n);
|
||||
node = new Node(item, children);
|
||||
} else node = new Node(item, _comparer);
|
||||
var pk = parent(item);
|
||||
if (pk.Equals(_root_id))
|
||||
_tree.Add(node);
|
||||
else if (_index.TryGetValue(pk, out Node pnode))
|
||||
pnode.children.Add(node);
|
||||
else {
|
||||
if (!_nursery.TryGetValue(pk, out SortedList<Node> l))
|
||||
_nursery.Add(pk, l = new SortedList<Node>(_comparer));
|
||||
l.Add(node);
|
||||
_tree.Add(node);
|
||||
}
|
||||
_index.Add(k, node);
|
||||
return true;
|
||||
}
|
||||
@@ -93,7 +109,10 @@ namespace bts.collections {
|
||||
_remove_from_nursery(pk, node);
|
||||
}
|
||||
if (node.children.Count > 0) {
|
||||
// any children left behind are orphans now, add them to the main _tree and _nursery
|
||||
_nursery.Add(k, node.children);
|
||||
foreach (var n in node.children)
|
||||
_tree.Add(n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,17 +134,22 @@ namespace bts.collections {
|
||||
// We are sure it is in the index because we just added it
|
||||
var node = _index[id(item)];
|
||||
if (_nursery.TryPopValue(id(item), out SortedList<Node> nl)) {
|
||||
// remove orphans from _tree (orphan-nodes must reside in the main _tree until parents arrive)
|
||||
foreach (var n in nl)
|
||||
_tree.Remove(n);
|
||||
if (node.children.Count == 0) {
|
||||
node.children = nl;
|
||||
} else if (node.children.Count > nl.Count) {
|
||||
// merge nl into node.children
|
||||
foreach (var cn in nl)
|
||||
node.children.Add(cn);
|
||||
} else {
|
||||
// merge node.children into nl
|
||||
foreach (var cn in node.children)
|
||||
nl.Add(cn);
|
||||
node.children = nl;
|
||||
if (node.children.Count > nl.Count) {
|
||||
// merge nl into node.children
|
||||
foreach (var cn in nl)
|
||||
node.children.Add(cn);
|
||||
} else {
|
||||
// merge node.children into nl
|
||||
foreach (var cn in node.children)
|
||||
nl.Add(cn);
|
||||
node.children = nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
TKey pk = parent(item);
|
||||
@@ -137,6 +161,7 @@ namespace bts.collections {
|
||||
if (!_nursery.TryGetValue(pk, out nl))
|
||||
_nursery.Add(pk, nl = new SortedList<Node>(_comparer));
|
||||
nl.Add(node);
|
||||
_tree.Add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,7 +197,6 @@ namespace bts.collections {
|
||||
} else if (!_nursery.TryGetValue(pk, out node_list)) {
|
||||
throw new KeyNotFoundException($"Replace was called with a parent-key ({pk}) that was not found in _index or _nursery; item-key was ({id(newval)}).");
|
||||
}
|
||||
//var node_list = pk.Equals(_root_id) ? _tree : _index.TryGetValue(pk, out Node pnode) ? pnode.children : _nursery[pk];
|
||||
node_list.Remove(node);
|
||||
node.value = newval;
|
||||
node_list.Add(node);
|
||||
@@ -187,32 +211,24 @@ namespace bts.collections {
|
||||
}
|
||||
}
|
||||
node.value = newval;
|
||||
_insert_node(node);
|
||||
}
|
||||
}
|
||||
|
||||
Node _init_node(T item) =>
|
||||
_nursery.TryPopValue(id(item), out SortedList<Node> nursery_list) ? new Node(item, nursery_list) : new Node(item, _comparer);
|
||||
|
||||
/// <summary>
|
||||
/// Inserts the node into the appropriate SortedList (i.e. roots, parent.inner, or nursery), but does NOT add it to <see cref="_index"/>, NOR check the nursery for any child-nodes waiting on this item.
|
||||
/// </summary>
|
||||
void _insert_node(Node node) {
|
||||
TKey pk = parent(node.value);
|
||||
if (pk.Equals(_root_id)) {
|
||||
_tree.Add(node);
|
||||
} else if (_index.TryGetValue(pk, out Node pnode)) {
|
||||
pnode.children.Add(node);
|
||||
} else {
|
||||
if (!_nursery.TryGetValue(pk, out SortedList<Node> nursery_list)) {
|
||||
_nursery.Add(pk, nursery_list = new SortedList<Node>(_comparer));
|
||||
if (pk.Equals(_root_id)) {
|
||||
_tree.Add(node);
|
||||
} else if (_index.TryGetValue(pk, out Node pnode)) {
|
||||
pnode.children.Add(node);
|
||||
} else {
|
||||
if (!_nursery.TryGetValue(pk, out SortedList<Node> nursery_list)) {
|
||||
_nursery.Add(pk, nursery_list = new SortedList<Node>(_comparer));
|
||||
}
|
||||
nursery_list.Add(node);
|
||||
_tree.Add(node);
|
||||
}
|
||||
nursery_list.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
void _remove_from_nursery(TKey pk, Node node) =>
|
||||
void _remove_from_nursery(TKey pk, Node node) {
|
||||
_nursery.TryPopValueIf(pk, nl => nl.Remove(node) && nl.Count == 0);
|
||||
_tree.Remove(node);
|
||||
}
|
||||
|
||||
IEnumerable<T> iterate(SortedList<Node> nodes) {
|
||||
foreach (var n in nodes) {
|
||||
@@ -259,10 +275,6 @@ namespace bts.collections {
|
||||
public IEnumerator<T> GetEnumerator() {
|
||||
foreach (T item in iterate(_tree))
|
||||
yield return item;
|
||||
foreach (var kv in _nursery) {
|
||||
foreach (T item in iterate(kv.Value))
|
||||
yield return item;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() {
|
||||
|
||||
+8
-2
@@ -2,8 +2,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace mbts.utils {
|
||||
namespace bts.utils {
|
||||
public static class CompareUtils {
|
||||
public static int safe_compare<T>(this T a, T b, Func<T, T, int> compare) =>
|
||||
a == null ? (b == null ? 0 : -1) : (b == null ? 1 : compare(a, b));
|
||||
|
||||
public static int safe_compare<T>(this T a, T b) where T : IComparable<T> =>
|
||||
a == null ? (b == null ? 0 : -1) : (b == null ? 1 : a.CompareTo(b));
|
||||
|
||||
#region Equality
|
||||
public static bool NullCheckEquals<T>(T x, T y) =>
|
||||
NullCheckEquals(x, y, (_x, _y) => _x.Equals(_y));
|
||||
@@ -41,7 +47,7 @@ namespace mbts.utils {
|
||||
public NonGenericComparerWrapper(IComparer<T> comparer) => _comparer = comparer;
|
||||
|
||||
public int Compare(object x, object y) =>
|
||||
_comparer.Compare(ObjectHelper.try_convert<T>(x), ObjectHelper.try_convert<T>(y));
|
||||
_comparer.Compare(ConvertUtils.try_convert<T>(x), ConvertUtils.try_convert<T>(y));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
+14
-7
@@ -1,9 +1,5 @@
|
||||
using mbts.ui.utility;
|
||||
|
||||
namespace System
|
||||
{
|
||||
public static class ObjectHelper
|
||||
{
|
||||
namespace System {
|
||||
public static class ConvertUtils {
|
||||
public static object try_convert(Type type, object obj) {
|
||||
try_convert(type, obj, out object result);
|
||||
return result;
|
||||
@@ -20,7 +16,7 @@ namespace System
|
||||
result = obj;
|
||||
return true;
|
||||
} else if (type.IsEnum && obj is string) {
|
||||
result = EnumHelper.try_parse(type, obj.ToString());
|
||||
result = try_parse_enum(type, obj.ToString());
|
||||
return true;
|
||||
} else if (type.IsNullable()) {
|
||||
return try_convert(type.GetGenericArguments()[0], obj, out result);
|
||||
@@ -85,6 +81,17 @@ namespace System
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static object try_parse_enum(Type enum_type, string value, bool ignore_case = true) {
|
||||
if (!enum_type.IsEnum) throw new ArgumentException("Must an enum type.", nameof(enum_type));
|
||||
Array vals = Enum.GetValues(enum_type);
|
||||
var str_comp = ignore_case ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture;
|
||||
foreach (object v in vals) {
|
||||
if (string.Equals(v.ToString(), value, str_comp))
|
||||
return v;
|
||||
}
|
||||
return Activator.CreateInstance(enum_type);
|
||||
}
|
||||
|
||||
public static bool update_value_type<T>(ref T field, T newval) where T : struct, IEquatable<T> {
|
||||
bool rv = field.Equals(newval);
|
||||
field = newval;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,6 @@
|
||||
using bts.collections;
|
||||
using bts.test;
|
||||
using bts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -81,21 +82,6 @@ namespace bts.tests {
|
||||
int id(Order order) => order.id;
|
||||
int pid(Order order) => order.parent_id;
|
||||
|
||||
/// <summary>
|
||||
/// This test has been made obsolete by <see cref="test_sorted_tree_state_transitions"/>; leaving it in place until the latter has been code-reviewed.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void test_sordid_tree() {
|
||||
for (int x = 0; x < 10; ++x) {
|
||||
var input = orders.ToList();
|
||||
input.Shuffle();
|
||||
var tree_asc = new SortedTree<Order, int>(Order.name_asc, id, pid, input);
|
||||
var tree_desc = new SortedTree<Order, int>(Order.name_desc, id, pid, input);
|
||||
Assert.IsTrue(tree_asc.SequenceEqual(orders));
|
||||
Assert.IsTrue(tree_desc.SequenceEqual(orders_desc));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void test_enumerate_group() {
|
||||
var comparer = Comparer<Order>.Create((l, r) => l.name.CompareTo(r.name));
|
||||
@@ -151,17 +137,20 @@ namespace bts.tests {
|
||||
// 1) Constructor Initialization
|
||||
var tree_asc = new SortedTree<Order, int>(Order.name_asc, id, pid, input);
|
||||
var tree_desc = new SortedTree<Order, int>(Order.name_desc, id, pid, input);
|
||||
assert_populated_then_clear();
|
||||
assert_state_then_clear(tree_asc, input, Order.name_asc);
|
||||
assert_state_then_clear(tree_desc, input, Order.name_desc);
|
||||
// 2) Insert
|
||||
foreach (var o in input) {
|
||||
tree_asc.Insert(o);
|
||||
tree_desc.Insert(o);
|
||||
}
|
||||
assert_populated_then_clear();
|
||||
assert_state_then_clear(tree_asc, input, Order.name_asc);
|
||||
assert_state_then_clear(tree_desc, input, Order.name_desc);
|
||||
// 3) Reset
|
||||
tree_asc.Reset(input);
|
||||
tree_desc.Reset(input);
|
||||
assert_populated_then_clear();
|
||||
assert_state_then_clear(tree_asc, input, Order.name_asc);
|
||||
assert_state_then_clear(tree_desc, input, Order.name_desc);
|
||||
// 4) Replace
|
||||
tree_asc.Reset(input);
|
||||
tree_desc.Reset(input);
|
||||
@@ -170,28 +159,12 @@ namespace bts.tests {
|
||||
Assert.IsTrue(tree_asc.TryReplace(id(v), _ => v));
|
||||
Assert.IsTrue(tree_desc.TryReplace(id(v), _ => v));
|
||||
}
|
||||
// verify asc
|
||||
var (expected_asc, expected_nursery_asc) = _build_tree(modified_input, Order.name_asc);
|
||||
assert_sequence_then_clear(tree_asc, expected_asc, expected_nursery_asc);
|
||||
// verify desc
|
||||
var (expected_desc, expected_nursery_desc) = _build_tree(modified_input, Order.name_desc);
|
||||
assert_sequence_then_clear(tree_desc, expected_desc, expected_nursery_desc);
|
||||
// DONE!! (local methods)
|
||||
void assert_populated_then_clear() {
|
||||
Assert.IsTrue(tree_asc.SequenceEqual(orders));
|
||||
Assert.IsTrue(tree_desc.SequenceEqual(orders_desc));
|
||||
clear_action(tree_asc);
|
||||
clear_action(tree_desc);
|
||||
Assert.IsFalse(tree_asc.Any());
|
||||
Assert.IsFalse(tree_desc.Any());
|
||||
}
|
||||
// verify asc/desc
|
||||
assert_state_then_clear(tree_asc, modified_input, Order.name_asc);
|
||||
assert_state_then_clear(tree_desc, modified_input, Order.name_desc);
|
||||
|
||||
void assert_sequence_then_clear(SortedTree<Order, int> tree, List<Order> expected_items, HashSet<int> expected_nursery) {
|
||||
var tree_list = tree.ToList();
|
||||
Assert.AreEqual(tree_list.Count, expected_items.Count + expected_nursery.Count);
|
||||
Assert.IsTrue(tree_list.Take(expected_items.Count).SequenceEqual(expected_items));
|
||||
// nursery order is non-deterministic, just make sure they are equivalent id-sets.
|
||||
Assert.IsTrue(new HashSet<int>(tree_list.Skip(expected_items.Count).Select(id)).SetEquals(expected_nursery));
|
||||
void assert_state_then_clear(SortedTree<Order, int> tree, IEnumerable<Order> vals, IComparer<Order> comp) {
|
||||
Assert.IsTrue(tree.SequenceEqual(_hierarchically_sorted_list(vals, comp)));
|
||||
clear_action(tree);
|
||||
Assert.IsFalse(tree.Any());
|
||||
}
|
||||
@@ -199,6 +172,74 @@ namespace bts.tests {
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void test_nursery() {
|
||||
var tree = new SortedTree<Order, int>(Order.name_asc, id, pid);
|
||||
int next_id = orders.Max(id) + 1;
|
||||
var parent = new Order('a', next_id++, Order.no_parent);
|
||||
// add 2 generations of orphans (in the test loop, these orphans will ALWAYS be added before there parent, so they aren't orphans persay, more just with a babysitter).
|
||||
// gen 1:
|
||||
var orphans = new List<Order> {
|
||||
new Order('b', next_id++, parent.id),
|
||||
new Order('c', next_id++, parent.id)
|
||||
};
|
||||
// gen 2: (Warning: there are some "magic" numbers here...this is a unit test, with fake data, so they are hard to avoid entirely).
|
||||
orphans.Add(new Order('d', next_id++, id(orphans[0])));
|
||||
orphans.Add(new Order('e', next_id++, id(orphans[1])));
|
||||
// let's add 1 orphan who's parent will NEVER arrive, unlike the orphans added above
|
||||
orphans.Add(new Order('x', next_id++, next_id++));
|
||||
var expected_result = _hierarchically_sorted_list(orders.Concat(orphans), Order.name_asc);
|
||||
// insert orphans at every position with respect to orders
|
||||
int count = 0;
|
||||
while (count++ < 10) {
|
||||
for (int i = 0; i < orders.Length; i++) {
|
||||
var input = orders.ToList();
|
||||
input.Shuffle();
|
||||
orphans.Shuffle();
|
||||
for (int j = 0; j < input.Count; j++) {
|
||||
if (j == i) {
|
||||
foreach (var o in orphans)
|
||||
tree.Insert(o);
|
||||
}
|
||||
tree.Insert(input[j]);
|
||||
}
|
||||
Assert.IsTrue(tree.SequenceEqual(expected_result));
|
||||
tree.Clear();
|
||||
Assert.IsFalse(tree.Any());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Order> _hierarchically_sorted_list(IEnumerable<Order> input, IComparer<Order> comp) {
|
||||
var node_index = input.ToDictionary(id, v => new TestNode(v));
|
||||
var tree_dict = new Dictionary<int, TestNode>();
|
||||
foreach (var o in input) {
|
||||
if (pid(o).Equals(Order.no_parent)) {
|
||||
tree_dict.Add(id(o), node_index[id(o)]);
|
||||
} else {
|
||||
if (node_index.TryGetValue(pid(o), out TestNode pnode))
|
||||
pnode.inner.Add(id(o), node_index[id(o)]);
|
||||
else {
|
||||
tree_dict.Add(id(o), node_index[id(o)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// build flat sorted list
|
||||
var flat_sorted = new List<Order>();
|
||||
var node_comp = comp.wrap<Order, TestNode>(n => n.value);
|
||||
insert_vals(tree_dict);
|
||||
return flat_sorted;
|
||||
// local methods
|
||||
void insert_vals(Dictionary<int, TestNode> map) {
|
||||
var sorted = map.Values.ToList();
|
||||
sorted.Sort(node_comp);
|
||||
foreach (var n in sorted) {
|
||||
flat_sorted.Add(n.value);
|
||||
insert_vals(n.inner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Order> _randomize_values(List<Order> input) {
|
||||
// shuffle ids
|
||||
var rand_ids = input.Select(id).ToList();
|
||||
@@ -224,47 +265,18 @@ namespace bts.tests {
|
||||
return reshuffled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of Orders, hierarchically sorted, and a HashSet of Order-ids whose parent is not present. Parentless nodes are NOT included in the list of values.
|
||||
/// </summary>
|
||||
(List<Order> sorted_vals, HashSet<int> nursery) _build_tree(IEnumerable<Order> items, IComparer<Order> comp) {
|
||||
var roots = new List<TestNode>();
|
||||
var nursery_map = new Dictionary<int, Dictionary<int, TestNode>>();
|
||||
var raw_item_map = items.ToDictionary(id);
|
||||
var node_map = new Dictionary<int, TestNode>();
|
||||
foreach (var v in items) {
|
||||
int k = id(v);
|
||||
int pk = pid(v);
|
||||
TestNode node;
|
||||
if (nursery_map.TryGetValue(k, out Dictionary<int, TestNode> inner)) {
|
||||
// adopt orphans from nursery
|
||||
node = new TestNode(v, inner);
|
||||
nursery_map.Remove(k);
|
||||
} else {
|
||||
node = new TestNode(v);
|
||||
}
|
||||
node_map.Add(k, node);
|
||||
if (pk.Equals(Order.no_parent)) {
|
||||
roots.Add(node);
|
||||
} else if (node_map.TryGetValue(pk, out TestNode pnode)) {
|
||||
pnode.inner.Add(k, node);
|
||||
} else {
|
||||
if (!nursery_map.TryGetValue(pk, out Dictionary<int, TestNode> ndict)) {
|
||||
nursery_map.Add(pk, ndict = new Dictionary<int, TestNode>());
|
||||
}
|
||||
ndict.Add(k, node);
|
||||
}
|
||||
void _write_tree_to_console(SortedTree<Order, int> tree) {
|
||||
foreach (var str in _fmt_output(tree.RootNodes))
|
||||
Console.WriteLine(str);
|
||||
}
|
||||
|
||||
IEnumerable<string> _fmt_output(IEnumerable<INode<Order>> nodes) => _fmt_output(nodes, 0);
|
||||
IEnumerable<string> _fmt_output(IEnumerable<INode<Order>> en, int depth) {
|
||||
foreach (var curr in en) {
|
||||
yield return new string('-', depth * 4) + curr.value.ToString();
|
||||
foreach (var str in _fmt_output(curr.inner, depth + 1))
|
||||
yield return str;
|
||||
}
|
||||
return (roots.OrderBy(n => n.value, comp)
|
||||
.SelectMany(iterate_inner_vals).ToList(),
|
||||
new HashSet<int>(nursery_map.Values
|
||||
.SelectMany(d => d.Values.SelectMany(iterate_inner_vals))
|
||||
.Select(id)));
|
||||
// local methods
|
||||
IEnumerable<Order> iterate_inner_vals(TestNode n) =>
|
||||
new[] { n.value }.Concat(
|
||||
n.inner.Values.OrderBy(cn => cn.value, comp)
|
||||
.SelectMany(iterate_inner_vals));
|
||||
}
|
||||
|
||||
class TestNode {
|
||||
@@ -279,4 +291,4 @@ namespace bts.tests {
|
||||
public readonly Dictionary<int, TestNode> inner;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,6 @@ message CMEOptions
|
||||
// Defines amount of time Feed Engine keeps cycling before going to sleep when no useful activity can be done
|
||||
optional uint32 spin_time = 4 [default = 1];
|
||||
optional uint32 channels_per_thread = 5 [default = 3];
|
||||
optional string thread_group = 10 [default=""]; // if present this will be used to retrieve affinity settings from Threads config key
|
||||
optional uint32 udp_socket_buffer_size = 11 [default = 33554432]; //32mb
|
||||
}
|
||||
message CMEChannel {
|
||||
|
||||
@@ -64,6 +64,6 @@ message ShellPingOptions {
|
||||
// 4000 is default Windows ping timeout as specified here:
|
||||
// https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490968(v=technet.10)
|
||||
optional int32 timeout_milliseconds_threshold = 3 [default = 4000];
|
||||
optional int32 logging_milliseconds_threshold = 4 [default = 25];
|
||||
optional int32 logging_milliseconds_threshold = 4 [default = 50];
|
||||
optional int32 maximum_backoff_milliseconds = 5 [default = 60000];
|
||||
}
|
||||
@@ -7,6 +7,6 @@ message OrdersSoftCleanupCutoff{
|
||||
|
||||
message SODTime{
|
||||
// utc time
|
||||
optional uint32 sod_hh = 20 [default=15];
|
||||
optional uint32 sod_hh = 20 [default=16];
|
||||
optional uint32 sod_mm = 30 [default=30];
|
||||
}
|
||||
@@ -33,8 +33,11 @@ string dump(IntPrice price) {
|
||||
string dump(PriceSize ps) {
|
||||
stringstream res;
|
||||
res << "{";
|
||||
res << "'price': " << std::setprecision(11) << ps.price() << ", ";
|
||||
res << "'size': " << ps.size() << " ";
|
||||
res << "'price': " << std::setprecision(11) << ps.price();
|
||||
if (!ps.is_nan()) {
|
||||
res << " (^" << (int)ps.exponent() << ")";
|
||||
}
|
||||
res << ", 'size': " << ps.size() << " ";
|
||||
// res << "'mant': " << ps.mantissa() << ", ";
|
||||
// res << "'exp': " << (int)ps.exponent() << " ";
|
||||
res << "}";
|
||||
@@ -162,34 +165,42 @@ string dump_entry(const HotDepthEntry& entry) {
|
||||
res << "{ ";
|
||||
res << "'timestamp': " << dump(entry.time()) << ", ";
|
||||
res << "'key': " << entry.key << ", ";
|
||||
|
||||
res << "\n'bid': [";
|
||||
for (const auto& level : entry.direct) {
|
||||
res << dump(level.bid()) << ", ";
|
||||
}
|
||||
res << "], ";
|
||||
|
||||
res << "\n'ask': [";
|
||||
for (const auto& level : entry.direct) {
|
||||
res << dump(level.ask()) << ", ";
|
||||
}
|
||||
res << "], ";
|
||||
|
||||
res << "'\nimplied_bid': [";
|
||||
for (const auto& level : entry.implied) {
|
||||
res << dump(level.bid()) << ", ";
|
||||
}
|
||||
res << "], ";
|
||||
|
||||
res << "'\nimplied_ask': [";
|
||||
for (const auto& level : entry.implied) {
|
||||
res << dump(level.ask()) << ", ";
|
||||
}
|
||||
res << "], ";
|
||||
|
||||
res << "\n'settlement': '" << dump(entry.settlement) << "', ";
|
||||
res << "'settlement': '" << dump(entry.settlement) << "', ";
|
||||
res << "'status': '" << CoconutSecurityStatus_Name((CoconutSecurityStatus)entry.status) << "', ";
|
||||
res << "'sequence': '" << entry.sequence << "', ";
|
||||
|
||||
res << "\n 'bid': [";
|
||||
for (const auto& level : entry.direct) {
|
||||
if (!level.bid().is_nan()) {
|
||||
res << dump(level.bid()) << ", ";
|
||||
}
|
||||
}
|
||||
res << "], ";
|
||||
|
||||
res << "\n 'ask': [";
|
||||
for (const auto& level : entry.direct) {
|
||||
if (!level.ask().is_nan()) {
|
||||
res << dump(level.ask()) << ", ";
|
||||
}
|
||||
}
|
||||
res << "], ";
|
||||
|
||||
res << "\n 'implied_bid': [";
|
||||
for (const auto& level : entry.implied) {
|
||||
if (!level.bid().is_nan()) {
|
||||
res << dump(level.bid()) << ", ";
|
||||
}
|
||||
}
|
||||
res << "], ";
|
||||
|
||||
res << "\n 'implied_ask': [";
|
||||
for (const auto& level : entry.implied) {
|
||||
if (!level.ask().is_nan()) {
|
||||
res << dump(level.ask()) << ", ";
|
||||
}
|
||||
}
|
||||
res << "]";
|
||||
|
||||
res << " }";
|
||||
return res.str();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ enum Platform {
|
||||
PLATFORM_SIM = 1;
|
||||
PLATFORM_MDP3ONIXS = 10;
|
||||
PLATFORM_CELOXICA = 13;
|
||||
PLATFORM_MDP3EMUMBA = 14;
|
||||
}
|
||||
|
||||
enum TradingStatus {
|
||||
|
||||
@@ -429,15 +429,15 @@ struct MDRelayServer : bts::co2::MarketDataRelayBase {
|
||||
api::user::TokenPayload payload;
|
||||
auto ents = _entitlements;
|
||||
const Entitlements* user_entitlement = nullptr;
|
||||
// Temporarily bypass all entitlements
|
||||
bool bypass_entitlement = true;
|
||||
bool bypass_entitlement = false;
|
||||
if (api::auth::decode_token(request.token(), &payload)) {
|
||||
bypass_entitlement = payload.wheel();
|
||||
if (!bypass_entitlement) {
|
||||
user_entitlement = get_entitlements(payload.id(), ents);
|
||||
}
|
||||
}
|
||||
_db.query(request, preply, user_entitlement, bypass_entitlement);
|
||||
// Temporarily bypass all entitlements
|
||||
_db.query(request, preply, user_entitlement, true);
|
||||
reply(*preply);
|
||||
#ifndef _WIN32
|
||||
auto elapsed = (TimeStamp::now() - start);
|
||||
|
||||
@@ -31,6 +31,7 @@ timeval SODPosition::_to_timeval(uint16_t hh, uint16_t mm, uint16_t ss){
|
||||
ptm->tm_hour=hh;
|
||||
ptm->tm_min=mm;
|
||||
ptm->tm_sec=ss;
|
||||
ptm->tm_isdst=-1;
|
||||
secs=mktime(ptm);
|
||||
timeval rv;
|
||||
rv.tv_sec=secs;
|
||||
|
||||
@@ -41,32 +41,32 @@ void produce()
|
||||
producer_handles.push_back(producer.add_security(fsec));
|
||||
|
||||
// initialized bid side book data
|
||||
std::array<md::PriceSize, md::COCONUT_MAX_DEPTH> bids = {
|
||||
md::PriceSize_from_double<7> (1.0,10),
|
||||
md::PriceSize_from_double<7> (2.0,20),
|
||||
md::PriceSize_from_double<7> (3.0,30),
|
||||
md::PriceSize_from_double<7> (4.0,40),
|
||||
md::PriceSize_from_double<7> (5.0,50),
|
||||
md::PriceSize_from_double<7> (6.0,60),
|
||||
md::PriceSize_from_double<7> (7.0,70),
|
||||
md::PriceSize_from_double<7> (8.0,80),
|
||||
md::PriceSize_from_double<7> (9.0,90),
|
||||
md::PriceSize_from_double<7> (10.0,100)
|
||||
};
|
||||
std::array<md::PriceSize, md::COCONUT_MAX_DEPTH> bids {{
|
||||
{ {100000000, -7 }, 100},
|
||||
{ { 90000000, -7 }, 10 },
|
||||
{ { 80000000, -7 }, 20 },
|
||||
{ { 70000000, -7 }, 30 },
|
||||
{ { 60000000, -7 }, 40 },
|
||||
{ { 50000000, -7 }, 50 },
|
||||
{ { 40000000, -7 }, 60 },
|
||||
{ { 30000000, -7 }, 70 },
|
||||
{ { 20000000, -7 }, 80 },
|
||||
{ { 10000000, -7 }, 90 }
|
||||
}};
|
||||
|
||||
// initialized ask side book data
|
||||
std::array<md::PriceSize, md::COCONUT_MAX_DEPTH> asks = {
|
||||
md::PriceSize_from_double<7> (1.0,10),
|
||||
md::PriceSize_from_double<7> (2.0,20),
|
||||
md::PriceSize_from_double<7> (3.0,30),
|
||||
md::PriceSize_from_double<7> (4.0,40),
|
||||
md::PriceSize_from_double<7> (5.0,50),
|
||||
md::PriceSize_from_double<7> (6.0,60),
|
||||
md::PriceSize_from_double<7> (7.0,70),
|
||||
md::PriceSize_from_double<7> (8.0,80),
|
||||
md::PriceSize_from_double<7> (9.0,90),
|
||||
md::PriceSize_from_double<7> (10.0,100)
|
||||
};
|
||||
std::array<md::PriceSize, md::COCONUT_MAX_DEPTH> asks {{
|
||||
{ { 10000000, -7 }, 10 },
|
||||
{ { 20000000, -7 }, 20 },
|
||||
{ { 30000000, -7 }, 30 },
|
||||
{ { 40000000, -7 }, 40 },
|
||||
{ { 50000000, -7 }, 50 },
|
||||
{ { 60000000, -7 }, 60 },
|
||||
{ { 70000000, -7 }, 70 },
|
||||
{ { 80000000, -7 }, 80 },
|
||||
{ { 90000000, -7 }, 90 },
|
||||
{ {100000000, -7 }, 100}
|
||||
}};
|
||||
|
||||
// Update book - this call does not use locks so should not be called concurrently
|
||||
producer_handles[0].update_direct(utils::TimeStamp::now(), bids, asks);
|
||||
|
||||
@@ -195,6 +195,15 @@ void dump_db(const vector<string> args) {
|
||||
md::db::load_securities(symbols, [&](const api::Security& security) {
|
||||
if (all || keys.find(security.id()) != keys.end()) {
|
||||
security.PrintDebugString();
|
||||
if (md::securitytype_of(security) == api::SECURITYTYPE_SYNTHETIC) {
|
||||
auto metadata = md::db::load_metadata();
|
||||
for (const auto &m : metadata) {
|
||||
if(m.security_key() == security.id()) {
|
||||
m.PrintDebugString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ This test verifies that clip limits are followed, and rule precedence works corr
|
||||
|
||||
Use the SIM exchange for all steps.
|
||||
|
||||
0. Pick a future, let's say CLX8, and veryify you can enter orders for it
|
||||
0. Pick a future, let's say CLX8, and verify you can enter orders for it
|
||||
|
||||
1. Pick another future, lets say BZQ8.
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ Prerequisites
|
||||
User settings
|
||||
-------------
|
||||
3. Navigate to http://sparkvm:8000 (or wherever your sparkd resides), Users tab
|
||||
4. Btween bts and bts_2 users, verify that have distinct operator ids (Order Routing tab)
|
||||
4. Between bts and bts_2 users, verify that have distinct operator ids (Order Routing tab)
|
||||
5. In another ssh session on your server, let's tail the sim fix log for orders
|
||||
tail -f ~/sparkdata/data/jetfix/sim/current/fix | grep --line-buffered 35=D | tr '\001' '|'
|
||||
6. Open up a client, login as bts, pick your favorite symbol and submit an order
|
||||
|
||||
@@ -4,25 +4,25 @@ enforced at both the security and account level)
|
||||
Use SIM for all steps of the test
|
||||
|
||||
0. Clear up your orders, fills and admin db so we don't have any lingering positions
|
||||
(run rm -r orders fills admin from /sparkdata/data/databases). Restart your sparkd
|
||||
(run rm -r orders fills admin from ~/sparkdata/data/databases). Restart your sparkd
|
||||
|
||||
1. Pick 2 futures, lets say SIU8 and SIZ8
|
||||
|
||||
2. In the Spark Admin, select the default account for your user (lets say ACC A)
|
||||
and enter a big clip, say 500000, so that clip limits don't interfere with this test.
|
||||
|
||||
3. Go to the Position limits and remove all entries at both the product and security level
|
||||
3. Go to the Position limits and remove all entries
|
||||
|
||||
4. Enter an SIU8 order. It should be rejected. Make sure the rejection message makes sense.
|
||||
|
||||
5. Enter a product level rule for SIM, Future, SI, 60, 120.
|
||||
5. Enter a rule for SIM, Future, SI, 60, 120.
|
||||
|
||||
6. Send 3 10 lot buys for both the futures. Make sure they go through.
|
||||
|
||||
7. Send a 1 lot on SIU8. The product level limit of 60 should not allow it. Make sure the rejection
|
||||
7. Send a 1 lot on SIU8. The limit of 60 should not allow it. Make sure the rejection
|
||||
message is clear.
|
||||
|
||||
8. Change the product level max to 70, and try a 10 lot again. This order should be allowed.
|
||||
8. Change the max to 70, and try a 10 lot again. This order should be allowed.
|
||||
Try another 10 lot and it should be stopped.
|
||||
|
||||
9. Cancel all the orders and try the same for short limit.
|
||||
@@ -7,9 +7,9 @@ iii. leg limits are checked when entering spread orders
|
||||
i:
|
||||
|
||||
1. Pick a 2 legged spread (lets say SIU8-SIZ8). Set the clip limits high for both spreads and futures
|
||||
so that they don't interfere. Remove all Security Position limits.
|
||||
so that they don't interfere.
|
||||
|
||||
2. For the Product Limits, set Max Long and Max Short of 100 and 110
|
||||
2. For the Position Limits, set Max Long and Max Short of 100 and 110
|
||||
for the SI futures and 20 and 30 for the SI spreads respectively.
|
||||
|
||||
3. Verify that the limits set in 2 work for futures(remember working orders count toward limit enforcement so you dont need
|
||||
@@ -17,4 +17,4 @@ fills). Cancel all the orders.
|
||||
|
||||
4. Verify that the limits set in 2. work for spreads. Cancel all the orders.
|
||||
|
||||
5. Make these product limits 1,000,000 to make them irrelevant
|
||||
5. Make these position limits 1,000,000 to make them irrelevant
|
||||
@@ -1,14 +1,14 @@
|
||||
This test verifies that users can only see trades that are in accounts for which they're permissioned
|
||||
|
||||
1. Start a client and the admin gui, choose a user other than bts
|
||||
1. Start a client and the admin gui, choose a user other than bts
|
||||
|
||||
2. For your user, add permissions to see all accounts in the system in the admin gui
|
||||
2. For your user, add permissions to see all accounts in the system in the Spark Admin
|
||||
|
||||
3. Enter some orders in the client for those accounts (you may have to add limits, etc), make some orders fill, cancel some orders
|
||||
|
||||
4. Now close the client, and in the admin UI pick another user (not bts) and remove trading access to the account you just traded into. Start the client again with the user you just de-permissioned. You should not be able to see any of the trades you just made
|
||||
4. Now close the client, and in the admin UI pick another user (not bts) and remove trading access to the accounts you just traded into. Start the client again with the user you just de-permissioned. You should not be able to see any of the trades you just made
|
||||
|
||||
5. Next re-permission your current user for the accounts with trades in them and the should show up in the UI.
|
||||
5. Next re-permission your current user for the accounts with trades in them and they should show up in the UI.
|
||||
|
||||
6. Start another client with -multiple with the original user and make sure you can still see all trades.
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
- Make sure you have limits to trade this future
|
||||
- Select Join order from the menu
|
||||
Label 1) Set join thresh to absolute 10
|
||||
Label 2) Set initial tick offset to 2
|
||||
|
||||
|
||||
The goal of the join order is to watch the opposite-inside market and join when the market *flips and
|
||||
@@ -12,14 +11,9 @@ has at least threshold size
|
||||
*flip is when the best offer becomes the best bid, or the market trades away from you (the line moves up in the gui)
|
||||
|
||||
Label 3) Put an order in to way down in the bid side of the book
|
||||
- Because of the parameter in label 2, the order should instead join two levels below the best bid
|
||||
- Watch the opposite inside market, if it flips make sure the order moves itself to join the new best bid (former offer)
|
||||
|
||||
|
||||
Goto Label 2 and set tick offset to 0
|
||||
{
|
||||
Orders should then go in where you put them
|
||||
}
|
||||
Goto Label l and test the ratio threshold
|
||||
{
|
||||
- Use a threshold of at least 1.0
|
||||
@@ -28,7 +22,7 @@ Goto Label 3 and try a sell order
|
||||
{
|
||||
}
|
||||
|
||||
Now do this test again with "Enable Hedge" checked and hedge ticks set to 1, hedge type set to limit
|
||||
Now do this test again but use a Cover of Join (that's a Cover order with a Join Child and a Limit Hedge, HedgeTicks = 1)
|
||||
|
||||
This should modify the behavior such that the algorithm will send a limit order on the opposite
|
||||
side of the market, one tick away from fill price in a quantity equivalent to the amount of the fill
|
||||
|
||||
@@ -6,11 +6,12 @@ Label 1) Set cross thresh to absolute 10
|
||||
|
||||
The goal of the lean order is to watch the opposite-inside market size and *cross when that size goes below the threshold
|
||||
(this also implies a cross if that size goes to zero and the market trades away from you)
|
||||
(if the market trades toward you, we just start watching the new ask)
|
||||
|
||||
|
||||
*cross means take an order working on the bid and 'cross' by buying into the asks. This is also called 'paying up'
|
||||
|
||||
- Open up order book and fills
|
||||
- Make sure OnToward behavior is set to No Change (not Cancel)
|
||||
Label 2) Put an order in to Join the best bid
|
||||
- Watch the opposite inside market, if it dips below the threshold (or trades away from you) make sure the order moves itself to cross
|
||||
- Verify that the order filled at the offer price
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
|
||||
- Open up a ladder for a liquid future
|
||||
- Make sure you have limits to trade this future
|
||||
- Select Tick order from the menu
|
||||
Label 1) Set cross thresh to absolute 10
|
||||
Label 2) Set initial tick offset to 1
|
||||
|
||||
|
||||
The goal of the tick order is to watch the opposite-inside market size and *cross when that size goes below the threshold
|
||||
(this also implies a cross if that size goes to zero and the market trades away from you)
|
||||
(if the market trades toward you, the algo will 'detach' or become a regular limit order by default)
|
||||
|
||||
*cross means take an order working on the bid and 'cross' by buying into the asks. This is also called 'paying up'
|
||||
|
||||
- Open up order book and fills
|
||||
Label 3) Put an order in to way down in the bid side of the book
|
||||
- Because of the parameter in label 2, the order should instead join at the best bid
|
||||
- Watch the opposite inside market, if it dips below the threshold or the market trades away make sure the order moves itself to cross
|
||||
- Verify that the order filled at the offer price
|
||||
- If the opposite inside market does not dip below threshhold, you should expect to be eventually filled at the bid price
|
||||
- If the opposite inside market trades toward you, you should see the algo detach and the limit be left working
|
||||
- Verify that these fills come in at the proper price, crosses at the offer, working fills at the bid
|
||||
|
||||
|
||||
Goto Label 2 and join the ask instead of the bid
|
||||
{
|
||||
}
|
||||
Goto Label l and test the ratio threshold
|
||||
{
|
||||
- Use a threshold of at least 1.0
|
||||
- Test with a larger order (say 100) to trigger crosses more quickly and across different price levels
|
||||
}
|
||||
@@ -16,13 +16,13 @@ and you may also want to clear your orders for a clean slate:
|
||||
|
||||
Throughout the test we'll refer to accounts ACC A and ACC A1. These specific accounts aren't necessary, but rather that we have fills in multiple distinct accounts.
|
||||
|
||||
Bring up the pnl form (empty) .
|
||||
Bring up the pnl form (empty).
|
||||
Bring up a SIM:SI ladder form, pick your favorite expiration. It should be completely empty since we're controlling the md, and the ACC A account should be selected in the account drop down list.
|
||||
Bring up an order ticket for your corresponding ladder
|
||||
place a buy order with price 14.000 and qty 10
|
||||
your ladder should populate now
|
||||
place a sell order with price 14.010 at qty 10
|
||||
this will give you a valid Midpoint for you PnL Price in the PnL
|
||||
this will give you a valid Midpoint for your PnL Price in the PnL
|
||||
Sell a 1 lot at your bid (14.000)
|
||||
The Start Net Pos should be 0
|
||||
Start Pnl should be 0
|
||||
@@ -33,9 +33,9 @@ Sell a 1 lot at your bid (14.000)
|
||||
PnL Price should be at the midpoint of your bid and ask (14.000 + 14.010)/2 = 14.005.
|
||||
Improve the bid
|
||||
Under ACC A1 account (this is important for the next step), enter a 10 lot bid at 14.005
|
||||
Observe the PnL Price reflect the current Midpoint (14.0075)
|
||||
Switch back to ACC A
|
||||
Sell a 1 lot at the current bid
|
||||
Observe the PnL Price reflect the current Midpoint (14.0075 displayed as 14.010)
|
||||
Switch back to ACC A
|
||||
Sell a 1 lot at the current bid
|
||||
You should now have rows for both the ACC A and ACC A1 account
|
||||
ACC A
|
||||
Day Long 1
|
||||
@@ -44,7 +44,7 @@ Sell a 1 lot at the current bid
|
||||
(14.005 [fill price] - 14.0075 [driver price]) * 1 [qty] * 5000 [cash per point] = -12.50
|
||||
Total Net Pos -1
|
||||
Total PnL = -12.5
|
||||
PnL Price = 14.0075
|
||||
PnL Price = 14.0075 (displayed as 14.010)
|
||||
ACC A1
|
||||
Day Long 1
|
||||
Day Short 0
|
||||
@@ -52,7 +52,7 @@ Sell a 1 lot at the current bid
|
||||
(14.0075 - 14.005) * 1 * 5000
|
||||
Move the market
|
||||
Move your working sell order up to 14.020
|
||||
The PnL Price should update to 14.0125 ((14.020 + 14.005) /2)
|
||||
The PnL Price should update to 14.0125 ((14.020 + 14.005) /2) (displayed as 14.015)
|
||||
The Day and Total PnLs should update to according to the same calculation as earlier
|
||||
ACC A: -37.5
|
||||
ACC A1: 37.5
|
||||
@@ -64,60 +64,57 @@ Check the Totals Footer
|
||||
Force the SOD process to aggregate the fills
|
||||
Configure your sod time to be after your last fill and before now.
|
||||
Note that SODTime is currently expressed in UTC, so you'll have to make the appropriate conversion.
|
||||
|
||||
|
||||
Here is a sample config:
|
||||
|
||||
|
||||
SODTime{
|
||||
value {
|
||||
sod_hh: 15
|
||||
sod_mm: 00
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Restart sparkd and the SOD process should consolidate your day fills so...
|
||||
|
||||
ACC A:
|
||||
|
||||
ACC A:
|
||||
Start Net Pos -1
|
||||
Start PnL -12.5
|
||||
(14.005 - 14.0125) * 2 * 5000 = -75
|
||||
(14.0125 - 14.000) * 1 * 5000 = 62.5
|
||||
-75 + 62.5 = -12.5
|
||||
Start PnL blank
|
||||
Day Long 0
|
||||
Day Short 0
|
||||
Day PnL 0
|
||||
Total Net Pos -1
|
||||
Total PnL -12.5
|
||||
PnL Price 14.0125
|
||||
ACC A1:
|
||||
PnL Price 14.0125 (displayed as 14.015)
|
||||
ACC A1:
|
||||
Start Net Pos 1
|
||||
Start PnL 37.5
|
||||
Start PnL blank
|
||||
Day Long 0
|
||||
Day Short 0
|
||||
Day PnL 0
|
||||
Total Net Pos 1
|
||||
Total PnL 37.5
|
||||
(14.0125 - 14.005) * 1 * 5000
|
||||
PnL Price 14.0125
|
||||
PnL Price 14.0125 (displayed as 14.015)
|
||||
|
||||
Sell a 1 lot as the current bid in ACC A
|
||||
ACC A:
|
||||
Start Net Pos -1 (no change)
|
||||
Start PnL -12.5 (no change)
|
||||
Start PnL -37.5
|
||||
Day Long 0
|
||||
Day Short 1
|
||||
Day PnL -37.5
|
||||
Total Net Pos -2
|
||||
Total PnL -50
|
||||
PnL Price 14.0125
|
||||
ACC A1:
|
||||
PnL Price 14.0125 (displayed as 14.015)
|
||||
ACC A1:
|
||||
Start Net Pos 1 (no change)
|
||||
Start PnL 37.5 (no change)
|
||||
Start PnL 37.5
|
||||
Day Long 1
|
||||
Day Short 0
|
||||
Day PnL 37.5
|
||||
Total Net Pos 2
|
||||
Total PnL 75
|
||||
PnL Price 14.0125
|
||||
PnL Price 14.0125 (displayed as 14.015)
|
||||
|
||||
|
||||
Test sorting and filtering
|
||||
@@ -1,23 +1,22 @@
|
||||
clear your fills and orders database:
|
||||
rm ~/sparkdata/data/databases/fills/*
|
||||
rm ~/sparkdata/data/databases/orders/*
|
||||
and bounce your server.
|
||||
and bounce your server.
|
||||
|
||||
0. We will force fills across for 3 securities, across 2 accounts. Lets pick 2 futures and
|
||||
one exchange traded spread (make sure there are no overlaps). Choose these securities
|
||||
such that there is market data (sim or cert) that you can get fills against (maybe bring up
|
||||
the market view and select securities from there). Bring up the 6 ladders. Make sure the position
|
||||
button the ladder displays -
|
||||
0. We will force fills across for 3 securities, across 2 accounts.
|
||||
a. Pick 2 futures and one exchange traded spread (make sure there are no overlaps).
|
||||
b. Choose these securities such that there is market data (sim or cert) that you can get fills against (maybe bring up the market view and select securities from there).
|
||||
c. Bring up the 6 ladders. Make sure the position button the ladder displays
|
||||
|
||||
1. Force buy and sell fills across the 6 ladders. Keep track
|
||||
of the long and short positions and verify that that the position
|
||||
button in the ladder is reflecting the net position carefully.
|
||||
|
||||
Open up the PNL and make sure the Day Long and Day Short positions match what you expect.
|
||||
The Start Net Pos should be 0. (The Total Net Pos in the PNL should match the pos button
|
||||
The Start Net Pos should be 0. (The Total Net Pos in the PNL should match the pos button
|
||||
in the ladder)
|
||||
|
||||
2. Now comes the SOD part. The SOD is what demarkates a day. Find the most recent time on your fills, select 1 minute past that and convert it to UTC and override the SOD time in your spark.conf
|
||||
2. Now comes the SOD part. The SOD is what demarcates a day. Find the most recent time on your fills, select 1 minute past that and convert it to UTC and override the SOD time in your spark.conf
|
||||
|
||||
Here's an example of what the key looks like:
|
||||
|
||||
@@ -30,10 +29,8 @@ SODTime{
|
||||
|
||||
3. Now restart the server. Verify that all rows in the fills have a Fill Kind 'Sod' and the time matches the SODTime (converted to your local time zone)
|
||||
|
||||
4. Verify that the ladder is displaying the correct position (it should be the same as before
|
||||
the server start)
|
||||
4. Verify that the ladder is displaying the correct position (it should be the same as before the server start)
|
||||
|
||||
5. Verify that the PNL is displaying the correct Start Net Pos and the Day part is 0.
|
||||
|
||||
6. Now force a few more fills. Verify that the ladder position box and the PNL is
|
||||
correctly counting them.
|
||||
6. Now force a few more fills. Verify that the ladder position box and the PNL is correctly counting them.
|
||||
@@ -1,7 +1,7 @@
|
||||
----Grid Settings Test (11 minutes) ---------
|
||||
|
||||
1) Open the Orderbook
|
||||
2) Click the Window Settings button at the bottom of the Spark menu to open the settings dialog
|
||||
2) Click the Settings button at the bottom of the Spark menu to open the settings dialog
|
||||
|
||||
----Columns----------------------------------
|
||||
|
||||
|
||||
@@ -14,21 +14,16 @@ Sound and Notifications Test (15 min)-------------------------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
0) Prepare:
|
||||
- Sounds are enabled by default, but we now have a key that can enable/disable them from the server as well. This was necessary to prevent crashing on systems without connected sound devices. If this key exists in your spark.conf, please make sure it's enabled = true (or simply remove it)
|
||||
SoundNotifications {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
- open an OrderBook, then click the Window Settings button in the Spark Menu to open the OWSD.
|
||||
- *add a sound trigger.
|
||||
|
||||
1) Sound Preview/Author Credentials:
|
||||
1) Sound Preview:
|
||||
First: check "Play Sound" (if it is not already checked)
|
||||
Perform the following steps for each trigger in the dropdown, the variable sound will be reffered to as 'X'
|
||||
- select 'X'
|
||||
- hover over the "?" help button next to the dropdown
|
||||
- the tool tip should contain some basic info about 'X':
|
||||
i) [Required] the official name (it may not exactly match the name in the dropdown, but it should be similar in subject matter, e.g. "Reload" vs "1911 Reload")
|
||||
ii) [Required] the author's name or username (e.g. "zstewart09")
|
||||
iii) [Optional] a url to the author's own site/account page (e.g. https://freesound.org/people/kianda/sounds/)
|
||||
- the last line in the tool tip should say: "Click to preview, Ctrl + click to copy to clipboard"
|
||||
- click the "?" button to confirm the preview works,
|
||||
- ctrl + click the "?" button, then paste the result in a text editor, it should be identical to the tool tip (except the last line, with clicking instructions)
|
||||
|
||||
2) Duplicate sound triggers do not cause crash:
|
||||
- *delete the sound trigger you added in the previous step.
|
||||
@@ -85,47 +80,8 @@ Prepare: open a ladder for a security that has steady market data activity (in t
|
||||
- enter a limit order ACROSS the market to trigger an immediate fill.
|
||||
- this time, the "When order is filled" sound should play; the "When order is canceled" sound should not be heard.
|
||||
|
||||
7) Toast Notifications:
|
||||
A) Simultaneously with sounds:
|
||||
- in the OWSD, check "Show Notification" for both the "filled" and "canceled" sound-triggers, then click apply.
|
||||
- enter a 1 lot limit order across the market to trigger an immediate fill.
|
||||
- as soon as it is filled, you should see a notification AND hear the sound.
|
||||
B) Without sounds:
|
||||
- in the OWSD, uncheck "Play Sound" in the "When order is filled" trigger.
|
||||
- you should be a pro by now, no more redundant baby talk: trigger an immediate fill.
|
||||
- you should see the filled notification, but not hear the sound.
|
||||
C) Rapid fire fills:
|
||||
- open a Fills window.
|
||||
- trigger a rapid succession of 1 lot limit order fills as you did earlier, by repeatedly clicking on a price well-across the market
|
||||
- the toast notifications should keep pace with the fills, as they arrive in the Fills window.
|
||||
- if it is hard to tell, most likely that means it is keeping up.
|
||||
- if the notifications continue to arrive more than a few seconds after the fills window has finished updating.
|
||||
D) Settings:
|
||||
First: in the OWSD, check "Play Sounds," then click OK (both sounds and notifications should be enabled now).
|
||||
----Notes---------------------------------------------------------------------------------------------------------------
|
||||
- you will be opening the Notification Settings Dialog (NSD), there are only a couple of properties in this form,
|
||||
so there is no "Apply" button, only an "OK" button which applies the changes and closes the window.
|
||||
the steps will not tell you to open the NSD again each time you need to change a different setting, but yes, that is what you need to do.
|
||||
If this is terribly annoying, tell John and he might add an "Apply" button for you ;)
|
||||
- this dialog contains "application-level" settings, which override Window settings.
|
||||
- if sounds/notifications are disabled here, any sounds/notifications in OrderBook Window Settings will be ignored.
|
||||
- COMING SOON: if they are disabled, the Orderbook settings dialog will indicate this to the user,
|
||||
to avoid potential frustration they might endure as they wonder why the notifications/sounds aren't working.
|
||||
-------------------------------------------------------------------------------------------------------------------------
|
||||
- from the launcher: Settings -> Settings to open the Notification Settings dialog.
|
||||
Note: this dialog also has 1 setting for sounds.
|
||||
- disable sounds (this should be obvious, it's just a checkbox), then click OK.
|
||||
- trigger a fill, and verify that the notification is shown, but the sound is not heard.
|
||||
- in the notification settings dialog, disable toast notifications, the click OK.
|
||||
- trigger a fill, and verify that neither the notification nor the sound are shown/played.
|
||||
- enable both sounds and notifications again.
|
||||
- trigger a fill, and verify that the sound is heard, and the notification shown.
|
||||
- in the NSD, change the Toast Notification "Flash Duration" to 1 second (or any duration that is different enough from the current, so that the difference is easily detectable), click OK.
|
||||
- trigger a fill, the notification box should disappear after thet appropriate time.
|
||||
- in the NSD, chagne the Toast Notification "Mode" to "Manual" (the duration control should be disabled now).
|
||||
- trigger a fill, the NSD should NOT dissappear.
|
||||
|
||||
8) Saved with workspace:
|
||||
7) Saved with workspace:
|
||||
----Note----------------------------------------------------------------------------------------------------------------------
|
||||
- you have completed the sound-functionality testing, don't be alarmed by the 4 sound triggers you are about to add.
|
||||
- this step just requires comparing 2 images of the settings dialog to confirm that they were retained with the workspace.
|
||||
@@ -136,11 +92,23 @@ Prepare: open a ladder for a security that has steady market data activity (in t
|
||||
- you may replace sounds referred to as 'A' and 'B' with whatever you like; if such free will is too cumbersome, A=Game Sound Correct, B=Powerup)
|
||||
- the steps won't specifically say "check Play Sound," but if the trigger has a sound, check it, otherwise don't.
|
||||
i) "When order is filled", "(any order)", Sound 'A'
|
||||
ii) "When order is filled", "(choose securities)" pick any 2 securities, Sound 'B', enable "Show Notifications"
|
||||
ii) "When order is filled", "(choose securities)" pick any 2 securities, Sound 'B'
|
||||
iii) "When order is canceled", "(any order)", Sound 'B'
|
||||
- close the shell, then restart it with the "Where I left off on" workspace.
|
||||
- open the OWSD to verify that the sound triggers were saved with the workspace.
|
||||
|
||||
8) Test shell does not crash when no sound card present
|
||||
- use a machine that does not have a sound card, such as eh-2 (check with Eric first)
|
||||
- update config to turn off sounds
|
||||
|
||||
SoundNotifications {
|
||||
enabled = false
|
||||
}
|
||||
- restart your shell to pick up your config change
|
||||
- Pressing the Preview Sound button should not crash the shell
|
||||
- Having a sound notification triggered by the orderbook should not crash the shell
|
||||
|
||||
|
||||
TEST COMPLETE-----------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user