time and sales - fix sorting, add trade key column
This commit is contained in:
1 parent
707b445e31
commit
dcbfadb413
5 files changed
+31
-21
No files matched your search
@@ -1,5 +1,4 @@
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.co2;
|
||||
using mbts.ui;
|
||||
using mbts.ui.utility;
|
||||
@@ -25,9 +24,10 @@ namespace mbts.spark
|
||||
security_filter.load_state(filters.security);
|
||||
price_filter.load_state(filters.price);
|
||||
size_filter.load_state(filters.size);
|
||||
trade_key_filter.load_state(filters.trade_key);
|
||||
security_key_filter.load_state(filters.security_key);
|
||||
}
|
||||
_resources.AddRange(show_ladder, hook_filters(rows_view, time_filter, security_filter, price_filter, size_filter, security_key_filter));
|
||||
_resources.AddRange(show_ladder, hook_filters(rows_view, time_filter, security_filter, price_filter, size_filter, trade_key_filter, security_key_filter));
|
||||
}
|
||||
|
||||
protected override Row row_factory(TradeInfo row_model) => new Row(this, row_model.security, row_model.trade);
|
||||
@@ -46,6 +46,7 @@ namespace mbts.spark
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> price_filter { get; } = new DoubleMinMax<Row>(r => r.price, nameof(Row.price));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> size_filter { get; } = new UIntMinMax<Row>(r => r.size, nameof(Row.size));
|
||||
public IDataGridColumnPersistentFilter<Row, string> security_key_filter { get; } = new RegexFinder<Row>(r => r.security_key.ToString(), nameof(Row.security_key));
|
||||
public IDataGridColumnPersistentFilter<Row, string> trade_key_filter { get; } = new RegexFinder<Row>(r => r.trade_key.ToString(), nameof(Row.trade_key));
|
||||
|
||||
public FilterStates get_filter_states() =>
|
||||
new FilterStates {
|
||||
@@ -53,22 +54,31 @@ namespace mbts.spark
|
||||
security = security_filter.get_state(),
|
||||
price = price_filter.get_state(),
|
||||
size = size_filter.get_state(),
|
||||
trade_key = trade_key_filter.get_state(),
|
||||
security_key = security_key_filter.get_state()
|
||||
};
|
||||
#endregion
|
||||
|
||||
public class Row : SecurityRow {
|
||||
public class Row : SecurityRow, IEquatable<Row> {
|
||||
readonly uint _trade_key;
|
||||
|
||||
public Row(TimeAndSalesVM parent, SecurityImmutable security, TradeMessageImmutable trade) : base(security) {
|
||||
_trade_key = trade.Key;
|
||||
time = trade.Time.lldatetime();
|
||||
price = trade.Mantissa * Math.Pow(10, trade.Exponent);
|
||||
size = trade.Size;
|
||||
show_ladder = new DelegateCommand(() => parent._show_ladder_async(this).ignore());
|
||||
}
|
||||
|
||||
public uint trade_key => _trade_key;
|
||||
public DateTime time { get; }
|
||||
public double price { get; }
|
||||
public uint size { get; }
|
||||
public ICommand show_ladder { get; }
|
||||
|
||||
public bool Equals(Row other) => other != null && other._trade_key == _trade_key;
|
||||
public override bool Equals(object obj) => Equals(obj as Row);
|
||||
public override int GetHashCode() => _trade_key.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.security_filter, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterActive="{Binding DataContext.security_filter.active, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterTemplate="{StaticResource RegexFinder}"/>
|
||||
<DataGridTextColumn Header="Time" Binding="{Binding time, StringFormat='M/d H:mm:ss'}"
|
||||
<DataGridTextColumn Header="Time" Binding="{Binding time, StringFormat='M/d h:mm:ss tt'}"
|
||||
c:DataGridEx.CellKey="{u:Enum Time, Type={u:Nested usp:TimeAndSalesView.Columns}}"
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.time_filter, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterActive="{Binding DataContext.time_filter.active, Source={u:DirectReference grid}}"
|
||||
@@ -54,6 +54,11 @@
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.size_filter, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterActive="{Binding DataContext.size_filter.active, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterTemplate="{StaticResource UIntMinMaxTemplate}"/>
|
||||
<DataGridTextColumn Header="Trade Key" Binding="{Binding trade_key}"
|
||||
c:DataGridEx.CellKey="{u:Enum TradeKey, Type={u:Nested usp:TimeAndSalesView.Columns}}"
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.trade_key_filter, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterActive="{Binding DataContext.trade_key_filter.active, Source={u:DirectReference grid}}"
|
||||
c:DataGridFilterProperties.FilterTemplate="{StaticResource RegexFinder}"/>
|
||||
<DataGridTextColumn Header="Security Key" Width="*" Binding="{Binding security_key}"
|
||||
c:DataGridEx.CellKey="{u:Enum SecurityKey, Type={u:Nested usp:TimeAndSalesView.Columns}}"
|
||||
c:DataGridFilterProperties.Filter="{Binding DataContext.security_key_filter, Source={u:DirectReference grid}}"
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
using mbts.spark;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace mbts.ui.spark
|
||||
{
|
||||
public partial class TimeAndSalesView : UserControl
|
||||
{
|
||||
public enum Columns { Time, Security, Price, Size, OrderType, SecurityKey }
|
||||
namespace mbts.ui.spark {
|
||||
public partial class TimeAndSalesView : UserControl {
|
||||
public enum Columns { Time, Security, Price, Size, OrderType, TradeKey, SecurityKey }
|
||||
|
||||
internal TimeAndSalesView(TimeAndSalesVM vm) {
|
||||
internal TimeAndSalesView() =>
|
||||
InitializeComponent();
|
||||
DataContext = vm;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,8 @@ using System.Reactive.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.spark
|
||||
{
|
||||
class TimeAndSalesWindow : SparkWindow<TimeAndSalesWindowFactory.StartupData>
|
||||
{
|
||||
namespace mbts.spark {
|
||||
class TimeAndSalesWindow : SparkWindow<TimeAndSalesWindowFactory.StartupData> {
|
||||
readonly MDConsumer _consumer;
|
||||
readonly TimeAndSalesWindowFactory _factory;
|
||||
|
||||
@@ -55,7 +53,7 @@ namespace mbts.spark
|
||||
public override UIElement Content => _view;
|
||||
public override IEnumerable<SparkCommand> Commands { get; }
|
||||
public override TimeAndSalesWindowFactory.StartupData SaveState => _state = new TimeAndSalesWindowFactory.StartupData(_state.security_criteria, _vm.Current.rows_view.GetSortingCriteria(), _vm.Current.get_filter_states());
|
||||
public override double MinWidth => 290 + SPARK_MENU_COLLAPSED_WIDTH + LAUNCHER_BUTTON_BORDER_WIDTH;
|
||||
public override double MinWidth => 444 + SPARK_MENU_COLLAPSED_WIDTH + LAUNCHER_BUTTON_BORDER_WIDTH;
|
||||
|
||||
public override void Dispose() {
|
||||
Disposable.dispose(ref _subscriptions);
|
||||
@@ -69,7 +67,7 @@ namespace mbts.spark
|
||||
var model = new TimeAndSalesModel(_bus, _consumer, _state.security_criteria);
|
||||
_vm.Push(new TimeAndSalesVM(_bus, model, state.sorting_criteria, state.filters));
|
||||
if (_view == null)
|
||||
_view = new TimeAndSalesView(_vm.Current);
|
||||
_view = new TimeAndSalesView { DataContext = _vm.Current };
|
||||
else
|
||||
_view.DataContext = _vm.Current;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ namespace bts.shell
|
||||
[ProtoMember(4)]
|
||||
public UIntMinMaxState size;
|
||||
[ProtoMember(5)]
|
||||
public string trade_key;
|
||||
[ProtoMember(6)]
|
||||
public string security_key;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user