Merge branch 'master' of bitbucket.org:bluetradesys/spark
This commit is contained in:
commit
a4296f1b79
118 files changed
+334
-102
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
-3
@@ -2,9 +2,6 @@
|
||||
|
||||
namespace mbts.ui.spark
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for TimeAndSalesView.xaml
|
||||
/// </summary>
|
||||
public partial class TimeAndSalesView : UserControl
|
||||
{
|
||||
public enum Columns { TradeTime, Security, Price, Size, OrderType }
|
||||
File renamed without changes.
+44
-75
@@ -20,28 +20,23 @@ using System.IO;
|
||||
using System.Windows.Input;
|
||||
using System.Windows;
|
||||
|
||||
namespace mbts.spark {
|
||||
internal class ContractPickerModel : ViewModelBase {
|
||||
namespace mbts.spark
|
||||
{
|
||||
internal class ContractPickerModel : ViewModelBase
|
||||
{
|
||||
|
||||
|
||||
public ContractPickerModel(IBus bus, bool edit_mode, SecurityCriteria instrument_criteria)
|
||||
{
|
||||
public ContractPickerModel(IBus bus, bool edit_mode, SecurityCriteria instrument_criteria) {
|
||||
_bus = bus;
|
||||
if (instrument_criteria == null)
|
||||
{
|
||||
if (instrument_criteria == null) {
|
||||
_search_criteria = new SecurityCriteria();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
_search_criteria = instrument_criteria;
|
||||
}
|
||||
is_edit_mode = edit_mode;
|
||||
_subs.Add(_bus.subscribe(SecuritiesTag).Subscribe(on_securities_changed));
|
||||
|
||||
add_criteria_command = new DelegateCommand(_ =>
|
||||
{
|
||||
security_criteria.Add(new SecurityCriteriaClause()
|
||||
{
|
||||
add_criteria_command = new DelegateCommand(_ => {
|
||||
security_criteria.Add(new SecurityCriteriaClause() {
|
||||
pretty_name = criteria_input_name,
|
||||
exchanges = selected_exchanges.ToArray(),
|
||||
security_types = selected_security_types.ToArray(),
|
||||
@@ -52,8 +47,7 @@ namespace mbts.spark {
|
||||
ok_button_command.TryRaiseCanExecuteChanged();
|
||||
});
|
||||
|
||||
remove_criteria_command = new DelegateCommand(_ =>
|
||||
{
|
||||
remove_criteria_command = new DelegateCommand(_ => {
|
||||
security_criteria.Remove(selected_security_criteria_clause);
|
||||
ok_button_command.TryRaiseCanExecuteChanged();
|
||||
});
|
||||
@@ -69,47 +63,36 @@ namespace mbts.spark {
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private readonly IBus _bus;
|
||||
private IList<IDisposable> _subs = new List<IDisposable>();
|
||||
|
||||
private void _compose_criteria_clause_name()
|
||||
{
|
||||
private void _compose_criteria_clause_name() {
|
||||
string proposed_name = string.Empty;
|
||||
if (selected_securities.Count > 0)
|
||||
{
|
||||
if (selected_securities.Count > 0) {
|
||||
proposed_name = all_securities.Where(s => selected_securities.Contains(s.Key)).Select(sec => sec.Value.security.ToString()).Aggregate((i, j) => $"{i} and {j}");
|
||||
} else if (selected_symbols.Count > 0)
|
||||
{
|
||||
} else if (selected_symbols.Count > 0) {
|
||||
proposed_name = $"{selected_symbols.Aggregate((i, j) => $"{i} and {j}")}";
|
||||
if (selected_security_types.Count > 0)
|
||||
{
|
||||
proposed_name += $" {selected_security_types.Select(sec_type => sec_type.ToString()).Aggregate((i,j) => $"{i}s and {j}s")}";
|
||||
if (selected_security_types.Count > 0) {
|
||||
proposed_name += $" {selected_security_types.Select(sec_type => sec_type.ToString()).Aggregate((i, j) => $"{i}s and {j}s")}";
|
||||
}
|
||||
if (selected_exchanges.Count > 0)
|
||||
{
|
||||
proposed_name += $" at {selected_exchanges.Select(exch => exch.ToString()).Aggregate((i,j) => $"{i} and {j}")}";
|
||||
}
|
||||
} else if (selected_security_types.Count > 0)
|
||||
{
|
||||
proposed_name = $"{selected_security_types.Select(sec_type => sec_type.ToString()).Aggregate((i, j) => $"{i}s and {j}s")}";
|
||||
if (selected_exchanges.Count > 0)
|
||||
{
|
||||
if (selected_exchanges.Count > 0) {
|
||||
proposed_name += $" at {selected_exchanges.Select(exch => exch.ToString()).Aggregate((i, j) => $"{i} and {j}")}";
|
||||
}
|
||||
} else if (selected_exchanges.Count > 0)
|
||||
{
|
||||
} else if (selected_security_types.Count > 0) {
|
||||
proposed_name = $"{selected_security_types.Select(sec_type => sec_type.ToString()).Aggregate((i, j) => $"{i}s and {j}s")}";
|
||||
if (selected_exchanges.Count > 0) {
|
||||
proposed_name += $" at {selected_exchanges.Select(exch => exch.ToString()).Aggregate((i, j) => $"{i} and {j}")}";
|
||||
}
|
||||
} else if (selected_exchanges.Count > 0) {
|
||||
proposed_name = $"{selected_exchanges.Select(exch => exch.ToString()).Aggregate((i, j) => $"{i} and {j}")}";
|
||||
}
|
||||
criteria_input_name = proposed_name;
|
||||
}
|
||||
|
||||
internal void exchange_selection_changed(IEnumerable<Venue> exchanges)
|
||||
{
|
||||
internal void exchange_selection_changed(IEnumerable<Venue> exchanges) {
|
||||
selected_exchanges = exchanges.ToList();
|
||||
symbols.sync_with(UserSymbol.get_all()
|
||||
.Where(s => exchanges.Contains(s.exchange))
|
||||
@@ -120,22 +103,19 @@ namespace mbts.spark {
|
||||
_compose_criteria_clause_name();
|
||||
}
|
||||
|
||||
internal void security_type_selection_changed(IEnumerable<SecurityType> security_types)
|
||||
{
|
||||
internal void security_type_selection_changed(IEnumerable<SecurityType> security_types) {
|
||||
selected_security_types = security_types.ToList();
|
||||
_update_securities();
|
||||
_compose_criteria_clause_name();
|
||||
}
|
||||
|
||||
internal void symbol_selection_changed(IEnumerable<string> symbols)
|
||||
{
|
||||
internal void symbol_selection_changed(IEnumerable<string> symbols) {
|
||||
selected_symbols = symbols.ToList();
|
||||
_update_securities();
|
||||
_compose_criteria_clause_name();
|
||||
}
|
||||
|
||||
internal void security_selection_changed(IEnumerable<SecurityImmutable> secs)
|
||||
{
|
||||
internal void security_selection_changed(IEnumerable<SecurityImmutable> secs) {
|
||||
selected_securities = secs.Select(s => s.Id).ToList();
|
||||
ok_button_command.TryRaiseCanExecuteChanged();
|
||||
_compose_criteria_clause_name();
|
||||
@@ -145,19 +125,16 @@ namespace mbts.spark {
|
||||
//var results = all_securities.Select(all => all.Value.security).Where(x => _security_in_criteria(x)).ToList();
|
||||
}
|
||||
|
||||
private void on_securities_changed(IReadOnlyDictionary<uint, SecurityMD> changed_securities)
|
||||
{
|
||||
private void on_securities_changed(IReadOnlyDictionary<uint, SecurityMD> changed_securities) {
|
||||
all_securities = changed_securities;
|
||||
securities.sync_with(changed_securities
|
||||
.Select(entry => entry.Value.security)
|
||||
);
|
||||
_update_securities();
|
||||
}
|
||||
internal void criteria_selection_changed(SecurityCriteriaClause changed_clause)
|
||||
{
|
||||
internal void criteria_selection_changed(SecurityCriteriaClause changed_clause) {
|
||||
selected_security_criteria_clause = changed_clause;
|
||||
if (changed_clause != null)
|
||||
{
|
||||
if (changed_clause != null) {
|
||||
SecurityCriteriaClauseChangedEventsArgs args = new SecurityCriteriaClauseChangedEventsArgs();
|
||||
args.securities = all_securities.Where(s => changed_clause.security_keys.Contains(s.Key)).Select(sec => sec.Value.security).ToArray();
|
||||
args.clause = changed_clause;
|
||||
@@ -166,8 +143,7 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void on_security_criteria_clause_changed(SecurityCriteriaClauseChangedEventsArgs e)
|
||||
{
|
||||
protected virtual void on_security_criteria_clause_changed(SecurityCriteriaClauseChangedEventsArgs e) {
|
||||
security_criteria_clause_changed?.Invoke(this, e);
|
||||
}
|
||||
|
||||
@@ -190,20 +166,19 @@ namespace mbts.spark {
|
||||
public ObservableCollection<SecurityCriteriaClause> security_criteria { get; } = new ObservableCollection<SecurityCriteriaClause>();
|
||||
|
||||
private SecurityCriteriaClause _selected_security_criteria_clause = new SecurityCriteriaClause();
|
||||
public SecurityCriteriaClause selected_security_criteria_clause
|
||||
{
|
||||
public SecurityCriteriaClause selected_security_criteria_clause {
|
||||
get { return _selected_security_criteria_clause; }
|
||||
set
|
||||
{
|
||||
_selected_security_criteria_clause = value;
|
||||
RaisePropertyChanged("selected_security_criteria_clause");
|
||||
}
|
||||
set {
|
||||
_selected_security_criteria_clause = value;
|
||||
RaisePropertyChanged("selected_security_criteria_clause");
|
||||
}
|
||||
}
|
||||
|
||||
private string _criteria_input_name;
|
||||
public string criteria_input_name {
|
||||
get { return _criteria_input_name; }
|
||||
set { _criteria_input_name = value;
|
||||
set {
|
||||
_criteria_input_name = value;
|
||||
RaisePropertyChanged("criteria_input_name");
|
||||
}
|
||||
}
|
||||
@@ -216,8 +191,7 @@ namespace mbts.spark {
|
||||
public event EventHandler<SecurityCriteriaClauseChangedEventsArgs> security_criteria_clause_changed;
|
||||
|
||||
public SecurityMD result {
|
||||
get
|
||||
{
|
||||
get {
|
||||
SecurityCriteriaClause scc = new SecurityCriteriaClause();
|
||||
scc.security_keys = selected_securities;
|
||||
SecurityCriteria crit = new SecurityCriteria(new SecurityCriteriaClause[] { scc });
|
||||
@@ -231,8 +205,7 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
|
||||
private void _update_securities()
|
||||
{
|
||||
private void _update_securities() {
|
||||
securities.sync_with(all_securities
|
||||
.Select(all => all.Value.security)
|
||||
// exchange filtering
|
||||
@@ -247,20 +220,17 @@ namespace mbts.spark {
|
||||
);
|
||||
}
|
||||
|
||||
public static bool security_in_criteria(SecurityCriteria criteria, SecurityImmutable sec_item)
|
||||
{
|
||||
foreach (SecurityCriteriaClause x in criteria.clauses)
|
||||
{
|
||||
public static bool security_in_criteria(SecurityCriteria criteria, SecurityImmutable sec_item) {
|
||||
foreach (SecurityCriteriaClause x in criteria.clauses) {
|
||||
bool check_exchanges = !(x.exchanges == null || x.exchanges.Length == 0);
|
||||
bool check_security_types = !(x.exchanges == null || x.security_types.Length == 0);
|
||||
bool check_symbols = !(x.symbols == null || x.symbols.Length == 0);
|
||||
bool check_security_keys = !(x.security_keys == null || x.security_keys.Count == 0);
|
||||
bool check_something_in_clause = check_exchanges || check_security_types || check_symbols || check_security_keys;
|
||||
|
||||
if (check_something_in_clause)
|
||||
{
|
||||
if (check_something_in_clause) {
|
||||
// we're checking something in here, so we want this to be a no-op in an && clause, so it has to be true
|
||||
bool iteration_result = true;
|
||||
bool iteration_result = true;
|
||||
if (check_exchanges) iteration_result = iteration_result && x.exchanges.Any(exchange => exchange == sec_item.Exchange);
|
||||
if (check_security_types) iteration_result = iteration_result && x.security_types.Any(sec_type => sec_type == sec_item.security_type());
|
||||
if (check_symbols) iteration_result = iteration_result && x.symbols.Any(sym => sym == sec_item.Symbol);
|
||||
@@ -271,8 +241,7 @@ namespace mbts.spark {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
public void Dispose() {
|
||||
Disposable.dispose(_subs);
|
||||
}
|
||||
|
||||
+33
-24
@@ -9,43 +9,48 @@
|
||||
<UserControl.Resources>
|
||||
<converters:BooleanToObjectConverter x:Key="bool_to_selectmode" ValueForTrue="Extended" ValueForFalse="One" />
|
||||
</UserControl.Resources>
|
||||
<DockPanel>
|
||||
<Grid Grid.IsSharedSizeScope="True" DockPanel.Dock="Top" Margin="12,0,12,0">
|
||||
<StackPanel>
|
||||
<Grid Grid.IsSharedSizeScope="True" Margin="12,0,12,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="250"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="300"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition SharedSizeGroup="share_col_width" Width="Auto"/>
|
||||
<ColumnDefinition SharedSizeGroup="share_col_width" Width="Auto"/>
|
||||
<ColumnDefinition SharedSizeGroup="share_col_width" Width="Auto"/>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition MinWidth="300" Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox Grid.Row="0" Grid.Column="0" Header="Exchanges">
|
||||
<ListBox x:Name="_exchanges" Grid.Row ="1" Grid.Column="0" SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}" ItemsSource="{Binding all_exchanges}" Margin="2" ></ListBox>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Row="0" Grid.Column="1" Header="Types">
|
||||
<ListBox x:Name="_security_types" Grid.Row ="1" Grid.Column="1" SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}" ItemsSource="{Binding security_types}" Margin="2"></ListBox>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Row="0" Grid.Column="2" Header="Symbols">
|
||||
<ListBox x:Name="_symbols" Grid.Row ="1" Grid.Column="2" SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}" ItemsSource="{Binding symbols}" Margin="2"></ListBox>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Row="0" Grid.Column="3" Header="Instruments">
|
||||
<ListBox x:Name="_securities" Grid.Row ="1" Grid.Column="3" SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}" ItemsSource="{Binding securities}" Margin="2" ></ListBox>
|
||||
</GroupBox>
|
||||
<Label Grid.Row ="0" Grid.Column="0" Content="Exchange"></Label>
|
||||
<Label Grid.Row ="0" Grid.Column="1" Content="Typs"></Label>
|
||||
<Label Grid.Row ="0" Grid.Column="2" Content="Symbols"></Label>
|
||||
<Label Grid.Row ="0" Grid.Column="3" Content="Securities"></Label>
|
||||
<ListBox x:Name="_exchanges" Grid.Row ="1" Grid.Column="0" SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}" ItemsSource="{Binding all_exchanges}" Margin="2,0,2,2" ></ListBox>
|
||||
<ListBox x:Name="_security_types" Grid.Row ="1" Grid.Column="1" Margin="2,0,2,2"
|
||||
SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}"
|
||||
ItemsSource="{Binding security_types}">
|
||||
</ListBox>
|
||||
<ListBox x:Name="_symbols" Grid.Row ="1" Grid.Column="2" Margin="2,0,2,2"
|
||||
SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}"
|
||||
ItemsSource="{Binding symbols}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible">
|
||||
</ListBox>
|
||||
<ListBox x:Name="_securities" Grid.Row ="1" Grid.Column="3" Margin="2,0,2,2"
|
||||
SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}"
|
||||
ItemsSource="{Binding securities}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||
HorizontalAlignment="Stretch">
|
||||
</ListBox>
|
||||
</Grid>
|
||||
<UniformGrid HorizontalAlignment="Right" Rows="1" Columns="2" DockPanel.Dock="Bottom" Margin="0,12,12,12">
|
||||
<Button Width="50" Margin="12,0,0,0" Command="{Binding ok_button_command}">Ok</Button>
|
||||
<Button Width="50" Margin="12,0,0,0" Command="ApplicationCommands.Close">Cancel</Button>
|
||||
</UniformGrid>
|
||||
<GroupBox Header="Picked instruments" DockPanel.Dock="Bottom" Margin="12,0,12,0" Visibility="{Binding is_edit_mode, Converter={StaticResource BoolToVisibility}}">
|
||||
<GroupBox Header="Picked instruments" Margin="12,0,12,0" Visibility="{Binding is_edit_mode, Converter={StaticResource BoolToVisibility}}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*" MinHeight="100"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="3*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Row="0" Grid.Column="0" Text="{Binding criteria_input_name}" Margin="2" IsReadOnly="True"></TextBox>
|
||||
<Button Grid.Row="0" Grid.Column="1" Command="{Binding add_criteria_command}" Margin="2" HorizontalAlignment="Left" Width="50">Add</Button>
|
||||
@@ -53,5 +58,9 @@
|
||||
<Button Grid.Row="1" Grid.Column="1" Command="{Binding remove_criteria_command}" Margin="2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="50">Remove</Button>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</DockPanel>
|
||||
<UniformGrid HorizontalAlignment="Right" Rows="1" Columns="2" Margin="0,12,12,12">
|
||||
<Button Width="50" Margin="12,0,0,0" Command="{Binding ok_button_command}">Ok</Button>
|
||||
<Button Width="50" Margin="12,0,0,0" Command="ApplicationCommands.Close">Cancel</Button>
|
||||
</UniformGrid>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 118 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user