Merge master

This commit is contained in:
Eric Harding committed 2019-02-07 11:24:35 -05:00
commit 82d7c28cfc
52 files changed
+1102 -186

No files matched your search

+2 -2
View File
@@ -75,10 +75,10 @@
"name": "SparkVM Launch",
"type": "cppdbg",
"request": "launch",
"program": "/home/bts/spark/build/ninja_debug/src/server/sparkd/sparkd",
"program": "/home/bts/spark/build/ninja_debug/server/sparkd",
"args": ["run"],
"stopAtEntry": false,
"cwd": "/home/bts/spark/build/ninja_debug/src/server/sparkd/",
"cwd": "/home/bts/spark/build/ninja_debug/server/",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
+35 -37
View File
@@ -1,11 +1,10 @@
# The BTS Development Process #
## The Big Picture ##
Our development work is organized in projects. A project is an effort
to specifiy, develop and validate a related set of additions to our
Spark platform. A project can be assigned to one more developers and a
developer might concurrently be assigned to multiple
## Projects ##
Our development work is organized in projects. A project is a
non-trivial effort to specify, develop and validate a related set of
additions to our Spark platform. A project can be assigned to one more
developers and a developer might concurrently be assigned to multiple
projects. Projects typically start out with specification work,
proceed to implementation and finish with validation efforts. At any
given time there will be multiple projects being worked on
@@ -14,16 +13,16 @@ are merged into the product and deployed to customers.
## The Details ##
Typically project ideas come from sales interactions, opposition
research and customer feedback, alltough on occasion development or
operational requirements will also suggest potentially valuable
research and customer feedback, all tough on occasion development or
operational requirements can also suggest valuable project
ideas. Whatever the source of a project idea the final decision of
which projects to pursue is always done by management. Once a project
idea has been selected for implementation the corresponding project
will go through several phases: inception, specification, development
and merge. We detail each of these phases below.
will go through several phases: inception, specification, development,
validation and merge.
* Inception. In this phase we create the infrastructure for the
project. Typically this means selecting a team, creating a project
* Inception. In this phase the infrastructure for the project is
created. Typically this means selecting a team, creating a project
case in Jira (that is a case assigned to the team@bluetradesys.com
Jira user) and possibly creating a new branch for the project. This
phase is mostly mechanical and the responsibility of Pedro.
@@ -32,11 +31,11 @@ phase is mostly mechanical and the responsibility of Pedro.
ill-considered idea project idea into a concrete, implementable
specification that attempts to maximize the value/cost ratio of the
project. It is hard to exaggerate the impact of a this phase on the
rest of the project. *Nothing* has more impact on our ability to
quickly deliver value to customers than good specification
work. Specification typically take the form of shared google docs,
using a mix of text and UI mockups to capture both user requirements
and suggested implementation strategies. Taha is responsible for this
rest of the project. *Nothing* has more impact on BTS's ability to
quickly deliver value to customers than good specification work. A
specification typically takes the form of a shared google docs using
a mix of text and UI mock-ups to capture both user requirements and
suggested implementation strategies. Taha and Kevin are responsible for this
phase.
* Development. Once a specification is complete, a team of developers
@@ -44,24 +43,26 @@ will use a project specific branch to implement the
specification. Periodically, typically once a week, progress on the
project is assessed by Pedro, possibly with the help of others. This
assessment takes the form of code reviews, demos, or just one-on-one
conversations. To ensure development does not go off on sub-optimal
tangents, developers are expected to continuously merge master into
the project branch as well as encouraged to create Pull Requests (PRs)
early in the project implementation, so that their work is kept
visible and integrated with that of the rest of the group. During the
conversations. To ensure development does not go off on tangents,
developers are expected to continuously merge master into the project
branch as well as encouraged to create Pull Requests (PRs) early in
the project implementation, so that their work is kept visible and
integrated with that of the rest of the group. During the
implementation phase developers should reach out to Pedro for UI
reviews, architecture and design concerns as well as specification
trade off concerns.
reviews, architecture and design questions and specification trade off
concerns.
* Verification. Once code is complete think carefully about the best way
to verify that it is good before it goes to production. We don't have a
dedicated QA cycle to flush out bugs so it's important that a change be
fully tested before it's marked "Ready to Merge." For any non-trivial
change consider enlisting a 'test buddy' to help review the code and
think of test cases that you may not have considered. Stability from
release to release is especially critical right now as we develop a
reputation in the futures world.
- Code Reviews
* Verification. Once code is complete it is the project's team job to
think carefully about the best way to verify that the work is solid
enough to go to production. We do not have a dedicated QA cycle to
flush out bugs so it is important for changes to be fully tested
before being marked ready to merge (RTM). For any non-trivial change
project teams should enlist a 'test buddy' from outside the team to
help review the code and think of test cases that they may not have
considered. Stability from release to release is especially critical
right now as we develop a reputation in the futures
world. Additionally, project teams are encouraged to make liberal use
of other testing techniques such as
- Unit tests
- System tests
- Manual tests
@@ -70,7 +71,7 @@ reputation in the futures world.
that includes Pedro should be created (unless, as mentioned above, an
early PR was already created in the development phase). Whether the PR
already existed or not, its description should be changed to start
with the "Ready To Merge" statement. This marks the project as ready
with the RTM (Ready To Merge) acronym. This marks the project as ready
to be merged into master. Once a week, typically on Mondays, Pedro
will go through every PR marked as "Ready To Merge", build it, check
it out and if everything looks good merge it to master. At the end of
@@ -79,6 +80,3 @@ number. This version will be go through some additional testing by
Brian and will then be deployed by Karl and Pete to customers
throughout the rest of the week.
## Tools ##
* Pre-Merge checklist
* Code Review tutorial
+19
View File
@@ -1,5 +1,24 @@
# Release Notes
## 1.4.11
### New Features
- Floating Order Book
- The floating order book provides a quick view of orders occupying a price level in the ladder
- Launch the Floating Order Book by middle-clicking a ladder badge
- Cancel orders by clicking on the red X in the Cancel column
- Quantity and Price modification
- Clicking on a row will select it, providing the option for changing your price and quantity
- Enter in a new value or use the up/down buttons to set a desired value
- Press the green checkbox to finalize your change and update the order
### SDK
- Improved SDK documentation and usability
### User Interface Improvements
- The following spreader quoting parameters have been deprecated:
- Hidden parameter
- Price Type setting of the Conditional parameter
### Bug Fixes
- Fixed a limit enforcement problem that could lead to 0 sized orders being sent to the exchange
## 1.4.10
### Bug Fixes
- Removed duplicate entries in performance log
@@ -205,7 +205,7 @@ namespace mbts.spark {
//new EnableHedgeModel(), //TAHA_SPREADER
new HedgeRatioModel(),
//new MinLeanQtyModel(), //TAHA_SPREADER
new QuoteHiddenModel(),
//new QuoteHiddenModel(),
new MarketDataTypeModel(),
new MarketDataCalculationModel(),
new QuoteThrottleEnabledModel(quote_throttle_inside_ticks, quote_throttle_outside_ticks),
@@ -213,7 +213,7 @@ namespace mbts.spark {
quote_throttle_outside_ticks,
new ConditionalQuoteEnabledModel(conditional_quoting_ticks, conditional_quoting_price_type),
conditional_quoting_ticks,
conditional_quoting_price_type,
//conditional_quoting_price_type,
//new QuoteInsideMarketThrottleEnabledModel(quote_inside_market_throttle_ticks, quote_inside_market_throttle_min_move),
//quote_inside_market_throttle_ticks,
//quote_inside_market_throttle_min_move,
@@ -0,0 +1,166 @@
<!-- MaxHeight will force only x rows before vertical scrollbar shows up -->
<!-- MinWidth will give enough room beyond the last column so that the the verical scrollbar does not eclipse the column content -->
<UserControl x:Class="mbts.spark.MiniOrderBookView" x:ClassModifier="internal"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:sp="clr-namespace:mbts.spark"
xmlns:uc="clr-namespace:mbts.ui"
xmlns:c="clr-namespace:mbts.ui.controls"
xmlns:usp="clr-namespace:mbts.ui.spark"
xmlns:uspcv="clr-namespace:mbts.ui.spark.converters"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:order="clr-namespace:bts.api.orderman;assembly=spark_api"
mc:Ignorable="d"
MaxHeight="240"
MinWidth="875"
d:DesignHeight="600" d:DesignWidth="1080"
FocusManager.IsFocusScope="True"
Background="{StaticResource CommonBackground}">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/view/Controls/DataGridEx/Filters/Views/FilterTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
<uspcv:TickDisplayConverter x:Key="TickDisplayConverter"/>
<uspcv:OrderSubTypeDisplayTextConverter x:Key="OrderSubTypeLongDisplayTextConverter" UseLongName="True" />
<DataTemplate x:Key="{x:Static sp:MiniOrderBookView.SubTypeFilterTemplateKey}">
<usp:FilterContentControl
ApplyCommandParameter="{Binding}"
ApplyCommand="{x:Static c:DataGridFilterProperties.CommitCommand}"
ClearCommandParameter="{Binding}"
ClearCommand="{x:Static c:DataGridFilterProperties.ClearCommand}"
>
<c:ListBoxEx
ItemsSource="{Binding items}"
Selection="{Binding selected_items}"
SelectionMode="Multiple"
ItemContainerStyle="{StaticResource ListBoxItemCheckBoxStyle}"
>
<c:ListBoxEx.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource OrderSubTypeLongDisplayTextConverter}}"/>
</DataTemplate>
</c:ListBoxEx.ItemTemplate>
</c:ListBoxEx>
</usp:FilterContentControl>
</DataTemplate>
<Style x:Key="{x:Static sp:MiniOrderBookView.RowStyleKey}" TargetType="ListBoxItem" BasedOn="{StaticResource DIYGridRowStyle}">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="False"/>
<Condition Binding="{Binding status}" Value="{uc:Enum Working, Type=order:OrderStatus}"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Background" Value="{x:Static Member=working_order_background_brush, MemberType={uc:Nested uc:BTSColors.Orders}}"/>
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
<DataTemplate x:Key="{x:Static sp:MiniOrderBookView.RowTemplateKey}">
<sp:MiniOrderBookRowView/>
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
<AdornerDecorator>
<Border BorderThickness="4" BorderBrush="LightGray">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<c:DIYGrid
x:Name="_grid"
Grid.Row="0"
Columns="{Binding columns}"
CurrentRow="{Binding current_row, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Rows="{Binding rows}"
RowStyle="{StaticResource {x:Static sp:MiniOrderBookView.RowStyleKey}}"
RowTemplate="{StaticResource {x:Static sp:MiniOrderBookView.RowTemplateKey}}"
SelectionHighlight="{Binding grid_settings_manager.selection_highlight, Mode=OneWay}"
RowsHorizontalScrollBarVisibility="Collapsed"
RowHeight="20"
>
<c:DIYGrid.Resources>
<ResourceDictionary>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Checked.Fill" Color="#FF595959"/>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Checked.Stroke" Color="#FF262626"/>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.MouseOver.Stroke" Color="#FF27C7F7"/>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.MouseOver.Fill" Color="#FFCCEEFB"/>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.MouseOver.Checked.Stroke" Color="#FF1CC4F7"/>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.MouseOver.Checked.Fill" Color="#FF82DFFB"/>
<PathGeometry x:Key="TreeArrow" Figures="M0,0 L0,6 L6,0 z"/>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Fill" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Stroke" Color="#FF818181"/>
<Style x:Key="{x:Static sp:OrderBookView.ExpandCollapseToggleStyleKey}" TargetType="{x:Type ToggleButton}">
<Setter Property="Focusable" Value="False"/>
<Setter Property="Width" Value="16"/>
<Setter Property="Height" Value="16"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="Transparent" Height="16" Padding="0,5,5,5" Width="16">
<Path x:Name="ExpandPath" Data="{StaticResource TreeArrow}" Fill="{StaticResource TreeViewItem.TreeArrow.Static.Fill}" Stroke="{StaticResource TreeViewItem.TreeArrow.Static.Stroke}">
<Path.RenderTransform>
<RotateTransform Angle="135" CenterY="3" CenterX="3"/>
</Path.RenderTransform>
</Path>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="RenderTransform" TargetName="ExpandPath">
<Setter.Value>
<RotateTransform Angle="180" CenterY="3" CenterX="3"/>
</Setter.Value>
</Setter>
<Setter Property="Fill" TargetName="ExpandPath" Value="{StaticResource TreeViewItem.TreeArrow.Static.Checked.Fill}"/>
<Setter Property="Stroke" TargetName="ExpandPath" Value="{StaticResource TreeViewItem.TreeArrow.Static.Checked.Stroke}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Stroke" TargetName="ExpandPath" Value="{StaticResource TreeViewItem.TreeArrow.MouseOver.Stroke}"/>
<Setter Property="Fill" TargetName="ExpandPath" Value="{StaticResource TreeViewItem.TreeArrow.MouseOver.Fill}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
<Condition Property="IsChecked" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Stroke" TargetName="ExpandPath" Value="{StaticResource TreeViewItem.TreeArrow.MouseOver.Checked.Stroke}"/>
<Setter Property="Fill" TargetName="ExpandPath" Value="{StaticResource TreeViewItem.TreeArrow.MouseOver.Checked.Fill}"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ToolTip}">
<Style.Triggers>
<Trigger Property="Content" Value="{x:Static sys:String.Empty}">
<Setter Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="Content" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</c:DIYGrid.Resources>
<c:DIYGrid.InputBindings>
<!--<MouseBinding MouseAction="LeftDoubleClick" Command="{x:Static c:DIYGrid.DefaultRowCommand}"/>
<KeyBinding Key="Return" Command="{x:Static c:DIYGrid.DefaultRowCommand}"/> -->
</c:DIYGrid.InputBindings>
<c:DIYGrid.CommandBindings>
<CommandBinding
Command="{x:Static c:DIYGrid.DefaultRowCommand}"
Executed="{x:Static c:DIYGrid.DefaultRowActionExecuted}"
CanExecute="{x:Static c:DIYGrid.DefaultRowActionCanExecute}"
/>
</c:DIYGrid.CommandBindings>
</c:DIYGrid>
</Grid>
</Border>
</AdornerDecorator>
</UserControl>
@@ -0,0 +1,26 @@
using mbts.ui.controls;
using System.Windows.Controls;
namespace mbts.spark {
internal partial class MiniOrderBookView : UserControl {
// IMPORTANT: these enums are stored as strings in the general-purpose GridColumnSettings proto, and are used to ID THE COLUMNS!
// Do NOT RENAME them! However, if you must, be sure to write an IShellWindowMigrationRule or something to account for backwards compatability.
public enum Columns { Security, Symbol, Time, LastChange, User, Account, Exchange, TimeInForce, OrderType, SubType, Side, Size, Price, Filled, AvgFilled, LastPrice, Status, LastMessage, SecurityKey, OrderKey, ParentKey, Cancel, EditableQty, EditablePrice }
public const string
SubTypeFilterTemplateKey = "SubTypeFilterTemplate",
ExpandCollapseToggleStyleKey = "ExpandCollapseToggleStyle",
RowStyleKey = "RowStyle",
RowTemplateKey = "RowTemplateKey",
CVRowStyleKey = "CVRowStyle",
CVRowTemplateKey = "CVRowTemplateKey";
public MiniOrderBookView(OrderBookVM vm) {
InitializeComponent();
DataContext = vm;
}
}
class MiniOrderBookRowView : DIYGrid.HighPerformanceRow<OrderBookRowVM, OrderBookView.Columns> {
public MiniOrderBookRowView() : base() { }
}
}
@@ -194,6 +194,10 @@ namespace mbts.spark {
// quantity
Add(qty_column = new SizeColumn(
new UIntMinMax<OrderSecurity>(ort => ort.order.quantity(), nameof(OrderBookRowVM.quantity))));
// edit quantity column
// not usually part of the main order book, but it's useful to add it
// rather than debugging the popup window
//Add(edit_qty_column = new EditableQtyColumn());
// filled quantity
Add(filled_qty_column = new FilledColumn(
new UIntMinMax<OrderSecurity>(ort => ort.order.filled(), nameof(OrderBookRowVM.filled_quantity))));
@@ -209,6 +213,10 @@ namespace mbts.spark {
nameof(OrderBookRowVM.price)),
DataGridFilterKnownTemplates.DoubleMinMax,
_wrap_comparer(r => r.price)));
// edit price column
// not usually part of the main order book, but it's useful to add it
// rather than debugging the popup window
//Add(edit_price_column = new OrderBookVM.EditablePriceColumn());
// avg filled price
Add(avg_price_column = new SimpleTextColumn<DoubleMinMaxState>(
Columns.AvgFilled,
@@ -291,6 +299,7 @@ namespace mbts.spark {
public event Action filter_changed;
public CancelColumn cancel_column { get; }
public SecurityColumn security_column { get; }
public SimpleTextColumn<string[]> symbol_column { get; }
public SimpleTextColumn<TimeFilterTuple> time_created_column { get; }
@@ -303,7 +312,9 @@ namespace mbts.spark {
public SimpleTextColumn<OrderSubType[]> sub_type_column { get; }
public SideColumn side_column { get; }
public SizeColumn qty_column { get; }
public EditableQtyColumn edit_qty_column { get; }
public SimpleTextColumn<DoubleMinMaxState> price_column { get; }
public EditablePriceColumn edit_price_column { get; }
public FilledColumn filled_qty_column { get; }
public SimpleTextColumn<DoubleMinMaxState> last_price_column { get; }
public SimpleTextColumn<DoubleMinMaxState> avg_price_column { get; }
@@ -509,7 +520,7 @@ namespace mbts.spark {
: base(key, header, get_text, sort_prop, width, filter, filter_template, comparer) { }
public void draw(OrderBookRowVM row, DrawingContext dc, ColumnGeometry position, double row_height) =>
CellRender.draw_text(dc, _get_glyph_context(row), font_size, _get_text(row), position, RowHeight,
CellRender.draw_text(dc, _get_glyph_context(row), font_size, _get_text(row), position, row_height,
font_brush, null, horizontal_alignment, VerticalAlignment.Center, DefaultCellPadding);
}
@@ -519,7 +530,7 @@ namespace mbts.spark {
: base(Columns.Side, "B/S", r => r.side.ToString(), nameof(OrderBookRowVM.side), DefaultColumnWidths.Side, filter, DataGridFilterKnownTemplates.EnumValues, _wrap_comparer(r => r.side)) { }
public void draw(OrderBookRowVM row, DrawingContext dc, ColumnGeometry position, double row_height) =>
CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.side.ToString(), position, RowHeight,
CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.side.ToString(), position, row_height,
RenderUtils.get_side_brush(row), null, horizontal_alignment, VerticalAlignment.Center, DefaultCellPadding);
}
@@ -530,7 +541,7 @@ namespace mbts.spark {
}
public void draw(OrderBookRowVM row, DrawingContext dc, ColumnGeometry position, double row_height) =>
CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.quantity.ToString(), position, RowHeight,
CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.quantity.ToString(), position, row_height,
RenderUtils.get_side_brush(row), null, horizontal_alignment, VerticalAlignment.Center, DefaultCellPadding);
}
@@ -541,7 +552,7 @@ namespace mbts.spark {
}
public void draw(OrderBookRowVM row, DrawingContext dc, ColumnGeometry position, double row_height) =>
CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.filled_quantity.ToString(), position, RowHeight,
CellRender.draw_text(dc, _get_glyph_context(row), font_size, row.filled_quantity.ToString(), position, row_height,
RenderUtils.get_side_brush(row), null, horizontal_alignment, VerticalAlignment.Center, DefaultCellPadding);
}
@@ -640,6 +651,8 @@ namespace mbts.spark {
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
grid.Children.Add(toggle_button);
grid.Children.Add(security_view);
grid.HorizontalAlignment = HorizontalAlignment.Center;
grid.VerticalAlignment = VerticalAlignment.Center;
//
var border = new Border { Child = grid };
CellRender.set_background_animation_bindings(border, nameof(OrderBookRowVM.security));
@@ -651,6 +664,88 @@ namespace mbts.spark {
base.OnSortDirectionChanged(new_value);
}
}
public class CancelColumn : FrameworkElementColumnBase<Columns> {
readonly BindingBase _command_binding;
public CancelColumn(string command_property) : base(Columns.Cancel) {
id = key.ToString();
Header = DefaultColumnHeaders.Cancel;
_command_binding = new Binding(command_property);
}
public override FrameworkElement view_factory() {
var grid = new Grid() {
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
var l1 = new System.Windows.Shapes.Line() {
StrokeThickness = 1,
Stroke = Brushes.White,
X1 = 0.5,
Y1 = 0.5,
X2 = 7,
Y2 = 7
};
var l2 = new System.Windows.Shapes.Line() {
StrokeThickness = 1,
Stroke = Brushes.White,
X1 = 0.5,
Y1 = 7,
X2 = 7,
Y2 = 0.5
};
grid.Children.Add(l1);
grid.Children.Add(l2);
var button = new Button() {
Content = grid,
Background = Brushes.Red,
Foreground = Brushes.White,
Margin = new Thickness(2),
VerticalAlignment = VerticalAlignment.Center,
Height = 14,
Width = 14
};
button.SetBinding(Button.CommandProperty, _command_binding);
return button;
}
}
public class EditableQtyColumn:FrameworkElementColumnBase<Columns> {
public EditableQtyColumn() : base(Columns.EditableQty) {
id = key.ToString();
Header = "Qty";
Width = 64;
}
public override FrameworkElement view_factory() {
var tick_up_down = new TickUpDownNullableUIntCommit();
tick_up_down.SetBinding(TickUpDownNullableUIntCommit.SourceValueProperty, nameof(OrderBookRowVM.prospective_quantity));
tick_up_down.SetBinding(TickUpDownNullableUIntCommit.OnCommitProperty, nameof(OrderBookRowVM.modify_order_quantity));
return tick_up_down;
}
}
public class EditablePriceColumn : FrameworkElementColumnBase<Columns> {
public EditablePriceColumn() : base(Columns.EditablePrice) {
id = key.ToString();
Header = "Price";
Width = 96;
}
public override FrameworkElement view_factory() {
var price_up_down = new PriceEntryCommitControl();
price_up_down.SetBinding(PriceEntryCommitControl.SourceValueProperty, nameof(OrderBookRowVM.prospective_price));
price_up_down.SetBinding(PriceEntryCommitControl.SourceContractSpecProperty, nameof(OrderBookRowVM.contract_spec));
price_up_down.SetBinding(PriceEntryCommitControl.OnCommitProperty, nameof(OrderBookRowVM.modify_order_price));
return price_up_down;
}
}
#endregion
static class RenderUtils {
@@ -6,6 +6,9 @@ using mbts.ui;
using mbts.ui.controls;
using mbts.ui.shell;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace mbts.spark {
@@ -13,16 +16,35 @@ namespace mbts.spark {
const string _unknown_security_price_format_string = "0.#########";
const int _unknown_security_price_num_fractional_digits = 9;
readonly OrderBookVM _owner;
IRaiseCanExecuteChangedCommand _show_order_modify_cmd, _toggle_expanded_cmd;
bool _is_parent, _is_expanded;
IRaiseCanExecuteChangedCommand _show_order_modify_cmd, _toggle_expanded_cmd, _cancel_cmd, _modify_order_quantity, _modify_order_price;
bool _is_parent, _is_expanded, _is_selected;
int _depth_level;
SecurityImmutable? _security => order_tuple.security;
public OrderBookRowVM(OrderBookVM owner, OrderSecurity order_tuple) {
// for mini-ob
uint _prospective_quantity;
double _prospective_price;
public OrderBookRowVM(OrderBookVM owner, OrderSecurity order_tuple, bool is_expanded) {
_owner = owner;
this.order_tuple = order_tuple;
is_visible = !is_child;
_is_expanded = is_expanded;
prospective_quantity = this.quantity;
prospective_price = this.price;
this.invalidated += OrderBookRowVM_invalidated;
}
private void OrderBookRowVM_invalidated() {
modify_order_quantity?.TryRaiseCanExecuteChanged();
modify_order_price?.TryRaiseCanExecuteChanged();
}
protected override void Dispose(bool disposing) {
this.invalidated -= OrderBookRowVM_invalidated;
base.Dispose(disposing);
}
public event Action invalidated;
@@ -35,6 +57,7 @@ namespace mbts.spark {
public uint parent_order_key => order.ParentKey;
public uint security_key => order.security_key();
public SecurityImmutable? security => _security;
public ContractSpecificationImmutable? contract_spec => security.spec_or_default();
public string security_text => security.display_name();
public Venue exchange => _security.exchange_or_default();
public string symbol => _security.symbol_or_default();
@@ -73,6 +96,29 @@ namespace mbts.spark {
}
}
public int depth_level { get => _depth_level; set => Set(ref _depth_level, value); }
public bool is_selected {
get => _is_selected;
set => Set(ref _is_selected, value);
}
public uint prospective_quantity {
get => _prospective_quantity;
set {
if (Set(ref _prospective_quantity, value)) {
RaisePropertyChanged(nameof(is_qty_dirty));
}
}
}
public double prospective_price {
get => _prospective_price;
set {
if (Set(ref _prospective_price, value)) {
RaisePropertyChanged(nameof(is_price_dirty));
}
}
}
public bool is_qty_dirty => this.prospective_quantity != this.quantity;
public bool is_price_dirty => this.prospective_price != this.price;
// Commands
public ICommand toggle_command => _toggle_expanded_cmd ?? (
_toggle_expanded_cmd = new DelegateCommand(() => is_expanded = !is_expanded));
@@ -80,6 +126,27 @@ namespace mbts.spark {
ICommand DIYGrid.IActionableRowVM.default_command => _show_order_modify_cmd ??
(_show_order_modify_cmd = new DelegateCommand(() => _owner.show_order_modify(this), () => status == OrderStatus.Working));
public ICommand cancel_command => _cancel_cmd ??
(_cancel_cmd = new DelegateCommand(() => _owner.cancel_order(this), () => status == OrderStatus.Working));
public ICommand modify_order_quantity => _modify_order_quantity ??
(_modify_order_quantity = new DelegateCommand(
(desired_quantity) => _owner.modify_order_quantity(this, (uint)desired_quantity),
(desired_quantity) =>
(desired_quantity != null && this.status == OrderStatus.Working && (uint)desired_quantity != this.quantity)
|| is_qty_dirty
)
);
public ICommand modify_order_price => _modify_order_price ??
(_modify_order_price = new DelegateCommand(
(desired_price) => _owner.modify_order_price(this, (double)desired_price),
(desired_price) =>
(desired_price != null && this.status == OrderStatus.Working && (double)desired_price != this.price)
|| is_price_dirty
)
);
// These fns present a way for the orderbook to avoid noisy, intermittent collection changes during "Expand/Collapse All" ops,
// when incremental changes are ignored in favor of a full reset, after 'is_expanded' is updated for all rows.
internal void expand_internal() => Set(ref _is_expanded, true);
@@ -104,6 +171,14 @@ namespace mbts.spark {
// however, the order-type and security cells DO use databindings - if these cells have changed, the PropertyChanged event must be raised regardless of whether or not invalidated is raised
if (old_order.order_type() != order.order_type())
RaisePropertyChanged(nameof(order_type), nameof(order_metadata));
if (old_order.quantity() != order.quantity()) {
RaisePropertyChanged(nameof(quantity));
RaisePropertyChanged(nameof(is_qty_dirty));
}
if (old_order.price() != order.price()) {
RaisePropertyChanged(nameof(price));
RaisePropertyChanged(nameof(is_price_dirty));
}
if (!had_security && _security.HasValue) {
RaisePropertyChanged(nameof(security), nameof(security_text));
// need to raise invalidated to refresh the price cells (the security.ContractSpec determines how they are formatted - Ticks!)
@@ -15,6 +15,7 @@ using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using static bts.shell.OrderBookWindowFactory;
@@ -38,36 +39,47 @@ namespace mbts.spark {
readonly IWindowSettingsManager<OrderBookGridSettings> _settings_manager;
readonly List<IDisposable> _resources;
OrderBookStartupData _state;
bool _is_row_collection_populated;
public OrderBookVM(IObservable<string> owner_title, IBus bus, INotificationService notification_service, OrdersModel model, IWindowSettingsManager<OrderBookGridSettings> settings_manager) {
public OrderBookVM(IObservable<string> owner_title, IBus bus, INotificationService notification_service, OrdersModel model, IWindowSettingsManager<OrderBookGridSettings> settings_manager, bool rows_are_initially_expanded = false) {
_bus = bus;
_model = model;
_settings_manager = settings_manager;
_columns = new OrderBookColumnCollection(bus, model,
model.on_order_securities.Select(x => (x.added.Values, x.removed.Values)));
_row_collection = new OrderBookRowCollection(ort => new OrderBookRowVM(this, ort), _columns.get_sorting_data().comparer) { filter = _columns.get_filter() };
_columns = new OrderBookColumnCollection(bus, model, model.on_order_securities.Select(x => (x.added.Values, x.removed.Values)));
// we use an ObservableAppendCollection b/c the mini-ob needs a cancel column at the front
columns = new ObservableAppendCollection<DIYGrid.ColumnBase>(_columns);
_row_collection = new OrderBookRowCollection(ort => new OrderBookRowVM(this, ort, rows_are_initially_expanded), _columns.get_sorting_data().comparer) { filter = _columns.get_filter() };
_row_collection.CollectionChanged += _row_collection_CollectionChanged;
_current_row = backing<OrderBookRowVM>(nameof(current_row));
_columns.filter_changed += on_filter_changed;
collapse_all_rows_command = new DelegateCommand(_row_collection.collapse_all);
expand_all_rows_command = new DelegateCommand(_row_collection.expand_all);
grid_settings_manager = _create_grid_settings_manager(owner_title, bus, notification_service, model, rows, columns);
grid_settings_manager = _create_grid_settings_manager(owner_title, bus, notification_service, model, rows, core_columns);
_resources = new List<IDisposable> {
model.on_orders.OnDispatcher().Subscribe(_row_collection.update),
settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager),
grid_settings_manager,
Disposable.Create(() => {
_columns.filter_changed -= on_filter_changed;
_row_collection.CollectionChanged -= _row_collection_CollectionChanged;
Disposable.dispose(_row_collection);
}),
_columns
};
if (settings_manager != null) {
_resources.Add(settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager));
}
void on_filter_changed() => _row_collection.filter = _columns.get_filter();
}
private void _row_collection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
is_row_collection_populated = _row_collection.Count != 0;
}
public event Action<OrderRecordImmutable?> selected_order_changed;
public event Action<bool> OnDisposed;
public ObservableCollection<DIYGrid.ColumnBase> columns => _columns;
public ObservableAppendCollection<DIYGrid.ColumnBase> columns { get; }
public ObservableCollection<DIYGrid.ColumnBase> core_columns => _columns;
public ObservableCollection<OrderBookRowVM> rows => _row_collection;
public OrderBookRowVM current_row { get => _current_row.Value; set => _current_row.Value = value ?? _selected_rows.FirstOrDefault(); }
public OrderRecordImmutable? current_order => current_row?.order;
@@ -76,7 +88,23 @@ namespace mbts.spark {
public ICommand collapse_all_rows_command { get; }
public ICommand expand_all_rows_command { get; }
public bool is_row_collection_populated {
get => _is_row_collection_populated;
set => Set(ref _is_row_collection_populated, value);
}
public void row_selection_changed(SelectionChangedEventArgs e) {
if (e.RemovedItems != null) {
foreach (var row_vm in e.RemovedItems.Cast<OrderBookRowVM>()) {
row_vm.is_selected = false;
}
}
if (e.AddedItems != null) {
foreach (var row_vm in e.AddedItems.Cast<OrderBookRowVM>()) {
row_vm.is_selected = true;
}
}
RowSelectionHelper.apply_changes(_selected_rows, e);
selected_order_changed?.Invoke(current_order);
}
@@ -137,6 +165,15 @@ namespace mbts.spark {
internal void show_order_modify(OrderBookRowVM row) =>
_bus.post(SparkTags.ShowModifyOrderTag, row.order_key);
internal void cancel_order(OrderBookRowVM row) =>
_bus.post(SparkTags.CancelOrders, new List<uint> { row.order_key });
internal void modify_order_quantity(OrderBookRowVM row, uint size) =>
_bus.post(SparkTags.UpdateOrder, (row.order_key, row.price, size));
internal void modify_order_price(OrderBookRowVM row, double price) =>
_bus.post(SparkTags.UpdateOrder, (row.order_key, price, row.quantity));
internal void on_expanded_changed(OrderBookRowVM row) {
using (_row_collection.defer_refresh(true)) {
if (row.is_expanded) {
@@ -193,7 +230,8 @@ namespace mbts.spark {
return pvm;
},
(gen, anims) => new OrderBookGridSettings(gen, anims.Select(a => new OrderRecordTuplePredicateAnimations(a.predicate_builder, a.cell_animations, a.row_animations, a.sound_notifications))),
notification_service.data_cache, col_settings_flags);
(notification_service == null) ? null : notification_service.data_cache,
col_settings_flags);
}
static OrderRecordTuplePredicate.PredicateTypeOneofCase _corresponding_predicate_type(Columns col) {
@@ -5,7 +5,7 @@ namespace mbts.spark {
internal partial class OrderBookView : UserControl {
// IMPORTANT: these enums are stored as strings in the general-purpose GridColumnSettings proto, and are used to ID THE COLUMNS!
// Do NOT RENAME them! However, if you must, be sure to write an IShellWindowMigrationRule or something to account for backwards compatability.
public enum Columns { Security, Symbol, Time, LastChange, User, Account, Exchange, TimeInForce, OrderType, SubType, Side, Size, Price, Filled, AvgFilled, LastPrice, Status, LastMessage, SecurityKey, OrderKey, ParentKey }
public enum Columns { Security, Symbol, Time, LastChange, User, Account, Exchange, TimeInForce, OrderType, SubType, Side, Size, Price, Filled, AvgFilled, LastPrice, Status, LastMessage, SecurityKey, OrderKey, ParentKey, Cancel, EditableQty, EditablePrice }
public const string
SubTypeFilterTemplateKey = "SubTypeFilterTemplate",
ExpandCollapseToggleStyleKey = "ExpandCollapseToggleStyle",
@@ -14,8 +14,6 @@ namespace mbts.spark {
CVRowStyleKey = "CVRowStyle",
CVRowTemplateKey = "CVRowTemplateKey";
public const double RowHeight = 17;
public OrderBookView(OrderBookVM vm) {
InitializeComponent();
DataContext = vm;
@@ -23,6 +21,6 @@ namespace mbts.spark {
}
class OrderBookRowView : DIYGrid.HighPerformanceRow<OrderBookRowVM, OrderBookView.Columns> {
public OrderBookRowView() : base(OrderBookView.RowHeight) { }
public OrderBookRowView() : base() { }
}
}
@@ -131,7 +131,7 @@ namespace mbts.spark {
return _vm.grid_settings_manager.create_vm(
// we need to get the most up to date GridSettings when launching b/c users may
// have changed some settings on the grid directly, like column widths.
s.general.with(_vm.columns.Select(c => c.create())),
s.general.with(_vm.core_columns.Select(c => c.create())),
this.observe_title()
);
}
@@ -90,6 +90,8 @@ namespace bts.shell {
public static OrderBookGridSettings DefaultGrid => new OrderBookGridSettings(_default_general_grid);
static GridSettings _default_general_grid => GridSettings.Default.with(DefaultColumns.all, DefaultColumns.sorting_criterion);
public static GridSettings default_mini_grid => GridSettings.Default.with(DefaultColumns.mini, DefaultColumns.sorting_criterion);
static class DefaultColumns {
public static GridColumnSettings security => new GridColumnSettings(Columns.Security.ToString(), DIYGrid.DefaultColumnHeaders.Security, width: DIYGrid.DefaultColumnWidths.Security);
@@ -145,7 +147,23 @@ namespace bts.shell {
yield return parent_key;
}
}
}
private static HashSet<GridColumnSettings> _mini_mode_columns_to_hide = new HashSet<GridColumnSettings> {
time_created, exchange, sub_type, quantity, price, avg_price, last_price, status, last_message, security_key, order_key, parent_key
};
public static IEnumerable<GridColumnSettings> mini {
get {
foreach (var col_setting in all) {
if (_mini_mode_columns_to_hide.Contains(col_setting)) {
yield return col_setting.with(is_visible: false);
} else {
yield return col_setting;
}
}
}
}
}
}
[ProtoContract]
+11 -1
View File
@@ -31,7 +31,7 @@
<Reference Include="WindowsBase" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.ComponentModel.Composition" />
<PackageReference Include="Google.Protobuf" Version="3.4.0" />
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
<PackageReference Include="IronPython" Version="2.7.7" />
<PackageReference Include="NAudio" Version="1.8.4" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
@@ -54,6 +54,7 @@
<ItemGroup>
<None Remove="Sounds\game_sound_correct.wav" />
<None Remove="Sounds\whistle.wav" />
<None Remove="view\Controls\TickUpDown\TickUpDownNullableUIntCommit.xaml" />
<None Remove="view\Shell\Workspaces\WorkspacesView.xaml" />
</ItemGroup>
<ItemGroup>
@@ -71,11 +72,20 @@
<Folder Include="view\Extensions\ItemsControl\ObservableItemsSource\" />
</ItemGroup>
<ItemGroup>
<Compile Update="view\Controls\TickUpDown\TickUpDownNullableUIntCommit.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="view\Shell\Workspaces\WorkspacesDialogView.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Modules\Trading\OrderBook\MiniOrderBook\MiniOrderBookView.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
<None Update="Modules\Trading\OrderBook\MiniOrderBook\OrderBookView.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
<None Update="view\Controls\DIYGrid\Settings\SimpleGridSettingsDialog.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
+16
View File
@@ -9,6 +9,7 @@ using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Media;
using FontFamily = System.Windows.Media.FontFamily;
@@ -38,6 +39,7 @@ namespace mbts.ui.controls {
CustomOrderDefinition.CustomOneofCase _parent_algo_type;
(Point p1, Point p2, Point p3) _current_triangle_vertices;
StreamGeometry _triangle_geometry;
Popup _popup;
static Badge() {
@@ -181,6 +183,7 @@ namespace mbts.ui.controls {
_has_multiple_orders_at_level = HasMultipleOrdersAtLevel;
_is_hedge_order = IsHedgeOrder;
_gcr.glyph_context = GlyphContext.create(FontFamily, FontWeight);
_popup = Popup;
}
public static readonly DependencyProperty TextLinesProperty =
@@ -264,6 +267,19 @@ namespace mbts.ui.controls {
(b, v) => b._is_hedge_order = v,
false);
public Popup Popup {
get { return (Popup)GetValue(PopupProperty); }
set { SetValue(PopupProperty, value); }
}
public static readonly DependencyProperty PopupProperty =
WPFHelper.create_dp<Popup, Badge>(
nameof(Popup),
FrameworkPropertyMetadataOptions.AffectsRender,
(b, v) => b._popup = v,
null);
protected override Size ArrangeOverride(Size finalSize) => finalSize;
protected override Size MeasureOverride(Size availableSize) {
@@ -97,7 +97,8 @@ namespace mbts.ui.controls {
DayPnL = "Day PnL",
TotalNetPos = "Total Net Pos",
TotalPnL = "Total PnL",
PnLPrice = "PnL Price";
PnLPrice = "PnL Price",
Cancel = "Cancel";
}
public interface IKeyedColumn<TColKey> {
@@ -139,6 +139,7 @@ namespace mbts.ui.controls {
public static readonly Thickness
DefaultCellPadding = new Thickness(4, 2, 4, 2),
AnimatableCellPadding = new Thickness(8, 2, 4, 2);
public static readonly Visibility DefaultRowsHorizontalScrollBarVisibility = Visibility.Visible;
#region RoutedCommands
public static readonly RoutedCommand SortCommand = new RoutedCommand(), DefaultRowCommand = new RoutedCommand();
@@ -695,6 +696,14 @@ namespace mbts.ui.controls {
public static readonly DependencyProperty SelectionModeProperty = ListBox.SelectionModeProperty.AddOwner(typeof(DIYGrid));
public Visibility RowsHorizontalScrollBarVisibility {
get { return (Visibility)GetValue(RowsHorizontalScrollBarVisibilityProperty); }
set { SetValue(RowsHorizontalScrollBarVisibilityProperty, value); }
}
public static readonly DependencyProperty RowsHorizontalScrollBarVisibilityProperty = DependencyProperty.Register(
nameof(RowsHorizontalScrollBarVisibility), typeof(Visibility), typeof(DIYGrid), new PropertyMetadata(DefaultRowsHorizontalScrollBarVisibility));
#endregion
// Internal Methods
@@ -335,7 +335,7 @@
</ControlTemplate>
</bts:DIYGridRowsPresenter.Template>
</bts:DIYGridRowsPresenter>
<ScrollBar Grid.Row="3" Grid.Column="1" Orientation="Horizontal" LargeChange="10" x:Name="_scroll_horiz" />
<ScrollBar Grid.Row="3" Grid.Column="1" Orientation="Horizontal" LargeChange="10" x:Name="_scroll_horiz" Visibility="{TemplateBinding RowsHorizontalScrollBarVisibility}" />
<!-- todo: All edit controls go in a canvas - edit api is called with an edit type. Hide all controls -->
<!-- This stole hours of my life. The Text binding down there used to be 'value' and I was encountering -->
@@ -1,4 +1,5 @@
using bts.proto;
using bts.utils;
using ProtoBuf;
using System;
using System.ComponentModel;
@@ -18,7 +19,7 @@ namespace mbts.ui.settings {
}
[ProtoContract]
class GridColumnSettings {
class GridColumnSettings : IEquatable<GridColumnSettings> {
const bool
_default_is_visible = true,
_default_is_collapsed = false;
@@ -103,5 +104,43 @@ namespace mbts.ui.settings {
width ?? this.width,
horizontal_alignment ?? this.horizontal_alignment,
horizontal_offset ?? this.horizontal_offset);
public bool Equals(GridColumnSettings other) =>
other != null &&
id == other.id &&
display_name == other.display_name &&
is_visible == other.is_visible &&
is_collapsed == other.is_collapsed &&
font_weight_override.Equals(other.font_weight_override) &&
font_color_override.Equals(other.font_color_override) &&
width == other.width &&
horizontal_alignment == other.horizontal_alignment &&
horizontal_offset == other.horizontal_offset &&
display_name == other.display_name;
public override bool Equals(object obj) =>
Equals(obj as GridColumnSettings);
public override int GetHashCode() =>
EqualityComparer.aggregate_hash(
id.GetHashCode(),
display_name.GetHashCode(),
is_visible.GetHashCode(),
is_collapsed.GetHashCode(),
font_weight_override.GetHashCode(),
font_color_override.GetHashCode(),
width.GetHashCode(),
horizontal_alignment.GetHashCode(),
horizontal_offset.GetHashCode(),
display_name.GetHashCode()
);
public override string ToString() {
return $"id: {id} display_name: {display_name}";
}
}
}
@@ -127,13 +127,15 @@ namespace mbts.ui {
col.set_fallback_font_params(new FontFamily(grid.font_family), grid.font_size, grid.font_color.rgb_color(), grid.font_weight);
_predicate_animations_data = value.predicate_animations;
_animation_defs.clear();
foreach (var pa in _predicate_animations_data) {
var predicate = pa.predicate_builder.create_predicate(_arg);
foreach (var s in pa.sound_notifications) {
_notification_subs.Add(_notification_service.link(predicate, s));
}
if (pa.predicate_builder is INotificationPredicateBuilder<TRowData, TPredicateBuilderArg> tpb && tpb.is_toast_enabled) {
_notification_subs.Add(_notification_service.link(tpb.create_notification_predicate(_arg)));
if (_notification_service != null && _arg != null) {
foreach (var pa in _predicate_animations_data) {
var predicate = pa.predicate_builder.create_predicate(_arg);
foreach (var s in pa.sound_notifications) {
_notification_subs.Add(_notification_service.link(predicate, s));
}
if (pa.predicate_builder is INotificationPredicateBuilder<TRowData, TPredicateBuilderArg> tpb && tpb.is_toast_enabled) {
_notification_subs.Add(_notification_service.link(tpb.create_notification_predicate(_arg)));
}
}
}
// ** in the unfortunate event that we botch backwards compatability, and the columns don't bear a 1:1 relationship with the column-settings
@@ -0,0 +1,72 @@
<UserControl x:Class="mbts.ui.controls.PriceEntryCommitControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:u="clr-namespace:mbts.ui"
xmlns:cv="clr-namespace:mbts.ui.converters"
xmlns:uspcv="clr-namespace:mbts.ui.spark.converters"
xmlns:c="clr-namespace:mbts.ui.controls"
xmlns:usp="clr-namespace:mbts.ui.spark"
d:DesignHeight="100" d:DesignWidth="800" x:Name="_me_price">
<UserControl.Resources>
<cv:NullableDoubleConverter x:Key="TickDefaultPriceConverter" DefaultValue="0"/>
<uspcv:TickDisplayConverter x:Key="TickDisplayConverter" x:Shared="False"/>
<ControlTemplate x:Key="ReadTemplate">
<Grid HorizontalAlignment="Right" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.ColumnSpan="2">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource TickDisplayConverter}">
<Binding Path="SourceValue" ElementName="_me_price"/>
<Binding Path="SourceContractSpec" ElementName="_me_price"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="EditTemplate">
<Grid HorizontalAlignment="Right" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<usp:PriceEntryControl x:Name="price_ticker"
Margin="0,0,2,0"
TickDefaultValue="{Binding SourceValue, ElementName=_me_price, Converter={StaticResource TickDefaultPriceConverter}, FallbackValue={u:Double 0}}"
ContractSpec="{Binding SourceContractSpec, ElementName=_me_price}"
Value="{Binding SourceValue, ElementName=_me_price}" />
<Button Grid.Column="2" x:Name="commit_button" CommandParameter="{Binding Value, ElementName=price_ticker}" Command="{Binding OnCommit, ElementName=_me_price}" Content="✔" >
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Background" Value="Green" />
<Setter Property="Foreground" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</Grid>
</ControlTemplate>
</UserControl.Resources>
<UserControl.Style>
<Style TargetType="UserControl">
<Setter Property="Template" Value="{StaticResource ReadTemplate}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding is_selected}" Value="True">
<Setter Property="Template" Value="{StaticResource EditTemplate}"/>
</DataTrigger>
<DataTrigger Binding="{Binding is_price_dirty}" Value="True">
<Setter Property="Template" Value="{StaticResource EditTemplate}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Style>
</UserControl>
@@ -0,0 +1,73 @@
using bts.api;
using System;
using System.Collections.Generic;
using System.Globalization;
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.controls {
/// <summary>
/// Interaction logic for PriceEntryCommitControl.xaml
/// </summary>
public partial class PriceEntryCommitControl : UserControl {
public static readonly DependencyProperty SourceValueProperty =
DependencyProperty.Register("SourceValue",
typeof(double),
typeof(PriceEntryCommitControl),
new FrameworkPropertyMetadata {
BindsTwoWayByDefault = true,
PropertyChangedCallback = source_value_changed
}
);
public double SourceValue {
get => (double)GetValue(SourceValueProperty);
set => SetValue(SourceValueProperty, value);
}
private static void source_value_changed(DependencyObject d, DependencyPropertyChangedEventArgs e) {
if (d is PriceEntryCommitControl _instance_of_me) {
_instance_of_me.Dispatcher.BeginInvoke(
(Action)(() => _instance_of_me.OnCommit?.TryRaiseCanExecuteChanged())
);
}
}
public static readonly DependencyProperty SourceContractSpecProperty =
DependencyProperty.Register("SourceContractSpec", typeof(ContractSpecificationImmutable?), typeof(PriceEntryCommitControl));
public ContractSpecificationImmutable? SourceContractSpec {
get => (ContractSpecificationImmutable?)GetValue(SourceContractSpecProperty);
set => SetValue(SourceContractSpecProperty, value);
}
// public static readonly DependencyProperty PriceTextProperty =
//DependencyProperty.Register("PricText", typeof(string), typeof(PriceEntryCommitControl));
// public string PriceText {
// get => (string)GetValue(PriceTextProperty);
// set => SetValue(PriceTextProperty, value);
// }
public static readonly DependencyProperty OnCommitProperty =
DependencyProperty.Register("OnCommit", typeof(ICommand), typeof(PriceEntryCommitControl));
public ICommand OnCommit {
get => (ICommand)GetValue(OnCommitProperty);
set => SetValue(OnCommitProperty, value);
}
public PriceEntryCommitControl() {
InitializeComponent();
}
}
}
@@ -0,0 +1,55 @@
<UserControl x:Class="mbts.ui.controls.TickUpDownNullableUIntCommit"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:c="clr-namespace:mbts.ui.controls"
d:DesignHeight="100" d:DesignWidth="800" x:Name="_me">
<UserControl.Resources>
<ControlTemplate x:Key="ReadTemplate">
<Grid HorizontalAlignment="Right" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.ColumnSpan="2" Text="{Binding SourceValue, ElementName=_me}" />
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="EditTemplate">
<Grid HorizontalAlignment="Right" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<c:TickUpDownNullableUInt x:Name="qty_ticker" Margin="0,0,2,0" Value="{Binding SourceValue, ElementName=_me}" />
<Button Grid.Column="2" x:Name="commit_button" CommandParameter="{Binding Value, ElementName=qty_ticker}" Command="{Binding OnCommit, ElementName=_me}" Content="✔" >
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Background" Value="Green" />
<Setter Property="Foreground" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</Grid>
</ControlTemplate>
</UserControl.Resources>
<UserControl.Style>
<Style TargetType="UserControl">
<Setter Property="Template" Value="{StaticResource ReadTemplate}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding is_selected}" Value="True">
<Setter Property="Template" Value="{StaticResource EditTemplate}"/>
</DataTrigger>
<DataTrigger Binding="{Binding is_qty_dirty}" Value="True">
<Setter Property="Template" Value="{StaticResource EditTemplate}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Style>
</UserControl>
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Globalization;
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.controls {
/// <summary>
/// Interaction logic for TickUpDownNullableUIntCommit.xaml
/// </summary>
public partial class TickUpDownNullableUIntCommit : UserControl {
public static readonly DependencyProperty SourceValueProperty =
DependencyProperty.Register("SourceValue",
typeof(uint?),
typeof(TickUpDownNullableUIntCommit),
new FrameworkPropertyMetadata {
BindsTwoWayByDefault = true,
PropertyChangedCallback = source_value_changed
}
);
private static void source_value_changed(DependencyObject d, DependencyPropertyChangedEventArgs e) {
if (d is TickUpDownNullableUIntCommit _instance_of_me) {
_instance_of_me.Dispatcher.BeginInvoke(
(Action)(() => _instance_of_me.OnCommit?.TryRaiseCanExecuteChanged())
);
}
}
public uint? SourceValue {
get => GetValue(SourceValueProperty) as uint?;
set => SetValue(SourceValueProperty, value);
}
public static readonly DependencyProperty OnCommitProperty =
DependencyProperty.Register("OnCommit", typeof(ICommand), typeof(TickUpDownNullableUIntCommit));
public ICommand OnCommit {
get => (ICommand)GetValue(OnCommitProperty);
set => SetValue(OnCommitProperty, value);
}
public TickUpDownNullableUIntCommit() {
InitializeComponent();
}
}
}
@@ -37,7 +37,7 @@ namespace mbts.spark {
readonly Property<Brush> _foreground, _background, _hoverbackground, _border, _parent_algo_type_brush;
readonly Property<bool> _is_exchange_order, _has_multiple_orders_at_same_level, _is_hedge_order;
readonly Property<CustomOrderDefinition.CustomOneofCase> _parent_algo_type;
readonly Property<string> _summary, _description;
readonly Property<string> _summary;
IObservable<LadderSettings.BadgeStyle> _bs;
LadderSettings.BadgeStyle _current_badge_style;
int _n_active_price_change_ops = 0;
@@ -63,7 +63,6 @@ namespace mbts.spark {
_hoverbackground = backing(nameof(hoverbackground), _color_bg_brush);
_border = backing(nameof(border), _color_bg_brush);
_summary = backing(nameof(summary), string.Empty);
_description = backing(nameof(description), string.Empty);
_is_exchange_order = backing(nameof(is_exchange_order), false);
_has_multiple_orders_at_same_level = backing(nameof(has_multiple_orders_at_same_level), false);
_is_hedge_order = backing(nameof(is_hedge_order), false);
@@ -75,6 +74,7 @@ namespace mbts.spark {
Brush get_foreground(LadderSettings s) => s.orders_column.foreground.rgb_brush();
//
add_order(o);
_dispose = Disposable.Create(
_bs.Subscribe(badge => {
_current_badge_style = badge;
@@ -122,7 +122,6 @@ namespace mbts.spark {
if (_orders.Any()) {
summary = _orders.Values.Select(order => order.short_description(_parent.security.ContractSpec)).Aggregate((s1, s2) => $"{s1}{Environment.NewLine}{Environment.NewLine}{s2}");
description = _orders.Values.Select(order => order.full_description(_parent.security)).Aggregate((s1, s2) => $"{s1}{Environment.NewLine}{Environment.NewLine}{s2}");
}
_set_badge_text();
@@ -185,11 +184,10 @@ namespace mbts.spark {
public Brush hoverbackground { get => _hoverbackground.Value; private set => _hoverbackground.Value = value; }
public Brush border { get => _border.Value; private set => _border.Value = value; }
public string summary { get => _summary.Value; private set => _summary.Value = value; }
public string description { get => _description.Value; private set => _description.Value = value; }
public bool is_exchange_order { get => _is_exchange_order.Value; private set => _is_exchange_order.Value = value; }
public bool has_multiple_orders_at_same_level { get => _has_multiple_orders_at_same_level.Value; private set => _has_multiple_orders_at_same_level.Value = value; }
public bool is_hedge_order { get => _is_hedge_order.Value; private set => _is_hedge_order.Value = value; }
public Brush parent_algo_type_brush { get => _parent_algo_type_brush.Value; private set => _parent_algo_type_brush.Value = value; }
public Brush parent_algo_type_brush { get => _parent_algo_type_brush.Value; private set => _parent_algo_type_brush.Value = value; }
// the setter is public so that the LadderVM can set this field
public CustomOrderDefinition.CustomOneofCase parent_algo_type { get => _parent_algo_type.Value; set => _parent_algo_type.Value = value; }
@@ -224,6 +222,56 @@ namespace mbts.spark {
}
}
public OrderBookVM create_orderbook_vm() {
// We are returning a new OrderBookVM each time b/c after
// successive launches of the mini-ob from the same badge, we get an exception
// System.InvalidOperationException: Sharing GridViewColumn among multiple GridViewColumnCollections or adding the same GridViewColumn into one GridViewColumnCollection more than once is not allowed.
// I checked with Eric and he guesses that what is happening is that the Popup is throwing away the grid, but the binding doesn't remove the columns from that grid
//
// I think returning a new OrderbookVM is okay at the moment since this Popup window will not be saving any state at this time
var price_filter = new filters.DoubleMinMaxState();
price_filter.minimum.value = real_price;
price_filter.maximum.value = real_price;
var obvm = new OrderBookVM(null, _parent.bus, null, _parent.model.order_gateway, null, true);
var state = new bts.shell.OrderBookWindowFactory.OrderBookStartupData(
new bts.shell.OrderBookWindowFactory.FilterStates {
security_criteria = new SecurityCriteria(_parent.security),
price = price_filter,
statuses = new[] { OrderStatus.Working }
},
bts.shell.OrderBookWindowFactory.OrderBookStartupData.default_mini_grid,
use_defaults: false
);
// NOTE:
// we might need the ObservableAppend to InsertAt
// if these EditXXX ever support settings.
// insert the cancel column
obvm.columns.Insert(0, new OrderBookVM.CancelColumn(nameof(OrderBookRowVM.cancel_command)));
var qty_col = obvm.columns.FirstOrDefault(x => x.id == OrderBookView.Columns.Size.ToString());
var qty_index = obvm.columns.indexOf(qty_col);
if (qty_index > -1) {
// insert the edit column in the same position that the hidden column occupies
var existing_editqty_col = obvm.columns.FirstOrDefault(x => x.id == OrderBookView.Columns.EditableQty.ToString());
var existing_editqty_index = obvm.columns.indexOf(existing_editqty_col);
if (existing_editqty_index == -1) {
obvm.columns.Insert(qty_index, new OrderBookVM.EditableQtyColumn());
}
}
var price_col = obvm.columns.FirstOrDefault(x => x.id == OrderBookView.Columns.Price.ToString());
var price_index = obvm.columns.indexOf(price_col);
if (price_index > -1) {
var existing_editprice_col = obvm.columns.FirstOrDefault(x => x.id == OrderBookView.Columns.EditablePrice.ToString());
var existing_editprice_index = obvm.columns.indexOf(existing_editprice_col);
if (existing_editprice_index == -1) {
// insert the edit price column immediately after the edit qty
obvm.columns.Insert(qty_index + 1, new OrderBookVM.EditablePriceColumn());
}
}
obvm.load_from(state);
return obvm;
}
public override string ToString() {
return $"Price: {this.price} Order Count: {this.orders.Count()}";
}
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@@ -91,15 +92,26 @@ namespace mbts.spark {
order.PropertyChanged += _order_PropertyChanged;
// get the stackpanel it belongs in
Panel panel = get_panel(price);
//var coords = GetAbsolutePlacement(panel, true);
// insert Badge and wire up DataContext
if (panel != null) {
panel.Children.Add(mkbadge(order));
panel.Children.Add(mkbadge(order, panel));
}
} //else {
//Log.Ui.warn($"Failed to add order ({order.id}): order already in {nameof(LadderGridHost)}'s {nameof(_orders)}.");
//}
}
public static Rect GetAbsolutePlacement(FrameworkElement element, bool relativeToScreen = false) {
var absolutePos = element.PointToScreen(new System.Windows.Point(0, 0));
if (relativeToScreen) {
return new Rect(absolutePos.X, absolutePos.Y, element.ActualWidth, element.ActualHeight);
}
var posMW = Application.Current.MainWindow.PointToScreen(new System.Windows.Point(0, 0));
absolutePos = new System.Windows.Point(absolutePos.X - posMW.X, absolutePos.Y - posMW.Y);
return new Rect(absolutePos.X, absolutePos.Y, element.ActualWidth, element.ActualHeight);
}
void _order_PropertyChanged(object sender, PropertyChangedEventArgs e) {
if (e.PropertyName == nameof(LadderOrderVM.price)) {
var order = (LadderOrderVM)sender;
@@ -108,35 +120,38 @@ namespace mbts.spark {
}
}
Badge mkbadge(LadderOrderVM order) {
Badge mkbadge(LadderOrderVM order, UIElement popup_placement_target) {
Badge b = new Badge();
b.DataContext = order;
// Hook up the style from xaml
b.Style = this.TryFindResource(typeof(Badge)) as Style;
b.MouseUp += (s, e) => {
b.MouseUp += async (s, e) => {
var curr_order = b.DataContext as LadderOrderVM;
if (e.ChangedButton == MouseButton.Middle) {
b.ContextMenu.DataContext = b.DataContext;
b.ContextMenu.IsOpen = true;
// close context menu after command executed
if (curr_order != null) {
Action command_executed = null;
command_executed = () => {
try {
b.ContextMenu.IsOpen = false;
curr_order.command_executed -= command_executed;
} catch (Exception ex) {
Log.Ui.warn($"Error in {typeof(LadderGridHost)}'s {typeof(Badge)} {nameof(LadderOrderVM.command_executed)} local handler: {ex}");
}
};
curr_order.command_executed += command_executed;
}
// create the new popup window in here
var obvm = order.create_orderbook_vm();
await Task.Delay(100); // Wait for obvm to load rows collection before showing UI to avoid a flash
var view = new MiniOrderBookView(obvm);
var popup = new System.Windows.Controls.Primitives.Popup {
// we only keep the obvm around assigned to the DataContext so that we can
// properly Dispose of it later when the popup is closed.
DataContext = obvm,
Child = view,
StaysOpen = false,
PlacementTarget = popup_placement_target,
Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom,
VerticalOffset = 5
};
popup.SetBinding(System.Windows.Controls.Primitives.Popup.IsOpenProperty,
nameof(OrderBookVM.is_row_collection_populated)
);
popup.Closed += (sender, event_args) => (popup.DataContext as IDisposable)?.Dispose();
b.Popup = popup;
} else if (e.ChangedButton == MouseButton.Left) {
if (curr_order?.cancel_command?.CanExecute(null) == true)
curr_order.cancel_command.Execute(null);
}
};
b.ContextMenuOpening += (s, e) => e.Handled = true;
return b;
}
@@ -533,29 +533,12 @@
<Setter Property="Foreground" Value="{Binding foreground}"/>
<Setter Property="TextLines" Value="{Binding text_lines}" />
<Setter Property="Width" Value="{x:Static controls:Badge.DefaultWidth}"/>
<Setter Property="ToolTip" Value="{Binding description}" />
<Setter Property="IsExchangeOrder" Value="{Binding is_exchange_order}" />
<Setter Property="HasMultipleOrdersAtLevel" Value="{Binding has_multiple_orders_at_same_level}" />
<Setter Property="IsHedgeOrder" Value="{Binding is_hedge_order}" />
<Setter Property="ParentAlgoType" Value="{Binding parent_algo_type}" />
<Setter Property="ParentAlgoTypeBrush" Value="{Binding parent_algo_type_brush}" />
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Command="{Binding cancel_command}" Header="Cancel">
<MenuItem.Icon>
<Image Source="{StaticResource CancelSelected}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="{Binding detach_command}" Header="Detach">
<MenuItem.Icon>
<Image Source="{StaticResource ModifyOrder}" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{Binding hoverbackground}" />
+1 -1
View File
@@ -15,7 +15,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.4.0" />
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
<PackageReference Include="System.Reactive" Version="3.1.1" />
</ItemGroup>
+1 -1
View File
@@ -21,7 +21,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.4.0" />
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
<PackageReference Include="System.Reactive" Version="3.1.1" />
<PackageReference Include="System.Reactive.PlatformServices" Version="3.1.1" />
<PackageReference Include="NUnit" Version="3.10.1" />
+1 -1
View File
@@ -22,7 +22,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.4.0" />
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
<PackageReference Include="System.Reactive" Version="3.1.1" />
<PackageReference Include="System.Reactive.PlatformServices" Version="3.1.1" />
<PackageReference Include="NUnit" Version="3.10.1" />
+37 -3
View File
@@ -12,6 +12,7 @@ using bts.test;
using bts.api.orderman;
using mbts;
using mbts.tests;
using bts.co2;
namespace bts.tests
{
@@ -36,6 +37,39 @@ namespace bts.tests
Disposable.dispose(ref _context);
}
async Task<IEnumerable<SecurityImmutable>> all_futures(string symbol) {
var request = new MDRequest() {
Host = "system_test",
Channels = {
new SecurityChannel() {
Time = 0,
Flags = 0,
Type = SecurityType.Future,
Exchange = Venue.Sim,
Symbol = symbol,
TradeCursor = 0,
RfqCursor = 0
}
}
};
var relay = _context.locate<MarketDataRelay>();
await Task.Delay(100);
var result = await relay.requestmd_async(request);
List<SecurityImmutable> securities = new List<SecurityImmutable>();
if (result.success) {
foreach (var ch in result.value.Channels) {
foreach (var update in ch.Updates) {
if (update.Security != null) {
securities.Add(new SecurityImmutable(update.Security));
}
}
}
}
return securities;
}
[Test]
public async Task test_clip_limits() {
//Get and set limit values from the admin service
@@ -53,9 +87,9 @@ namespace bts.tests
//create Orders Here
bts.md.MarketDataClient mdc = new bts.md.MarketDataClient();
SecurityImmutable? sec = await mdc.find_security_async(y => y.Symbol == test_symbol && y.Exchange == Venue.Sim);
var all = await all_futures(test_symbol);
SecurityImmutable? sec = all.FirstOrDefault();
Assert.IsTrue(sec.HasValue);
uint under_limit_order_key;
uint over_limit_order_key;
+1 -1
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<Platform>x64</Platform>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
+3 -3
View File
@@ -8,10 +8,10 @@ using System.Linq;
namespace sparkcmd {
class Program {
static void Main(string[] args) {
static int Main(string[] args) {
mbts.config.Configuration.initialize();
var commands = ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);
return;
return ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);
}
}
}
+2 -3
View File
@@ -2,8 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net471</TargetFramework>
<!--<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>-->
<TargetFrameworks>net471;netcoreapp2.1</TargetFrameworks>
<RuntimeIdentifiers>win7-x64;ubuntu.16.04-x64</RuntimeIdentifiers>
<Authors>Blue Trading Systems</Authors>
<Company>Blue Trading Systems</Company>
@@ -18,7 +17,7 @@
<ProjectReference Include="../spark_api/spark_api.csproj" />
<!--<ProjectReference Include="..\spark\Spark.csproj" />-->
<ProjectReference Include="..\spark_core\spark_core.csproj" />
<ProjectReference Include="..\spark_test\spark_test.csproj" Condition="'$(Configuration)'=='Debug'" />
<ProjectReference Include="..\spark_test\spark_test.csproj" />
<!--<Proto3 Include="**/*.proto" />-->
</ItemGroup>
+7
View File
@@ -3,3 +3,10 @@
rm -rf $1
mkdir $1
cp -r $2/files/* $1
for filename in $1/*; do
if [[ $filename == *.xz ]]; then
echo Decompressing $filename
unxz $filename
fi
done
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/services/AdminService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDClient.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityCache.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SecurityOracle.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp)
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/services/AdminService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metrics/system_metrics.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderBuilder.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.cpp;orderman/limiter/ProductLimitNode.cpp;orderman/limiter/ProductLimitTree.cpp;orderman/limiter/SecurityLimitNode.cpp;orderman/limiter/SecurityLimitTree.cpp;orderman/limiter/tests/limit_tests.cpp;orderman/order_factory/DynaLine truncated
+1
View File
@@ -0,0 +1 @@
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/services/AdminService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp)
+1
View File
@@ -14,6 +14,7 @@ namespace internal {
using namespace ::google::protobuf;
using namespace bts::expression;
using namespace bts::util::proto;
using std::vector;
ConfigValueQueue::ConfigValueQueue(IPropertyEvaluator& evaluator) :
_eval(evaluator),
+3 -3
View File
@@ -124,14 +124,14 @@ message RecordOptions {
// Replay options
//
message ReplayOptions {
optional string host = 1 [default = "mdreplay"];
optional string base_path = 2 [default = "/spark"];
optional string file_name = 3 [default = "futures.coconut"];
optional string url = 1 [default = "http://mdreplay.bluetradesys.local/spark/futures.coconut"];
// 2.0 = double speed, 0.5 = half speed
optional double speed = 11 [default = 1.0];
optional bool interactive = 12 [default = false];
optional string fallback = 20 [default ="data_files/futures.coconut"];
}
message RelayOptions {
@@ -50,6 +50,7 @@
#include <stack>
#include <limits>
#include <vector>
using std::vector;
#include "text_format.h"
+26 -3
View File
@@ -183,23 +183,46 @@ void replay_url(const std::string& url, IRelayWriter& writer, int32_t naggle_ms)
auto filename = url.substr(last_slash+1);
filename = os::sparkdata_path("data/replay/") + filename;
utils::download_file_if_newer(host, path, filename);
replay_file(filename, writer, naggle_ms, true);
if (boost::filesystem::exists(filename)) {
replay_file(filename, writer, naggle_ms, true);
}
}
void replay_url_with_fallback(const std::string& url, IRelayWriter& writer, int32_t naggle_ms) {
// loops forever
replay_url(url, writer, naggle_ms);
// If it returns it means it failed to download or play cached
const auto fallback = config::get<ReplayOptions>().fallback();
if (boost::filesystem::exists(fallback)) {
replay_file(fallback, writer, naggle_ms);
}
}
shared_ptr<IRelayWriter> mkrelayproducer(bool shared);
/*this is the public one*/
void replay_recording(const string& filename, int32_t naggle_ms) {
void replay_recording(const string& filename, int32_t naggle_ms, const std::string fallback) {
auto writer = mkrelayproducer(true);
if (config::get<ReplayOptions>().interactive()) {
naggle_ms = -1;
}
// Try relay_url/replay_file
// If it fails resort to the fallback location
if (filename.find("http://") == 0) {
// loops forever
replay_url(filename, *writer, naggle_ms);
}
else {
else if (boost::filesystem::exists(filename)) {
// loops forever
replay_file(filename, *writer, naggle_ms);
}
// try fallback
if (boost::filesystem::exists(fallback)) {
replay_file(fallback, *writer, naggle_ms);
}
}
void print_recording(const string& filename) {
ConsoleReplayWriter writer;
+2 -1
View File
@@ -28,8 +28,9 @@ void record_everything(std::string path, std::string filename);
void print_recording(const std::string&);
void unprint_recording(const std::string& src, const std::string& dest);
void trace_recording(const std::string& file, security_key key);
void replay_recording(const std::string&, int32_t delay_ms);
void replay_recording(const std::string&, int32_t delay_ms, const std::string fallback="");
void replay_url(const std::string& url, IRelayWriter& writer, int32_t naggle_ms);
void replay_url_with_fallback(const std::string& url, IRelayWriter& writer, int32_t naggle_ms);
void replay_file(const std::string& filename, IRelayWriter& writer, int32_t naggle_ms, bool loop=false);
}}//namespace
+29 -28
View File
@@ -276,7 +276,7 @@ void NativeOrder::on_init_from_exe_report(
NativeOrder::~NativeOrder() {}
void NativeOrder::_on_activate(Price p, Quantity q,
bool NativeOrder::_on_activate(Price p, Quantity q,
bts::orderman::OrderServices &services,
trace::CorID const &trace) {
auto scoped_log =
@@ -300,7 +300,7 @@ void NativeOrder::_on_activate(Price p, Quantity q,
"Dropping order {}",
key().value());
transition(ORDER_STATUS_REJECTED_BY_SPARK, "Exchange gateway is down");
return;
return false;
}
// can we trade?
@@ -316,7 +316,7 @@ void NativeOrder::_on_activate(Price p, Quantity q,
transition(ORDER_STATUS_REJECTED_BY_SPARK,
fmt::format("Unauthorized order: {}", lqr.error_msg));
return;
return false;
}
// can we trade this security, with this size?
@@ -333,7 +333,7 @@ void NativeOrder::_on_activate(Price p, Quantity q,
transition(ORDER_STATUS_REJECTED_BY_SPARK,
fmt::format("Order would breach limit: {}", lqr.error_msg));
return;
return false;
}
// are we under the messaging threshold?
@@ -344,7 +344,7 @@ void NativeOrder::_on_activate(Price p, Quantity q,
key().value());
transition(ORDER_STATUS_REJECTED_BY_SPARK,
"Messaging threshold breached");
return;
return false;
}
// if we are here we are good.
@@ -383,21 +383,22 @@ void NativeOrder::_on_activate(Price p, Quantity q,
auto const &ts = services.get_time_str();
me->create_transact_time_bm = encoding.overwrite(
me->create_transact_time_bm, &ts.value()[0], ts.value().size());
return true;
}
void NativeOrder::warm_up_activate(OrderServicesData&data, OrderServices& services) {
void NativeOrder::warm_up_activate(OrderServicesData &data,
OrderServices &services) {
bts_assert(!me->services);
me->services = &services;
init_order_services(data,services);
_on_activate(Price(0),Quantity(0),services, trace::CorID{});
init_order_services(data, services);
_on_activate(Price(0), Quantity(0), services, trace::CorID{});
me->services->unsubscribe_from_exe_report(
*me->session_services,me->exe_report_sid);
me->services->unsubscribe_from_cancel_reject(
*me->session_services,me->cancel_reject_sid);
me->services->unsubscribe_from_gateway_status(
*me->session_services);
me->services = nullptr;
me->services->unsubscribe_from_exe_report(*me->session_services,
me->exe_report_sid);
me->services->unsubscribe_from_cancel_reject(*me->session_services,
me->cancel_reject_sid);
me->services->unsubscribe_from_gateway_status(*me->session_services);
me->services = nullptr;
}
void NativeOrder::on_activate(Price p, Quantity q,
@@ -408,22 +409,22 @@ void NativeOrder::on_activate(Price p, Quantity q,
switch (me->state.status()) {
case ORDER_STATUS_INACTIVE: {
case ORDER_STATUS_INACTIVE:
// this is a brand new order
if (_on_activate(p, q, services, trace)) {
me->services->queue_fix(*me->session_services,
jetfix::MessageTypes::NewOrderSingle,
me->create_encoding, trace);
_on_activate(p,q,services,trace);
me->services->queue_fix(*me->session_services,
jetfix::MessageTypes::NewOrderSingle,
me->create_encoding, trace);
me->services->governor(*me->session_services).record_sent();
me->state.set_status(ORDER_STATUS_PENDING_WORKING);
me->services->governor(*me->session_services).record_sent();
me->state.set_status(ORDER_STATUS_PENDING_WORKING);
LOG(OrderMan, Info, "Sent new order with key {} to gateway",
key().value());
// early return so we skip the expensive report_state() call
return;
}
LOG(OrderMan, Info, "Sent new order with key {} to gateway",
key().value());
// early return so we skip the expensive report_state() call
return;
}
break;
// all cases below are for orders recovered from disk
case ORDER_STATUS_WORKING:
+1 -1
View File
@@ -39,7 +39,7 @@ protected:
struct PImpl;
std::unique_ptr<PImpl> me;
void _on_activate(Price, Quantity, bts::orderman::OrderServices &,
bool _on_activate(Price, Quantity, bts::orderman::OrderServices &,
trace::CorID const &);
void on_exe_report(const NewExecutionReportEvent &);
void on_cancel_reject(const CancelRejectEvent &);
+1 -3
View File
@@ -544,7 +544,6 @@ uint64_t tick_count() {
#endif
}
#ifdef _WIN32
std::vector<std::string> g_cmd_args;
bool g_cmd_args_set;
@@ -559,14 +558,13 @@ extern "C" BTS_EXPORT void provide_command_line(const char **argv, int argc) {
g_cmd_args_set = true;
}
}
#endif
std::vector<std::string> get_command_line() {
#ifdef _WIN32
if (g_cmd_args_set) {
// return cached copy
return g_cmd_args;
}
#ifdef _WIN32
for (int index = 0; index < __argc; index++) {
if (__argv != nullptr) {
g_cmd_args.push_back(__argv[index]);
+1
View File
@@ -65,6 +65,7 @@ HTTPStream::HTTPStream(const std::string& host, const std::string& path, const s
HTTPStream::~HTTPStream() { }
// returns true if file was downloaded
bool download_file_if_newer(const string& host, const string& path, const string& destination) {
struct stat st = boost::initialized_value;
stat(destination.c_str(), &st);
+35 -13
View File
@@ -62,10 +62,25 @@ run ```build_examples.sh``` to make sure you can build the examples, this will p
$ cd ~/spark_sdk/examples
$ ./build_examples.sh
```
### Server Layout
* Spark servers reside on a port, usually 8000, but your production instance could be on a different $PORT
##### SDK Package Layout
* The sdk puts logs in ``~/sparkdata/data/logging/log``
* The sdk package has binaries in ``spark_skd/lib``
* Put plugins in ``spark_sdk/lib/plugins/`` for debugging
##### Production layout
* Production Logs are in ``~/$PORT/sparkdata/data/logging/log`` on the host
* Production binaries are in ``/sparkbin`` inside the docker container
* Production algo plugins should go into the ``/sparkbin/plugins`` directory
### Recorded market data
* If you want to see prices, before you start sparkd, you'll have to extract the futures.coconut.tar.gz found at the root of the sdk repo and place futures.coconut in ``~/sparkdata/data/replay/``
## Debugging
Copy the order_plugin_example.so to ```spark_sdk/lib/plugins/``` and start the sparkd server process inside gdb
Copy the order_plugin_example.so to ``spark_sdk/lib/plugins/`` and start the sparkd server process inside gdb
```
$ cp -f order_plugin_example.so ~/spark_sdk/lib/plugins/
$ cd ~/spark_sdk/lib
@@ -87,24 +102,31 @@ $ cp -f order_plugin_example.so ~/spark_sdk/lib/plugins/
$ cd ~/spark_sdk/lib
$ ./sparkd run
```
## Connect to Admin (Risk) UI to set limits or add users
* Browse to http://location:$PORT
* Login as bts, no password
* Add or manage user trading and market data permissions by clicking the Users icon on the left side
* Add or manage accounts and risk limits by clicking on the Accounts icon on the left side
## Other interesting web accessible things
* When you have a running server you can:
* Browse to http://location/$PORT/config to check configuration overrides
* Browse to http://location:$PORT/perf_trace to see socket to socket latencies
* Send us an email for help: api_support@bluetradesys.com
## Connect Spark windows client
* To start a spark client, use the -ConfigServer parameter to point at this new server
```
> spark.exe -ConfigServer http://location/8000/config
> spark.exe -ConfigServer http://location:$PORT/config
```
Or create a file called spark.conf at %APPDATA%\bts\conf\ that contains:
```
include: "http://location:8000/config/"
include: "http://location:$PORT/config/"
```
## Notes
* When you have a running server you can:
* Browse to http://location/8000 to set risk limits and create users
* Browse to http://location/8000/config to check configuration overrides
* Browse to http://location/8000/perf_trace to see socket to socket latencies
* Send us an email for help: api_support@bluetradesys.com
## Download the Spark windows client
* Download the bts installer here:
@@ -148,7 +148,7 @@ int start_exchange_sim()
switch(conf.source_case()) {
case config::ExchangeSim::SOURCE_NOT_SET:
case config::ExchangeSim::kReplayUrl:
md::replay_url(conf.replay_url(),
md::replay_url_with_fallback(conf.replay_url(),
player,
config::get<md::RelayOptions>().naggle_ms());
break;
+5 -3
View File
@@ -58,9 +58,11 @@ void clean_dir(const std::string base_path) {
}
void run_replay() {
auto naggle_ms = config::get<RelayOptions>().naggle_ms();
auto file = "http://mdreplay.bluetradesys.local/spark/futures.coconut";
replay_recording(file, naggle_ms);
auto naggle_ms = config::get<RelayOptions>().naggle_ms();
const auto& options = config::get<ReplayOptions>();
auto file = options.url();
auto fallback_path = options.fallback();
replay_recording(file, naggle_ms, fallback_path);
}
void run_onixs() {
+5
View File
@@ -13,6 +13,11 @@ IF %ERRORLEVEL% NEQ 0 GOTO :ERROR_AND_END
msbuild /m /p:debugtype=portable /p:platform=x64 /clp:verbosity=minimal /clp:summary spark_client.sln /p:Configuration=release
IF %ERRORLEVEL% NEQ 0 GOTO :ERROR_AND_END
:: build netcore
cd src\client\sparkcmd
dotnet publish -f netcoreapp2.1 -c release
IF %ERRORLEVEL% NEQ 0 GOTO :ERROR_AND_END
GOTO :END
:ERROR_AND_END
+5
View File
@@ -16,7 +16,12 @@ endfunction(update_file)
# the list of dependencies in it - this file should be treated as part of
# CMakeLists.txt (source controlled, etc.).
function(update_deps_file deps)
if (WIN32)
set(deps_file "CMakeDeps_win.cmake")
else ()
set(deps_file "CMakeDeps.cmake")
endif()
# Normalize the list so it's the same on every machine
list(REMOVE_DUPLICATES deps)
list(SORT deps)