merging
This commit is contained in:
commit
2cb539508a
59 files changed
+911
-567
No files matched your search
Vendored
+1
-1
@@ -187,7 +187,7 @@
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "/home/bts/spark/build/ninja_debug/src/server/sparkd/sparkd",
|
||||
"args": ["test", "-a", "LoadSessionKeys"],
|
||||
"args": ["test", "[md]"],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "/home/bts/spark/build/ninja_debug/src/server/sparkd/",
|
||||
"environment": [],
|
||||
|
||||
+2
-1
@@ -36,4 +36,5 @@ else ()
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} -DNDEBUG -O3")
|
||||
add_subdirectory(src/lib)
|
||||
add_subdirectory(src/server/sparkd)
|
||||
endif()
|
||||
add_subdirectory(src/web)
|
||||
endif()
|
||||
@@ -1,5 +1,4 @@
|
||||
using mbts.spark.filters;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace mbts.ui.spark {
|
||||
/// <summary>
|
||||
@@ -8,9 +7,7 @@ namespace mbts.ui.spark {
|
||||
partial class MarketViewView : UserControl {
|
||||
public enum Columns { Security, Volume, Last, LastSize, Position, WorkingBids, Bid, BidSize, Ask, AskSize, WorkingAsks, Settlement, DayChange, SessionLow, SessionHigh, SecurityKey }
|
||||
|
||||
public MarketViewView() {
|
||||
public MarketViewView() =>
|
||||
InitializeComponent();
|
||||
DataGridFilterHelper.set_filter_key_event_hooks(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark">
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
FocusManager.IsFocusScope="True">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using mbts.spark.filters;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace mbts.ui.spark {
|
||||
/// <summary>
|
||||
@@ -8,9 +7,7 @@ namespace mbts.ui.spark {
|
||||
partial class TimeAndSalesView : UserControl {
|
||||
public enum Columns { Time, Security, Price, Size, OrderType, TradeKey, SecurityKey }
|
||||
|
||||
public TimeAndSalesView() {
|
||||
InitializeComponent();
|
||||
DataGridFilterHelper.set_filter_key_event_hooks(this);
|
||||
}
|
||||
public TimeAndSalesView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,7 @@ namespace mbts.ui.spark {
|
||||
/// Interaction logic for SyntheticManagementView.xaml
|
||||
/// </summary>
|
||||
internal partial class SyntheticManagementView : UserControl {
|
||||
public SyntheticManagementView() {
|
||||
public SyntheticManagementView() =>
|
||||
InitializeComponent();
|
||||
DataGridFilterHelper.set_filter_key_event_hooks(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using mbts.spark.filters;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace mbts.ui.spark {
|
||||
/// <summary>
|
||||
@@ -8,9 +7,7 @@ namespace mbts.ui.spark {
|
||||
partial class FillsView : UserControl {
|
||||
public enum Columns { FillTime, User, Account, Exchange, Security, TimeInForce, OrderType, Side, Price, Size, FillKey, OrderKey, SecurityKey, ExchangeOrderID }
|
||||
|
||||
public FillsView() {
|
||||
public FillsView() =>
|
||||
InitializeComponent();
|
||||
DataGridFilterHelper.set_filter_key_event_hooks(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,15 +48,14 @@ namespace mbts.spark {
|
||||
|
||||
public OrderPropertiesEditorVM(OrdersModel model, IObservable<SecurityImmutable> security_source, IObservable<InlineOrderProperties> order_properties) {
|
||||
_model = model;
|
||||
//accounts = model.factory.accounts.ToArray();
|
||||
order_types = new ObservableAutoWrapper<IOrderTypeVM, CustomOrderDefinition.CustomOneofCase>(_order_types_model, ot => OrderTypeVMFactory.create(ot, model, security_source));
|
||||
//_selected_account = backing(nameof(selected_account), string.Empty, false, val => !String.IsNullOrWhiteSpace(val) && accounts.Contains(val));
|
||||
_accounts = backing(
|
||||
nameof(selected_account),
|
||||
model.factory.subscribe_accounts(),
|
||||
order_properties.Select(ops => ops.account),
|
||||
() => string.Empty,
|
||||
val => !String.IsNullOrWhiteSpace(val) && accounts.Contains(val));
|
||||
val => (!String.IsNullOrWhiteSpace(val) && accounts.Contains(val), "Please select an account")
|
||||
);
|
||||
_time_in_force = backing(
|
||||
nameof(selected_time_in_force),
|
||||
security_source.Select(s => model.factory.default_time_in_forces(s)),
|
||||
@@ -64,7 +63,6 @@ namespace mbts.spark {
|
||||
() => model.factory.default_time_in_force(security),
|
||||
tif => time_in_forces.Contains(tif));
|
||||
InlineOrderProperties props = new InlineOrderProperties();
|
||||
//auto_select_prop(props.account, _selected_account, accounts, () => model.factory.default_account);
|
||||
_dispose = Disposable.Create(
|
||||
security_source.ObserveOnDispatcher().Subscribe(s => {
|
||||
security = s;
|
||||
@@ -83,7 +81,6 @@ namespace mbts.spark {
|
||||
}),
|
||||
order_properties.ObserveOnDispatcher().Subscribe(p => {
|
||||
props = p;
|
||||
//auto_select_account();
|
||||
auto_select_order_type();
|
||||
})
|
||||
);
|
||||
|
||||
@@ -380,6 +380,14 @@ namespace mbts.ui.shell
|
||||
protected SelectorProperty<T> backing<T>(string name, IObservable<IEnumerable<T>> items, IObservable<InlineUserProperty<T>> desired_item, Func<T> select_default, params Func<T, bool>[] validation_steps) =>
|
||||
backing(name, items, desired_item, select_default, validation_steps.Select(v => new PropertyValidation<T>(v)).ToList());
|
||||
|
||||
/// <summary>
|
||||
/// Returns a SelectorProperty<T> that observes an items source, and a desired item. When either observable ticks, it determines whether or not to assign the selected_item property.
|
||||
/// This overload makes it a little easier to access the overload where a message is supplied to the validation logic.
|
||||
/// <para/>Notes: If the user has selected an item (ie the selected_item has been assigned through the public setter), the desired item will be ignored unless force_override is true.
|
||||
/// <para/>If the user has not selected an item, but the current items do not contain the desired item, it will re-evaluate whether or not to select the item when new items arrive. /// </summary>
|
||||
protected SelectorProperty<T> backing<T>(string name, IObservable<IEnumerable<T>> items, IObservable<InlineUserProperty<T>> desired_item, Func<T> select_default, params Func<T, (bool valid, string msg)>[] validation_steps) =>
|
||||
backing(name, items, desired_item, select_default, validation_steps.Select(v => new PropertyValidation<T>(v)).ToList());
|
||||
|
||||
/// <summary>
|
||||
/// Returns a SelectorProperty<T> that observes an items source, and a desired item. When either observable ticks, it determines whether or not to assign the selected_item property.
|
||||
/// <para/>Notes: If the user has selected an item (ie the selected_item has been assigned through the public setter), the desired item will be ignored unless force_override is true.
|
||||
@@ -473,6 +481,14 @@ namespace mbts.ui.shell
|
||||
void IObserver<IEnumerable<T>>.OnError(Exception error) { }
|
||||
void IObserver<IEnumerable<T>>.OnCompleted() { }
|
||||
|
||||
void _run_validation(T val) {
|
||||
var invalid_steps = _validation_steps.Select(v => v.validate(val)).Where(r => !r.valid);
|
||||
if (invalid_steps.Count() > 0) {
|
||||
var error_msg = string.Join("\n", invalid_steps.Where(r => !string.IsNullOrEmpty(r.msg)).Select(r => r.msg));
|
||||
_owner.set_error(_prop_name, error_msg, true);
|
||||
} else _owner.clear_error(_prop_name);
|
||||
}
|
||||
|
||||
void _try_auto_select() {
|
||||
if (_is_user_selected_item) {
|
||||
if (desired_item_valid() && _desired_item.force_override)
|
||||
@@ -483,6 +499,11 @@ namespace mbts.ui.shell
|
||||
var item = _select_default();
|
||||
if (_items.Contains(item))
|
||||
_set_selected_item(item);
|
||||
else {
|
||||
// the _set_selected_item has never been entered, so validation has never ran, force it here
|
||||
// so that if some value is required, the valdiation logic will catch it
|
||||
_run_validation(item);
|
||||
}
|
||||
}
|
||||
bool desired_item_valid() =>
|
||||
_desired_item != null && _desired_item.has_value && _items.Contains(_desired_item.value);
|
||||
@@ -495,11 +516,7 @@ namespace mbts.ui.shell
|
||||
_selected_item = value;
|
||||
Changed?.Invoke(old, value);
|
||||
_owner.RaisePropertyChanged(_prop_name);
|
||||
var invalid_steps = _validation_steps.Select(v => v.validate(value)).Where(r => !r.valid).ToList();
|
||||
if (invalid_steps.Count > 0) {
|
||||
var error_msg = string.Join("\n", invalid_steps.Where(r => !string.IsNullOrEmpty(r.msg)).Select(r => r.msg));
|
||||
_owner.set_error(_prop_name, error_msg, true);
|
||||
} else _owner.clear_error(_prop_name);
|
||||
_run_validation(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,14 @@
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.utility;
|
||||
using mbts.ui.utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark.filters {
|
||||
static class DataGridFilterHelper {
|
||||
public static IDisposable set_filter_key_event_hooks(FrameworkElement view_root) {
|
||||
return WPFHelper.add_key_down_handler_to_parent_on_loaded<Window>(view_root, (s, e) => {
|
||||
switch (e.Key) {
|
||||
case Key.Enter: act_on_open_filter(on_enter); break;
|
||||
case Key.Escape: act_on_open_filter(on_escape); break;
|
||||
default: return;
|
||||
}
|
||||
e.Handled = true;
|
||||
});
|
||||
public static IDisposable hook_filters<TRow>(ObservableFilterCollection<TRow> rows, Action filter_action, params IDataGridColumnFilter<TRow>[] filters) =>
|
||||
_hook_filters(filter_action, filters);
|
||||
|
||||
void act_on_open_filter(Action<PopupControl> action) {
|
||||
if (view_root.visual_children_where(el => el is PopupControl).Cast<PopupControl>().FirstOrDefault(p => p.IsOpen) is PopupControl popup)
|
||||
action(popup);
|
||||
}
|
||||
void on_enter(PopupControl open_filter_popup) {
|
||||
if (open_filter_popup.find_ancestor_of_type<DataGridColumnHeader>() is DataGridColumnHeader col_header) {
|
||||
if (DataGridFilterProperties.GetFilter(col_header.Column) is IDataGridColumnFilter filter)
|
||||
filter.apply.TryExecuteIfCan(null);
|
||||
}
|
||||
}
|
||||
void on_escape(PopupControl open_filter_popup) =>
|
||||
open_filter_popup.IsOpen = false;
|
||||
}
|
||||
|
||||
public static IDisposable hook_filters<TRow>(ObservableFilterCollection<TRow> rows, Action filter_action, params IDataGridColumnFilter<TRow>[] filters) {
|
||||
return _hook_filters(filter_action, filters);
|
||||
}
|
||||
public static IDisposable hook_filters<TRow>(ObservableFilterCollection<TRow> rows, params IDataGridColumnFilter<TRow>[] filters) {
|
||||
return _hook_filters(set_filter, filters);
|
||||
void set_filter() {
|
||||
@@ -80,6 +51,5 @@ namespace mbts.spark.filters {
|
||||
|
||||
static List<IDataGridColumnFilter<TRow>> _get_active_filters<TRow>(IDataGridColumnFilter<TRow>[] filters) =>
|
||||
filters.Where(f => f.active.HasValue && f.active.Value).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,37 @@
|
||||
using System.Windows;
|
||||
using mbts.spark.filters;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.ui.controls {
|
||||
static class DataGridFilterProperties {
|
||||
#region FilterTemplate
|
||||
public static readonly DependencyProperty FilterTemplateProperty = DependencyProperty.RegisterAttached("FilterTemplate", typeof(DataTemplate), typeof(DataGridFilterProperties));
|
||||
#region Commands
|
||||
public static readonly RoutedCommand
|
||||
CommitCommand = new RoutedCommand("Commit", typeof(DataGridFilterProperties)),
|
||||
ClearCommand = new RoutedCommand("Clear", typeof(DataGridFilterProperties));
|
||||
|
||||
public static readonly ExecutedRoutedEventHandler commit_executed = (s, e) => {
|
||||
e.Handled = true;
|
||||
(e.Parameter as IDataGridColumnFilter)?.apply.TryExecuteIfCan(null);
|
||||
};
|
||||
|
||||
public static readonly CanExecuteRoutedEventHandler commit_can_execute = (s, e) => {
|
||||
e.Handled = true;
|
||||
e.CanExecute = e.Parameter is IDataGridColumnFilter f && f.apply.CanExecute(null);
|
||||
};
|
||||
|
||||
public static readonly ExecutedRoutedEventHandler clear_executed = (s, e) => {
|
||||
e.Handled = true;
|
||||
(e.Parameter as IDataGridColumnFilter)?.clear.TryExecuteIfCan(null);
|
||||
};
|
||||
|
||||
public static readonly CanExecuteRoutedEventHandler clear_can_execute = (s, e) => {
|
||||
e.Handled = true;
|
||||
e.CanExecute = e.Parameter is IDataGridColumnFilter f && f.clear.CanExecute(null);
|
||||
};
|
||||
#endregion
|
||||
|
||||
#region FilterTemplate
|
||||
public static readonly DependencyProperty FilterTemplateProperty = DependencyProperty.RegisterAttached("FilterTemplate", typeof(DataTemplate), typeof(DataGridFilterProperties));
|
||||
public static DataTemplate GetFilterTemplate(DependencyObject d) { return d.GetValue(FilterTemplateProperty) as DataTemplate; }
|
||||
public static void SetFilterTemplate(DependencyObject d, DataTemplate value) { d.SetValue(FilterTemplateProperty, value); }
|
||||
#endregion
|
||||
|
||||
@@ -16,8 +16,22 @@
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}"/>
|
||||
<Border Grid.Row="1" Background="{x:Static u:BTSColors.dialog_skirt_brush}" HorizontalAlignment="Stretch" Padding="10,8">
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Button Command="{TemplateBinding ApplyCommand}" IsDefault="True" Focusable="False" Style="{StaticResource CommonButton}">Apply</Button>
|
||||
<Button Margin="8,0,0,0" Command="{TemplateBinding ClearCommand}" Focusable="False" Style="{StaticResource CommonButton}">Clear</Button>
|
||||
<Button
|
||||
Content="Apply"
|
||||
CommandParameter="{TemplateBinding ApplyCommandParameter}"
|
||||
Command="{TemplateBinding ApplyCommand}"
|
||||
IsDefault="True"
|
||||
Focusable="False"
|
||||
Style="{StaticResource CommonButton}"
|
||||
/>
|
||||
<Button
|
||||
Margin="8,0,0,0"
|
||||
Content="Clear"
|
||||
CommandParameter="{TemplateBinding ClearCommandParameter}"
|
||||
Command="{TemplateBinding ClearCommand}"
|
||||
Focusable="False"
|
||||
Style="{StaticResource CommonButton}"
|
||||
/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
+11
-9
@@ -17,6 +17,13 @@ namespace mbts.ui.spark {
|
||||
public ICommand ApplyCommand { get => GetValue(ApplyCommandProperty) as ICommand; set => SetValue(ApplyCommandProperty, value); }
|
||||
#endregion
|
||||
|
||||
#region ApplyCommandParameter
|
||||
public static readonly DependencyProperty ApplyCommandParameterProperty = DependencyProperty.Register(
|
||||
nameof(ApplyCommandParameter), typeof(object), typeof(FilterContentControl));
|
||||
|
||||
public object ApplyCommandParameter { get => GetValue(ApplyCommandParameterProperty); set => SetValue(ApplyCommandParameterProperty, value); }
|
||||
#endregion
|
||||
|
||||
#region ClearCommand
|
||||
public static readonly DependencyProperty ClearCommandProperty = DependencyProperty.Register(
|
||||
nameof(ClearCommand), typeof(ICommand), typeof(FilterContentControl));
|
||||
@@ -24,16 +31,11 @@ namespace mbts.ui.spark {
|
||||
public ICommand ClearCommand { get => GetValue(ClearCommandProperty) as ICommand; set => SetValue(ClearCommandProperty, value); }
|
||||
#endregion
|
||||
|
||||
#region CancelCommand
|
||||
public static readonly DependencyProperty CancelCommandProperty = DependencyProperty.Register(
|
||||
nameof(CancelCommand), typeof(ICommand), typeof(FilterContentControl));
|
||||
#region ClearCommandParameter
|
||||
public static readonly DependencyProperty ClearCommandParameterProperty = DependencyProperty.Register(
|
||||
nameof(ClearCommandParameter), typeof(object), typeof(FilterContentControl));
|
||||
|
||||
public ICommand CancelCommand { get => GetValue(CancelCommandProperty) as ICommand; set => SetValue(CancelCommandProperty, value); }
|
||||
public object ClearCommandParameter { get => GetValue(ClearCommandParameterProperty); set => SetValue(ClearCommandParameterProperty, value); }
|
||||
#endregion
|
||||
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e) {
|
||||
if (e.Key == Key.Enter)
|
||||
ApplyCommand.TryExecuteIfCan(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,12 @@
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<sys:Double x:Key="MinMaxWidth">160</sys:Double>
|
||||
<DataTemplate x:Key="DoubleMinMaxTemplate">
|
||||
<usp:FilterContentControl ApplyCommand="{Binding apply}" ClearCommand="{Binding clear}" CancelCommand="{Binding cancel}">
|
||||
<usp:FilterContentControl
|
||||
ApplyCommandParameter="{Binding}"
|
||||
ApplyCommand="{x:Static c:DataGridFilterProperties.CommitCommand}"
|
||||
ClearCommandParameter="{Binding}"
|
||||
ClearCommand="{x:Static c:DataGridFilterProperties.ClearCommand}"
|
||||
>
|
||||
<usp:DoubleMinMaxFilterControl
|
||||
x:Name="Filter"
|
||||
Minimum="{Binding minimum}"
|
||||
@@ -30,7 +35,12 @@
|
||||
</usp:FilterContentControl>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="IntMinMaxTemplate">
|
||||
<usp:FilterContentControl ApplyCommand="{Binding apply}" ClearCommand="{Binding clear}" CancelCommand="{Binding cancel}">
|
||||
<usp:FilterContentControl
|
||||
ApplyCommandParameter="{Binding}"
|
||||
ApplyCommand="{x:Static c:DataGridFilterProperties.CommitCommand}"
|
||||
ClearCommandParameter="{Binding}"
|
||||
ClearCommand="{x:Static c:DataGridFilterProperties.ClearCommand}"
|
||||
>
|
||||
<usp:IntMinMaxFilterControl
|
||||
x:Name="Filter"
|
||||
Minimum="{Binding minimum}"
|
||||
@@ -42,7 +52,12 @@
|
||||
</usp:FilterContentControl>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="UIntMinMaxTemplate">
|
||||
<usp:FilterContentControl ApplyCommand="{Binding apply}" ClearCommand="{Binding clear}" CancelCommand="{Binding cancel}">
|
||||
<usp:FilterContentControl
|
||||
ApplyCommandParameter="{Binding}"
|
||||
ApplyCommand="{x:Static c:DataGridFilterProperties.CommitCommand}"
|
||||
ClearCommandParameter="{Binding}"
|
||||
ClearCommand="{x:Static c:DataGridFilterProperties.ClearCommand}"
|
||||
>
|
||||
<usp:UIntMinMaxFilterControl
|
||||
x:Name="Filter"
|
||||
Minimum="{Binding minimum}"
|
||||
@@ -54,7 +69,12 @@
|
||||
</usp:FilterContentControl>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="UShortMinMaxTemplate">
|
||||
<usp:FilterContentControl ApplyCommand="{Binding apply}" ClearCommand="{Binding clear}" CancelCommand="{Binding cancel}">
|
||||
<usp:FilterContentControl
|
||||
ApplyCommandParameter="{Binding}"
|
||||
ApplyCommand="{x:Static c:DataGridFilterProperties.CommitCommand}"
|
||||
ClearCommandParameter="{Binding}"
|
||||
ClearCommand="{x:Static c:DataGridFilterProperties.ClearCommand}"
|
||||
>
|
||||
<usp:UShortMinMaxFilterControl
|
||||
x:Name="Filter"
|
||||
Minimum="{Binding minimum}"
|
||||
@@ -66,7 +86,12 @@
|
||||
</usp:FilterContentControl>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="ULongMinMaxTemplate">
|
||||
<usp:FilterContentControl ApplyCommand="{Binding apply}" ClearCommand="{Binding clear}" CancelCommand="{Binding cancel}">
|
||||
<usp:FilterContentControl
|
||||
ApplyCommandParameter="{Binding}"
|
||||
ApplyCommand="{x:Static c:DataGridFilterProperties.CommitCommand}"
|
||||
ClearCommandParameter="{Binding}"
|
||||
ClearCommand="{x:Static c:DataGridFilterProperties.ClearCommand}"
|
||||
>
|
||||
<usp:ULongMinMaxFilterControl
|
||||
x:Name="Filter"
|
||||
Minimum="{Binding minimum}"
|
||||
@@ -78,7 +103,12 @@
|
||||
</usp:FilterContentControl>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="TimeFilterTemplate">
|
||||
<usp:FilterContentControl ApplyCommand="{Binding apply}" ClearCommand="{Binding clear}" CancelCommand="{Binding cancel}">
|
||||
<usp:FilterContentControl
|
||||
ApplyCommandParameter="{Binding}"
|
||||
ApplyCommand="{x:Static c:DataGridFilterProperties.CommitCommand}"
|
||||
ClearCommandParameter="{Binding}"
|
||||
ClearCommand="{x:Static c:DataGridFilterProperties.ClearCommand}"
|
||||
>
|
||||
<c:TimeFilterControl
|
||||
x:Name="Filter"
|
||||
Mode="{Binding mode}"
|
||||
@@ -98,7 +128,12 @@
|
||||
</usp:FilterContentControl>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="DiscreteValuesTemplate">
|
||||
<usp:FilterContentControl ApplyCommand="{Binding apply}" ClearCommand="{Binding clear}" CancelCommand="{Binding cancel}">
|
||||
<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}"
|
||||
@@ -108,7 +143,12 @@
|
||||
</usp:FilterContentControl>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="EnumValuesTemplate">
|
||||
<usp:FilterContentControl ApplyCommand="{Binding apply}" ClearCommand="{Binding clear}" CancelCommand="{Binding cancel}">
|
||||
<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}"
|
||||
@@ -119,7 +159,12 @@
|
||||
</usp:FilterContentControl>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="RegexTemplate">
|
||||
<usp:FilterContentControl ApplyCommand="{Binding apply}" ClearCommand="{Binding clear}" CancelCommand="{Binding cancel}">
|
||||
<usp:FilterContentControl
|
||||
ApplyCommandParameter="{Binding}"
|
||||
ApplyCommand="{x:Static c:DataGridFilterProperties.CommitCommand}"
|
||||
ClearCommandParameter="{Binding}"
|
||||
ClearCommand="{x:Static c:DataGridFilterProperties.ClearCommand}"
|
||||
>
|
||||
<Grid Width="160">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
|
||||
@@ -13,6 +13,10 @@ namespace mbts.ui.controls {
|
||||
static PopupControl() =>
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(PopupControl), new FrameworkPropertyMetadata(typeof(PopupControl)));
|
||||
|
||||
public static readonly RoutedCommand
|
||||
OpenCommand = new RoutedCommand("Open", typeof(PopupControl)),
|
||||
CloseCommand = new RoutedCommand("Close", typeof(PopupControl));
|
||||
|
||||
public static readonly RoutedEvent OpenedEvent = EventManager.RegisterRoutedEvent(nameof(Opened), RoutingStrategy.Bubble, typeof(EventHandler), typeof(PopupControl));
|
||||
public static readonly RoutedEvent ClosedEvent = EventManager.RegisterRoutedEvent(nameof(Closed), RoutingStrategy.Bubble, typeof(EventHandler), typeof(PopupControl));
|
||||
|
||||
@@ -67,10 +71,17 @@ namespace mbts.ui.controls {
|
||||
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsOpenChanged));
|
||||
static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
|
||||
var target = (PopupControl)d;
|
||||
if ((bool)e.NewValue)
|
||||
if ((bool)e.NewValue) {
|
||||
target.RaiseEvent(new RoutedEventArgs(OpenedEvent, target));
|
||||
else
|
||||
(FocusManager.GetFocusScope(target) as UIElement)?.Focus();
|
||||
Keyboard.Focus(target);
|
||||
target?._popup?.Child?.Focus();
|
||||
} else {
|
||||
target.ReleaseMouseCapture();
|
||||
target.RaiseEvent(new RoutedEventArgs(ClosedEvent, target));
|
||||
if (target.IsKeyboardFocused || target.IsKeyboardFocusWithin)
|
||||
Keyboard.ClearFocus();
|
||||
}
|
||||
}
|
||||
public bool IsOpen { get => (bool)GetValue(IsOpenProperty); set => SetValue(IsOpenProperty, value); }
|
||||
#endregion
|
||||
@@ -103,6 +114,8 @@ namespace mbts.ui.controls {
|
||||
if (_ignore_open_command) _ignore_open_command = false;
|
||||
else IsOpen = true;
|
||||
});
|
||||
CommandBindings.Add(new CommandBinding(OpenCommand, (s, e) => IsOpen = true));
|
||||
CommandBindings.Add(new CommandBinding(CloseCommand, (s, e) => IsOpen = false));
|
||||
}
|
||||
|
||||
private IDisposable _popup_hook;
|
||||
|
||||
@@ -146,6 +146,26 @@
|
||||
IsOpen="{Binding Path='Column.(c:DataGridFilterProperties.FilterOpen)', Mode=TwoWay, RelativeSource={RelativeSource AncestorType=DataGridColumnHeader}}"
|
||||
ContentTemplate="{Binding Path='Column.(c:DataGridFilterProperties.FilterTemplate)', RelativeSource={RelativeSource AncestorType=DataGridColumnHeader}}"
|
||||
Content="{Binding Path='Column.(c:DataGridFilterProperties.Filter)', RelativeSource={RelativeSource AncestorType=DataGridColumnHeader}}">
|
||||
<c:PopupControl.InputBindings>
|
||||
<KeyBinding
|
||||
Key="Return"
|
||||
CommandParameter="{Binding Path='Column.(c:DataGridFilterProperties.Filter)', RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridColumnHeader}}"
|
||||
Command="{x:Static c:DataGridFilterProperties.CommitCommand}"
|
||||
/>
|
||||
<KeyBinding Key="Esc" Command="{x:Static c:PopupControl.CloseCommand}"/>
|
||||
</c:PopupControl.InputBindings>
|
||||
<c:PopupControl.CommandBindings>
|
||||
<CommandBinding
|
||||
Command="{x:Static c:DataGridFilterProperties.CommitCommand}"
|
||||
Executed="{x:Static c:DataGridFilterProperties.commit_executed}"
|
||||
CanExecute="{x:Static c:DataGridFilterProperties.commit_can_execute}"
|
||||
/>
|
||||
<CommandBinding
|
||||
Command="{x:Static c:DataGridFilterProperties.ClearCommand}"
|
||||
Executed="{x:Static c:DataGridFilterProperties.clear_executed}"
|
||||
CanExecute="{x:Static c:DataGridFilterProperties.clear_can_execute}"
|
||||
/>
|
||||
</c:PopupControl.CommandBindings>
|
||||
<c:PopupControl.Header>
|
||||
<Grid>
|
||||
<Image x:Name="FilterPopupImage" Height="9" Width="9" Margin="3">
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
|
||||
public enum BadgeStyle { Normal, Kevin }
|
||||
public enum BadgeStyle { Normal, Alternate }
|
||||
|
||||
[ProtoMember(1)]
|
||||
public double row_height { get; set; }
|
||||
|
||||
@@ -228,7 +228,8 @@
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid x:Name="_root">
|
||||
<AdornerDecorator>
|
||||
<Grid x:Name="_root">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="112"/>
|
||||
<ColumnDefinition Width="2"/>
|
||||
@@ -469,4 +470,5 @@
|
||||
</Button.Template>
|
||||
</Button>
|
||||
</Grid>
|
||||
</AdornerDecorator>
|
||||
</UserControl>
|
||||
@@ -107,8 +107,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
internal static void render_last(DrawingVisual dv, GlyphContext glyph_context, NativePriceSize last, int index, double row_height, LadderColumnSettings settings) {
|
||||
using (var dc = dv.RenderOpen())
|
||||
using (_draw_with_clip(dc, settings, row_height, index)) {
|
||||
using (var dc = dv.RenderOpen()) {
|
||||
var gr = format_text(last.size.ToString(), index, row_height, settings, glyph_context);
|
||||
dc.DrawGlyphRun(new SolidColorBrush(settings.foreground.rgb_color()), gr);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace mbts.spark {
|
||||
public PAndLView(PAndLVM vm) {
|
||||
InitializeComponent();
|
||||
DataContext = vm;
|
||||
DataGridFilterHelper.set_filter_key_event_hooks(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,8 @@
|
||||
xmlns:uspcv="clr-namespace:mbts.ui.spark.converters"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="1080">
|
||||
d:DesignHeight="600" d:DesignWidth="1080"
|
||||
FocusManager.IsFocusScope="True">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
using System.Windows.Controls;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Data;
|
||||
using bts.collections;
|
||||
using bts.spark;
|
||||
using System.Collections.Generic;
|
||||
using mbts.spark.filters;
|
||||
using mbts.ui.controls;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace mbts.spark {
|
||||
internal partial class OrderBookView : UserControl {
|
||||
@@ -15,7 +10,6 @@ namespace mbts.spark {
|
||||
InitializeComponent();
|
||||
_vm = vm;
|
||||
DataContext = vm;
|
||||
DataGridFilterHelper.set_filter_key_event_hooks(this);
|
||||
foreach (var col in _grid.Columns) {
|
||||
if (DataGridEx.GetColumnName(col) == _vm.current_sort_description.PropertyName) {
|
||||
col.SortDirection = _vm.current_sort_description.Direction;
|
||||
|
||||
@@ -273,7 +273,7 @@ enum ExecType
|
||||
EXEC_TYPE_RESTATED = 68 ;
|
||||
EXEC_TYPE_PENDING_REPLACE = 69 ;
|
||||
EXEC_TYPE_TRADE_CORRECT = 71 ;
|
||||
EXEC_TYPE_CANCEL_ACK = 72 ;
|
||||
EXEC_TYPE_TRADE_CANCEL = 72 ;
|
||||
}
|
||||
|
||||
enum SpreaderChildKind {
|
||||
|
||||
@@ -22,11 +22,9 @@ ShmDumper::ShmDumper(const string& name) : _name(name)
|
||||
ShmDumper::~ShmDumper() {}
|
||||
|
||||
double dump(TimeStamp time) {
|
||||
// stringstream temp;
|
||||
// temp << (TimeStamp::now() - time).seconds();
|
||||
// return temp.str();
|
||||
return (TimeStamp::now() - time).seconds();
|
||||
}
|
||||
|
||||
string dump(PriceSize ps) {
|
||||
stringstream res;
|
||||
res << "{";
|
||||
@@ -156,7 +154,7 @@ string dump_entry(const ColdEntry& entry) {
|
||||
string dump_entry(const HotDepthEntry& entry) {
|
||||
stringstream res;
|
||||
res << "{ ";
|
||||
res << "'timestamp': " << dump(entry.timestamp) << ", ";
|
||||
res << "'timestamp': " << dump(entry.time()) << ", ";
|
||||
res << "'key': " << entry.key << ", ";
|
||||
|
||||
res << "'bids': [";
|
||||
@@ -180,7 +178,7 @@ string dump_entry(const HotDepthEntry& entry) {
|
||||
string dump_entry(const HotEntry& entry) {
|
||||
stringstream res;
|
||||
res << "{ ";
|
||||
res << "'timestamp': " << dump(entry.timestamp) << ", ";
|
||||
res << "'timestamp': " << dump(entry.time()) << ", ";
|
||||
res << "'key': " << entry.key << ", ";
|
||||
res << "'bid': " << dump(entry.bid) << ", ";
|
||||
res << "'ask': " << dump(entry.ask) << ", ";
|
||||
|
||||
@@ -35,7 +35,7 @@ void MDConsumerHandle::init(const ColdHeader& cheader, const ColdEntry& centry,
|
||||
set_hot(pvhot);
|
||||
}
|
||||
|
||||
TimeStamp copy_bbo(const TimeStamp& time, const SingleWriterPriceSizeStore& in_bid, const SingleWriterPriceSizeStore& in_ask, PriceSize& out_bid, PriceSize& out_ask) {
|
||||
TimeStamp copy_bbo(const HotEntry& hot, PriceSize& out_bid, PriceSize& out_ask) {
|
||||
// We expect the time, in_bid and in_ask to be changing (rapidly)
|
||||
//
|
||||
TimeStamp t;
|
||||
@@ -45,11 +45,11 @@ TimeStamp copy_bbo(const TimeStamp& time, const SingleWriterPriceSizeStore& in_b
|
||||
// hopefully check the heartbeat.
|
||||
const int max_attempts = 1619200;
|
||||
do {
|
||||
t = time;
|
||||
out_bid = in_bid.load();
|
||||
out_ask = in_ask.load();
|
||||
t = hot.time();
|
||||
out_bid = hot.bid.load();
|
||||
out_ask = hot.ask.load();
|
||||
++attempts;
|
||||
} while((t != time || t == TimeStamp::invalid()) && attempts < max_attempts);
|
||||
} while((t != hot.time() || t == TimeStamp::invalid()) && attempts < max_attempts);
|
||||
if (attempts >= max_attempts) {
|
||||
return TimeStamp::invalid();
|
||||
}
|
||||
@@ -57,8 +57,7 @@ TimeStamp copy_bbo(const TimeStamp& time, const SingleWriterPriceSizeStore& in_b
|
||||
}
|
||||
|
||||
TimeStamp copy_depth(
|
||||
const TimeStamp& time,
|
||||
const SingleWriterPriceSizeStore* source,
|
||||
const HotDepthEntry& hot,
|
||||
size_t count,
|
||||
PriceSize* bid, PriceSize* ask)
|
||||
{
|
||||
@@ -66,12 +65,13 @@ TimeStamp copy_depth(
|
||||
int attempts = 0;
|
||||
const int max_attempts = 1619200;
|
||||
do {
|
||||
t = hot.time();
|
||||
for (size_t x = 0; x < count; ++x) {
|
||||
bid[x] = source[2*x].load();
|
||||
ask[x] = source[2*x+1].load();
|
||||
bid[x] = hot.bid(x).load();
|
||||
ask[x] = hot.ask(x).load();
|
||||
}
|
||||
t = time;
|
||||
} while((t != time || t == TimeStamp::invalid()) && attempts < max_attempts);
|
||||
++attempts;
|
||||
} while((t != hot.time() || t == TimeStamp::invalid()) && attempts < max_attempts);
|
||||
if (attempts >= max_attempts) {
|
||||
return TimeStamp::invalid();
|
||||
}
|
||||
@@ -206,9 +206,9 @@ TimeStamp MDConsumerHandle::last_market_update() const {
|
||||
case HANDLETYPE_VOID:
|
||||
return TimeStamp::invalid();
|
||||
case HANDLETYPE_DEPTH:
|
||||
return book.hot->timestamp;
|
||||
return book.hot->time();
|
||||
case HANDLETYPE_BBO:
|
||||
return bbo.hot->timestamp;
|
||||
return bbo.hot->time();
|
||||
case HANDLETYPE_SYNTHETIC:
|
||||
return sane::max<TimeStamp>(synthetic.def->legs, [](const MDConsumerHandle& h) { return h.last_market_update(); });
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ struct SyntheticStrategy {
|
||||
std::vector<MDConsumerHandle> legs;
|
||||
};
|
||||
|
||||
TimeStamp copy_bbo(const TimeStamp&, const SingleWriterPriceSizeStore&, const SingleWriterPriceSizeStore&, PriceSize&, PriceSize& );
|
||||
TimeStamp copy_depth(const TimeStamp& time, const SingleWriterPriceSizeStore* source, size_t count, PriceSize* bid, PriceSize* ask);
|
||||
TimeStamp copy_bbo(const HotEntry& src, PriceSize& out_bid, PriceSize& out_ask);
|
||||
TimeStamp copy_depth(const HotDepthEntry&, size_t count, PriceSize* bid, PriceSize* ask);
|
||||
TimeStamp copy_depth(const SyntheticStrategy&, size_t count, PriceSize* bid, PriceSize* ask);
|
||||
|
||||
enum class HandleReadResult {
|
||||
@@ -83,16 +83,16 @@ public:
|
||||
|
||||
switch(_type) {
|
||||
case HANDLETYPE_DEPTH:
|
||||
if (book.hot->timestamp > time || book.hot->timestamp == TimeStamp::invalid()) {
|
||||
TimeStamp temp = copy_bbo(book.hot->timestamp, book.hot->bid(0), book.hot->ask(0), bid, ask);
|
||||
if (book.hot->time() > time || book.hot->time() == TimeStamp::invalid()) {
|
||||
TimeStamp temp = copy_depth(*book.hot, 1, &bid, &ask);
|
||||
if (temp == TimeStamp::invalid()) { return HandleReadResult::BUSY; }
|
||||
time = temp;
|
||||
return HandleReadResult::SUCCESS;
|
||||
}
|
||||
return HandleReadResult::NO_CHANGE;
|
||||
case HANDLETYPE_BBO:
|
||||
if (bbo.hot->timestamp > time || bbo.hot->timestamp == TimeStamp::invalid()) {
|
||||
TimeStamp temp = copy_bbo(bbo.hot->timestamp, bbo.hot->bid, bbo.hot->ask, bid, ask);
|
||||
if (bbo.hot->time() > time || bbo.hot->time() == TimeStamp::invalid()) {
|
||||
TimeStamp temp = copy_bbo(*bbo.hot, bid, ask);
|
||||
if (temp == TimeStamp::invalid()) { return HandleReadResult::BUSY; }
|
||||
time = temp;
|
||||
return HandleReadResult::SUCCESS;
|
||||
@@ -114,8 +114,8 @@ public:
|
||||
switch(_type) {
|
||||
case HANDLETYPE_VOID: return HandleReadResult::NO_CHANGE;
|
||||
case HANDLETYPE_DEPTH:
|
||||
if (book.hot->timestamp > time || book.hot->timestamp == TimeStamp::invalid()) {
|
||||
TimeStamp temp = copy_depth(book.hot->timestamp, book.hot->book, std::min(copydepth, COCONUT_MAX_DEPTH), bids, asks);
|
||||
if (book.hot->time() > time || book.hot->time() == TimeStamp::invalid()) {
|
||||
TimeStamp temp = copy_depth(*book.hot, std::min(copydepth, COCONUT_MAX_DEPTH), bids, asks);
|
||||
if (temp == TimeStamp::invalid()) { return HandleReadResult::BUSY; }
|
||||
time = temp;
|
||||
return HandleReadResult::SUCCESS;
|
||||
|
||||
@@ -73,74 +73,35 @@ void MDProducerHandle::set_legs(const std::vector<security_key>& legs) {
|
||||
}
|
||||
}
|
||||
|
||||
void MDProducerHandle::update_bid(TimeStamp time, const PriceSize price, uint32_t depth) {
|
||||
if (!has_depth()) {
|
||||
if (depth == 0 && hdata().bid.store(price)) {
|
||||
hdata().timestamp = time;
|
||||
hheader().bbo_count++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
bts_assert(depth < COCONUT_MAX_DEPTH);
|
||||
if (hdepth().bid(depth).store(price)) {
|
||||
hdepth().timestamp = time;
|
||||
if (depth == 0) {
|
||||
hheader().bbo_count++;
|
||||
hdepth().status = COCONUTSECURITYSTATUS_OK;
|
||||
}
|
||||
else { hheader().depth_count++; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MDProducerHandle::update_ask(TimeStamp time, const PriceSize price, uint32_t depth) {
|
||||
if (!has_depth()) {
|
||||
if (depth == 0 && hdata().ask.store(price)) {
|
||||
hdata().timestamp = time;
|
||||
hheader().bbo_count++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
bts_assert(depth < COCONUT_MAX_DEPTH);
|
||||
if (hdepth().ask(depth).store(price)) {
|
||||
hdepth().timestamp = time;
|
||||
if (depth == 0) {
|
||||
hheader().bbo_count++;
|
||||
hdepth().status = COCONUTSECURITYSTATUS_OK;
|
||||
}
|
||||
else { hheader().depth_count++; }
|
||||
}
|
||||
}
|
||||
}
|
||||
void MDProducerHandle::update_bbo(TimeStamp time, const PriceSize bid, const PriceSize ask, uint16_t seq) {
|
||||
if (!has_depth()) {
|
||||
auto oldtime = hdata().timestamp;
|
||||
hdata().timestamp = TimeStamp::invalid();
|
||||
auto oldtime = hdata().time();
|
||||
hdata().set_time(TimeStamp::invalid());
|
||||
bool set_bid = hdata().bid.store(bid);
|
||||
bool set_ask = hdata().ask.store(ask);
|
||||
hdata().status = COCONUTSECURITYSTATUS_OK;
|
||||
if (set_bid || set_ask) {
|
||||
hdata().timestamp = time;
|
||||
hdata().set_time(time);
|
||||
hdata().sequence = seq;
|
||||
hheader().bbo_count++;
|
||||
}
|
||||
else {
|
||||
hdata().timestamp = oldtime;
|
||||
hdata().set_time(oldtime);
|
||||
}
|
||||
}
|
||||
else {
|
||||
auto oldtime = hdepth().timestamp;
|
||||
hdepth().timestamp = TimeStamp::invalid();
|
||||
auto oldtime = hdepth().time();
|
||||
hdepth().set_time(TimeStamp::invalid());
|
||||
bool set_bid = hdepth().bid(0).store(bid);
|
||||
bool set_ask = hdepth().ask(0).store(ask);
|
||||
hdepth().status = COCONUTSECURITYSTATUS_OK;
|
||||
if (set_bid || set_ask) {
|
||||
hdepth().timestamp = time;
|
||||
hdepth().set_time(time);
|
||||
hdepth().sequence = seq;
|
||||
hheader().bbo_count++;
|
||||
}
|
||||
else {
|
||||
hdepth().timestamp = oldtime;
|
||||
hdepth().set_time(oldtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,16 +218,11 @@ void MDProducerHandle::update_fixing_price(TimeStamp, Price ) {
|
||||
void MDProducerHandle::mark_deleted() {
|
||||
TimeStamp ts = TimeStamp::now();
|
||||
cdata().deleted = true;
|
||||
PriceSize& no_market = PriceSize::NO_MARKET;
|
||||
if (has_depth()) {
|
||||
update_bbo(ts, no_market, no_market);
|
||||
}
|
||||
else {
|
||||
for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) {
|
||||
update_bid(ts, no_market, x);
|
||||
update_ask(ts, no_market, x);
|
||||
}
|
||||
std::array<PriceSize,COCONUT_MAX_DEPTH> blank;
|
||||
for (size_t x = 0; x < blank.size(); ++x) {
|
||||
blank[x] = PriceSize::NO_MARKET;
|
||||
}
|
||||
update_book(ts, blank, blank, 0);
|
||||
}
|
||||
|
||||
}}//namespace
|
||||
|
||||
@@ -34,9 +34,25 @@ public:
|
||||
}
|
||||
void set_legs(const std::vector<security_key>& legs);
|
||||
|
||||
void update_bid(TimeStamp time, const PriceSize bid, uint32_t depth=0); // hot
|
||||
void update_ask(TimeStamp time, const PriceSize ask, uint32_t depth=0); // hot
|
||||
void update_bbo(TimeStamp time, const PriceSize bid_price, const PriceSize ask_price, uint16_t seq=0); // hot
|
||||
void update_book(TimeStamp time, std::array<PriceSize,COCONUT_MAX_DEPTH>& bids, std::array<PriceSize,COCONUT_MAX_DEPTH>& asks, uint16_t seq=0) {
|
||||
if (!has_depth()) {
|
||||
update_bbo(time, bids[0], asks[0], seq);
|
||||
}
|
||||
else {
|
||||
auto& book = hdepth();
|
||||
book.set_time(TimeStamp::invalid());
|
||||
for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) {
|
||||
book.bid(x).store(bids[x]);
|
||||
book.ask(x).store(asks[x]);
|
||||
}
|
||||
book.status = co2::COCONUTSECURITYSTATUS_OK;
|
||||
book.sequence = seq;
|
||||
book.set_time(time);
|
||||
hheader().depth_count++;
|
||||
}
|
||||
}
|
||||
|
||||
void set_status(co2::CoconutSecurityStatus status); // hot
|
||||
|
||||
// Updates trade log and last trade
|
||||
|
||||
@@ -36,23 +36,29 @@ struct ALIGNED_(CACHE_LINE) HotHeader {
|
||||
|
||||
// These should not be cache line aligned because they are small enough for multiple to fit on one line easily
|
||||
struct ALIGNED_(32) HotEntry {
|
||||
HotEntry() : timestamp(), bid(), ask(), key(invalid_security_key), sequence(0), status(co2::COCONUTSECURITYSTATUS_OK) {}
|
||||
HotEntry() : timestamp(TimeStamp(0)), bid(), ask(), key(invalid_security_key), sequence(0), status(co2::COCONUTSECURITYSTATUS_OK) {}
|
||||
uint32_t size() const { return sizeof(HotEntry); }
|
||||
TimeStamp timestamp; // 8
|
||||
private:
|
||||
std::atomic<TimeStamp> timestamp; // 8
|
||||
public:
|
||||
SingleWriterPriceSizeStore bid; // 8
|
||||
SingleWriterPriceSizeStore ask; // 8
|
||||
security_key key; // 4
|
||||
uint16_t sequence; // 2
|
||||
uint8_t status; // 1
|
||||
void set_time(const TimeStamp& t) { timestamp.store(t, std::memory_order_release); }
|
||||
TimeStamp time() const { return timestamp.load(std::memory_order_acquire); }
|
||||
};
|
||||
|
||||
const uint32_t COCONUT_MAX_DEPTH = 10;
|
||||
struct ALIGNED_(CACHE_LINE) HotDepthEntry {
|
||||
HotDepthEntry() :
|
||||
timestamp(), key(invalid_security_key), status(co2::COCONUTSECURITYSTATUS_OK), book(), sequence(0)
|
||||
timestamp(TimeStamp(0)), key(invalid_security_key), status(co2::COCONUTSECURITYSTATUS_OK), book(), sequence(0)
|
||||
{ }
|
||||
uint32_t size() const { return sizeof(HotDepthEntry); }
|
||||
TimeStamp timestamp; // 8
|
||||
private:
|
||||
std::atomic<TimeStamp> timestamp; // 8
|
||||
public:
|
||||
security_key key; // NOTE: key is at a different offset than it is in HotEntry
|
||||
uint8_t status; // 1
|
||||
// Interleave bid/ask values so the top of book is always on the first line
|
||||
@@ -63,6 +69,8 @@ struct ALIGNED_(CACHE_LINE) HotDepthEntry {
|
||||
const SingleWriterPriceSizeStore& bid(uint32_t depth) const { return book[depth*2]; }
|
||||
SingleWriterPriceSizeStore& ask(uint32_t depth) { return book[depth*2+1]; }
|
||||
const SingleWriterPriceSizeStore& ask(uint32_t depth) const { return book[depth*2+1]; }
|
||||
void set_time(const TimeStamp& t) { timestamp.store(t, std::memory_order_release); }
|
||||
TimeStamp time() const { return timestamp.load(std::memory_order_acquire); }
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <unordered_map>
|
||||
#include <iostream>
|
||||
@@ -54,13 +55,12 @@ class RelayProducer : public IRelayWriter {
|
||||
bool snapshot = update.has_security();
|
||||
// If this is a snapshot an empty book() means "no market" rather than "no change"
|
||||
if (update.has_book() || snapshot) {
|
||||
// Write bbo first
|
||||
handle.update_bbo(updated, book_at(update.book().bids(), 0), book_at(update.book().asks(), 0));
|
||||
// Then update depth remembering to always overwrite the whole book (for shinking markets)
|
||||
for (size_t x = 1; x < COCONUT_MAX_DEPTH; ++x) {
|
||||
handle.update_bid(updated, book_at(update.book().bids(), x), x);
|
||||
handle.update_ask(updated, book_at(update.book().asks(), x), x);
|
||||
std::array<PriceSize,COCONUT_MAX_DEPTH> bids, asks;
|
||||
for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) {
|
||||
bids[x] = book_at(update.book().bids(), x);
|
||||
asks[x] = book_at(update.book().asks(), x);
|
||||
}
|
||||
handle.update_book(updated, bids, asks);
|
||||
}
|
||||
if (update.has_customer_bbo()) {
|
||||
handle.update_customer_bbo(updated, convert(update.customer_bbo().bid()), convert(update.customer_bbo().ask()));
|
||||
|
||||
@@ -281,8 +281,7 @@ public:
|
||||
// Add bbo data for those expirations
|
||||
auto write_time = TimeStamp::now();
|
||||
for (auto& p : producers) {
|
||||
p.update_bid(write_time, PriceSize::from_double<2>(5.0, 5));
|
||||
p.update_ask(write_time, PriceSize::from_double<2>(5.0, 5));
|
||||
p.update_bbo(write_time, PriceSize::from_double<2>(5.0, 5), PriceSize::from_double<2>(5.0, 5));
|
||||
}
|
||||
|
||||
// Symbol list for the consumer
|
||||
|
||||
@@ -33,18 +33,12 @@ ostream& operator<< (ostream& os, const PS& val) {
|
||||
|
||||
void setup_market(MDProducerHandle producer, const vector<PS>& bids, const vector<PS>& asks) {
|
||||
auto ts = TimeStamp::now();
|
||||
for (size_t x = 0; x < bids.size(); ++x) {
|
||||
const auto& bid = bids[x];
|
||||
producer.update_bid(ts, PriceSize::from_double<7>(bid.price, bid.size), x);
|
||||
}
|
||||
for (size_t x = 0; x < asks.size(); ++x) {
|
||||
const auto& ask = asks[x];
|
||||
producer.update_ask(ts, PriceSize::from_double<7>(ask.price, ask.size), x);
|
||||
}
|
||||
for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) {
|
||||
if (x >= bids.size()) producer.update_bid(ts, PriceSize::NO_MARKET, x);
|
||||
if (x >= asks.size()) producer.update_ask(ts, PriceSize::NO_MARKET, x);
|
||||
}
|
||||
|
||||
std::array<PriceSize,COCONUT_MAX_DEPTH> bids_a = { }, asks_a = { };
|
||||
std::transform(bids.begin(), bids.end(), bids_a.begin(), [](const PS& ps) { return PriceSize::from_double<7>(ps.price, ps.size); });
|
||||
std::transform(asks.begin(), asks.end(), asks_a.begin(), [](const PS& ps) { return PriceSize::from_double<7>(ps.price, ps.size); });
|
||||
|
||||
producer.update_book(ts, bids_a, asks_a);
|
||||
}
|
||||
|
||||
void expect_market(MDConsumerHandle handle, const vector<PS> bids, const vector<PS>& asks) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
set(sources cmds/AutoCert.cpp;cmds/Benchmark.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/Help.cpp;cmds/Md.cpp;cmds/QuickTest.cpp;cmds/Run.cpp;cmds/RunSim.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;dspark/mirage.cpp;dspark/mirage/routing/Router.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/book/Book.cpp;exchange_sim/book/ExchangeSim.proto;exchange_sim/book/Order.cpp;exchange_sim/book/OrderMatcher.cpp;exchange_sim/book/book_transform.cpp;exchange_sim/tests/test_book_transform.cpp;http/ApiGateway.cpp;http/WebServer.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;main.cpp;md/platforms/celoxica/CXListener.cpp;md/platforms/celoxica/CXMain.cpp;md/platforms/celoxica/tests/cx_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/MDP3Utils.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;mercury/actors/Actor.cpp;mercury/broker/AsyncEventBroker.cpp;mercury/broker/CoreEventBroker.cpp;mercury/broker/IEventBroker.cpp;mercury/events/TimerEvent.cpp;mercury/mercury_utils/Executor.cpp;mercury/mercury_utils/IPollableActor.cpp;mercury/mercury_utils/mercury_common.cpp;mercury/synopsis/SynopsisBuilder.cpp;mercury/topics/ITopic.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/OrderStore.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/Limiter.cpp;orderman/order_factory/OrderFactory.cpp;orderman/order_router/OrderRouter.cpp;orderman/orderman_utils/fix_order_codec.cpp;orderman/orders/IcebergOrder.cpp;orderman/orders/NativeOrder.cpp;orderman/orders/Order.cpp;orderman/orders/TimeBoxOrder.cpp;orderman/orders/spreader_orders/SpreaderOrder.cpp;orderman/orders/spreader_orders/spreader/SingleFillHedger.cpp;orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckCancelledStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckCancelledWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderEndStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderStartStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForCancelAllStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWorkingStateWorker.cpp;orderman/orders/spreader_orders/tests/spreader_tests.cpp;orderman/server/OrderServiceServer.cpp;orderman/tests/fat_wrapper_tests.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/tests/PersistenceServiceTests.cpp;position/IMarginObserver.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/PositionServiceCore.cpp;position/tests/PositionTests.cpp;support/ErrorReportService.cpp;testing/catch_test_runner.cpp;tracing/bts_trace_c.c;user/AccountServiceServer.cpp;user/AdminServiceServer.cpp;user/UserServiceServer.cpp;user/tests/UserAndAccountTests.cpp;user/tests/admin_service_tests.cpp)
|
||||
set(sources cmds/AutoCert.cpp;cmds/Benchmark.cpp;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/Help.cpp;cmds/Md.cpp;cmds/QuickTest.cpp;cmds/Run.cpp;cmds/RunSim.cpp;cmds/Span.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;dspark/mirage.cpp;dspark/mirage/routing/Router.cpp;exchange_sim/ExchangeSim.cpp;exchange_sim/ExchangeSimApplication.cpp;exchange_sim/book/Book.cpp;exchange_sim/book/ExchangeSim.proto;exchange_sim/book/Order.cpp;exchange_sim/book/OrderMatcher.cpp;exchange_sim/book/book_transform.cpp;exchange_sim/tests/test_book_transform.cpp;http/ApiGateway.cpp;http/WebServer.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;main.cpp;md/platforms/celoxica/CXListener.cpp;md/platforms/celoxica/CXMain.cpp;md/platforms/celoxica/tests/cx_tests.cpp;md/platforms/mdp3_onixs/MDP3Listener.cpp;md/platforms/mdp3_onixs/MDP3Main.cpp;md/platforms/mdp3_onixs/MDP3Utils.cpp;md/platforms/mdp3_onixs/tests/mdp3_tests.cpp;md/run_md.cpp;mercury/actors/Actor.cpp;mercury/broker/AsyncEventBroker.cpp;mercury/broker/CoreEventBroker.cpp;mercury/broker/IEventBroker.cpp;mercury/events/TimerEvent.cpp;mercury/mercury_utils/Executor.cpp;mercury/mercury_utils/IPollableActor.cpp;mercury/mercury_utils/mercury_common.cpp;mercury/synopsis/SynopsisBuilder.cpp;mercury/topics/ITopic.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/OrderStore.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/Limiter.cpp;orderman/limiter/tests/limit_tests.cpp;orderman/order_factory/OrderFactory.cpp;orderman/order_router/OrderRouter.cpp;orderman/orderman_utils/fix_order_codec.cpp;orderman/orders/IcebergOrder.cpp;orderman/orders/NativeOrder.cpp;orderman/orders/Order.cpp;orderman/orders/TimeBoxOrder.cpp;orderman/orders/spreader_orders/SpreaderOrder.cpp;orderman/orders/spreader_orders/spreader/SingleFillHedger.cpp;orderman/orders/spreader_orders/spreader/SingleLegQuoter.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckCancelledStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWaitingForFirstAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/hedger/hedger_states/HedgerWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterEndStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterStartStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForCancelAckStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckCancelledWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForFirstAckWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWaitingForSizeStateWorker.cpp;orderman/orders/spreader_orders/spreader/quoter/quoter_states/QuoterWorkingStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderEndStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderStartStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWaitingForCancelAllStateWorker.cpp;orderman/orders/spreader_orders/spreader_states/SpreaderWorkingStateWorker.cpp;orderman/orders/spreader_orders/tests/spreader_tests.cpp;orderman/server/OrderServiceServer.cpp;orderman/tests/fat_wrapper_tests.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/tests/PersistenceServiceTests.cpp;position/IMarginObserver.cpp;position/IPositionObserver.cpp;position/MarginServiceCore.cpp;position/PositionServiceCore.cpp;position/tests/PositionTests.cpp;support/ErrorReportService.cpp;testing/catch_test_runner.cpp;tracing/bts_trace_c.c;user/AdminServiceServer.cpp;user/UserServiceServer.cpp;user/tests/admin_service_tests.cpp)
|
||||
+310
-100
@@ -10,9 +10,11 @@
|
||||
#include "server/sparkd/jetfix/codec/i32_toa.h"
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sys/select.h>
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
@@ -20,23 +22,52 @@ namespace cmd {
|
||||
unsigned int their_sn;
|
||||
unsigned int last_received_sn;
|
||||
|
||||
std::ofstream f("/home/ppinto/fix_log");
|
||||
void reset_sn(std::string const &session = "99") {
|
||||
std::ofstream seq("/home/ppinto/seq_num_" + session);
|
||||
seq << 1;
|
||||
}
|
||||
|
||||
int get_next_sn() {
|
||||
int get_next_sn(std::string const &session = "99") {
|
||||
int result = 0;
|
||||
{
|
||||
std::ifstream seq("/home/ppinto/seq_num");
|
||||
std::ifstream seq("/home/ppinto/seq_num_" + session);
|
||||
seq >> result;
|
||||
}
|
||||
{
|
||||
std::ofstream seq("/home/ppinto/seq_num");
|
||||
std::ofstream seq("/home/ppinto/seq_num_" + session);
|
||||
seq << 1 + result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string make_resend_req(int seqnum, int last_seq_num_processed, int begin_s,
|
||||
int end_s) {
|
||||
int end_s, std::string const &target_subid) {
|
||||
std::string seq_num_str(9, ' ');
|
||||
i32_toa(seqnum, &seq_num_str[0], 9);
|
||||
|
||||
std::string last_seq_num_str(9, ' ');
|
||||
i32_toa(last_seq_num_processed, &last_seq_num_str[0], 9);
|
||||
|
||||
auto time_str = datetime::FIX_timestamp(datetime::now());
|
||||
|
||||
auto body = fmt::format("35=2\001"
|
||||
"34={}\001" // sn
|
||||
"369={}\001" // their sn
|
||||
"52={}\001" // time
|
||||
"49=MBX004N\001"
|
||||
"56=CME\001"
|
||||
"142=US,NC\001"
|
||||
"7={}\001" // begin
|
||||
"16={}\001" // end
|
||||
"50=BTS\001"
|
||||
"57={}\001",
|
||||
seq_num_str, last_seq_num_str, time_str, begin_s,
|
||||
end_s, target_subid);
|
||||
return body;
|
||||
}
|
||||
|
||||
std::string make_hb(int seqnum, int last_seq_num_processed,
|
||||
std::string const &target_subid) {
|
||||
std::string seq_num_str(9, ' ');
|
||||
i32_toa(seqnum, &seq_num_str[0], 9);
|
||||
|
||||
@@ -46,45 +77,22 @@ std::string make_resend_req(int seqnum, int last_seq_num_processed, int begin_s,
|
||||
auto time_str = datetime::FIX_timestamp(datetime::now());
|
||||
|
||||
auto body =
|
||||
fmt::format("35=2\001"
|
||||
fmt::format("35=0\001"
|
||||
"34={}\001" // sn
|
||||
"369={}\001" // their sn
|
||||
"52={}\001" // time
|
||||
"49=MBX004N\001"
|
||||
"56=CME\001"
|
||||
"57=99\001"
|
||||
"142=US,NC\001"
|
||||
"7={}\001" // begin
|
||||
"16={}\001" // end
|
||||
"50=BTS\001",
|
||||
seq_num_str, last_seq_num_str, time_str, begin_s, end_s);
|
||||
return body;
|
||||
}
|
||||
|
||||
std::string make_hb(int seqnum, int last_seq_num_processed) {
|
||||
std::string seq_num_str(9, ' ');
|
||||
i32_toa(seqnum, &seq_num_str[0], 9);
|
||||
|
||||
std::string last_seq_num_str(9, ' ');
|
||||
i32_toa(last_seq_num_processed, &last_seq_num_str[0], 9);
|
||||
|
||||
auto time_str = datetime::FIX_timestamp(datetime::now());
|
||||
|
||||
auto body = fmt::format("35=0\001"
|
||||
"34={}\001" // sn
|
||||
"369={}\001" // their sn
|
||||
"52={}\001" // time
|
||||
"49=MBX004N\001"
|
||||
"56=CME\001"
|
||||
"57=99\001"
|
||||
"142=US,NC\001"
|
||||
"50=BTS\001",
|
||||
seq_num_str, last_seq_num_str, time_str);
|
||||
"50=BTS\001"
|
||||
"57={}\001",
|
||||
seq_num_str, last_seq_num_str, time_str, target_subid);
|
||||
return body;
|
||||
}
|
||||
|
||||
std::string make_hb(int seqnum, int last_seq_num_processed,
|
||||
std::string const &test_id) {
|
||||
std::string const &test_id,
|
||||
std::string const &target_subid) {
|
||||
std::string seq_num_str(9, ' ');
|
||||
i32_toa(seqnum, &seq_num_str[0], 9);
|
||||
|
||||
@@ -99,15 +107,17 @@ std::string make_hb(int seqnum, int last_seq_num_processed,
|
||||
"52={}\001" // time
|
||||
"49=MBX004N\001"
|
||||
"56=CME\001"
|
||||
"57=99\001"
|
||||
"112={}\001"
|
||||
"142=US,NC\001"
|
||||
"50=BTS\001",
|
||||
seq_num_str, last_seq_num_str, time_str, test_id);
|
||||
"50=BTS\001"
|
||||
"57={}\001",
|
||||
seq_num_str, last_seq_num_str, time_str, test_id,
|
||||
target_subid);
|
||||
return body;
|
||||
}
|
||||
|
||||
std::string make_logon(int seqnum, int last_seq_num_processed) {
|
||||
std::string make_logon(int seqnum, int last_seq_num_processed,
|
||||
std::string const &target_subid) {
|
||||
std::string seq_num_str(9, ' ');
|
||||
i32_toa(seqnum, &seq_num_str[0], 9);
|
||||
|
||||
@@ -117,7 +127,7 @@ std::string make_logon(int seqnum, int last_seq_num_processed) {
|
||||
auto time_str = datetime::FIX_timestamp(datetime::now());
|
||||
|
||||
auto ld = bts::glbx::calculate_hmac("MBX", seq_num_str, "MBX004N", "BTS",
|
||||
time_str, "99", "30", "US,NC",
|
||||
time_str, target_subid, "30", "US,NC",
|
||||
last_seq_num_str, "O2", "1.0", "BTS");
|
||||
|
||||
auto body = fmt::format("35=A\001"
|
||||
@@ -126,7 +136,6 @@ std::string make_logon(int seqnum, int last_seq_num_processed) {
|
||||
"52={}\001" // time
|
||||
"49=MBX004N\001"
|
||||
"56=CME\001"
|
||||
"57=99\001"
|
||||
"142=US,NC\001"
|
||||
"50=BTS\001"
|
||||
"98=0\001"
|
||||
@@ -138,10 +147,11 @@ std::string make_logon(int seqnum, int last_seq_num_processed) {
|
||||
"355={}\001" // encoded text
|
||||
"1400=CME-1-SHA-256\001"
|
||||
"1401={}\001" // sig size
|
||||
"1402={}\001",
|
||||
"1402={}\001"
|
||||
"57={}\001",
|
||||
seq_num_str, last_seq_num_str, time_str,
|
||||
ld.access_key.size(), ld.access_key,
|
||||
ld.signature.size(), ld.signature);
|
||||
ld.signature.size(), ld.signature, target_subid);
|
||||
|
||||
return body;
|
||||
}
|
||||
@@ -165,16 +175,18 @@ std::string add_header_footer(std::string const &body) {
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
|
||||
void send(tcp::socket &socket, std::string const &body) {
|
||||
void send(tcp::socket &socket, std::string const &body,
|
||||
std::string const &session = "99") {
|
||||
auto all = add_header_footer(body);
|
||||
std::ofstream f("/home/ppinto/fix_log_" + session,
|
||||
std::fstream::out | std::fstream::app);
|
||||
f << all << "\n";
|
||||
f.flush();
|
||||
boost::asio::write(socket, boost::asio::buffer(all.data(), all.size()));
|
||||
std::replace(all.begin(), all.end(), '\001', '|');
|
||||
std::cout << "> " << all << "\n";
|
||||
}
|
||||
|
||||
std::string receive(tcp::socket &s) {
|
||||
std::string receive(tcp::socket &s, std::string const &session = "99") {
|
||||
std::string buffer(1024, ' ');
|
||||
|
||||
std::string str;
|
||||
@@ -193,6 +205,8 @@ std::string receive(tcp::socket &s) {
|
||||
}
|
||||
}
|
||||
|
||||
std::ofstream f("/home/ppinto/fix_log_" + session,
|
||||
std::fstream::out | std::fstream::app);
|
||||
f << str << "\n";
|
||||
f.flush();
|
||||
auto human_str = str;
|
||||
@@ -203,7 +217,8 @@ std::string receive(tcp::socket &s) {
|
||||
last_received_sn = parser.get_seq_num();
|
||||
if (parser.type() == jetfix::MessageTypes::TestRequest) {
|
||||
auto req_id = parser.get_test_req_id();
|
||||
send(s, make_hb(get_next_sn(), last_received_sn, req_id));
|
||||
send(s, make_hb(get_next_sn(session), last_received_sn, req_id, session),
|
||||
session);
|
||||
}
|
||||
|
||||
return str;
|
||||
@@ -219,13 +234,13 @@ void DetectAGapAndReceiveGapFill() {
|
||||
tcp::socket socket(io_service);
|
||||
boost::asio::connect(socket, endpoint_iterator);
|
||||
|
||||
send(socket, make_logon(get_next_sn(), their_sn));
|
||||
send(socket, make_logon(get_next_sn(), their_sn, "99"));
|
||||
auto logon_ack = receive(socket);
|
||||
their_sn = jetfix::InMsgBuffer(logon_ack).get_seq_num();
|
||||
|
||||
bts::sleep_for(30s);
|
||||
// send hb
|
||||
send(socket, make_hb(get_next_sn(), their_sn));
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
|
||||
std::string msg;
|
||||
do {
|
||||
@@ -235,8 +250,8 @@ void DetectAGapAndReceiveGapFill() {
|
||||
auto their_new_sn = jetfix::InMsgBuffer(msg).get_seq_num();
|
||||
|
||||
// send gap resolution req
|
||||
send(socket,
|
||||
make_resend_req(get_next_sn(), their_sn, their_sn + 1, their_new_sn));
|
||||
send(socket, make_resend_req(get_next_sn(), their_sn, their_sn + 1,
|
||||
their_new_sn, "99"));
|
||||
|
||||
do {
|
||||
msg = receive(socket);
|
||||
@@ -246,16 +261,16 @@ void DetectAGapAndReceiveGapFill() {
|
||||
|
||||
bts::sleep_for(30s);
|
||||
// send hb with the right sn
|
||||
send(socket, make_hb(get_next_sn(), new_sn - 1));
|
||||
send(socket, make_hb(get_next_sn(), new_sn - 1, "99"));
|
||||
|
||||
do {
|
||||
msg = receive(socket);
|
||||
} while (jetfix::InMsgBuffer(msg).type() != jetfix::MessageTypes::HB);
|
||||
their_new_sn = jetfix::InMsgBuffer(msg).get_seq_num();
|
||||
send(socket, make_hb(get_next_sn(), their_new_sn));
|
||||
send(socket, make_hb(get_next_sn(), their_new_sn, "99"));
|
||||
do {
|
||||
bts::sleep_for(30s);
|
||||
send(socket, make_hb(get_next_sn(), new_sn - 1));
|
||||
send(socket, make_hb(get_next_sn(), new_sn - 1, "99"));
|
||||
} while (true);
|
||||
}
|
||||
|
||||
@@ -269,13 +284,13 @@ void ProcessingMessageGapsOfMoreThan2500Messages() {
|
||||
tcp::socket socket(io_service);
|
||||
boost::asio::connect(socket, endpoint_iterator);
|
||||
|
||||
send(socket, make_logon(get_next_sn(), their_sn));
|
||||
send(socket, make_logon(get_next_sn(), their_sn, "99"));
|
||||
auto logon_ack = receive(socket);
|
||||
their_sn = jetfix::InMsgBuffer(logon_ack).get_seq_num();
|
||||
|
||||
bts::sleep_for(30s);
|
||||
// send hb
|
||||
send(socket, make_hb(get_next_sn(), their_sn));
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
|
||||
std::string msg;
|
||||
do {
|
||||
@@ -286,8 +301,9 @@ void ProcessingMessageGapsOfMoreThan2500Messages() {
|
||||
|
||||
while (their_new_sn > their_sn) {
|
||||
// send gap resolution req
|
||||
send(socket, make_resend_req(get_next_sn(), their_sn, their_sn + 1,
|
||||
std::min(their_sn + 2500, their_new_sn)));
|
||||
send(socket,
|
||||
make_resend_req(get_next_sn(), their_sn, their_sn + 1,
|
||||
std::min(their_sn + 2500, their_new_sn), "99"));
|
||||
|
||||
do {
|
||||
msg = receive(socket);
|
||||
@@ -298,20 +314,22 @@ void ProcessingMessageGapsOfMoreThan2500Messages() {
|
||||
}
|
||||
bts::sleep_for(30s);
|
||||
// send hb with the right sn
|
||||
send(socket, make_hb(get_next_sn(), their_sn));
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
|
||||
do {
|
||||
msg = receive(socket);
|
||||
} while (jetfix::InMsgBuffer(msg).type() != jetfix::MessageTypes::HB);
|
||||
their_sn = jetfix::InMsgBuffer(msg).get_seq_num();
|
||||
send(socket, make_hb(get_next_sn(), their_sn));
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
do {
|
||||
bts::sleep_for(30s);
|
||||
send(socket, make_hb(get_next_sn(), their_sn));
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
} while (true);
|
||||
}
|
||||
|
||||
std::string make_order(int seqnum, int last_seq_num_processed) {
|
||||
std::string make_order(int seqnum, int last_seq_num_processed,
|
||||
std::string const &sec_desc,
|
||||
std::string const &target_subid) {
|
||||
std::string seq_num_str(9, ' ');
|
||||
i32_toa(seqnum, &seq_num_str[0], 9);
|
||||
|
||||
@@ -327,26 +345,28 @@ std::string make_order(int seqnum, int last_seq_num_processed) {
|
||||
"50=BTS\001" // SenderSubID
|
||||
"49=MBX004N\001" // SenderCompID
|
||||
"56=CME\001" // TargetCompID
|
||||
"57=99\001" // TargetSubID
|
||||
"142=US,NC\001" // SenderLocationID
|
||||
|
||||
"1=BTS\001" // Account
|
||||
"54=1\001" // Side
|
||||
"1028=Y\001" // ManualOrderIndicator
|
||||
"204=1\001" // CustomerOrFirm
|
||||
"9702=1\001" // CTICode
|
||||
"107=0GLBX8\001" // SecurityDesc
|
||||
"11=1\001" // ClOrdId
|
||||
"38=5\001" // Quantity
|
||||
"40=2\001" // OrdType
|
||||
"44=1\001" // Price
|
||||
"60={}\001" // TransactTime
|
||||
"1=BTS\001" // Account
|
||||
"54=1\001" // Side
|
||||
"1028=Y\001" // ManualOrderIndicator
|
||||
"204=1\001" // CustomerOrFirm
|
||||
"9702=1\001" // CTICode
|
||||
"107={}\001" // SecurityDesc
|
||||
"11=1\001" // ClOrdId
|
||||
"38=6\001" // Quantity
|
||||
"40=2\001" // OrdType
|
||||
"44=25\001" // Price
|
||||
"60={}\001" // TransactTime
|
||||
"57={}\001" // TargetSubID
|
||||
,
|
||||
seq_num_str, last_seq_num_str, time_str, time_str);
|
||||
seq_num_str, last_seq_num_str, time_str, sec_desc,
|
||||
time_str, target_subid);
|
||||
return body;
|
||||
}
|
||||
|
||||
std::string make_seq_reset(int seqnum, int last_seq_num_processed, int new_seq_no) {
|
||||
std::string make_seq_reset(int seqnum, int last_seq_num_processed,
|
||||
int new_seq_no, std::string const &target_subid) {
|
||||
std::string seq_num_str(9, ' ');
|
||||
i32_toa(seqnum, &seq_num_str[0], 9);
|
||||
|
||||
@@ -362,14 +382,16 @@ std::string make_seq_reset(int seqnum, int last_seq_num_processed, int new_seq_n
|
||||
"50=BTS\001" // SenderSubID
|
||||
"49=MBX004N\001" // SenderCompID
|
||||
"56=CME\001" // TargetCompID
|
||||
"57=99\001" // TargetSubID
|
||||
"142=US,NC\001" // SenderLocationID
|
||||
|
||||
"122={}\001" // OrigSendTime
|
||||
"43=N\001" // PossibleDupFlag
|
||||
"123=Y\001" // GapFilFlag
|
||||
"36={}\001" // GapFilFlag
|
||||
,seq_num_str, last_seq_num_str, time_str,time_str,new_seq_no);
|
||||
"122={}\001" // OrigSendTime
|
||||
"43=N\001" // PossibleDupFlag
|
||||
"123=Y\001" // GapFilFlag
|
||||
"36={}\001" // GapFilFlag
|
||||
"57=99\001" // TargetSubID
|
||||
,
|
||||
seq_num_str, last_seq_num_str, time_str, time_str,
|
||||
new_seq_no, target_subid);
|
||||
return body;
|
||||
}
|
||||
|
||||
@@ -383,13 +405,13 @@ void ReceivingAndProcessingMultipleGaps() {
|
||||
tcp::socket socket(io_service);
|
||||
boost::asio::connect(socket, endpoint_iterator);
|
||||
|
||||
send(socket, make_logon(get_next_sn(), their_sn));
|
||||
send(socket, make_logon(get_next_sn(), their_sn, "99"));
|
||||
auto logon_ack = receive(socket);
|
||||
their_sn = jetfix::InMsgBuffer(logon_ack).get_seq_num();
|
||||
|
||||
bts::sleep_for(30s);
|
||||
// send hb
|
||||
send(socket, make_hb(get_next_sn(), their_sn));
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
|
||||
std::string msg;
|
||||
do {
|
||||
@@ -398,7 +420,7 @@ void ReceivingAndProcessingMultipleGaps() {
|
||||
|
||||
// logged in, send order
|
||||
uint32_t previous_sn = 0;
|
||||
send(socket, make_order(get_next_sn(), last_received_sn));
|
||||
send(socket, make_order(get_next_sn(), last_received_sn, "0GLBX8", "99"));
|
||||
|
||||
// process messages until we notice a gap
|
||||
do {
|
||||
@@ -408,23 +430,23 @@ void ReceivingAndProcessingMultipleGaps() {
|
||||
|
||||
// send resend request
|
||||
auto end_of_gap = last_received_sn - 1;
|
||||
send(socket,
|
||||
make_resend_req(get_next_sn(), their_sn, previous_sn + 1, end_of_gap));
|
||||
send(socket, make_resend_req(get_next_sn(), their_sn, previous_sn + 1,
|
||||
end_of_gap, "99"));
|
||||
|
||||
auto er1 = receive(socket);
|
||||
auto er2 = receive(socket);
|
||||
|
||||
// 2nd gap
|
||||
send(socket,
|
||||
make_resend_req(get_next_sn(), their_sn, last_received_sn - 1, last_received_sn - 1 ));
|
||||
send(socket, make_resend_req(get_next_sn(), their_sn, last_received_sn - 1,
|
||||
last_received_sn - 1, "99"));
|
||||
|
||||
receive(socket);
|
||||
|
||||
bts::sleep_for(30s);
|
||||
send(socket, make_hb(get_next_sn(), their_sn));
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
receive(socket);
|
||||
bts::sleep_for(30s);
|
||||
send(socket, make_hb(get_next_sn(), their_sn));
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
receive(socket);
|
||||
}
|
||||
|
||||
@@ -439,13 +461,13 @@ void RespondToResendRequest() {
|
||||
tcp::socket socket(io_service);
|
||||
boost::asio::connect(socket, endpoint_iterator);
|
||||
|
||||
send(socket, make_logon(get_next_sn(), their_sn));
|
||||
send(socket, make_logon(get_next_sn(), their_sn, "99"));
|
||||
auto logon_ack = receive(socket);
|
||||
their_sn = jetfix::InMsgBuffer(logon_ack).get_seq_num();
|
||||
|
||||
bts::sleep_for(30s);
|
||||
// send hb
|
||||
send(socket, make_hb(get_next_sn(), their_sn));
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
|
||||
std::string msg;
|
||||
do {
|
||||
@@ -453,26 +475,214 @@ void RespondToResendRequest() {
|
||||
} while (jetfix::InMsgBuffer(msg).type() != jetfix::MessageTypes::HB);
|
||||
|
||||
// logged in, send order
|
||||
send(socket, make_order(get_next_sn(), last_received_sn));
|
||||
send(socket, make_order(get_next_sn(), last_received_sn));
|
||||
send(socket, make_order(get_next_sn(), last_received_sn, "0GLBX8", "99"));
|
||||
send(socket, make_order(get_next_sn(), last_received_sn, "0GLBX8", "99"));
|
||||
|
||||
// wait for receive request
|
||||
do {
|
||||
msg = receive(socket);
|
||||
} while (jetfix::InMsgBuffer(msg).type() != jetfix::MessageTypes::ResendRequest);
|
||||
} while (jetfix::InMsgBuffer(msg).type() !=
|
||||
jetfix::MessageTypes::ResendRequest);
|
||||
auto start = jetfix::InMsgBuffer(msg).get_begin_seq_no();
|
||||
|
||||
auto sn = get_next_sn();
|
||||
send(socket,make_seq_reset(sn,last_received_sn,sn+1));
|
||||
|
||||
send(socket, make_seq_reset(start, last_received_sn, sn, "99"));
|
||||
|
||||
bts::sleep_for(30s);
|
||||
send(socket, make_hb(get_next_sn(), their_sn));
|
||||
send(socket, make_hb(sn, their_sn, "99"));
|
||||
receive(socket);
|
||||
bts::sleep_for(30s);
|
||||
send(socket, make_hb(get_next_sn(), their_sn));
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
receive(socket);
|
||||
}
|
||||
|
||||
void BiDirectionalResendRequestScenario() {
|
||||
boost::asio::io_service io_service;
|
||||
|
||||
tcp::resolver resolver(io_service);
|
||||
tcp::resolver::query query("69.50.112.199", "61920");
|
||||
tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
|
||||
|
||||
tcp::socket socket(io_service);
|
||||
boost::asio::connect(socket, endpoint_iterator);
|
||||
|
||||
send(socket, make_logon(get_next_sn(), their_sn, "99"));
|
||||
auto logon_ack = receive(socket);
|
||||
their_sn = jetfix::InMsgBuffer(logon_ack).get_seq_num();
|
||||
|
||||
bts::sleep_for(30s);
|
||||
// send hb
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
|
||||
std::string msg;
|
||||
do {
|
||||
msg = receive(socket);
|
||||
} while (jetfix::InMsgBuffer(msg).type() != jetfix::MessageTypes::HB);
|
||||
|
||||
// logged in, send 4 orders
|
||||
send(socket, make_order(get_next_sn(), last_received_sn, "0GLBX8", "99"));
|
||||
send(socket, make_order(get_next_sn(), last_received_sn, "0GLBX8", "99"));
|
||||
send(socket, make_order(get_next_sn(), last_received_sn, "0GLBX8", "99"));
|
||||
send(socket, make_order(get_next_sn(), last_received_sn, "0GLBX8", "99"));
|
||||
|
||||
uint32_t previous_sn = 0;
|
||||
// process messages until we notice a gap
|
||||
do {
|
||||
previous_sn = last_received_sn;
|
||||
msg = receive(socket);
|
||||
} while ((last_received_sn - previous_sn) == 1);
|
||||
|
||||
// send resend request
|
||||
auto end_of_gap = last_received_sn - 1;
|
||||
send(socket, make_resend_req(get_next_sn(), their_sn, previous_sn + 1,
|
||||
end_of_gap, "99"));
|
||||
|
||||
// process messages until we notice a resend req
|
||||
do {
|
||||
msg = receive(socket);
|
||||
} while (jetfix::InMsgBuffer(msg).type() !=
|
||||
jetfix::MessageTypes::ResendRequest);
|
||||
|
||||
auto start = jetfix::InMsgBuffer(msg).get_begin_seq_no();
|
||||
auto sn = get_next_sn();
|
||||
send(socket, make_seq_reset(start, last_received_sn, sn, "99"));
|
||||
|
||||
bts::sleep_for(30s);
|
||||
send(socket, make_hb(sn, their_sn, "99"));
|
||||
receive(socket);
|
||||
bts::sleep_for(30s);
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
receive(socket);
|
||||
}
|
||||
|
||||
void ProcessRealTimeMessagesDuringAResendResponse() {
|
||||
boost::asio::io_service io_service;
|
||||
|
||||
tcp::resolver resolver(io_service);
|
||||
tcp::resolver::query query("69.50.112.199", "61920");
|
||||
tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
|
||||
|
||||
tcp::socket socket(io_service);
|
||||
boost::asio::connect(socket, endpoint_iterator);
|
||||
|
||||
send(socket, make_logon(get_next_sn(), their_sn, "99"));
|
||||
auto logon_ack = receive(socket);
|
||||
their_sn = jetfix::InMsgBuffer(logon_ack).get_seq_num();
|
||||
|
||||
bts::sleep_for(30s);
|
||||
// send hb
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
|
||||
std::string msg;
|
||||
do {
|
||||
msg = receive(socket);
|
||||
} while (jetfix::InMsgBuffer(msg).type() != jetfix::MessageTypes::HB);
|
||||
|
||||
// logged in, send 4 orders
|
||||
send(socket, make_order(get_next_sn(), last_received_sn, "0GLBX8", "99"));
|
||||
send(socket, make_order(get_next_sn(), last_received_sn, "0GLBX8", "99"));
|
||||
send(socket, make_order(get_next_sn(), last_received_sn, "0GLBX8", "99"));
|
||||
|
||||
uint32_t previous_sn = 0;
|
||||
// process messages until we notice a gap
|
||||
do {
|
||||
previous_sn = last_received_sn;
|
||||
msg = receive(socket);
|
||||
} while ((last_received_sn - previous_sn) == 1);
|
||||
|
||||
// send resend request
|
||||
auto end_of_gap = last_received_sn - 1;
|
||||
send(socket, make_resend_req(get_next_sn(), their_sn, previous_sn + 1,
|
||||
end_of_gap, "99"));
|
||||
|
||||
// get 2 msgs
|
||||
receive(socket);
|
||||
receive(socket);
|
||||
bts::sleep_for(30s);
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
receive(socket);
|
||||
bts::sleep_for(30s);
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
receive(socket);
|
||||
}
|
||||
|
||||
void ProcessSequenceStreamsBasedOnSessionAndMarketSegment() {
|
||||
boost::filesystem::remove("/home/ppinto/fix_log_70");
|
||||
boost::filesystem::remove("/home/ppinto/fix_log_99");
|
||||
|
||||
reset_sn();
|
||||
reset_sn("70");
|
||||
|
||||
std::thread t([]() {
|
||||
boost::asio::io_service io_service;
|
||||
tcp::resolver resolver(io_service);
|
||||
tcp::resolver::query query("69.50.112.199", "61920");
|
||||
tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
|
||||
|
||||
tcp::socket socket(io_service);
|
||||
boost::asio::connect(socket, endpoint_iterator);
|
||||
|
||||
send(socket, make_logon(get_next_sn(), their_sn, "99"));
|
||||
auto logon_ack = receive(socket);
|
||||
their_sn = jetfix::InMsgBuffer(logon_ack).get_seq_num();
|
||||
|
||||
bts::sleep_for(30s);
|
||||
// send hb
|
||||
send(socket, make_hb(get_next_sn(), their_sn, "99"));
|
||||
|
||||
for (;;) {
|
||||
fd_set readSet;
|
||||
FD_ZERO(&readSet);
|
||||
FD_SET(STDIN_FILENO, &readSet);
|
||||
struct timeval tv = {0, 10000}; // 10 seconds, 0 microseconds;
|
||||
if (select(STDIN_FILENO + 1, &readSet, NULL, NULL, &tv) < 0)
|
||||
perror("select");
|
||||
|
||||
if (FD_ISSET(STDIN_FILENO, &readSet))
|
||||
break;
|
||||
else
|
||||
receive(socket);
|
||||
}
|
||||
send(socket,
|
||||
make_order(get_next_sn("99"), last_received_sn, "1ZWU9", "99"));
|
||||
while (true)
|
||||
receive(socket);
|
||||
});
|
||||
|
||||
std::thread t2([]() {
|
||||
boost::asio::io_service io_service;
|
||||
tcp::resolver resolver(io_service);
|
||||
tcp::resolver::query query("69.50.112.183", "61920");
|
||||
tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
|
||||
|
||||
tcp::socket socket(io_service);
|
||||
boost::asio::connect(socket, endpoint_iterator);
|
||||
|
||||
send(socket, make_logon(get_next_sn("70"), their_sn, "70"), "70");
|
||||
auto logon_ack = receive(socket, "70");
|
||||
their_sn = jetfix::InMsgBuffer(logon_ack).get_seq_num();
|
||||
|
||||
bts::sleep_for(30s);
|
||||
// send hb
|
||||
send(socket, make_hb(get_next_sn("70"), their_sn, "70"), "70");
|
||||
|
||||
std::string msg;
|
||||
do {
|
||||
msg = receive(socket, "70");
|
||||
} while (jetfix::InMsgBuffer(msg).type() != jetfix::MessageTypes::HB);
|
||||
|
||||
send(socket,
|
||||
make_order(get_next_sn("70"), last_received_sn, "1AJCH0", "70"),
|
||||
"70");
|
||||
while (true)
|
||||
receive(socket, "70");
|
||||
});
|
||||
t.join();
|
||||
t2.join();
|
||||
}
|
||||
|
||||
int AutoCert::execute(std::vector<std::string> const &) {
|
||||
RespondToResendRequest();
|
||||
ProcessSequenceStreamsBasedOnSessionAndMarketSegment();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -441,37 +441,17 @@ void ExchangeSimApplication::update_md(std::string const &sec_desc) {
|
||||
|
||||
auto price_factor = pow(10, handle.security().display_factor);
|
||||
|
||||
auto n_bids = book.bids.size();
|
||||
uint i = 0;
|
||||
auto it = book.bids.begin();
|
||||
for (; i < std::min(md::COCONUT_MAX_DEPTH, (uint32_t)n_bids); i++, it++) {
|
||||
auto p = it->first.value() * price_factor;
|
||||
auto sz = it->second.value();
|
||||
auto psz = md::PriceSize::from_double<7>(p, sz);
|
||||
LOG(ExSim, Diag, "Updating market data for {}. Depth: {} : Buy {}@{}",
|
||||
sec_desc, i, sz, p);
|
||||
handle.update_bid(utils::TimeStamp::now(), psz, i);
|
||||
}
|
||||
for (uint i = n_bids; i < md::COCONUT_MAX_DEPTH; i++) {
|
||||
auto psz = md::PriceSize::from_double<7>(os::nan(), 0);
|
||||
handle.update_bid(utils::TimeStamp::now(), psz, i);
|
||||
}
|
||||
|
||||
auto n_asks = book.asks.size();
|
||||
i = 0;
|
||||
it = book.asks.begin();
|
||||
for (; i < std::min(md::COCONUT_MAX_DEPTH, (uint32_t)n_asks); i++, it++) {
|
||||
auto p = it->first.value() * price_factor;
|
||||
auto sz = it->second.value();
|
||||
auto psz = md::PriceSize::from_double<7>(p, sz);
|
||||
LOG(ExSim, Diag, "Updating market data for {}. Depth: {} : Sell {}@{}",
|
||||
sec_desc, i, sz, p);
|
||||
handle.update_ask(utils::TimeStamp::now(), psz, i);
|
||||
}
|
||||
for (uint i = n_asks; i < md::COCONUT_MAX_DEPTH; i++) {
|
||||
auto psz = md::PriceSize::from_double<7>(os::nan(), 0);
|
||||
handle.update_ask(utils::TimeStamp::now(), psz, i);
|
||||
}
|
||||
const auto cmax = md::COCONUT_MAX_DEPTH;
|
||||
std::array<md::PriceSize,cmax> bids_temp = { }, asks_temp = { };
|
||||
auto bids_end = book.bids.size() > cmax ?
|
||||
std::next(book.bids.begin(), cmax) : book.bids.end();
|
||||
std::transform(book.bids.begin(), bids_end, bids_temp.begin(),
|
||||
[&](const auto& bs) { return md::PriceSize::from_double<7>(bs.first.value()*price_factor, bs.second.value()); });
|
||||
auto asks_end = book.asks.size() > cmax ?
|
||||
std::next(book.asks.begin(), cmax) : book.asks.end();
|
||||
std::transform(book.asks.begin(), asks_end, asks_temp.begin(),
|
||||
[&](const auto& bs) { return md::PriceSize::from_double<7>(bs.first.value()*price_factor, bs.second.value()); });
|
||||
handle.update_book(utils::TimeStamp::now(), bids_temp, asks_temp);
|
||||
|
||||
auto new_trades = matcher.get_new_trades();
|
||||
for (auto &t : new_trades)
|
||||
|
||||
@@ -174,22 +174,30 @@ namespace http {
|
||||
boost::filesystem::path web_ui_path(const boost::filesystem::path& root) {
|
||||
auto reldir = root / "web/ui";
|
||||
if (boost::filesystem::exists(reldir)) return reldir;
|
||||
else if (root.has_parent_path()) return web_ui_path(root.parent_path());
|
||||
reldir = root / "ui";
|
||||
if (boost::filesystem::exists(reldir)) return reldir;
|
||||
if (root.has_parent_path()) return web_ui_path(root.parent_path());
|
||||
return _www;
|
||||
}
|
||||
|
||||
boost::filesystem::path map_path_to_filesystem(const std::string& resource) {
|
||||
std::string config = "/config";
|
||||
std::string files = "/files";
|
||||
std::string error_reports = "/error_reports";
|
||||
|
||||
if (resource.compare(0, config.size(), config) == 0) {
|
||||
LOG(Api,Info,"config");
|
||||
return _www + resource;
|
||||
}
|
||||
else if (resource.compare(0, files.size(), files) == 0) {
|
||||
LOG(Api,Info,"files");
|
||||
return _www + resource.substr(files.size());
|
||||
}
|
||||
#ifndef RELEASE
|
||||
// To enable this in release it probably needs a password
|
||||
else if (resource.compare(0, error_reports.size(), error_reports) == 0) {
|
||||
auto errp = boost::filesystem::path(getenv("HOME")) / ".bts/data/error_reports" / resource.substr(error_reports.size());
|
||||
if (boost::filesystem::exists(errp)) return errp;
|
||||
}
|
||||
#endif
|
||||
return web_ui_path(os::get_install_path()) / resource;
|
||||
}
|
||||
|
||||
@@ -213,9 +221,14 @@ namespace http {
|
||||
if (boost::iequals(resource, "/config/.all")) {
|
||||
return_dotall(con);
|
||||
}
|
||||
if (boost::iequals(resource, "/bts_installer.exe") && boost::filesystem::is_regular_file(_www+"/bts_installer.exe")) {
|
||||
else if (boost::iequals(resource, "/bts_installer.exe") && boost::filesystem::is_regular_file(_www+"/bts_installer.exe")) {
|
||||
return_file(con, _www + "/bts_installer.exe");
|
||||
}
|
||||
else if (boost::iequals(resource, "/robots.txt")) {
|
||||
con->set_status(websocketpp::http::status_code::ok);
|
||||
std::string body = "User-agent: *\nDisallow: /";
|
||||
con->set_body(body);
|
||||
}
|
||||
else {
|
||||
auto path = map_path_to_filesystem(resource);
|
||||
if (boost::filesystem::is_directory(path)) {
|
||||
|
||||
@@ -313,7 +313,6 @@ void MDP3Listener::onDefinition(onixs::Handler&, const onixs::Security&, const o
|
||||
void MDP3Listener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, const onixs::ConsolidatedBook& book) {
|
||||
// tracepoint (bts_trace,quoter,(char*) "onConsolidatedBookBegin", sec.id(), _latest_sequence);
|
||||
|
||||
|
||||
auto data = _index.get_security(sec.id());
|
||||
if (data == nullptr) return;
|
||||
bts_assert(data->id == (uint32_t)sec.id());
|
||||
@@ -331,8 +330,12 @@ void MDP3Listener::onBookUpdate(onixs::Handler&, const onixs::Security& sec, con
|
||||
BookData& cache = found ? *find_iter : _book_updates.back();
|
||||
|
||||
// Overwrite all entries every time
|
||||
size_t bids_size = data->handle.has_depth() ? book.bids().size() : min((size_t)book.bids().size(), (size_t)1);
|
||||
size_t asks_size = data->handle.has_depth() ? book.offers().size() : min((size_t)book.offers().size(), (size_t)1);
|
||||
size_t bids_size = book.bids().size();
|
||||
size_t asks_size = book.offers().size();
|
||||
if (!data->handle.has_depth()) {
|
||||
bids_size = min(bids_size, size_t { 1 });
|
||||
asks_size = min(asks_size, size_t { 1 });
|
||||
}
|
||||
for (size_t x = 0; x < bids_size; ++x) {
|
||||
cache.bids[x] = pricesize_of_price_size(book.bids()[x].price(), display_factor, book.bids()[x].quantity());
|
||||
}
|
||||
@@ -625,15 +628,8 @@ void MDP3Listener::flush_books() {
|
||||
// This is called at the end of the packet
|
||||
// Write all book updates to shared memory and reset for the next packet
|
||||
for (auto& entry : _book_updates) {
|
||||
// bbo first
|
||||
uint16_t sequence = (_latest_sequence & 0xFFFF);
|
||||
entry.handle.update_bbo(_packet_arrived, entry.bids[0], entry.asks[0], sequence);
|
||||
|
||||
// todo: Need an atomic write function
|
||||
for (size_t x = 1; x < COCONUT_MAX_DEPTH; ++x) {
|
||||
entry.handle.update_bid(_packet_arrived, entry.bids[x], x);
|
||||
entry.handle.update_ask(_packet_arrived, entry.asks[x], x);
|
||||
}
|
||||
entry.handle.update_book(_packet_arrived, entry.bids, entry.asks, sequence);
|
||||
}
|
||||
// Reset pending updates
|
||||
_book_updates.clear();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <tbb/concurrent_queue.h>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
#include <array>
|
||||
|
||||
namespace bts {
|
||||
namespace md {
|
||||
@@ -129,8 +130,8 @@ private:
|
||||
struct BookData {
|
||||
BookData(MDProducerHandle& handle);
|
||||
MDProducerHandle handle;
|
||||
PriceSize bids[10];
|
||||
PriceSize asks[10];
|
||||
std::array<PriceSize, COCONUT_MAX_DEPTH> bids;
|
||||
std::array<PriceSize, COCONUT_MAX_DEPTH> asks;
|
||||
};
|
||||
std::vector<BookData> _book_updates;
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ void ExecutionGateway::on_exe_report(
|
||||
" lost fills. Please investigate.",
|
||||
sk.value());
|
||||
else {
|
||||
// Ignore trade correction msgs. CME does not included the full
|
||||
// Ignore trade correction messages. CME does not included the full
|
||||
// id of the trade being corrected and we have no way of
|
||||
// resolving it here. We could still parse the correction and
|
||||
// push the resolution problem downstream but that would make
|
||||
@@ -141,6 +141,17 @@ void ExecutionGateway::on_exe_report(
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore unsupported trade cancelation messages.
|
||||
if (msg.get<fix::ExecType>() == api::orderman::EXEC_TYPE_TRADE_CANCEL) {
|
||||
LOG(OrderMan,Error,
|
||||
"Received unsupported trade cancel msg. "
|
||||
"This correction will not be forwarded. The trader should be alerted. "
|
||||
"Order: {} SecKey: {} ",
|
||||
ok.value(), sk.value());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Ignore leg fills, we care only about the actual security fill
|
||||
if (msg.has<fix::MultiLegReportingType>() &&
|
||||
msg.get<fix::MultiLegReportingType>() == 2)
|
||||
@@ -153,6 +164,7 @@ void ExecutionGateway::on_exe_report(
|
||||
// allocate from our pool
|
||||
auto data = me->exe_report_pool.construct();
|
||||
|
||||
data->exec_type = api::orderman::ExecType(msg.get<fix::ExecType>());
|
||||
data->msg_seq_num = msg.get<fix::MsgSeqNum>();
|
||||
// copy data from fix msg to our structure
|
||||
if (msg.has<fix::Account>())
|
||||
@@ -167,7 +179,6 @@ void ExecutionGateway::on_exe_report(
|
||||
api::orderman::TimeInForce(msg.get<fix::TimeInForce>());
|
||||
data->order_type =
|
||||
api::orderman::NativeOrderType(msg.get<fix::OrdType>());
|
||||
data->exec_type = api::orderman::ExecType(msg.get<fix::ExecType>());
|
||||
data->order_status =
|
||||
api::orderman::NativeOrderStatus(msg.get<fix::OrdStatus>());
|
||||
data->manual_order_indicator =
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
#include "server/sparkd/mercury/events/TimerEvent.h"
|
||||
#include "server/sparkd/orderman/actors/order_manager/OrderServices.h"
|
||||
#include "server/sparkd/orderman/actors/order_manager/OrderServicesData.h"
|
||||
#include "server/sparkd/orderman/events/NewAdminDataEvent.h"
|
||||
#include "server/sparkd/orderman/events/OrderManagerReadyEvent.h"
|
||||
#include "server/sparkd/orderman/order_factory/OrderFactory.h"
|
||||
#include "server/sparkd/orderman/orders/Order.h"
|
||||
#include "server/sparkd/securities/ISecurityDB.h"
|
||||
#include "server/sparkd/orderman/events/NewAdminDataEvent.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace orderman {
|
||||
|
||||
using namespace mercury;
|
||||
|
||||
enum class OrderManager::State { WAIT_SEC, WAIT_ORDERS, READY };
|
||||
enum class OrderManager::State { WAIT_ADMIN, WAIT_SEC, WAIT_ORDERS, READY };
|
||||
|
||||
struct OrderManager::OrderInfo {
|
||||
OrderInfo(Order &o, OrderServicesData &data)
|
||||
@@ -32,7 +32,7 @@ struct OrderManager::OrderInfo {
|
||||
};
|
||||
|
||||
struct OrderManager::PImpl {
|
||||
PImpl(Actor &owner) : state(State::WAIT_SEC), services_data(owner) {}
|
||||
PImpl(Actor &owner) : state(State::WAIT_ADMIN), services_data(owner) {}
|
||||
|
||||
State state;
|
||||
std::unordered_map<OrderKey, OrderInfo> orders;
|
||||
@@ -47,9 +47,6 @@ OrderManager::~OrderManager() {}
|
||||
void OrderManager::init() {
|
||||
subscribe<NewAdminDataEvent>(
|
||||
[this](auto const &admin_update) { this->on_admin_data(admin_update); });
|
||||
|
||||
subscribe<NewSecuritiesEvent>(
|
||||
[this](auto const &sec_update) { this->on_securities(sec_update); });
|
||||
}
|
||||
|
||||
void OrderManager::on_securities(
|
||||
@@ -57,7 +54,7 @@ void OrderManager::on_securities(
|
||||
if (update.events) {
|
||||
|
||||
// update our security db and accumulate for the sake of the limiter
|
||||
std::vector<api::Security const*> secs;
|
||||
std::vector<api::Security const *> secs;
|
||||
for (auto const &ev : *(update.events)) {
|
||||
auto sec_ptr = ev.security;
|
||||
secs.push_back(sec_ptr);
|
||||
@@ -338,14 +335,23 @@ void OrderManager::init_order_services() {
|
||||
std::make_unique<ContentSubscription<CreateOrderReplyEvent>>(*this);
|
||||
}
|
||||
|
||||
void OrderManager::on_admin_data(const mercury::Update<NewAdminDataEvent> &m)
|
||||
{
|
||||
if (m.events)
|
||||
void OrderManager::on_admin_data(const mercury::Update<NewAdminDataEvent> &m) {
|
||||
if (m.events) {
|
||||
|
||||
if (me->state == State::WAIT_ADMIN) {
|
||||
LOG(OrderMan, Info, "Order manager received admin data. Subscribing "
|
||||
"to security list now ");
|
||||
me->state = State::WAIT_SEC;
|
||||
subscribe<NewSecuritiesEvent>([this](auto const &sec_update) {
|
||||
this->on_securities(sec_update);
|
||||
});
|
||||
}
|
||||
|
||||
for (auto ev : *m.events) {
|
||||
me->services_data.order_router.update(*ev.admin_data);
|
||||
me->services_data.limiter.update(*ev.admin_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,4 +33,4 @@ public:
|
||||
}
|
||||
const api::Product& product() const {return _product;}
|
||||
};
|
||||
}}
|
||||
}}
|
||||
@@ -81,4 +81,4 @@ private:
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
}}
|
||||
}}
|
||||
@@ -0,0 +1 @@
|
||||
set(sources ../lib/api/apicore.proto;../lib/api/apigateway.proto;../lib/api/apioptions.proto;../lib/api/services/AdminService.proto;../lib/api/services/ApiUnitTestService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/api/services/UserService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;api/build.sh;api/node_modules/cssstyle/scripts/run_tests.sh;api/node_modules/exit/test/fixtures/create-files.sh;api/node_modules/protobufjs/cli/node_modules/acorn-jsx/node_modules/acorn/bin/update_authors.sh;api/node_modules/watch/release.sh;api/quiet_build.sh)
|
||||
@@ -0,0 +1,41 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(web)
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/tools/safe_dep_glob.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/tools/Protobuf.cmake)
|
||||
|
||||
# DEPENDENCIES
|
||||
|
||||
# service protos
|
||||
set(PROTO_GLOBS
|
||||
../lib/api/*.proto
|
||||
../lib/api/services/*.proto
|
||||
../lib/domain_model/*.proto
|
||||
../lib/sparkproto/*.proto
|
||||
../lib/md/protos/*.proto
|
||||
../../externals/linux/include/google/protobuf/descriptor.proto
|
||||
../../externals/linux/include/google/protobuf/timestamp.proto
|
||||
)
|
||||
|
||||
file (GLOB_RECURSE Proto_Deps RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${PROTO_GLOBS})
|
||||
file (GLOB_RECURSE Proto_Deps_For_Tool RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/api ${PROTO_GLOBS})
|
||||
file (GLOB_RECURSE Api_Src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} api/src/)
|
||||
file (GLOB_RECURSE Ui_Src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} api/ui/src/)
|
||||
file (GLOB_RECURSE build_scripts RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} api/*.sh)
|
||||
|
||||
set (All_Deps ${Proto_Deps} ${Api_Src} ${Ui_Src} ${build_scripts})
|
||||
|
||||
# this is used to communicate to other repositories that the build
|
||||
# needs to happen again (because a file was added)
|
||||
update_deps_file("${All_Deps}")
|
||||
# END DEPENDENCIES
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/../web/ui/bundle.js
|
||||
COMMAND /bin/bash ${CMAKE_CURRENT_SOURCE_DIR}/api/quiet_build.sh
|
||||
ARGS ${Proto_Deps_For_Tool}
|
||||
COMMENT "Building Web UI"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/api
|
||||
DEPENDS ${All_Deps})
|
||||
|
||||
add_custom_target(web_ui_bundle ALL DEPENDS ${CMAKE_BINARY_DIR}/../web/ui/bundle.js)
|
||||
|
||||
+12
-3
@@ -5,7 +5,16 @@ OUT=../../../build/web/
|
||||
rm -rf $OUT/api
|
||||
mkdir -p $OUT/api
|
||||
mkdir -p $OUT/api/fable
|
||||
PROTO_LIST="../../lib/api/*.proto ../../lib/api/services/*.proto ../../lib/domain_model/*.proto ../../lib/sparkproto/*.proto ../../lib/md/protos/*.proto ../../../externals/linux/include/google/protobuf/descriptor.proto ../../../externals/linux/include/google/protobuf/timestamp.proto"
|
||||
|
||||
if [ "$#" -gt 0 ]
|
||||
then
|
||||
PROTO_LIST="$@"
|
||||
FULL=1
|
||||
else
|
||||
PROTO_LIST="../../lib/api/*.proto ../../lib/api/services/*.proto ../../lib/domain_model/*.proto ../../lib/sparkproto/*.proto ../../lib/md/protos/*.proto ../../../externals/linux/include/google/protobuf/descriptor.proto ../../../externals/linux/include/google/protobuf/timestamp.proto"
|
||||
FULL=0
|
||||
fi
|
||||
|
||||
export PYTHONPATH=../../../externals/linux/python/
|
||||
PROTOC=../../../externals/linux/bin/protoc
|
||||
ORANGE='\033[0;33m'
|
||||
@@ -47,12 +56,12 @@ echo -e \* ${ORANGE} ts2fable ${NOCOLOR}
|
||||
ts2fable $OUT/api
|
||||
# ts2fable $OUT/api/gen
|
||||
|
||||
if [ "$1" == "-full" ]; then
|
||||
if [ "$FULL" == "1" ]; then
|
||||
echo \* fable
|
||||
cd ../ui/
|
||||
npm install
|
||||
cd src
|
||||
cp -r ../public/* ../$OUT/ui/
|
||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 dotnet restore
|
||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 dotnet fable webpack -- -p
|
||||
cp -r ../public/* ../$OUT/ui/
|
||||
fi
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "spark-api",
|
||||
"version": "1.0.0",
|
||||
"description": "Blue Trading Systems Spark API",
|
||||
"repository": { },
|
||||
"engineStrict": true,
|
||||
"engines": {
|
||||
"node": ">= 8.9.0"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
tmpfile=$(mktemp /tmp/quiet_build_log.XXXX)
|
||||
./build.sh $@ #>$tmpfile 2>&1
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
rm $tmpfile
|
||||
exit 0
|
||||
else
|
||||
cat $tmpfile
|
||||
exit 1
|
||||
fi
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "ui",
|
||||
"version": "1.0.0",
|
||||
"description": "Simple Fable App",
|
||||
"repository": { },
|
||||
"scripts": {
|
||||
"build": "webpack -p",
|
||||
"start": "webpack-dev-server",
|
||||
|
||||
@@ -3,6 +3,17 @@ $brand_primary: #0086bf
|
||||
$primary: $brand_primary
|
||||
$shell_gray: #f6f6f6
|
||||
|
||||
$table-background-color: $shell_gray
|
||||
$table-cell-border: 0
|
||||
$table-row-hover-background-color: $shell_gray
|
||||
|
||||
$navbar-background-color: $brand_primary
|
||||
$navbar-item-color: #fff
|
||||
$navbar-item-hover-color: #ffffff
|
||||
$navbar-item-hover-background-color: lighten($brand_primary, 5%)
|
||||
$navbar-item-active-color: #333333
|
||||
$navbar-item-active-background-color: $shell_gray
|
||||
|
||||
@import '../node_modules/bulma/bulma'
|
||||
|
||||
html
|
||||
@@ -16,4 +27,5 @@ html
|
||||
.title
|
||||
color: #ffffff
|
||||
font-weight: 600
|
||||
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ let update msg (model:Model) =
|
||||
model, Cmd.Empty
|
||||
| AddAccount ->
|
||||
// Create a new scratch account. Send to server after user has filled in details
|
||||
{ model with scratch = emptyAccount; selectedAccount = Some { emptyAccount with name = "" }; gridSelection = emptySelection }, Cmd.Empty
|
||||
{ model with scratch = emptyAccount; selectedAccount = Some { emptyAccount with name = "" }; gridSelection = emptySelection }, Cmd.ofMsg <| SelectTab General
|
||||
| SaveScratch ->
|
||||
match isNewAccount model.scratch with
|
||||
| true -> model, Cmd.ofExistingPromise (createAccount model.admin model.scratch) id (string>>ErrorOccured)
|
||||
|
||||
@@ -30,7 +30,8 @@ let saveButton model dispatch =
|
||||
let generalView model dispatch =
|
||||
let account = model.scratch
|
||||
div [] [
|
||||
Fields.text "ID" (string account.id) [Props.Disabled true] ignore
|
||||
p [ Style [FontWeight "Bold"] ] [ str ("ID: " + (string account.id))]
|
||||
br []
|
||||
Fields.text "Name" account.name [] (AccountName >> Update >> dispatch)
|
||||
Fields.text "Description" account.description [] (Description >> Update >> dispatch)
|
||||
Fields.checkbox "Is Active" account.isActive [] (IsActive >> Update >> dispatch)
|
||||
@@ -87,28 +88,15 @@ let creditLimitsView model dispatch = div [] [str "lorem ipsum"]
|
||||
let exchangeSettings model dispatch =
|
||||
let cme = model.scratch.exchangeAccountData.cmeAccountData
|
||||
let send = UpdateCME>>dispatch
|
||||
div [ClassName "columns"] [
|
||||
div [ClassName "column is-narrow"] [
|
||||
aside [ClassName "menu"] [
|
||||
ul [ClassName "menu-list"] [
|
||||
li [] [
|
||||
a [ClassName "is-active"] [str "CME" ]
|
||||
]
|
||||
// Comming soon
|
||||
// li [] [ a [] [str "ICE" ] ]
|
||||
]
|
||||
]
|
||||
]
|
||||
div [ClassName "column"] [
|
||||
Fields.enumSelect "CTI" cme.cti CTICode.values [] (CTI>>send)
|
||||
Fields.enumSelect "Origin" cme.origin CustomerOrFirm.values [] (Origin>>send)
|
||||
Fields.text "Takeup Member Code" cme.takeupMemberCode [] (TakeupMember>>send)
|
||||
Fields.text "Clearing Account" cme.clearingAccount [] (ClearingAccount>>send)
|
||||
Fields.text "Direct Electronic Access" cme.directElectronicAccess [] (DirectElectronicAccess>>send)
|
||||
Fields.text "Trading Capacity" cme.tradingCapacity [] (TradingCapacity>>send)
|
||||
Fields.text "Liquidity Provision" cme.liquidityProvision [] (LiquidityProvision>>send)
|
||||
Fields.map "Misc Tag Mapping" cme.miscTags [] (MiscTagMapping>>send)
|
||||
]
|
||||
div [] [
|
||||
Fields.enumSelect "CTI" cme.cti CTICode.values [] (CTI>>send)
|
||||
Fields.enumSelect "Origin" cme.origin CustomerOrFirm.values [] (Origin>>send)
|
||||
//Fields.text "Takeup Member Code" cme.takeupMemberCode [] (TakeupMember>>send)
|
||||
Fields.text "Clearing Account" cme.clearingAccount [] (ClearingAccount>>send)
|
||||
//Fields.text "Direct Electronic Access" cme.directElectronicAccess [] (DirectElectronicAccess>>send)
|
||||
//Fields.text "Trading Capacity" cme.tradingCapacity [] (TradingCapacity>>send)
|
||||
//Fields.text "Liquidity Provision" cme.liquidityProvision [] (LiquidityProvision>>send)
|
||||
//Fields.map "Misc Tag Mapping" cme.miscTags [] (MiscTagMapping>>send)
|
||||
]
|
||||
|
||||
|
||||
@@ -122,10 +110,6 @@ let tabContent model dispatch =
|
||||
| PositionLimitsTab -> positionLimitsView model dispatch
|
||||
| CreditLimitsTab -> creditLimitsView model dispatch
|
||||
| ExchangeSettingsTab -> exchangeSettings model dispatch)
|
||||
div [ClassName "field is-grouped"] [
|
||||
saveButton model dispatch
|
||||
Button.button "Revert" "is-light" "" (if isDirty model then Enabled else Disabled) (fun _ -> dispatch <| SelectAccount selectedAccount)
|
||||
]
|
||||
]
|
||||
| None ->
|
||||
span [Style [ Color "Red" ]] [ str "Select an account" ]
|
||||
@@ -152,11 +136,6 @@ let isActiveItem a b = if a = b then "is-active" else ""
|
||||
let accountsMenu (accounts:BTSAccount[]) selectedAccount dispatch =
|
||||
div [ClassName "column is-narrow"] [
|
||||
aside [ ClassName "menu" ] [
|
||||
p [ ClassName "menu-label" ] [
|
||||
Button.faIcon "server"
|
||||
str " Accounts"
|
||||
accountControls selectedAccount dispatch
|
||||
]
|
||||
ul [ClassName "menu-list"] [
|
||||
for account in accounts do
|
||||
yield li [] [
|
||||
@@ -166,6 +145,7 @@ let accountsMenu (accounts:BTSAccount[]) selectedAccount dispatch =
|
||||
str account.name]
|
||||
]
|
||||
]
|
||||
accountControls selectedAccount dispatch
|
||||
]
|
||||
]
|
||||
|
||||
@@ -188,6 +168,11 @@ let root (model:Model) dispatch =
|
||||
div [ClassName "columns"] [
|
||||
accountsMenu data.accounts model.selectedAccount dispatch
|
||||
div [ ClassName "column" ] [
|
||||
div [ ClassName "is-pulled-right"; Style [MarginLeft "1em"] ] [ saveButton model dispatch ]
|
||||
(*div [ClassName "field is-grouped"] [
|
||||
saveButton model dispatch
|
||||
Button.button "Revert" "is-light" "" (if isDirty model then Enabled else Disabled) (fun _ -> dispatch <| SelectAccount selectedAccount)
|
||||
]*)
|
||||
div [ ClassName "tabs is-small is-boxed" ] [
|
||||
ul [] [
|
||||
tabHeader General model.tab dispatch
|
||||
|
||||
+63
-27
@@ -24,27 +24,66 @@ let isCurrentPage page currentPage =
|
||||
| _ -> false
|
||||
|
||||
|
||||
let menuItem label icon state currentPage dispatch =
|
||||
li [] [
|
||||
a [ OnClick (fun _ -> Navigate state |> dispatch)
|
||||
classList [ "is-active", isCurrentPage (fst state) currentPage ] ] [
|
||||
let navButton classy href faClass txt =
|
||||
p
|
||||
[ ClassName "control" ]
|
||||
[ a
|
||||
[ ClassName (sprintf "button %s" classy)
|
||||
Href href ]
|
||||
[ span
|
||||
[ ClassName "icon" ]
|
||||
[ i
|
||||
[ ClassName (sprintf "fa %s" faClass) ]
|
||||
[ ] ]
|
||||
span
|
||||
[ ]
|
||||
[ str txt ] ] ]
|
||||
|
||||
let navButtons =
|
||||
span
|
||||
[ ClassName "nav-item" ]
|
||||
[ div
|
||||
[ ClassName "field is-grouped" ]
|
||||
[ navButton "" "/" "fa-sign-out" "Logout"
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
let navItem label icon state currentPage dispatch =
|
||||
a [
|
||||
OnClick (fun _ -> Navigate state |> dispatch)
|
||||
classList [ "navbar-item", true; "is-active", isCurrentPage (fst state) currentPage ]
|
||||
]
|
||||
[
|
||||
Button.faIcon icon
|
||||
str (" " + label) ] ]
|
||||
Fields.nbsp
|
||||
str label
|
||||
]
|
||||
|
||||
let menu currentPage sc dispatch =
|
||||
let tmap (a,b) (fa,fb) = (fa a, fb b)
|
||||
aside
|
||||
[ ClassName "menu" ]
|
||||
[ p
|
||||
[ ClassName "menu-label" ]
|
||||
[ str "General" ]
|
||||
ul
|
||||
[ ClassName "menu-list" ] [
|
||||
menuItem "Users" "users" (tmap (Users.State.init sc) (UsersModel, Cmd.map UsersMsg)) currentPage dispatch
|
||||
menuItem "Accounts" "server" (tmap (Accounts.State.init sc) (AccountsModel,Cmd.map AccountsMsg)) currentPage dispatch
|
||||
] ]
|
||||
|
||||
let menu' = lazyView3With (fun a b -> isCurrentPage (fst a) (fst b)) menu
|
||||
|
||||
let navRoot currentPage sc dispatch =
|
||||
let tmap (a,b) (fa,fb) = (fa a, fb b)
|
||||
nav
|
||||
[ ClassName "navbar" ]
|
||||
[
|
||||
div [ ClassName "navbar-brand" ]
|
||||
[
|
||||
h1
|
||||
[ ClassName "navbar-item" ]
|
||||
[
|
||||
span [] [ str "BTS Spark Admin " ]
|
||||
span [ Style [ CSSProp.Color "#ddf"; FontSize "60%"; MarginLeft "1em"] ] [ str " (beta)" ]
|
||||
]
|
||||
navItem "Users" "users" (tmap (Users.State.init sc) (UsersModel, Cmd.map UsersMsg)) currentPage dispatch
|
||||
navItem "Accounts" "server" (tmap (Accounts.State.init sc) (AccountsModel,Cmd.map AccountsMsg)) currentPage dispatch
|
||||
]
|
||||
|
||||
div [ ClassName "nav-right" ]
|
||||
[ navButtons ]
|
||||
]
|
||||
|
||||
let nav' = lazyView3With (fun a b -> isCurrentPage (fst a) (fst b)) navRoot
|
||||
|
||||
let topLevel sc currentPage dispatch content =
|
||||
div
|
||||
@@ -53,19 +92,16 @@ let topLevel sc currentPage dispatch content =
|
||||
[ ClassName "navbar-bg" ]
|
||||
[ div
|
||||
[ ClassName "container" ]
|
||||
[ Navbar.View.root ] ]
|
||||
[ nav' currentPage sc dispatch ] ]
|
||||
div
|
||||
[ ClassName "section" ]
|
||||
[ div
|
||||
[ ClassName "container" ]
|
||||
[ div
|
||||
[ ClassName "columns" ]
|
||||
[ div
|
||||
[ ClassName "column is-2" ]
|
||||
[ menu' currentPage sc dispatch ]
|
||||
div
|
||||
[ ClassName "column" ]
|
||||
[ content ] ] ] ] ]
|
||||
[ div []
|
||||
[ content ]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
let root model dispatch =
|
||||
match model with
|
||||
|
||||
@@ -12,17 +12,25 @@ let isDisabled = function
|
||||
| Disabled -> true
|
||||
| Enabled -> false
|
||||
|
||||
let fabutton title icon disabled click =
|
||||
p [ ClassName "control" ] [
|
||||
a [ ClassName "button is-light"
|
||||
let fabutton title icon disabled click =
|
||||
a [ ClassName "button is-light"
|
||||
HTMLAttr.Disabled (isDisabled disabled)
|
||||
Title title
|
||||
OnClick click ] [
|
||||
span [ ClassName "icon is-small" ] [
|
||||
i [ ClassName (sprintf "fa fa-%s" icon)] [ ] ]
|
||||
]
|
||||
|
||||
let falink title icon disabled click =
|
||||
span [
|
||||
HTMLAttr.Disabled (isDisabled disabled)
|
||||
Title title
|
||||
OnClick click ] [
|
||||
span [ ClassName "icon is-small" ] [
|
||||
i [ ClassName (sprintf "fa fa-%s" icon)] [ ] ]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
let button text flavor icon disabled click =
|
||||
p [ ClassName "control" ] [
|
||||
a [ ClassName (sprintf "button %s" flavor)
|
||||
|
||||
@@ -9,6 +9,8 @@ open Global
|
||||
open Fable
|
||||
open JSMap
|
||||
|
||||
let nbsp = span [ Style [PaddingLeft "1ex"] ][str " "]
|
||||
|
||||
let text (lbl:string) (dv:string) (attrs:IHTMLProp list) onchange =
|
||||
div [ ClassName "field" ]
|
||||
[
|
||||
@@ -89,7 +91,7 @@ let map (lbl:string) (dv:JSMap<string>) (attrs:IHTMLProp list) (onchange: JSMap<
|
||||
[HTMLAttr.Disabled true; Placeholder "Enter New Item Name:"; ]
|
||||
[ OnBlur ((fun ev -> !!ev.target?value |> newEntry )) ]
|
||||
[
|
||||
Button.fabutton "Cancel" "times" Button.Enabled ignore
|
||||
Button.fabutton "" "" Button.Enabled ignore
|
||||
Button.fabutton "Add" "check" Button.Enabled ignore
|
||||
]
|
||||
change
|
||||
|
||||
@@ -24,9 +24,16 @@ let createRow (r:row) =
|
||||
| None -> tr [ ClassName r.className ] (List.map<cell, ReactElement> createCell r.cells)
|
||||
| Some h -> tr [ ClassName r.className ] (th [] [str h] :: (List.map<cell, ReactElement> createCell r.cells))
|
||||
|
||||
let createTable (headers:row) (rl:row list) =
|
||||
table [ ClassName "table" ]
|
||||
[
|
||||
thead [] [ createRow headers ]
|
||||
tbody [ ] (List.map<row,ReactElement> createRow rl)
|
||||
]
|
||||
let createTable (headers:row option) (rl:row list) =
|
||||
let tbl = match headers with
|
||||
| Some h ->
|
||||
[
|
||||
thead [] [ createRow h ]
|
||||
tbody [] (List.map<row,ReactElement> createRow rl)
|
||||
]
|
||||
| None ->
|
||||
[ tbody [] (List.map<row,ReactElement> createRow rl) ]
|
||||
table [ ClassName "table is-narrow" ] tbl
|
||||
|
||||
|
||||
|
||||
@@ -2,39 +2,6 @@ module Navbar.View
|
||||
|
||||
open Fable.Helpers.React
|
||||
open Fable.Helpers.React.Props
|
||||
open System.Drawing
|
||||
|
||||
let navButton classy href faClass txt =
|
||||
p
|
||||
[ ClassName "control" ]
|
||||
[ a
|
||||
[ ClassName (sprintf "button %s" classy)
|
||||
Href href ]
|
||||
[ span
|
||||
[ ClassName "icon" ]
|
||||
[ i
|
||||
[ ClassName (sprintf "fa %s" faClass) ]
|
||||
[ ] ]
|
||||
span
|
||||
[ ]
|
||||
[ str txt ] ] ]
|
||||
|
||||
let navButtons =
|
||||
span
|
||||
[ ClassName "nav-item" ]
|
||||
[ div
|
||||
[ ClassName "field is-grouped" ]
|
||||
[ navButton "" "/" "fa-sign-out" "Logout"
|
||||
]
|
||||
]
|
||||
|
||||
let root =
|
||||
nav
|
||||
[ ClassName "nav" ]
|
||||
[ div
|
||||
[ ClassName "nav-left" ]
|
||||
[ h1
|
||||
[ ClassName "nav-item is-brand title is-4" ]
|
||||
[ str "BTS Spark Admin" ] ]
|
||||
div
|
||||
[ ClassName "nav-right" ]
|
||||
[ navButtons ] ]
|
||||
@@ -12,6 +12,9 @@ open Fable.PowerPack.PromiseImpl
|
||||
open bts.api.admin
|
||||
open Global
|
||||
|
||||
let isNewAccount (user:BTSUser) =
|
||||
user.id = 0
|
||||
|
||||
let getAdminData (admin:IAdminService) =
|
||||
Cmd.ofPromise
|
||||
admin.get_admin_data
|
||||
@@ -112,6 +115,7 @@ let saveUser (admin:IAdminService) (user:BTSUser) = promise {
|
||||
}
|
||||
|
||||
let deleteUser (admin:IAdminService) (user:BTSUser) = promise {
|
||||
alert Info "Deletion is not implemented on the server"
|
||||
let! result = admin.delete_user { id = user.id }
|
||||
if (result.isSuccess) then
|
||||
let! data = admin.get_admin_data()
|
||||
@@ -206,7 +210,7 @@ let update msg (model:Users.Types.Model) : Model * Cmd<Msg> =
|
||||
model, Cmd.ofExistingPromise (deleteUser model.admin model.scratchUser) id (box>>ErrorOccured)
|
||||
|
||||
| AddUser ->
|
||||
{ model with scratchUser = { defaultScratchUser with name = "New User" } }, Cmd.Empty
|
||||
{ model with scratchUser = { defaultScratchUser with name = "New User" } }, Cmd.ofMsg (SwitchTab General)
|
||||
| SwitchTab tb ->
|
||||
{model with currentTab = tb}, Cmd.Empty
|
||||
|
||||
|
||||
@@ -25,22 +25,21 @@ let isActiveUser (id:int) (currentUser:BTSUser) =
|
||||
| true -> "is-active"
|
||||
| false -> ""
|
||||
|
||||
let saveButton model dispatch =
|
||||
let buttonText = "Save"
|
||||
let saveButton (model:Users.Types.Model) dispatch =
|
||||
let buttonText = if State.isNewAccount model.scratchUser then "Create" else "Save"
|
||||
let dirty = State.userIsdirty State.defaultScratchUser model.scratchUser (State.getCurrentUser model.scratchUser model.userList)
|
||||
let enabled = if dirty then Button.Enabled else Button.Disabled
|
||||
let flavor = if dirty then "is-success" else "is-light"
|
||||
Button.button buttonText flavor "" enabled (fun _ -> dispatch SaveUser)
|
||||
|
||||
|
||||
let generalTabContent (model:Model) (dispatch:Msg->Unit) =
|
||||
div []
|
||||
[
|
||||
Fields.text "User Id" (model.scratchUser.id.ToString()) [ Disabled true ] ignore
|
||||
Fields.text "User Login" model.scratchUser.name [ ] (Name >> UpdateField >> dispatch)
|
||||
Fields.password "User Password" model.scratchUser.password [ ] (Password >> UpdateField >> dispatch)
|
||||
p [ Style [FontWeight "Bold"] ] [ str ("ID: " + model.scratchUser.id.ToString())]
|
||||
br []
|
||||
Fields.text "Name" model.scratchUser.name [ ] (Name >> UpdateField >> dispatch)
|
||||
Fields.password "Password" model.scratchUser.password [ ] (Password >> UpdateField >> dispatch)
|
||||
Fields.checkbox "Is Active" model.scratchUser.isActive [] (IsActive >> UpdateField >> dispatch)
|
||||
saveButton model dispatch
|
||||
]
|
||||
|
||||
let accountNameLookup (accountsList:BTSAccount list) (id:string) =
|
||||
@@ -60,7 +59,7 @@ let accountsTabContent (model:Model) (dispatch:Msg->Unit) =
|
||||
isHeader = false
|
||||
}
|
||||
{
|
||||
content = Button.button "" "is-white" "times" Button.Enabled (fun _ -> i |> (RemoveAccount >> UpdateField >> dispatch))
|
||||
content = Button.button "" "is-light" "times" Button.Enabled (fun _ -> i |> (RemoveAccount >> UpdateField >> dispatch))
|
||||
className = ""
|
||||
isHeader = false
|
||||
}
|
||||
@@ -71,67 +70,39 @@ let accountsTabContent (model:Model) (dispatch:Msg->Unit) =
|
||||
]
|
||||
let accMap = Map.ofList(List.map<BTSAccount,(string*string)> (fun a -> a.id.ToString(), a.name) model.accountsList)
|
||||
let rows = rws @ [{cells = [ {content = Fields.mapSelect "" accMap "Add Account" (AddAccount >> UpdateField >> dispatch); className = ""; isHeader = true } ]; className = ""; header = None }]
|
||||
let headers:TableControl.row = {cells = [ {content = str "Accounts"; className = ""; isHeader = true }; {content = str "Remove"; className = ""; isHeader = true } ]; className = ""; header = None }
|
||||
//let headers:TableControl.row = {cells = [ {content = str "Accounts"; className = ""; isHeader = true }; {content = str "Remove"; className = ""; isHeader = true } ]; className = ""; header = None }
|
||||
div []
|
||||
[
|
||||
TableControl.createTable headers rows
|
||||
saveButton model dispatch
|
||||
TableControl.createTable None rows
|
||||
]
|
||||
|
||||
let mdEntitlementsTabContent (model:Model) (dispatch:Msg->Unit) =
|
||||
let cmeData = model.scratchUser.userData.exchangeMdEntitlementData.cmeData
|
||||
div []
|
||||
[
|
||||
div [ ClassName "columns"]
|
||||
div []
|
||||
[
|
||||
div [ClassName "column is-narrow"]
|
||||
[
|
||||
aside [ClassName "menu"] [
|
||||
ul [ClassName "menu-list"]
|
||||
[
|
||||
li [] [ a [ClassName "is-active"] [str "CME" ]]
|
||||
]
|
||||
]
|
||||
]
|
||||
div [ ClassName "column" ]
|
||||
[
|
||||
Fields.checkbox "CBOT" cmeData.cbotEntitlement.canView [] (CBOTEntitlement >> UpdateField >> dispatch)
|
||||
Fields.checkbox "CME" cmeData.cmeEntitlement.canView [] (CMEEntitlement >> UpdateField >> dispatch)
|
||||
Fields.checkbox "NYMEX" cmeData.nymexEntitlement.canView [] (NYMEXEntitlement >> UpdateField >> dispatch)
|
||||
Fields.checkbox "BMANDF" cmeData.bmandfEntitlement.canView [] (BMANDFEntitlement >> UpdateField >> dispatch)
|
||||
Fields.checkbox "COMEX" cmeData.comexEntitlement.canView [] (COMEXEntitlement >> UpdateField >> dispatch)
|
||||
Fields.checkbox "CME Europe" cmeData.cmeEuropeEntitlement.canView [] (CMEEuropeEntitlement >> UpdateField >> dispatch)
|
||||
|
||||
saveButton model dispatch
|
||||
]
|
||||
]
|
||||
Fields.checkbox "CBOT" cmeData.cbotEntitlement.canView [] (CBOTEntitlement >> UpdateField >> dispatch)
|
||||
Fields.checkbox "CME" cmeData.cmeEntitlement.canView [] (CMEEntitlement >> UpdateField >> dispatch)
|
||||
Fields.checkbox "NYMEX" cmeData.nymexEntitlement.canView [] (NYMEXEntitlement >> UpdateField >> dispatch)
|
||||
Fields.checkbox "BMANDF" cmeData.bmandfEntitlement.canView [] (BMANDFEntitlement >> UpdateField >> dispatch)
|
||||
Fields.checkbox "COMEX" cmeData.comexEntitlement.canView [] (COMEXEntitlement >> UpdateField >> dispatch)
|
||||
Fields.checkbox "CME Europe" cmeData.cmeEuropeEntitlement.canView [] (CMEEuropeEntitlement >> UpdateField >> dispatch)
|
||||
]
|
||||
]
|
||||
|
||||
let orderRoutingTabContent (model:Model) (dispatch:Msg->Unit) =
|
||||
let cmeData = model.scratchUser.userData.exchangeUserData.cmeData
|
||||
div []
|
||||
[
|
||||
div [ ClassName "columns"]
|
||||
div []
|
||||
[
|
||||
div [ClassName "column is-narrow"]
|
||||
[
|
||||
aside [ClassName "menu"] [
|
||||
ul [ClassName "menu-list"]
|
||||
[
|
||||
li [] [ a [ClassName "is-active"] [str "CME" ]]
|
||||
]
|
||||
]
|
||||
]
|
||||
div [ ClassName "column" ]
|
||||
[
|
||||
Fields.text "Operator ID" cmeData.operatorId [] (OperatorID >> UpdateField >> dispatch)
|
||||
Fields.text "ATS Operator ID" cmeData.atsOperatorId [] (ATSOperatorID >> UpdateField >> dispatch)
|
||||
Fields.text "SMP ID" cmeData.smpId [] (SMPID >> UpdateField >> dispatch)
|
||||
Fields.text "SMP Instruction" cmeData.smpInstruction [] (SMPInstruction >> UpdateField >> dispatch)
|
||||
Fields.text "Max Order Rate Per Connection" cmeData.maxOrderRatePerConnection [] (MaxOrderRatePerConnection >> UpdateField >> dispatch)
|
||||
Fields.map "Misc Tag Mapping" cmeData.miscTags [] (MiscTags >> UpdateField >> dispatch)
|
||||
saveButton model dispatch
|
||||
]
|
||||
Fields.text "Operator ID" cmeData.operatorId [] (OperatorID >> UpdateField >> dispatch)
|
||||
Fields.text "ATS Operator ID" cmeData.atsOperatorId [] (ATSOperatorID >> UpdateField >> dispatch)
|
||||
//Fields.text "SMP ID" cmeData.smpId [] (SMPID >> UpdateField >> dispatch)
|
||||
//Fields.text "SMP Instruction" cmeData.smpInstruction [] (SMPInstruction >> UpdateField >> dispatch)
|
||||
//Fields.text "Max Order Rate Per Connection" cmeData.maxOrderRatePerConnection [] (MaxOrderRatePerConnection >> UpdateField >> dispatch)
|
||||
//Fields.map "Misc Tag Mapping" cmeData.miscTags [] (MiscTags >> UpdateField >> dispatch)
|
||||
]
|
||||
]
|
||||
|
||||
@@ -145,7 +116,8 @@ let tabContent (model:Model) (dispatch:Msg->Unit) =
|
||||
|
||||
let userControls (usersList:BTSUser list) (currentUser:BTSUser) (dispatch:Msg->Unit) (disabled:bool)=
|
||||
div [ ClassName "field is-grouped has-addons" ]
|
||||
[ p [ ClassName "control" ]
|
||||
[
|
||||
(*p [ ClassName "control" ]
|
||||
[ a [ ClassName "button is-light"
|
||||
Title "Clone"
|
||||
OnClick (fun _ -> dispatch <| Clone currentUser)
|
||||
@@ -155,26 +127,31 @@ let userControls (usersList:BTSUser list) (currentUser:BTSUser) (dispatch:Msg->U
|
||||
[ i [ ClassName "fa fa-clone" ]
|
||||
[ ] ]
|
||||
]
|
||||
]
|
||||
p [ ClassName "control" ]
|
||||
]*)
|
||||
(*p [ ClassName "control" ]
|
||||
[ a [ ClassName "button is-light"
|
||||
Title "Delete"
|
||||
OnClick (fun _ -> dispatch <| Delete currentUser)
|
||||
OnClick (fun _ -> dispatch <| Delete currentUser)
|
||||
Disabled disabled
|
||||
]
|
||||
[ span [ ClassName "icon is-small" ]
|
||||
[ i [ ClassName "fa fa-minus" ] [ ]
|
||||
]
|
||||
]
|
||||
]
|
||||
]*)
|
||||
p [ ClassName "control" ]
|
||||
[ a [ ClassName "button is-light"
|
||||
Title "Add"
|
||||
OnClick (fun _ -> dispatch <| AddUser)
|
||||
]
|
||||
[ span [ ClassName "icon is-small" ]
|
||||
[ i [ ClassName "fa fa-plus" ] [ ]
|
||||
[
|
||||
|
||||
span [ ClassName "icon is-small" ]
|
||||
[
|
||||
i [ ClassName "fa fa-plus" ] [ ]
|
||||
]
|
||||
Fields.nbsp
|
||||
str "Add"
|
||||
]
|
||||
]
|
||||
(*p [ ClassName "control" ]
|
||||
@@ -195,28 +172,27 @@ let usersMenu (usersList:BTSUser list) (currentUser:BTSUser) (dispatch:Msg->Unit
|
||||
[ ClassName "column is-narrow" ]
|
||||
[
|
||||
aside [ ClassName "menu" ]
|
||||
[ p [ ClassName "menu-label" ]
|
||||
[
|
||||
Button.faIcon "users"
|
||||
str " Users"
|
||||
userControls usersList currentUser dispatch (not (State.userIsSelected currentUser State.defaultScratchUser))
|
||||
]
|
||||
[
|
||||
ul [ ClassName "menu-list" ]
|
||||
[ li [ ]
|
||||
[ a [ ]
|
||||
[ str "" ]
|
||||
ul [ ]
|
||||
[ for u in (List.sortBy (fun (usrrec:BTSUser) ->
|
||||
(usrrec.name)) usersList) do yield li [] [
|
||||
a [
|
||||
ClassName (isActiveUser u.id currentUser)
|
||||
OnClick (fun _ -> (u |> SwitchUser |> dispatch))
|
||||
]
|
||||
[ str u.name ]
|
||||
]
|
||||
]
|
||||
]
|
||||
[ for u in (List.sortBy (fun (usrrec:BTSUser) ->
|
||||
(usrrec.name)) usersList) do yield li []
|
||||
[
|
||||
a [
|
||||
ClassName (isActiveUser u.id currentUser)
|
||||
OnClick (fun _ -> (u |> SwitchUser |> dispatch))
|
||||
]
|
||||
[
|
||||
str u.name
|
||||
Fields.nbsp
|
||||
span [Style [TextAlign Right]]
|
||||
[
|
||||
Button.falink "Delete" "times" Button.Enabled ((fun _ -> dispatch <| Delete u))
|
||||
]
|
||||
]
|
||||
|
||||
]
|
||||
]
|
||||
userControls usersList currentUser dispatch (not (State.userIsSelected currentUser State.defaultScratchUser))
|
||||
]
|
||||
]
|
||||
|
||||
@@ -231,6 +207,7 @@ let root (model:Model) (dispatch:Msg->Unit) =
|
||||
div
|
||||
[ ClassName "column" ]
|
||||
[
|
||||
div [ ClassName "is-pulled-right"; Style [MarginLeft "1em"] ] [ saveButton model dispatch ]
|
||||
div [ ClassName "tabs is-small is-boxed" ]
|
||||
[ ul [ ]
|
||||
[ li [ ClassName (isActiveTab Tab.General model.currentTab) ]
|
||||
|
||||
@@ -16,6 +16,7 @@ ignore = Path .vscode
|
||||
ignore = Path src/client
|
||||
ignore = Path src/web/api/node_modules
|
||||
ignore = Path src/web/ui/node_modules
|
||||
ignore = Path src/web/ui/src/obj
|
||||
force = $SOURCE
|
||||
batch = true
|
||||
confirmbigdel = false
|
||||
|
||||
Reference in new issue
Block a user