Merge branch 'master' of bitbucket.org:bluetradesys/spark
This commit is contained in:
commit
2e091ba290
13 files changed
+325
-195
No files matched your search
Vendored
+17
@@ -1,6 +1,23 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"stopOnEntry": false,
|
||||
"pythonPath": "${config:python.pythonPath}",
|
||||
"program": "${file}",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"env": {},
|
||||
"envFile": "${workspaceRoot}/.env",
|
||||
"args": [ "DEBUG" ],
|
||||
"debugOptions": [
|
||||
"WaitOnAbnormalExit",
|
||||
"WaitOnNormalExit",
|
||||
"RedirectOutput"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "WSL Launch",
|
||||
"type": "cppdbg",
|
||||
|
||||
+1
-1
Submodule externals updated: d71750db2a...56d97f6b28.
@@ -32,20 +32,6 @@ namespace mbts.spark {
|
||||
Logger.info(bts.log.Subsystem.ui, $"Cancel {ct}");
|
||||
}
|
||||
|
||||
public IMessage[] default_orders {
|
||||
get {
|
||||
return new IMessage[] {
|
||||
new MarketOrder (),
|
||||
new LimitOrder (),
|
||||
new StopMarketOrder (),
|
||||
new StopLimitOrder (),
|
||||
new IcebergOrder(),
|
||||
new BTSStopOrder (),
|
||||
new BTSIcebergOrder ()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public OrdersModel order_gateway => _order_gateway;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ using bts.spark;
|
||||
using Google.Protobuf;
|
||||
using bts.api;
|
||||
using mbts.ui.utility;
|
||||
using mbts.spark.utilities;
|
||||
|
||||
namespace mbts.spark {
|
||||
class LadderVM : DisposableViewModelBase, IKeyListener {
|
||||
@@ -50,7 +51,7 @@ namespace mbts.spark {
|
||||
|
||||
// Order
|
||||
_selected_order_type = backing(nameof(selected_order_type), Order.Types.TimeInForce.Day);
|
||||
algo_types = _model.default_orders.SelectMany(wrap_order).ToArray();
|
||||
algo_types = OrderDataHelper.Defaults.Algos.SelectMany(wrap_order).ToArray();
|
||||
_revert = backing(nameof(revert), false);
|
||||
|
||||
// Orders
|
||||
@@ -166,6 +167,8 @@ namespace mbts.spark {
|
||||
Property<bool> _revert;
|
||||
public bool revert { get => _revert.Value; set => _revert.set(value); }
|
||||
|
||||
public string[] accounts { get; } = new[] { "Account1", "Account2", "Account3", "Account4" };
|
||||
public string account { get => _order_template.Account; set => _order_template.Account = value; }
|
||||
public Order.Types.TimeInForce[] order_types => Enum.GetValues(typeof(Order.Types.TimeInForce)).Cast<Order.Types.TimeInForce>().ToArray();
|
||||
Property<Order.Types.TimeInForce> _selected_order_type;
|
||||
public Order.Types.TimeInForce selected_order_type { get => _selected_order_type.Value; set => _selected_order_type.Value = value; }
|
||||
|
||||
@@ -5,58 +5,38 @@
|
||||
xmlns:controls="clr-namespace:mbts.ui.controls"
|
||||
xmlns:spark="clr-namespace:mbts.spark"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
xmlns:uag="clr-namespace:mbts.ui.spark.algo"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
Height="600"
|
||||
Width="400"
|
||||
TextElement.FontSize="11">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/AlgoDetailsPopupControl.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Margin="5,5,5,0">
|
||||
<StackPanel Margin="5,0">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<ComboBox ItemsSource="{Binding algo_types}" SelectedItem="{Binding selected_algo_type}" Margin="2">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<usp:AlgoTypeItem AlgoType="{Binding algo_type}" Metadata="{Binding meta}"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<ComboBox ItemsSource="{Binding order_types}" SelectedItem="{Binding selected_order_type}" Margin="2" />
|
||||
<StackPanel Margin="0,5">
|
||||
<Button Height="40" Margin="2" Command="{Binding cancel_command}" CommandParameter="All">Cxl All</Button>
|
||||
</StackPanel.Resources>
|
||||
<StackPanel Margin="0,0,0,5">
|
||||
<Button Height="30" Margin="2" Command="{Binding cancel_command}" CommandParameter="All">Cxl All</Button>
|
||||
<Button Margin="2" Command="{Binding cancel_command}" CommandParameter="Bids" Background="{mbts:BTSColor MarketData.bid}" Foreground="White">Cxl Bids</Button>
|
||||
<Button Margin="2" Command="{Binding cancel_command}" CommandParameter="Asks" Background="{mbts:BTSColor MarketData.ask}" Foreground="White">Cxl Asks</Button>
|
||||
</StackPanel>
|
||||
<!-- reset to defaults after order -->
|
||||
<CheckBox IsChecked="{Binding revert}">Revert</CheckBox>
|
||||
|
||||
<Border BorderBrush="LightGray" BorderThickness="1" Margin="2,5,0,5">
|
||||
<controls:ObjectEditor Margin="0,2"
|
||||
EditableObject="{Binding selected_algo_type.order_details}">
|
||||
<controls:ObjectEditor.Resources>
|
||||
<DataTemplate DataType="{x:Type sys:Double}" x:Key="{x:Type sys:Double}">
|
||||
<WrapPanel>
|
||||
<TextBlock Grid.Row="1" Text="{Binding Name}" VerticalAlignment="Center" Margin="0" />
|
||||
<controls:TickUpDownDouble Width="40" Value="{Binding Value}" />
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type sys:UInt32}" x:Key="{x:Type sys:UInt32}">
|
||||
<WrapPanel>
|
||||
<TextBlock Grid.Row="1" Text="{Binding Name}" VerticalAlignment="Center" Margin="0" />
|
||||
<controls:TickUpDownUInt Width="40" Value="{Binding Value}" />
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</controls:ObjectEditor.Resources>
|
||||
</controls:ObjectEditor>
|
||||
</Border>
|
||||
|
||||
<TextBox HorizontalContentAlignment="Right" Text="{Binding calculator.value}" Margin="2" />
|
||||
<ItemsControl ItemsSource="{Binding calculator.buttons}" Focusable="False">
|
||||
<ItemsControl.ItemsPanel>
|
||||
@@ -71,8 +51,11 @@
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<Button Margin="2" HorizontalAlignment="Stretch" Command="{Binding calculator.click}" CommandParameter="0">Clear</Button>
|
||||
<ComboBox Grid.ColumnSpan="2" Margin="2" ItemsSource="{Binding accounts}" SelectedItem="{Binding account}"/>
|
||||
<ComboBox ItemsSource="{Binding order_types}" SelectedItem="{Binding selected_order_type}" Margin="2" />
|
||||
<uag:AlgoDetailsPopupControl ItemsSource="{Binding algo_types}" SelectedItem="{Binding selected_algo_type}" Margin="2" ExpandDirection="Left"/>
|
||||
|
||||
<!--<ListBox IsEnabled="False" Margin="0,5">
|
||||
<!--<ListBox IsEnabled="False" Margin="0,5">
|
||||
<ListBoxItem>10</ListBoxItem>
|
||||
<ListBoxItem>2</ListBoxItem>
|
||||
<ListBoxItem>25</ListBoxItem>
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Linq;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark {
|
||||
public class OrderTypeVM {
|
||||
public class OrderTypeVM : ui.spark.algo.AlgoDetailsPopupControl.IAlgoTypeVM {
|
||||
// this template is shared with the parent vm so mutations are visible
|
||||
Order _order_template;
|
||||
IFieldAccessor _accessor;
|
||||
|
||||
@@ -10,17 +10,7 @@
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/view/Resources/Converters.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/PriceEntryControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/PriceOffsetControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/QuantityMeasureControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/AbsolutePriceTriggerControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/QuantityTriggerControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/PriceTriggerControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/TimeWindowControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/BTSStopOrderControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/BTSIcebergOrderControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Popup/PopupControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/AlgoDetailsPopupControl.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<sys:Double x:Key="HorizontalSpacing">8.0</sys:Double>
|
||||
<sys:Double x:Key="VerticalSpacing">4.0</sys:Double>
|
||||
@@ -108,115 +98,9 @@
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox Grid.ColumnSpan="2" Margin="0,2" ItemsSource="{Binding accounts}" SelectedItem="{Binding account}"/>
|
||||
<ComboBox Grid.Row="1" Grid.ColumnSpan="2" Margin="0,2" ItemsSource="{Binding time_in_forces}" SelectedItem="{Binding time_in_force}"/>
|
||||
<ComboBox Grid.Row="2" Margin="0,2" ItemsSource="{Binding algo_types_view}" SelectedItem="{Binding algo_type}">
|
||||
<ComboBox.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.ContainerStyle>
|
||||
<Style TargetType="GroupItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GroupItem">
|
||||
<StackPanel>
|
||||
<ItemsPresenter/>
|
||||
<Rectangle Height="1" Fill="{x:Static uc:BTSColors.logo_brush}" HorizontalAlignment="Stretch"/>
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</GroupStyle.ContainerStyle>
|
||||
</GroupStyle>
|
||||
</ComboBox.GroupStyle>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<usp:AlgoTypeItem AlgoType="{Binding algo_type}" Metadata="{Binding meta}"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<c:PopupControl Grid.Row="2" Grid.Column="1" Margin="4,2,0,2" Content="{Binding algo_type.order_details}" PopupPlacement="Right">
|
||||
<c:PopupControl.ContentTemplateSelector>
|
||||
<usp:OrderModificationTemplateSelector>
|
||||
<usp:OrderModificationTemplateSelector.StopLimitOrderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock FontWeight="SemiBold">Stop Price</TextBlock>
|
||||
<c:TickUpDownDouble Grid.Column="1" Margin="12,0,0,0" Width="80" Value="{Binding StopPrice}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.StopLimitOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.StopMarketOrderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock FontWeight="SemiBold">Stop Price</TextBlock>
|
||||
<c:TickUpDownDouble Grid.Column="1" Margin="12,0,0,0" Width="80" Value="{Binding StopPrice}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.StopMarketOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.IcebergOrderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock FontWeight="SemiBold">Show Quantity</TextBlock>
|
||||
<c:TickUpDownUInt Grid.Column="1" Margin="12,0,0,0" Width="80" Value="{Binding ShowQuantity}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.IcebergOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.BTSStopOrderTemplate>
|
||||
<DataTemplate>
|
||||
<uag:BTSStopOrderControl Order="{Binding}"/>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.BTSStopOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.BTSIcebergOrderTemplate>
|
||||
<DataTemplate>
|
||||
<uag:BTSIcebergOrderControl Order="{Binding}"/>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.BTSIcebergOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.ReflectionTemplate>
|
||||
<DataTemplate>
|
||||
<c:ObjectEditor EditableObject="{Binding}">
|
||||
<c:ObjectEditor.CustomDataTemplates>
|
||||
<DataTemplate DataType="{x:Type sp:PriceTrigger}">
|
||||
<GroupBox Header="{Binding Name}">
|
||||
<uag:PriceTriggerControl PriceTrigger="{Binding Value}"/>
|
||||
</GroupBox>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type sp:QuantityMeasure}">
|
||||
<GroupBox Header="{Binding Name}">
|
||||
<uag:QuantityMeasureControl QuantityMeasure="{Binding Value}"/>
|
||||
</GroupBox>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type sp:PriceOffset}">
|
||||
<GroupBox Header="{Binding Name}">
|
||||
<uag:PriceOffsetControl PriceOffset="{Binding Value}"/>
|
||||
</GroupBox>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type sp:BTSIcebergOrder}">
|
||||
<uag:BTSIcebergOrderControl Order="{Binding Value}"/>
|
||||
</DataTemplate>
|
||||
</c:ObjectEditor.CustomDataTemplates>
|
||||
</c:ObjectEditor>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.ReflectionTemplate>
|
||||
</usp:OrderModificationTemplateSelector>
|
||||
</c:PopupControl.ContentTemplateSelector>
|
||||
</c:PopupControl>
|
||||
<uag:AlgoDetailsPopupControl Grid.Row="2" Margin="0,2" ItemsSource="{Binding algo_types}" SelectedItem="{Binding algo_type}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -19,18 +19,14 @@ namespace mbts.spark
|
||||
_model = model;
|
||||
_dispose = order.Subscribe(o => {
|
||||
_order = o;
|
||||
_algo_types.Clear();
|
||||
foreach (var a in _get_algo_types()) _algo_types.Add(a);
|
||||
algo_types.Clear();
|
||||
foreach (var a in _get_algo_types()) algo_types.Add(a);
|
||||
RaisePropertyChanged(nameof(account), nameof(algo_type), nameof(time_in_force));
|
||||
});
|
||||
_algo_types = new ObservableCollection<OrderTypeVM>(_get_algo_types());
|
||||
algo_types_view = CollectionViewSource.GetDefaultView(_algo_types);
|
||||
algo_types_view.GroupDescriptions.Add(new PropertyGroupDescription(nameof(OrderTypeVM.is_bts_type)));
|
||||
algo_types_view.SortDescriptions.Add(new SortDescription(nameof(OrderTypeVM.is_bts_type), ListSortDirection.Ascending));
|
||||
algo_types = new ObservableCollection<OrderTypeVM>(_get_algo_types());
|
||||
}
|
||||
|
||||
private readonly OrdersModel _model;
|
||||
private readonly ObservableCollection<OrderTypeVM> _algo_types;
|
||||
private Order _order = new Order { LimitOrder = new LimitOrder() };
|
||||
|
||||
private IEnumerable<OrderTypeVM> _get_algo_types() {
|
||||
@@ -42,9 +38,9 @@ namespace mbts.spark
|
||||
|
||||
public string[] accounts { get; } = new[] { "Account1", "Account2", "Account3", "Account4" };
|
||||
public string account { get => _order.Account; set => _order.Account = value; }
|
||||
public ICollectionView algo_types_view { get; private set; }
|
||||
public ObservableCollection<OrderTypeVM> algo_types { get; }
|
||||
public OrderTypeVM algo_type {
|
||||
get => _algo_types.FirstOrDefault(o => o.is_selected);
|
||||
get => algo_types.FirstOrDefault(o => o.is_selected);
|
||||
set {
|
||||
if (value != null) value.is_selected = true;
|
||||
RaisePropertyChanged();
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
<ColumnDefinition MinWidth="120"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<usp:OrderModificationControl Grid.ColumnSpan="3" />
|
||||
<Button Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinHeight="40" Background="{u:BTSColor MarketData.bid}" Foreground="White" FontWeight="Bold" u:Behavior.CloseWindow="True" Command="{Binding send_order}" CommandParameter="{u:Enum Buy, Type=msys:BuySell}">Buy</Button>
|
||||
<Button Grid.Row="2" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinHeight="40" Background="{u:BTSColor MarketData.ask}" Foreground="White" FontWeight="Bold" u:Behavior.CloseWindow="True" Command="{Binding send_order}" CommandParameter="{u:Enum Sell, Type=msys:BuySell}">Sell</Button>
|
||||
<Button Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinHeight="40" Background="{u:BTSColor MarketData.bid}" Foreground="White" FontWeight="Bold" u:Behavior.CloseWindow="True" Command="{Binding send_order}" CommandParameter="{u:Enum Buy, Type=msys:Side}">Buy</Button>
|
||||
<Button Grid.Row="2" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinHeight="40" Background="{u:BTSColor MarketData.ask}" Foreground="White" FontWeight="Bold" u:Behavior.CloseWindow="True" Command="{Binding send_order}" CommandParameter="{u:Enum Sell, Type=msys:Side}">Sell</Button>
|
||||
</Grid>
|
||||
<u:WindowStyle.TitleContentTemplate>
|
||||
<DataTemplate>
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
xmlns:uag="clr-namespace:mbts.ui.spark.algo">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/view/Resources/Converters.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/PriceEntryControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/PriceOffsetControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/QuantityMeasureControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/AbsolutePriceTriggerControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/QuantityTriggerControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/PriceTriggerControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/TimeWindowControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/BTSStopOrderControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Algo/BTSIcebergOrderControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Popup/PopupControl.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<Style TargetType="uag:AlgoDetailsPopupControl">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="uag:AlgoDetailsPopupControl">
|
||||
<Grid x:Name="Root">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="4"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox x:Name="PART_AlgoTypeComboBox" ItemsSource="{TemplateBinding ItemsView}" SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch">
|
||||
<ComboBox.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.ContainerStyle>
|
||||
<Style TargetType="GroupItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GroupItem">
|
||||
<StackPanel>
|
||||
<ItemsPresenter/>
|
||||
<Rectangle Height="1" Fill="{x:Static u:BTSColors.logo_brush}" HorizontalAlignment="Stretch"/>
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</GroupStyle.ContainerStyle>
|
||||
</GroupStyle>
|
||||
</ComboBox.GroupStyle>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<usp:AlgoTypeItem AlgoType="{Binding algo_type}" Metadata="{Binding meta}"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<c:PopupControl x:Name="PART_AlgoDetailsPopup" Grid.Column="2" Content="{Binding SelectedItem.order_details, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<c:PopupControl.ContentTemplateSelector>
|
||||
<usp:OrderModificationTemplateSelector>
|
||||
<usp:OrderModificationTemplateSelector.StopLimitOrderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock FontWeight="SemiBold">Stop Price</TextBlock>
|
||||
<c:TickUpDownDouble Grid.Column="1" Margin="12,0,0,0" Width="80" Value="{Binding StopPrice}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.StopLimitOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.StopMarketOrderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock FontWeight="SemiBold">Stop Price</TextBlock>
|
||||
<c:TickUpDownDouble Grid.Column="1" Margin="12,0,0,0" Width="80" Value="{Binding StopPrice}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.StopMarketOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.IcebergOrderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock FontWeight="SemiBold">Show Quantity</TextBlock>
|
||||
<c:TickUpDownUInt Grid.Column="1" Margin="12,0,0,0" Width="80" Value="{Binding ShowQuantity}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.IcebergOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.BTSStopOrderTemplate>
|
||||
<DataTemplate>
|
||||
<uag:BTSStopOrderControl Order="{Binding}"/>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.BTSStopOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.BTSIcebergOrderTemplate>
|
||||
<DataTemplate>
|
||||
<uag:BTSIcebergOrderControl Order="{Binding}"/>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.BTSIcebergOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.ReflectionTemplate>
|
||||
<DataTemplate>
|
||||
<c:ObjectEditor EditableObject="{Binding}">
|
||||
<c:ObjectEditor.CustomDataTemplates>
|
||||
<DataTemplate DataType="{x:Type sp:PriceTrigger}">
|
||||
<GroupBox Header="{Binding Name}">
|
||||
<uag:PriceTriggerControl PriceTrigger="{Binding Value}"/>
|
||||
</GroupBox>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type sp:QuantityMeasure}">
|
||||
<GroupBox Header="{Binding Name}">
|
||||
<uag:QuantityMeasureControl QuantityMeasure="{Binding Value}"/>
|
||||
</GroupBox>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type sp:PriceOffset}">
|
||||
<GroupBox Header="{Binding Name}">
|
||||
<uag:PriceOffsetControl PriceOffset="{Binding Value}"/>
|
||||
</GroupBox>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type sp:BTSIcebergOrder}">
|
||||
<uag:BTSIcebergOrderControl Order="{Binding Value}"/>
|
||||
</DataTemplate>
|
||||
</c:ObjectEditor.CustomDataTemplates>
|
||||
</c:ObjectEditor>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.ReflectionTemplate>
|
||||
</usp:OrderModificationTemplateSelector>
|
||||
</c:PopupControl.ContentTemplateSelector>
|
||||
</c:PopupControl>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="ExpandDirection" Value="Left">
|
||||
<Setter Property="PopupPlacement" TargetName="PART_AlgoDetailsPopup" Value="Left"/>
|
||||
<Setter Property="Grid.Column" TargetName="PART_AlgoDetailsPopup" Value="0"/>
|
||||
<Setter Property="Grid.Column" TargetName="PART_AlgoTypeComboBox" Value="2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="ExpandDirection" Value="Right">
|
||||
<Setter Property="PopupPlacement" TargetName="PART_AlgoDetailsPopup" Value="Right"/>
|
||||
<Setter Property="Grid.Column" TargetName="PART_AlgoDetailsPopup" Value="2"/>
|
||||
<Setter Property="Grid.Column" TargetName="PART_AlgoTypeComboBox" Value="0"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,99 @@
|
||||
using bts.spark;
|
||||
using Google.Protobuf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace mbts.ui.spark.algo
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AlgoDetailsPopupControl.xaml
|
||||
/// </summary>
|
||||
public class AlgoDetailsPopupControl : Control
|
||||
{
|
||||
static AlgoDetailsPopupControl() {
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(AlgoDetailsPopupControl), new FrameworkPropertyMetadata(typeof(AlgoDetailsPopupControl)));
|
||||
}
|
||||
|
||||
public interface IAlgoTypeVM {
|
||||
Order.AlgoOrderTypeOneofCase algo_type { get; }
|
||||
bool is_bts_type { get; }
|
||||
OrderMetadata meta { get; }
|
||||
IMessage order_details { get; }
|
||||
}
|
||||
|
||||
#region ExpandDirection
|
||||
public static readonly DependencyProperty ExpandDirectionProperty = DependencyProperty.Register(nameof(ExpandDirection), typeof(ExpandDirection), typeof(AlgoDetailsPopupControl),
|
||||
new PropertyMetadata(ExpandDirection.Right, OnExpandDirectionChanged, CoerceExpandDirection));
|
||||
|
||||
private static object CoerceExpandDirection(DependencyObject d, object baseValue) {
|
||||
if (baseValue is ExpandDirection) {
|
||||
var ed = (ExpandDirection)baseValue;
|
||||
if (ed == ExpandDirection.Left || ed == ExpandDirection.Right) return ed;
|
||||
}
|
||||
return ExpandDirectionProperty.DefaultMetadata;
|
||||
}
|
||||
|
||||
private static void OnExpandDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
|
||||
((AlgoDetailsPopupControl)d).TrySetGridColumnWidths();
|
||||
}
|
||||
|
||||
public ExpandDirection ExpandDirection { get => (ExpandDirection)GetValue(ExpandDirectionProperty); set => SetValue(ExpandDirectionProperty, value); }
|
||||
#endregion
|
||||
|
||||
#region ItemsSource
|
||||
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(nameof(ItemsSource), typeof(IEnumerable<IAlgoTypeVM>), typeof(AlgoDetailsPopupControl),
|
||||
new PropertyMetadata(null, OnItemsSourceChanged, CoerceItemsSource));
|
||||
private static object CoerceItemsSource(DependencyObject d, object baseValue) { return baseValue as IEnumerable<IAlgoTypeVM> ?? Enumerable.Empty<IAlgoTypeVM>(); }
|
||||
private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
|
||||
var cvs = CollectionViewSource.GetDefaultView(e.NewValue);
|
||||
cvs.GroupDescriptions.Add(new PropertyGroupDescription(nameof(IAlgoTypeVM.is_bts_type)));
|
||||
cvs.SortDescriptions.Add(new SortDescription(nameof(IAlgoTypeVM.is_bts_type), ListSortDirection.Ascending));
|
||||
d.SetValue(ItemsViewPropertyKey, cvs);
|
||||
}
|
||||
public IEnumerable<IAlgoTypeVM> ItemsSource { get => GetValue(ItemsSourceProperty) as IEnumerable<IAlgoTypeVM>; set => SetValue(ItemsSourceProperty, value); }
|
||||
#endregion
|
||||
|
||||
#region ItemsView (ReadOnly)
|
||||
private static readonly DependencyPropertyKey ItemsViewPropertyKey = DependencyProperty.RegisterReadOnly(nameof(ItemsView), typeof(ICollectionView), typeof(AlgoDetailsPopupControl), new PropertyMetadata(null));
|
||||
internal static readonly DependencyProperty ItemsViewProperty = ItemsViewPropertyKey.DependencyProperty;
|
||||
internal ICollectionView ItemsView { get => GetValue(ItemsViewProperty) as ICollectionView; private set => SetValue(ItemsViewPropertyKey, value); }
|
||||
#endregion
|
||||
|
||||
public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register(nameof(SelectedItem), typeof(IAlgoTypeVM), typeof(AlgoDetailsPopupControl),
|
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
||||
public IAlgoTypeVM SelectedItem { get => GetValue(SelectedItemProperty) as IAlgoTypeVM; set => SetValue(SelectedItemProperty, value); }
|
||||
|
||||
private void TrySetGridColumnWidths() {
|
||||
var grid = GetTemplateChild("Root") as Grid;
|
||||
if (grid != null && grid.ColumnDefinitions.Count > 2) {
|
||||
switch (ExpandDirection) {
|
||||
case ExpandDirection.Left:
|
||||
grid.ColumnDefinitions[0].Width = GridLength.Auto;
|
||||
grid.ColumnDefinitions[2].Width = new GridLength(1, GridUnitType.Star);
|
||||
break;
|
||||
case ExpandDirection.Right:
|
||||
grid.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star);
|
||||
grid.ColumnDefinitions[2].Width = GridLength.Auto;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate() {
|
||||
TrySetGridColumnWidths();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,6 @@ namespace mbts.ui.controls
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(PopupControl), new FrameworkPropertyMetadata(typeof(PopupControl)));
|
||||
}
|
||||
|
||||
enum PopupState { Opening, Open, Closing, Closed }
|
||||
|
||||
#region PopupPlacement
|
||||
public static readonly DependencyProperty PopupPlacementProperty = DependencyProperty.Register("PopupPlacement", typeof(PlacementMode), typeof(PopupControl), new PropertyMetadata(PlacementMode.Right, OnPopupPlacementChanged));
|
||||
private static void OnPopupPlacementChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { d.SetValue(IsOpenTransformPropertyKey, _get_is_open_transform((PlacementMode)e.NewValue)); }
|
||||
|
||||
@@ -45,6 +45,7 @@ def type_name_cpp(name_with_ns):
|
||||
# Map protobuf raw types to intermediate type tree
|
||||
#
|
||||
MethodModel = namedtuple("MethodModel", "name comment server_streaming has_complex_key key_type key_field output_type_full output_type_cpp output_type input_type_full input_type_cpp input_type")
|
||||
KeyData = namedtuple("KeyData", "type field")
|
||||
def transform_method(m, keydata):
|
||||
return MethodModel(
|
||||
name=m.name,
|
||||
@@ -87,25 +88,23 @@ def transform_message(i):
|
||||
return r
|
||||
|
||||
ServiceModel = namedtuple("ServiceModel", "name comment method")
|
||||
def transform_service(service, keydata):
|
||||
KeyModel = namedtuple("KeyModel", "type field")
|
||||
DefaultKeyModel = KeyModel("int", "id")
|
||||
def transform_service(service, keymap):
|
||||
return ServiceModel(
|
||||
service.name,
|
||||
option(service.options, apioptions_pb2.service_description, ""),
|
||||
[transform_method(m, keydata) for m in service.method])
|
||||
[transform_method(m, keymap.get(m.output_type, DefaultKeyModel)) for m in service.method])
|
||||
|
||||
FileModel = namedtuple("FileModel", "name package namespace_csharp message_type service enum_type")
|
||||
KeyModel = namedtuple("KeyModel", "type field")
|
||||
def transform_file(p):
|
||||
def transform_file(p, keymap):
|
||||
message_types = [transform_message(m) for m in p.message_type]
|
||||
# Note: this keydata thing is wrong... this will find the first key in the file not the key for the service
|
||||
keydata = next((KeyModel(f.type,f.name) for m in message_types for f in m.field if f.is_key), None)
|
||||
keydata = keydata or next((KeyModel(f.type,f.name) for m in message_types for f in m.field if f.name == 'id'), KeyModel("int","id"))
|
||||
return FileModel(
|
||||
name = p.name,
|
||||
package = p.package,
|
||||
namespace_csharp = p.package,
|
||||
message_type = message_types,
|
||||
service = [transform_service(s, keydata) for s in p.service],
|
||||
service = [transform_service(s, keymap) for s in p.service],
|
||||
enum_type = [transform_enum(e) for e in p.enum_type]
|
||||
)
|
||||
|
||||
@@ -229,14 +228,28 @@ def generate_code(request, response):
|
||||
'type': lambda this,item: item.split('.')[-1:][0],
|
||||
'camel': lambda _,f: camel_case(f),
|
||||
}
|
||||
# for proto_file in request.proto_file:
|
||||
# todo: for all files on the input
|
||||
# get a list of their messages and Key fields
|
||||
# pass this as a dictionary into transform_file
|
||||
# pass
|
||||
keymap = {}
|
||||
# Generate a map of keys for all types across files
|
||||
for proto_file in request.proto_file:
|
||||
for msg in proto_file.message_type:
|
||||
# check eachfield
|
||||
found_key = False
|
||||
namekey = ".{}.{}".format(proto_file.package,msg.name)
|
||||
for field in msg.field:
|
||||
if option(field.options, apioptions_pb2.key, False):
|
||||
found_key = True
|
||||
keymap[namekey] = KeyData(to_type_model(field, msg), field.name)
|
||||
break
|
||||
# If no field was annotated as a key but there's a field named "id" use that
|
||||
if not found_key:
|
||||
for field in msg.field:
|
||||
if field.name == "id":
|
||||
keymap[namekey] = KeyData(to_type_model(field, msg), field.name)
|
||||
break
|
||||
|
||||
for proto_file in request.proto_file:
|
||||
if proto_file.name in request.file_to_generate:
|
||||
proto_file = transform_file(proto_file)
|
||||
proto_file = transform_file(proto_file, keymap)
|
||||
# Path on response.file name is interpreted differently by the c# and c++ code gen
|
||||
filename = ('strip_out_path' in params) and os.path.split(proto_file.name)[1] or proto_file.name
|
||||
source_name = os.path.splitext(filename)[0]
|
||||
|
||||
Reference in new issue
Block a user