Merge branch 'master' of bitbucket.org:bluetradesys/spark
This commit is contained in:
commit
c9c12dc540
57 files changed
+665
-199
No files matched your search
Vendored
+3
-1
@@ -37,6 +37,8 @@
|
||||
"${localappdata}/lxss/rootfs/usr/include"
|
||||
],
|
||||
"defines": [
|
||||
"__linux__",
|
||||
"__x86_64__"
|
||||
],
|
||||
"browse": {
|
||||
"path": [
|
||||
@@ -47,7 +49,7 @@
|
||||
"${localappdata}/lxss/rootfs/usr/local/include",
|
||||
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed",
|
||||
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu",
|
||||
"${localappdata}/lxss/rootfs/usr/include"
|
||||
"${localappdata}/lxss/rootfs/usr/include/*"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"databaseFilename": ""
|
||||
|
||||
Vendored
+17
@@ -87,6 +87,23 @@
|
||||
"/bts/": "${workspaceRoot}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Docker attach",
|
||||
"type": "cppdbg",
|
||||
"request": "attach",
|
||||
"program": "/bts/build/gcc_debug/src/server/sparkd/sparkd",
|
||||
"processId": "${command:pickRemoteProcess}",
|
||||
"MIMode": "gdb",
|
||||
"pipeTransport": {
|
||||
"pipeCwd": "${workspaceRoot}",
|
||||
"pipeProgram": "c:\\program files\\git\\usr\\bin\\ssh.exe",
|
||||
"pipeArgs": ["-p 2000","root@localhost"],
|
||||
"debuggerPath": "/usr/bin/gdb"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/bts/": "${workspaceRoot}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "eh-3 launch",
|
||||
"type": "cppdbg",
|
||||
|
||||
Vendored
+7
-3
@@ -20,10 +20,14 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"taskName": "server_build",
|
||||
"taskName": "server_build",
|
||||
"type": "shell",
|
||||
"command": ".\\tools\\serverbuild.cmd",
|
||||
"problemMatcher":"$gcc",
|
||||
"command": ".\\tools\\ssh_serverbuild.cmd",
|
||||
|
||||
"problemMatcher": {
|
||||
"base": "$gcc",
|
||||
"fileLocation": "relative"
|
||||
},
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ if (WIN32)
|
||||
add_subdirectory(src/lib)
|
||||
else ()
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} \
|
||||
-Wall -pedantic -Wextra -Werror -Wno-missing-braces --std=c++14")
|
||||
-Wall -pedantic -Wextra -Werror -Wno-missing-braces --std=c++14 -fdiagnostics-color")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} -DNDEBUG -O3")
|
||||
add_subdirectory(src/lib)
|
||||
add_subdirectory(src/server/sparkd)
|
||||
|
||||
+1
-1
Submodule docker/linux updated: d43f6c8df0...d4a32d3259.
@@ -7,7 +7,6 @@ namespace mbts
|
||||
public static class TickExtensions
|
||||
{
|
||||
#region Public Extensions (is_valid, format, parse, tick_up, tick_down)
|
||||
|
||||
public static bool is_valid(this TickFactors tick) { return tick.tick_unit > 0 && tick.tick_unit <= (tick.tick_base * 0.5); }
|
||||
public static bool is_valid(this RegionalTickFactors regional_tick) { return regional_tick.low_tick.is_valid() && regional_tick.high_tick.is_valid(); /*&& regional_tick.low_tick.tick_base == regional_tick.high_tick.tick_base;*/ }
|
||||
|
||||
@@ -34,25 +33,76 @@ namespace mbts
|
||||
return _parse(regional_tick, text);
|
||||
}
|
||||
|
||||
public static double tick_up(this TickFactors tick, double input) {
|
||||
if (DoubleHelper.IsNaNOrInfinity(input) || !tick.is_valid()) return input;
|
||||
return _tick(tick, input, true);
|
||||
}
|
||||
public static double tick_up(this RegionalTickFactors regional_tick, double input) {
|
||||
if (DoubleHelper.IsNaNOrInfinity(input) || !regional_tick.is_valid()) return input;
|
||||
return input <= regional_tick.low_tick_inclusive_end ? regional_tick.low_tick.tick_up(input) : regional_tick.high_tick.tick_up(input);
|
||||
}
|
||||
public static double tick_down(this TickFactors tick, double input) {
|
||||
if (DoubleHelper.IsNaNOrInfinity(input) || !tick.is_valid()) return input;
|
||||
return _tick(tick, input, false);
|
||||
}
|
||||
public static double tick_down(this RegionalTickFactors regional_tick, double input) {
|
||||
if (DoubleHelper.IsNaNOrInfinity(input) || !regional_tick.is_valid()) return input;
|
||||
return input <= regional_tick.low_tick_inclusive_end ? regional_tick.low_tick.tick_down(input) : regional_tick.high_tick.tick_down(input);
|
||||
public static double tickup(this TickFactors tick, double input) { return tick.tickup(input, 1); }
|
||||
public static double tickup(this TickFactors tick, double input, uint count) {
|
||||
if (DoubleHelper.IsNaNOrInfinity(input)) return input;
|
||||
double tuf = tick.tick_unit_frac();
|
||||
input -= input % tuf;
|
||||
double val = input + tuf * count;
|
||||
return _round_tick(tuf, val);
|
||||
}
|
||||
|
||||
public static double tickup(this RegionalTickFactors regional_tick, double input) { return regional_tick.tickup(input, 1); }
|
||||
public static double tickup(this RegionalTickFactors regional_tick, double input, uint count) {
|
||||
if (DoubleHelper.IsNaNOrInfinity(input)) return input;
|
||||
double val, tuf;
|
||||
if (input < regional_tick.low_tick_inclusive_end) {
|
||||
tuf = regional_tick.low_tick.tick_unit_frac();
|
||||
input -= input % tuf;
|
||||
val = input + tuf * count;
|
||||
if (val > regional_tick.low_tick_inclusive_end) {
|
||||
count -= (uint)Math.Ceiling((regional_tick.low_tick_inclusive_end - input) / tuf);
|
||||
tuf = regional_tick.high_tick.tick_unit_frac();
|
||||
val = regional_tick.low_tick_inclusive_end + tuf * count;
|
||||
}
|
||||
} else {
|
||||
tuf = regional_tick.high_tick.tick_unit_frac();
|
||||
input -= input % tuf;
|
||||
val = input + tuf * count;
|
||||
}
|
||||
return _round_tick(tuf, val);
|
||||
}
|
||||
|
||||
public static double tickdown(this TickFactors tick, double input) { return tick.tickdown(input, 1); }
|
||||
public static double tickdown(this TickFactors tick, double input, uint count) {
|
||||
if (DoubleHelper.IsNaNOrInfinity(input)) return input;
|
||||
double tuf = tick.tick_unit_frac();
|
||||
double remainder = input % tuf;
|
||||
if (remainder > 0) input += tuf - remainder;
|
||||
double val = input - tuf * count;
|
||||
return _round_tick(tuf, val);
|
||||
}
|
||||
|
||||
public static double tickdown(this RegionalTickFactors regional_tick, double input) { return regional_tick.tickdown(input, 1); }
|
||||
public static double tickdown(this RegionalTickFactors regional_tick, double input, uint count) {
|
||||
if (DoubleHelper.IsNaNOrInfinity(input)) return input;
|
||||
double val, tuf;
|
||||
if (input > regional_tick.low_tick_inclusive_end) {
|
||||
tuf = regional_tick.high_tick.tick_unit_frac();
|
||||
double remainder = input % tuf;
|
||||
if (remainder > 0) input += tuf - remainder;
|
||||
val = input - count * tuf;
|
||||
if (val < regional_tick.low_tick_inclusive_end) {
|
||||
count -= (uint)Math.Ceiling((input - regional_tick.low_tick_inclusive_end) / tuf);
|
||||
tuf = regional_tick.low_tick.tick_unit_frac();
|
||||
return regional_tick.low_tick_inclusive_end - tuf * count;
|
||||
}
|
||||
} else {
|
||||
tuf = regional_tick.low_tick.tick_unit_frac();
|
||||
val = input - tuf * count;
|
||||
}
|
||||
return _round_tick(tuf, val);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Members
|
||||
private static decimal tick_unit_frac_dec(this TickFactors tick) { return new decimal(tick.tick_unit / tick.tick_base); }
|
||||
private static double tick_unit_frac(this TickFactors tick) { return tick.tick_unit / tick.tick_base; }
|
||||
private static char separator(this TickFactors tick) {
|
||||
double tb_log10 = Math.Log10(tick.tick_base);
|
||||
return tb_log10 >= 1 && tb_log10 % 1 == 0 ? '.' : '-';
|
||||
}
|
||||
|
||||
private static string _format_no_tick(double value, double display_multiplier, bool show_commas) {
|
||||
if (!double.IsNaN(display_multiplier)) value *= display_multiplier;
|
||||
return value.ToString(show_commas ? "#,0" : "0");
|
||||
@@ -64,13 +114,6 @@ namespace mbts
|
||||
return double.IsNaN(display_multiplier) || display_multiplier == 0.0 ? result : result / display_multiplier;
|
||||
}
|
||||
|
||||
private static decimal tick_unit_frac_dec(this TickFactors tick) { return new decimal(tick.tick_unit / tick.tick_base); }
|
||||
private static double tick_unit_frac(this TickFactors tick) { return tick.tick_unit / tick.tick_base; }
|
||||
private static char separator(this TickFactors tick) {
|
||||
double tb_log10 = Math.Log10(tick.tick_base);
|
||||
return tb_log10 >= 1 && tb_log10 % 1 == 0 ? '.' : '-';
|
||||
}
|
||||
|
||||
private static double _parsed_or_nan(string text) { return double.TryParse(text, out double d) ? d : double.NaN; }
|
||||
private static double _get_integer_part(string integer_text) {
|
||||
return string.IsNullOrEmpty(integer_text) ? 0 : int.TryParse(integer_text, NumberStyles.Any, CultureInfo.CurrentCulture, out int result) ? result : double.NaN;
|
||||
@@ -115,21 +158,6 @@ namespace mbts
|
||||
return integer_part + numerator_part / tick.tick_base;
|
||||
}
|
||||
|
||||
private const double _precision_const = 0.000000001;
|
||||
|
||||
private static double _tick(TickFactors tick, double input, bool tick_up) {
|
||||
if (double.IsNaN(input)) return double.NaN;
|
||||
if (input < 0) return -(_tick(tick, -input, !tick_up));
|
||||
else {
|
||||
double unit = tick.tick_unit / tick.tick_base;
|
||||
// IEEERemainder represents the shortest distance to a multiple of the unit, can be negative or positive
|
||||
// makes it easy to check if the input is ~= unit multiple (within the precision const)
|
||||
double ieeer = Math.IEEERemainder(input, unit);
|
||||
if (Math.Abs(ieeer) <= _precision_const) return tick_up ? (input - ieeer) + unit : (input - ieeer) - unit;
|
||||
else return ieeer < 0 ? (tick_up ? input - ieeer : input + ieeer) : (tick_up ? input - ieeer + unit : input + ieeer - unit);
|
||||
}
|
||||
}
|
||||
|
||||
private static string _format_tick(TickFactors tick, double value, bool show_commas) {
|
||||
if (value < 0) return "-" + _format_tick(tick, Math.Abs(value), show_commas);
|
||||
int integer_part = (int)Math.Floor(value);
|
||||
@@ -146,11 +174,16 @@ namespace mbts
|
||||
return integer_part_text + tick.separator() + decimal_part.ToString(new string('0', _n_display_digits(tick.tick_base)));
|
||||
}
|
||||
|
||||
private static double _round_tick(double tick_unit_frac, double input) {
|
||||
return input + Math.IEEERemainder(input, tick_unit_frac);
|
||||
}
|
||||
|
||||
private static int _n_display_digits(double tick_base) {
|
||||
double log_tick_base = Math.Log10(tick_base);
|
||||
int floor = (int)Math.Floor(log_tick_base);
|
||||
double dec = log_tick_base - floor;
|
||||
return Math.Max(1, dec > 0 ? ++floor : floor);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using bts.api;
|
||||
using mbts.collections.extensions;
|
||||
using mbts.user.settings;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
@@ -34,18 +34,11 @@ namespace mbts.spark {
|
||||
return mid;
|
||||
}
|
||||
|
||||
|
||||
public static double tickup(this ContractSpecification contract, double value) { return tick(contract, value, true, 1); }
|
||||
public static double tickup(this ContractSpecification contract, double value, int count) { return tick(contract, value, true, count); }
|
||||
public static double tickdown(this ContractSpecification contract, double value) { return tick(contract, value, false, 1); }
|
||||
public static double tickdown(this ContractSpecification contract, double value, int count) { return tick(contract, value, false, count); }
|
||||
static double tick(ContractSpecification spec, double value, bool up, int count) {
|
||||
double factor = up ? 1 : -1;
|
||||
for (int x = 0; x < count; ++x) {
|
||||
value += spec.ticksize(value) * factor;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static double tickup(this ContractSpecification contract, double value) { return _get_regional_ticks(contract).tickup(value); }
|
||||
public static double tickup(this ContractSpecification contract, double value, int count) { return _get_regional_ticks(contract).tickup(value, (uint)count); }
|
||||
public static double tickdown(this ContractSpecification contract, double value) { return _get_regional_ticks(contract).tickdown(value); }
|
||||
public static double tickdown(this ContractSpecification contract, double value, int count) { return _get_regional_ticks(contract).tickdown(value, (uint)count); }
|
||||
|
||||
public static double round_to_tick(this ContractSpecification spec, double value) {
|
||||
double intpart = (long)value;
|
||||
@@ -66,9 +59,20 @@ namespace mbts.spark {
|
||||
return count;
|
||||
}
|
||||
|
||||
public static int[] get_tick_jump_quantities(ContractSpecification spec) { return _ticks_cache.TryGetValue(spec.LowTick, out (TickFactors tf, int[] jumps) result) ? result.jumps : new[] { 1, 5, 10, 25, 50, 100 }; }
|
||||
private static TickFactors _get_tick_factors(double tick) { return _ticks_cache.TryGetValue(tick, out (TickFactors tick_factors, int[] preset_price_ticks) result) ? result.tick_factors : _default_tick; }
|
||||
public static int[] get_tick_jump_quantities(ContractSpecification spec) {
|
||||
return _ticks_cache.TryGetValue(spec.LowTick, out (TickFactors tf, int[] jumps) result) ? result.jumps : new[] { 1, 5, 10, 25, 50, 100 };
|
||||
}
|
||||
public static RegionalTickFactors _get_regional_ticks(ContractSpecification spec) {
|
||||
return _regional_ticks_cache.GetOrAdd((spec.LowTick, spec.HighTick, spec.PriceBreak), _create_regional_ticks);
|
||||
}
|
||||
private static RegionalTickFactors _create_regional_ticks((double low_tick, double high_tick, double price_break) def) {
|
||||
return new RegionalTickFactors { low_tick = _get_tick_factors(def.low_tick), high_tick = _get_tick_factors(def.high_tick), low_tick_inclusive_end = def.price_break };
|
||||
}
|
||||
private static TickFactors _get_tick_factors(double tick) {
|
||||
return _ticks_cache.TryGetValue(tick, out (TickFactors tick_factors, int[] preset_price_ticks) result) ? result.tick_factors : _default_tick;
|
||||
}
|
||||
private static readonly TickFactors _default_tick = new TickFactors(100, 1);
|
||||
private static readonly ConcurrentDictionary<(double low_tick, double high_tick, double price_break), RegionalTickFactors> _regional_ticks_cache = new ConcurrentDictionary<(double low_tick, double high_tick, double price_break), RegionalTickFactors>();
|
||||
private static readonly IReadOnlyDictionary<double, (TickFactors tick_factors, int[] preset_price_ticks)> _ticks_cache = new ReadOnlyDictionary<double, (TickFactors tick_factors, int[] preset_price_ticks)>(new[] {
|
||||
new { tick_unit = 0.05, tick_factors = new TickFactors(100, 5), jump_quantities = new[] { 1, 5, 10, 20, 100, 200 } },
|
||||
new { tick_unit = 0.10, tick_factors = new TickFactors(100, 10), jump_quantities = new[] { 1, 5, 10, 20, 100, 200 } },
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace mbts.spark {
|
||||
class LadderVM : DisposableViewModelBase, IKeyListener {
|
||||
readonly LadderModel _model;
|
||||
readonly DispatcherTimer _timer;
|
||||
Order _order_template = new Order();
|
||||
Order _order_template;
|
||||
LadderSettings _settings;
|
||||
|
||||
public const string SAVE_NAME = "SparkLadder";
|
||||
|
||||
public LadderVM(LadderModel model, IObservable<LadderSettings> settings) {
|
||||
_model = model;
|
||||
_order_template.Security = model.security;
|
||||
_order_template = OrderDataHelper.Defaults.Order(_model.security);
|
||||
_timer = new DispatcherTimer() {
|
||||
Interval = TimeSpan.FromMilliseconds(100),
|
||||
IsEnabled = true
|
||||
@@ -53,6 +53,7 @@ namespace mbts.spark {
|
||||
_selected_order_type = backing(nameof(selected_order_type), Order.Types.TimeInForce.Day);
|
||||
algo_types = OrderDataHelper.Defaults.Algos.SelectMany(wrap_order).ToArray();
|
||||
_revert = backing(nameof(revert), false);
|
||||
show_ticket_command = new DelegateCommand(show_ticket);
|
||||
|
||||
// Orders
|
||||
_internal_orders = new ObservableCollection<OrderBookEntry>();
|
||||
@@ -129,23 +130,12 @@ namespace mbts.spark {
|
||||
|
||||
public ICommand cancel_command { get; }
|
||||
public ICommand send_order_command { get; }
|
||||
public ICommand show_ticket_command { get; }
|
||||
|
||||
internal void show_ticket(object _) {
|
||||
var bmp = new System.Windows.Media.Imaging.BitmapImage();
|
||||
bmp.BeginInit();
|
||||
bmp.UriSource = new Uri("http://edge-qa2/OrderTicket.png");
|
||||
bmp.EndInit();
|
||||
new System.Windows.Window() {
|
||||
Width = 255,
|
||||
Height = 177,
|
||||
Content = new System.Windows.Controls.Image() {
|
||||
Source = bmp
|
||||
}
|
||||
}.Show();
|
||||
internal void show_ticket() {
|
||||
_model.order_gateway.show_order_ticket(_order_template.Clone());
|
||||
}
|
||||
|
||||
public ICommand show_ticket_command => new DelegateCommand(show_ticket);
|
||||
|
||||
public void send_order((double price,Side? side) args) {
|
||||
if (args.side.HasValue) {
|
||||
Order order = _order_template.Clone();
|
||||
@@ -167,7 +157,7 @@ namespace mbts.spark {
|
||||
Property<bool> _revert;
|
||||
public bool revert { get => _revert.Value; set => _revert.set(value); }
|
||||
|
||||
public string[] accounts { get; } = new[] { "Account1", "Account2", "Account3", "Account4" };
|
||||
public string[] accounts { get; } = ImportedResources.Accounts;
|
||||
public string account { get => _order_template.Account; set => _order_template.Account = value; }
|
||||
public Order.Types.TimeInForce[] order_types => Enum.GetValues(typeof(Order.Types.TimeInForce)).Cast<Order.Types.TimeInForce>().ToArray();
|
||||
Property<Order.Types.TimeInForce> _selected_order_type;
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<ComboBox Grid.ColumnSpan="2" Margin="2" ItemsSource="{Binding accounts}" SelectedItem="{Binding account}"/>
|
||||
<ComboBox ItemsSource="{Binding order_types}" SelectedItem="{Binding selected_order_type}" Margin="2" />
|
||||
<uag:AlgoDetailsPopupControl ItemsSource="{Binding algo_types}" SelectedItem="{Binding selected_algo_type}" Margin="2" ExpandDirection="Left"/>
|
||||
<StackPanel Margin="0,0,0,5">
|
||||
<Button Height="30" Margin="2" Command="{Binding cancel_command}" CommandParameter="All">Cxl All</Button>
|
||||
<Button Margin="2" Command="{Binding cancel_command}" CommandParameter="Bids" Background="{mbts:BTSColor MarketData.bid}" Foreground="White">Cxl Bids</Button>
|
||||
@@ -51,9 +54,6 @@
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<Button Margin="2" HorizontalAlignment="Stretch" Command="{Binding calculator.click}" CommandParameter="0">Clear</Button>
|
||||
<ComboBox Grid.ColumnSpan="2" Margin="2" ItemsSource="{Binding accounts}" SelectedItem="{Binding account}"/>
|
||||
<ComboBox ItemsSource="{Binding order_types}" SelectedItem="{Binding selected_order_type}" Margin="2" />
|
||||
<uag:AlgoDetailsPopupControl ItemsSource="{Binding algo_types}" SelectedItem="{Binding selected_algo_type}" Margin="2" ExpandDirection="Left"/>
|
||||
</StackPanel>
|
||||
<Button Margin="5,0,5,5" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Command="{Binding show_ticket_command}">Ticket</Button>
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
<TextBlock Grid.Column="1" Grid.Row="0" Text="H:" Margin="{StaticResource text_margin}" />
|
||||
<TextBlock Grid.Column="1" Grid.Row="1" Text="L:" Margin="{StaticResource text_margin}" />
|
||||
<TextBlock Grid.Column="2" Grid.Row="0" Text="{Binding high, Mode=OneWay}" Foreground="{mbts:BTSColor success}" FontWeight="Bold" />
|
||||
<TextBlock Grid.Column="2" Grid.Row="1" Text="{Binding low, Mode=OneWay}" Foreground="{mbts:BTSColor error}" FontWeight="Bold" />
|
||||
<TextBlock Grid.Column="2" Grid.Row="1" Text="{Binding low, Mode=OneWay}" Foreground="{mbts:BTSColor danger}" FontWeight="Bold" />
|
||||
<TextBlock Grid.Column="3" Grid.Row="0" Text="O:" Margin="{StaticResource text_margin}" />
|
||||
<TextBlock Grid.Column="3" Grid.Row="1" Text="V:" Margin="{StaticResource text_margin}" />
|
||||
<TextBlock Grid.Column="4" Grid.Row="0" Text="{Binding open, Mode=OneWay}" FontWeight="Bold" />
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace mbts.spark {
|
||||
|
||||
public ICommand shatter_command => new DelegateCommand(_ => model.order_gateway.shatter(_order.order().Id), _ => !has_parent);
|
||||
public ICommand cancel_command => new DelegateCommand(_ => model.order_gateway.cancel_order(new OrderID[] {_order.order().Id}), _ => !has_parent);
|
||||
public ICommand modify_command => new DelegateCommand(_parent.show_ticket, _ => !has_parent);
|
||||
public ICommand modify_command => new DelegateCommand(() => model.order_gateway.show_order_modify(_order.order().Clone()), () => !has_parent);
|
||||
|
||||
public Brush foreground => Brushes.Black;
|
||||
public Brush background { get; private set; }
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace mbts.spark
|
||||
public IObservable<int> security_position(SecurityKey key) { return _positions_demuxer.subscribe(key).DistinctUntilChanged(); }
|
||||
public void show_ladder(Security security) { _bus.post(ShowLadderTag, new ShowLadderMessage(security)); }
|
||||
public void show_order_modify(Order order) { _bus.post(ShowOrderModifyTag, new ShowOrderModifyMessage(order)); }
|
||||
public void show_order_ticket(Order order) { _bus.post(ShowOrderTicketTag, new ShowOrderTicketMessage(order)); }
|
||||
public void show_order_ticket(Order order) { _orders_model.show_order_ticket(order); }
|
||||
public void set_securities(IEnumerable<Security> securities) { _securities_subject.OnNext(new HashSet<SecurityKey>(securities.Select(s => s.Id))); }
|
||||
public void Dispose() {
|
||||
Disposable.dispose(_subs);
|
||||
|
||||
@@ -85,7 +85,9 @@ namespace mbts.spark
|
||||
private static Security _get_security(DataGridCellInfo cell) { return (cell.Item as Row)?.security.value; }
|
||||
private static Order _create_order(DataGridCellInfo cell) { return _create_order((Row)cell.Item, (Columns)DataGridEx.GetArgument(cell.Column)); }
|
||||
private static Order _create_order(Row row, Columns col) {
|
||||
var order = new Order { Security = row.security.value, MarketOrder = new MarketOrder(), Price = 0, Size = 1 };
|
||||
var order = OrderDataHelper.Defaults.Order(row.security.value, Order.AlgoOrderTypeOneofCase.MarketOrder);
|
||||
order.Price = 0;
|
||||
order.Size = 1;
|
||||
switch(col) {
|
||||
case Columns.Bid: order.Price = row.bid_price.output; break;
|
||||
case Columns.BidSize: order.Price = row.bid_price.output; order.Size = row.bid_size.output; break;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<UserControl x:Class="mbts.ui.spark.OrderModificationControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:uc="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace mbts.spark
|
||||
});
|
||||
}
|
||||
|
||||
public string[] accounts { get; } = new[] { "Account1", "Account2", "Account3", "Account4" };
|
||||
public string[] accounts { get; } = ImportedResources.Accounts;
|
||||
public string account { get => _order.Account; set => _order.Account = value; }
|
||||
public ObservableCollection<OrderTypeVM> algo_types { get; }
|
||||
public OrderTypeVM algo_type {
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace mbts.spark.utilities
|
||||
{
|
||||
public static IBus Bus => _instance.bus;
|
||||
public static string UserName => _instance.user_name;
|
||||
public static readonly string[] Accounts = new[] { "Account1", "Account2", "Account3", "Account4" };
|
||||
|
||||
#region Misc Extensions (should put these in a more appropriate place eventually)
|
||||
public static IObservable<Security> ToSecurity(this IObservable<uint> securityKey) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using bts.spark;
|
||||
using Google.Protobuf;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace mbts.spark.utilities
|
||||
{
|
||||
@@ -38,12 +39,22 @@ namespace mbts.spark.utilities
|
||||
BTSIcebergOrder
|
||||
};
|
||||
|
||||
public static Order Order(Security security) {
|
||||
return new Order {
|
||||
public static Order Order(Security security) { return Order(security, bts.spark.Order.AlgoOrderTypeOneofCase.LimitOrder); }
|
||||
public static Order Order(Security security, Order.AlgoOrderTypeOneofCase algo_type) {
|
||||
var rv = new Order {
|
||||
Account = ImportedResources.Accounts.FirstOrDefault(),
|
||||
User = ImportedResources.UserName,
|
||||
Security = security,
|
||||
LimitOrder = new LimitOrder()
|
||||
};
|
||||
switch (algo_type) {
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.LimitOrder: rv.LimitOrder = new LimitOrder(); break;
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.MarketOrder: rv.MarketOrder = new MarketOrder(); break;
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.StopLimitOrder: rv.StopLimitOrder = new StopLimitOrder(); break;
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.StopMarketOrder: rv.StopMarketOrder = new StopMarketOrder(); break;
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.BtsStopOrder: rv.BtsStopOrder = BTSStopOrder; break;
|
||||
case bts.spark.Order.AlgoOrderTypeOneofCase.BtsIcebergOrder: rv.BtsIcebergOrder = BTSIcebergOrder; break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_api"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:uag="clr-namespace:mbts.ui.spark.algo">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_api"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_api"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_api"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_api"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_api"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:uag="clr-namespace:mbts.ui.spark.algo">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_api"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
xmlns:uag="clr-namespace:mbts.ui.spark.algo">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_api"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_api"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:uag="clr-namespace:mbts.ui.spark.algo">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_core"
|
||||
xmlns:sp="clr-namespace:bts.spark;assembly=spark_api"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:uag="clr-namespace:mbts.ui.spark.algo">
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
<Style BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" TargetType="{x:Type Button}">
|
||||
<Setter Property="BorderBrush" Value="{StaticResource AccentColor1}" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="Background" Value="{StaticResource ControlBackground}" />
|
||||
<Setter Property="Background" Value="#e1e1e1" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsDefault" Value="True">
|
||||
<Setter Property="Background" Value="{StaticResource AccentColor1}" />
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
<Proto3 Remove="../../lib/api/services/MarketDataRelay.proto" />
|
||||
<Proto2 Include="../../lib/config/protos/*.proto" />
|
||||
<Proto3 Include="../../lib/domain_model/Security.proto" />
|
||||
<Proto3 Include="../../lib/sparkproto/SparkProtos.proto" />
|
||||
<Proto3 Update="../../lib/api/services/OutOfProcessURLListener.proto">
|
||||
<!-- <CompileOptions>internal_access:</CompileOptions> -->
|
||||
</Proto3>
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Proto3 Include="../../lib/sparkproto/SparkProtos.proto" />
|
||||
<Proto3 Include="../../lib/md/protos/co2.proto" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -2,6 +2,103 @@
|
||||
JetFIX {
|
||||
value {
|
||||
connection {
|
||||
# cert
|
||||
name: "cme_mbx"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.177"
|
||||
socket_connect_port: 61920
|
||||
sender_compid: "MBX004N"
|
||||
target_compid: "CME"
|
||||
target_subid: "64"
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
raw_data: "T8F8F"
|
||||
}
|
||||
connection {
|
||||
# cert
|
||||
name: "cme_mc1"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.177"
|
||||
socket_connect_port: 61921
|
||||
sender_compid: "MC1004N"
|
||||
target_compid: "CME"
|
||||
target_subid: "64"
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
raw_data: "S4PMA"
|
||||
}
|
||||
connection {
|
||||
# cert
|
||||
name: "cme_mc5"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.177"
|
||||
socket_connect_port: 61922
|
||||
sender_compid: "MC5004N"
|
||||
target_compid: "CME"
|
||||
target_subid: "64"
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
raw_data: "TOL92"
|
||||
}
|
||||
connection {
|
||||
# cert
|
||||
name: "cme_mc7"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.177"
|
||||
socket_connect_port: 61923
|
||||
sender_compid: "MC7004N"
|
||||
target_compid: "CME"
|
||||
target_subid: "64"
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
raw_data: "QDQ16"
|
||||
}
|
||||
connection {
|
||||
# cert
|
||||
name: "cme_mc8"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.177"
|
||||
socket_connect_port: 61924
|
||||
sender_compid: "MC7004N"
|
||||
target_compid: "CME"
|
||||
target_subid: "64"
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
raw_data: "QE9DB"
|
||||
}
|
||||
connection {
|
||||
# cert
|
||||
name: "cme_m5y"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.177"
|
||||
socket_connect_port: 61880
|
||||
sender_compid: "M5Y004N"
|
||||
target_compid: "CME"
|
||||
target_subid: "64"
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
raw_data: "TOAN4"
|
||||
}
|
||||
connection {
|
||||
# new release
|
||||
name: "cme_ans"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.177"
|
||||
@@ -16,12 +113,34 @@ JetFIX {
|
||||
sender_subid: "BTS"
|
||||
raw_data: "T4CST"
|
||||
}
|
||||
connection {
|
||||
# new release
|
||||
name: "cme_t39"
|
||||
platform: GLBX
|
||||
socket_connect_host_ip: "69.50.112.177"
|
||||
socket_connect_port: 23761
|
||||
sender_compid: "T39004N"
|
||||
target_compid: "CME"
|
||||
target_subid: "64"
|
||||
start_time: "00:30:00"
|
||||
end_time: "23:30:00"
|
||||
start_day: "sunday"
|
||||
end_day: "friday"
|
||||
sender_subid: "BTS"
|
||||
raw_data: "1JE9X"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SparkConnection {
|
||||
value {
|
||||
connection_name: "cme_ans"
|
||||
}
|
||||
}
|
||||
rule: "System.host_name=='pp-6'"
|
||||
value {connection_name: "cme_m5y"}
|
||||
}
|
||||
|
||||
SparkConnection {
|
||||
rule: "System.host_name=='TAHA-SUPER_spark'"
|
||||
value {connection_name: "cme_mc1"}
|
||||
}
|
||||
|
||||
SparkConnection {value {connection_name: "cme_mbx"}}
|
||||
@@ -41,9 +41,19 @@ std::string unpack_msg_args(std::array<uint8_t,SZ> const&buffer, const char*msg_
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename... Args> struct CheckPtr {
|
||||
const static auto value = true;
|
||||
};
|
||||
|
||||
template <typename Head, typename... Tail>
|
||||
struct CheckPtr<Head,Tail...> : public CheckPtr<Tail...> {
|
||||
static_assert(!std::is_pointer<Head>::value,"Pointers cannot be logged");
|
||||
};
|
||||
|
||||
template <size_t SZ, typename... Args>
|
||||
void pack_msg_args(std::array<uint8_t,SZ> &buffer,Args&&...args) {
|
||||
using Store = std::tuple<typename std::remove_reference<Args>::type...>;
|
||||
static_assert(CheckPtr<Args...>::value,"Illegal type logged");
|
||||
if(sizeof(Store) <= SZ)
|
||||
new (&buffer[0]) Store(std::forward<Args>(args)...);
|
||||
else {
|
||||
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
"Waited far too long for key: {} security discovery may be hung."
|
||||
" symbol: {} type: {}",
|
||||
key,
|
||||
(*ppcold)->security.symbol(),
|
||||
std::string((*ppcold)->security.symbol()),
|
||||
SecurityType_Name((*ppcold)->security.type));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -241,9 +241,9 @@ void convert_security(const Security& src, FixedSecurity& dest, bool set_securit
|
||||
default:
|
||||
break;
|
||||
}
|
||||
dest.price_break = src.contract_spec().price_break();
|
||||
dest.low_tick = src.contract_spec().low_tick();
|
||||
dest.high_tick = src.contract_spec().high_tick();
|
||||
dest.price_break = src.contract_spec().price_break() / src.contract_spec().price_multiplier();
|
||||
dest.low_tick = src.contract_spec().low_tick() / src.contract_spec().price_multiplier();
|
||||
dest.high_tick = src.contract_spec().high_tick() / src.contract_spec().price_multiplier();
|
||||
|
||||
switch(securitytype_of(src)) {
|
||||
case SECURITYTYPE_FUTURE: {
|
||||
|
||||
@@ -165,7 +165,7 @@ Dispatcher& Dispatcher::create_new(const char* name) {
|
||||
temp.run();
|
||||
}
|
||||
catch(const std::exception& ex) {
|
||||
LOG(Gen,Error ,"Exception on dispatcher thread: {}" ,ex.what());
|
||||
LOG(Gen,Error ,"Exception on dispatcher thread: {}" ,std::string(ex.what()));
|
||||
bts_assert_msg(false, ex.what());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
set(sources ;cmds/CmdRegistry.cpp;cmds/Help.cpp;cmds/Run.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;cmds/TestOrderman.cpp;event_grid/EventNode.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/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;orderman/components/FillRecorder.cpp;orderman/components/Gateway.cpp;orderman/components/MDSource.cpp;orderman/components/NativeOrderMan.cpp;orderman/components/OrderRecorder.cpp;orderman/components/SpreaderOrderMan.cpp;orderman/events/ExecutionReport.cpp;orderman/events/NativeOrderStateChange.cpp;orderman/events/SpreaderOrderStateChange.cpp;orderman/events/TimeChange.cpp;orderman/native_orders/NativeOrder.cpp;orderman/native_orders/NativeOrderBuilder.cpp;orderman/native_orders/NativeOrderFactory.cpp;orderman/persistence/FillDB.cpp;orderman/persistence/OrderDB.cpp;orderman/persistence/gen_order_id.cpp;orderman/service/OrderServiceServer.cpp;orderman/spreader_orders/SpreaderOrder.cpp;orderman/spreader_orders/SpreaderOrderBase.cpp;orderman/utils/fix_order_codec.cpp;orderman/utils/orderman_utils.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/tests/PersistenceServiceTests.cpp;risk_limits/IRiskLimitObserver.cpp;risk_limits/RiskLimitManager.cpp;risk_limits/RiskLimiter.cpp;risk_limits/SharedRiskLimiter.cpp;risk_limits/SymbolKey.cpp;risk_limits/tests/RiskLimitsTests.cpp;securities/SecurityDB.cpp;spreader/QuoteLegPriceQuantityState.cpp;spreader/SimpleSpreader.cpp;spreader/SingleFillHedger.cpp;spreader/SingleLegQuoter.cpp;spreader/SpreaderBase.cpp;spreader/SpreaderTests.cpp;testing/catch_test_runner.cpp;user/UserServiceServer.cpp)
|
||||
set(sources ;cmds/CmdRegistry.cpp;cmds/ConfigCheck.cpp;cmds/Help.cpp;cmds/Md.cpp;cmds/Run.cpp;cmds/Test.cpp;cmds/TestCeloxica.cpp;cmds/TestOrderman.cpp;event_grid/EventNode.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/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;orderman/components/FillRecorder.cpp;orderman/components/Gateway.cpp;orderman/components/MDSource.cpp;orderman/components/NativeOrderMan.cpp;orderman/components/OrderRecorder.cpp;orderman/components/SpreaderOrderMan.cpp;orderman/events/ExecutionReport.cpp;orderman/events/NativeOrderStateChange.cpp;orderman/events/SpreaderOrderStateChange.cpp;orderman/events/TimeChange.cpp;orderman/native_orders/NativeOrder.cpp;orderman/native_orders/NativeOrderBuilder.cpp;orderman/native_orders/NativeOrderFactory.cpp;orderman/persistence/FillDB.cpp;orderman/persistence/OrderDB.cpp;orderman/persistence/gen_order_id.cpp;orderman/service/OrderServiceServer.cpp;orderman/spreader_orders/SpreaderOrder.cpp;orderman/spreader_orders/SpreaderOrderBase.cpp;orderman/utils/fix_order_codec.cpp;orderman/utils/orderman_utils.cpp;persistence/IStore.cpp;persistence/PersistenceServiceServer.cpp;persistence/SqliteStore.cpp;persistence/tests/PersistenceServiceTests.cpp;risk_limits/IRiskLimitObserver.cpp;risk_limits/RiskLimitManager.cpp;risk_limits/RiskLimiter.cpp;risk_limits/SharedRiskLimiter.cpp;risk_limits/SymbolKey.cpp;risk_limits/tests/RiskLimitsTests.cpp;securities/SecurityDB.cpp;spreader/QuoteLegPriceQuantityState.cpp;spreader/SimpleSpreader.cpp;spreader/SingleFillHedger.cpp;spreader/SingleLegQuoter.cpp;spreader/SpreaderBase.cpp;spreader/SpreaderTests.cpp;testing/catch_test_runner.cpp;user/UserServiceServer.cpp)
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "ConfigCheck.h"
|
||||
#include "lib/config/ConfigCheck.h"
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
|
||||
int ConfigCheck::execute(std::vector<std::string> const &args)
|
||||
{
|
||||
std::vector<const char*> ch_args;
|
||||
for (auto const &s : args)
|
||||
ch_args.push_back(s.c_str());
|
||||
configcheck(ch_args.size(),&ch_args[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string ConfigCheck::help ()
|
||||
{
|
||||
return "Config check help.";
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "ICmd.h"
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
|
||||
class ConfigCheck : public ICmd
|
||||
{
|
||||
public:
|
||||
int execute(std::vector<std::string> const &args);
|
||||
std::string help();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "Md.h"
|
||||
#include "server/sparkd/cmds/CmdRegistry.h"
|
||||
#include "server/sparkd/md/run_md.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
|
||||
int Md::execute(std::vector<std::string> const &args)
|
||||
{
|
||||
bts::md::md_tool(args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string Md::help ()
|
||||
{
|
||||
return "Md command";
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "ICmd.h"
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
|
||||
class Md : public ICmd
|
||||
{
|
||||
public:
|
||||
int execute(std::vector<std::string> const &args);
|
||||
std::string help ();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "lib/api/public/ServiceContext.h"
|
||||
#include "lib/api/services/OrderService.client.pb.h"
|
||||
#include "server/sparkd/cmds/Run.h"
|
||||
#include "server/sparkd/securities/SecurityDB.h"
|
||||
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/utils/PBUtils.h"
|
||||
@@ -16,8 +17,9 @@
|
||||
#include "server/sparkd/orderman/events/GatewayBeginReplay.h"
|
||||
#include "server/sparkd/event_grid/events/Init.h"
|
||||
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
|
||||
@@ -27,53 +29,47 @@ using namespace spark;
|
||||
|
||||
enum class CurrentOrderType {UNDEFINED,SPREADER,NATIVE};
|
||||
|
||||
void fill_leg_key(Security&, size_t leg_index)
|
||||
securities::SecurityDB *sec_db = nullptr;
|
||||
|
||||
std::pair<Security const*,Security const*> get_front_month_es_futures ()
|
||||
{
|
||||
// TODO, fill in the key for the legs
|
||||
// leg_index=0 ES 12/15/2017
|
||||
// leg_index=1 ES 3/16/2018
|
||||
bts_assert(leg_index == 0 || leg_index == 1);
|
||||
if (!sec_db)
|
||||
sec_db = new securities::SecurityDB();
|
||||
|
||||
std::pair<Security const*,Security const*> result;
|
||||
|
||||
std::map<datetime::PTime,Security const*> es_futures;
|
||||
|
||||
for (auto const &kvp : sec_db->retrieve_all()) {
|
||||
auto sec = *kvp.second;
|
||||
if (sec.symbol() == "ES" && sec.has_future()) {
|
||||
auto exp = datetime::make_ptime(sec.future().expiration_year(),
|
||||
sec.future().expiration_month(),
|
||||
sec.future().expiration_day());
|
||||
if (exp > datetime::now())
|
||||
es_futures[exp] = &sec;
|
||||
}
|
||||
}
|
||||
|
||||
bts_assert(es_futures.size() >= 2);
|
||||
auto exp_it = es_futures.begin();
|
||||
result = std::make_pair(exp_it->second,(++exp_it)->second);
|
||||
return result;
|
||||
}
|
||||
|
||||
Security make_spreader_security()
|
||||
{
|
||||
api::orderman::CreateSpreaderOrder r;
|
||||
// Specification
|
||||
api::ContractSpecification spec;
|
||||
spec.set_low_tick(0.25);
|
||||
spec.set_high_tick(0.25);
|
||||
// leg 1
|
||||
api::FutureContract leg_1_future_contract;
|
||||
leg_1_future_contract.set_expiration_day(15);
|
||||
leg_1_future_contract.set_expiration_month(12);
|
||||
leg_1_future_contract.set_expiration_year(2017);
|
||||
Security leg_1_security;
|
||||
// TODO, set id
|
||||
leg_1_security.set_symbol("ES");
|
||||
leg_1_security.set_exchange(api::VENUE_GLBX);
|
||||
leg_1_security.mutable_contract_spec()->MergeFrom(spec);
|
||||
leg_1_security.mutable_future()->MergeFrom(leg_1_future_contract);
|
||||
fill_leg_key(leg_1_security, 0);
|
||||
auto leg_secs = get_front_month_es_futures();
|
||||
|
||||
ContractLeg leg_1_contract_leg;
|
||||
leg_1_contract_leg.mutable_security()->MergeFrom(leg_1_security);
|
||||
*leg_1_contract_leg.mutable_security() = *leg_secs.first;
|
||||
leg_1_contract_leg.set_quantity(1.0);
|
||||
leg_1_contract_leg.set_side(api::SIDE_BUY);
|
||||
leg_1_contract_leg.set_price_multiplier(1.0);
|
||||
|
||||
// leg 2
|
||||
api::FutureContract leg_2_future_contract;
|
||||
leg_2_future_contract.set_expiration_day(16);
|
||||
leg_2_future_contract.set_expiration_month(3);
|
||||
leg_2_future_contract.set_expiration_year(2018);
|
||||
Security leg_2_security;
|
||||
// TODO, set id
|
||||
leg_2_security.set_symbol("ES");
|
||||
leg_2_security.set_exchange(api::VENUE_GLBX);
|
||||
leg_2_security.mutable_contract_spec()->MergeFrom(spec);
|
||||
leg_2_security.mutable_future()->MergeFrom(leg_2_future_contract);
|
||||
fill_leg_key(leg_2_security, 1);
|
||||
ContractLeg leg_2_contract_leg;
|
||||
leg_2_contract_leg.mutable_security()->MergeFrom(leg_2_security);
|
||||
*leg_2_contract_leg.mutable_security() = *leg_secs.second;
|
||||
leg_2_contract_leg.set_quantity(1.0);
|
||||
leg_2_contract_leg.set_side(api::SIDE_SELL);
|
||||
leg_2_contract_leg.set_price_multiplier(1.0);
|
||||
@@ -85,6 +81,10 @@ Security make_spreader_security()
|
||||
synth_contract.mutable_legs()->Add()->MergeFrom(leg_1_contract_leg);
|
||||
synth_contract.mutable_legs()->Add()->MergeFrom(leg_2_contract_leg);
|
||||
|
||||
// Specification
|
||||
api::ContractSpecification spec;
|
||||
spec.set_low_tick(0.25);
|
||||
spec.set_high_tick(0.25);
|
||||
Security rv;
|
||||
rv.set_exchange(api::VENUE_GLBX);
|
||||
rv.mutable_contract_spec()->MergeFrom(spec);
|
||||
@@ -122,7 +122,7 @@ ExecutionStrategy create_execution_strategy(uint32_t leg_1_id, uint32_t leg_2_id
|
||||
}
|
||||
|
||||
api::orderman::CreateSpreaderOrder create_spreader_order_creation(std::string account_name, std::string operator_id, uint32_t security_key,
|
||||
Price price, Quantity quantity, api::Side side)
|
||||
Price price, Quantity quantity, api::Side side)
|
||||
{
|
||||
Security sec = make_spreader_security();
|
||||
uint32_t leg_1_id = sec.synthetic().legs(0).security().id();
|
||||
@@ -148,11 +148,11 @@ api::orderman::CreateOrderRequest make_spreader_order_create_request(api::Side s
|
||||
api::orderman::CreateSpreaderOrder create_order = create_spreader_order_creation("BTS", "BTS", 0, price, quantity, side);
|
||||
result.mutable_spreader()->MergeFrom(create_order);
|
||||
/*auto &spreader = *result.mutable_spreader();
|
||||
spreader.set_account_name("BTS");
|
||||
spreader.set_operator_id("BTS");
|
||||
spreader.set_side(side);
|
||||
spreader.set_price(price.value());
|
||||
spreader.set_quantity(quantity.value());*/
|
||||
spreader.set_account_name("BTS");
|
||||
spreader.set_operator_id("BTS");
|
||||
spreader.set_side(side);
|
||||
spreader.set_price(price.value());
|
||||
spreader.set_quantity(quantity.value());*/
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ int TestOrderman::execute(std::vector<std::string> const &)
|
||||
uint32_t sec_key;char side; double price; int quantity;
|
||||
std::cin >> sec_key >> side >> price >> quantity;
|
||||
auto resp = client.create_order(make_native_order_create_request(SecurityKey(sec_key),
|
||||
side == 'b' ? api::SIDE_BUY : api::SIDE_SELL,
|
||||
side == 'b' ? api::SIDE_BUY : api::SIDE_SELL,
|
||||
Price(price),
|
||||
Quantity(quantity)));
|
||||
if (resp.success()) {
|
||||
|
||||
@@ -38,7 +38,7 @@ bool SocketConnection::connect ()
|
||||
LOG (Jetfix,Error,
|
||||
"Failed to allocate socket when connecting to {}:{} errno:{} msg: {}",
|
||||
_cfg.socket_connect_host_ip (), _cfg.socket_connect_port (),
|
||||
er, strerror_r(er,msg,sizeof(msg)));
|
||||
er, std::string(strerror_r(er,msg,sizeof(msg))));
|
||||
_fd = -1;
|
||||
return false;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ int SocketConnection::read (char* to_buffer,size_t read_count)
|
||||
auto er = errno;
|
||||
char msg [256];
|
||||
LOG (Jetfix,Warn,"Could not read from jetfix connection. {}",
|
||||
strerror_r(er,msg,sizeof(msg)));
|
||||
std::string(strerror_r(er,msg,sizeof(msg))));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ int SocketConnection::write (WriteVec const&vec,size_t vec_size,size_t cid)
|
||||
auto er = errno;
|
||||
char msg [256];
|
||||
LOG (Jetfix,Warn,"Could not write to jetfix connection. ",
|
||||
strerror_r(er,msg,sizeof(msg)));
|
||||
std::string(strerror_r(er,msg,sizeof(msg))));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -491,8 +491,8 @@ void CoreGateway::transition (State new_state)
|
||||
{
|
||||
LOG (Jetfix,Warn,"Transitioning Jetfix gateway {} from {} to {}",
|
||||
me->cfg.name (),
|
||||
state_name (me->state),
|
||||
state_name (new_state));
|
||||
std::string(state_name (me->state)),
|
||||
std::string(state_name (new_state)));
|
||||
me->state = new_state;
|
||||
check_state_invariants ();
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ void Session::receive (InMsgBuffer const&msg)
|
||||
{
|
||||
LOG (Jetfix,Error, "Discarding repeated message: {} sn: {} state: {} conn: {}",
|
||||
(char) msg.type (), msg.get_seq_num (),
|
||||
state_name (me->state), me->cfg.name ());
|
||||
std::string(state_name (me->state)), me->cfg.name ());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -569,7 +569,7 @@ void Session::logout (JetFIXError::Code error,std::string const &extra_info)
|
||||
level = Info;
|
||||
|
||||
LOG (Jetfix,level,"Logging out of jetfix session: {} {} conn: {}",
|
||||
JetFIXError::code_msg (error), extra_info, me->cfg.name ());
|
||||
std::string(JetFIXError::code_msg (error)), extra_info, me->cfg.name ());
|
||||
|
||||
me->start_of_logout = me->now ();
|
||||
internal_send (make_logout (me->cfg));
|
||||
@@ -590,7 +590,7 @@ void Session::terminate_session (JetFIXError::Code error,std::string const&extra
|
||||
level = Info;
|
||||
|
||||
LOG (Jetfix,level,"Jetfix session disconnected: {} {} conn: {}",
|
||||
JetFIXError::code_msg (error), extra_info, me->cfg.name ());
|
||||
std::string(JetFIXError::code_msg (error)), extra_info, me->cfg.name ());
|
||||
|
||||
transition (State::TERMINATED);
|
||||
me->event_sink.session_terminated ();
|
||||
@@ -677,7 +677,9 @@ bool Session::resend_request_active ()
|
||||
void Session::transition (State new_state)
|
||||
{
|
||||
LOG (Jetfix,Warn,"Jetfix connection {} transitioning from {} to {}",
|
||||
me->cfg.name (), state_name (me->state), state_name (new_state));
|
||||
me->cfg.name (),
|
||||
std::string(state_name (me->state)),
|
||||
std::string(state_name (new_state)));
|
||||
me->state = new_state;
|
||||
}
|
||||
|
||||
|
||||
+10
-13
@@ -1,16 +1,17 @@
|
||||
#include "lib/os/os.h"
|
||||
|
||||
#include "lib/utils/init_spark_lib.h"
|
||||
#include "lib/config/ConfigCheck.h"
|
||||
#include "server/sparkd/md/run_md.h"
|
||||
#include "lib/os/os.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "server/sparkd/cmds/CmdRegistry.h"
|
||||
|
||||
// to add a command add the header here and the the REGISTER call below
|
||||
// don't touch this file except to add commands.
|
||||
#include "server/sparkd/cmds/Test.h"
|
||||
#include "server/sparkd/cmds/Run.h"
|
||||
#include "server/sparkd/cmds/Help.h"
|
||||
#include "server/sparkd/cmds/TestOrderman.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "server/sparkd/cmds/TestCeloxica.h"
|
||||
#include "server/sparkd/cmds/Md.h"
|
||||
#include "server/sparkd/cmds/ConfigCheck.h"
|
||||
|
||||
#define BEGIN_CMD
|
||||
#define REGISTER(CMD) bts::cmd::CmdRegistry::register_cmd<bts::cmd::CMD> (#CMD)
|
||||
@@ -21,22 +22,18 @@ int main( int argc, const char*argv[] )
|
||||
using namespace bts;
|
||||
|
||||
os::set_thread_name("main");
|
||||
if (argc > 1 && strcmp(argv[1], "configcheck")==0) {
|
||||
configcheck(argc-2, argv+2);
|
||||
}
|
||||
else if (argc > 1 && strcmp(argv[1], "md") == 0) {
|
||||
std::vector<std::string> args(argv+2, argv+argc);
|
||||
bts::md::md_tool(args);
|
||||
}
|
||||
utils::init_spark_lib();
|
||||
LOG(Gen,Warn,"Sparkd launched --------------------------------------------------------------------");
|
||||
|
||||
LOG(Gen,Warn,"------------------------------------ Sparkd launched --------------------------------");
|
||||
|
||||
BEGIN_CMD;
|
||||
REGISTER (Test);
|
||||
REGISTER (Help);
|
||||
REGISTER (Run);
|
||||
REGISTER (Md);
|
||||
REGISTER (TestOrderman);
|
||||
REGISTER (TestCeloxica);
|
||||
REGISTER (ConfigCheck);
|
||||
END_CMD;
|
||||
|
||||
utils::finit_spark_lib();
|
||||
|
||||
@@ -120,6 +120,10 @@ void MDP3Listener::onInstrumentRecovery(onixs::Handler& h) {
|
||||
void MDP3Listener::onEndOfInstrumentRecovery(onixs::Handler& h, const onixs::RecoveryCompletionArgs&) {
|
||||
LOG(MarketData,Info, "Finished Security definition recovery for channel {}", h.settings().channel());
|
||||
}
|
||||
// void MDP3Listener::onGap(onixs::Handler& h, const Security&, unsigned) {
|
||||
// update_all_status(COCONUTSECURITYSTATUS_PACKET_LOSS);
|
||||
// LOG(MarketData,Info, "Gap detected on channel {}", h.settings().channel());
|
||||
// }
|
||||
|
||||
//
|
||||
// Gap Recovery
|
||||
@@ -166,8 +170,17 @@ void MDP3Listener::onEndOfPacket(onixs::Handler&, const onixs::PacketArgs&) {
|
||||
// Security discovery
|
||||
|
||||
template <class Price>
|
||||
double double_of_price(const Price& price) {
|
||||
return price.mantissa() * pow10(price.exponent());
|
||||
double double_of_price(const Price& price, int8_t display_factor) {
|
||||
return price.mantissa() * pow10(price.exponent() + display_factor);
|
||||
}
|
||||
|
||||
inline PriceSize pricesize_of_price_size(const onixs::PRICE price, int8_t display_factor, Size size) {
|
||||
PriceSize result(price.mantissa(), price.exponent() + display_factor, size);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline datetime::LLDateTime ll_of_timestamp(const onixs::Timestamp& ts) {
|
||||
return datetime::ll_from_parts(ts.year(), (int)ts.month() - 1, ts.day(), ts.hour(), ts.minute(), ts.second(), ts.millisecond());
|
||||
}
|
||||
|
||||
template <class Definition>
|
||||
@@ -185,6 +198,10 @@ datetime::Date date_of_maturity(const Definition& def) {
|
||||
return result;
|
||||
}
|
||||
|
||||
datetime::Date date_of_timestamp(const onixs::Timestamp& ts) {
|
||||
return datetime::Date(ts.year(), (int)ts.month(), ts.day());
|
||||
}
|
||||
|
||||
template <class Definition>
|
||||
void set_security_common(const Definition& def, FixedSecurity& fsec) {
|
||||
fsec.numeric_id = def.securityId();
|
||||
@@ -208,14 +225,15 @@ void MDP3Listener::onDefinition(onixs::Handler&, const onixs::Security& osec, co
|
||||
FixedFutureSecurity fsec;
|
||||
set_security_common(sec, fsec);
|
||||
fsec.price_break = 0;
|
||||
fsec.low_tick = fsec.high_tick = double_of_price(sec.minPriceIncrement());
|
||||
// low/high tick are stored non-premultiplied and multiplied in conversion to api::Secutity
|
||||
fsec.low_tick = fsec.high_tick = double_of_price(sec.minPriceIncrement(), 0);
|
||||
auto expiration = date_of_maturity(sec);
|
||||
fsec.expiration_year = expiration.year;
|
||||
fsec.expiration_month = expiration.month;
|
||||
fsec.expiration_day = expiration.day;
|
||||
onixs::PRICE price;
|
||||
if (sec.unitOfMeasureQty(price)) {
|
||||
fsec.cme_unit_of_measure_qty = double_of_price(price);
|
||||
fsec.cme_unit_of_measure_qty = double_of_price(price, 0);
|
||||
}
|
||||
add_security(fsec);
|
||||
}
|
||||
@@ -234,19 +252,19 @@ void MDP3Listener::onDefinition(onixs::Handler&, const onixs::Security&, const o
|
||||
|
||||
onixs::PRICE price;
|
||||
if (sec.unitOfMeasureQty(price)) {
|
||||
fsec.cme_unit_of_measure_qty = double_of_price(price);
|
||||
fsec.cme_unit_of_measure_qty = double_of_price(price, 0);
|
||||
}
|
||||
|
||||
onixs::PRICE strike_price;
|
||||
bts_assert(sec.strikePrice(strike_price));
|
||||
fsec.strike = double_of_price(strike_price);
|
||||
fsec.strike = double_of_price(strike_price, fsec.display_factor);
|
||||
|
||||
onixs::PRICE min_tick;
|
||||
sec.minPriceIncrement(min_tick);
|
||||
|
||||
int8_t tick_rule;
|
||||
if (sec.tickRule(tick_rule)) {
|
||||
decode_ticks(tick_rule, double_of_price(min_tick), fsec);
|
||||
decode_ticks(tick_rule, double_of_price(min_tick, 0), fsec);
|
||||
}
|
||||
|
||||
fsec.call_put = sec.putOrCall() == onixs::PutOrCall::Call ? api::PUTORCALL_CALL : api::PUTORCALL_PUT;
|
||||
@@ -279,11 +297,11 @@ void MDP3Listener::onDefinition(onixs::Handler&, const onixs::Security&, const o
|
||||
const auto& leg = sec.legs()[x];
|
||||
onixs::PRICE price;
|
||||
if (leg.legPrice(price)) {
|
||||
fsec.legs[x].leg_price = double_of_price(price);
|
||||
fsec.legs[x].leg_price = double_of_price(price, fsec.display_factor);
|
||||
}
|
||||
onixs::DecimalQty qty;
|
||||
if (leg.legOptionDelta(qty)) {
|
||||
fsec.legs[x].leg_delta = double_of_price(qty);
|
||||
fsec.legs[x].leg_delta = double_of_price(qty, 0);
|
||||
}
|
||||
fsec.legs[x].leg_quantity = leg.legRatioQty();
|
||||
fsec.legs[x].leg_side = leg.legSide() == onixs::LegSide::BuySide ? api::SIDE_BUY : api::SIDE_SELL;
|
||||
@@ -293,14 +311,6 @@ void MDP3Listener::onDefinition(onixs::Handler&, const onixs::Security&, const o
|
||||
_index.add_spread_legs(fsec.numeric_id, leg_exchange_ids);
|
||||
}
|
||||
|
||||
inline PriceSize pricesize_of_price_size(const onixs::PRICE price, int8_t display_factor, Size size) {
|
||||
PriceSize result(price.mantissa(), price.exponent() + display_factor, size);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline datetime::LLDateTime ll_of_timestamp(const onixs::Timestamp& ts) {
|
||||
return datetime::ll_from_parts(ts.year(), (int)ts.month() - 1, ts.day(), ts.hour(), ts.minute(), ts.second(), ts.millisecond());
|
||||
}
|
||||
|
||||
//
|
||||
// Book
|
||||
@@ -357,6 +367,8 @@ void MDP3Listener::onTrade(onixs::Handler&, const onixs::Security& sec, const on
|
||||
|
||||
//
|
||||
// RFQ
|
||||
void MDP3Listener::onQuoteRequest(onixs::Handler&, const onixs::Security&, const onixs::QuoteRequestRelatedSymArgs&) {
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
@@ -374,7 +386,136 @@ void MDP3Listener::onElectronicVolumn(onixs::Handler&, const onixs::Security& se
|
||||
|
||||
//
|
||||
// Misc
|
||||
|
||||
void MDP3Listener::onSettlementPrice(onixs::Handler&, const onixs::Security& sec, const onixs::DailyStatisticsArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
onixs::PRICE price;
|
||||
onixs::Timestamp time;
|
||||
args.entry().entryPx(price);
|
||||
args.entry().tradingReferenceDate(time);
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
data->handle.update_settlement(
|
||||
utils::TimeStamp::now(),
|
||||
double_of_price(price, display_factor),
|
||||
date_of_timestamp(time));
|
||||
}
|
||||
}
|
||||
void MDP3Listener::onSettlementPrice(onixs::Handler&, const onixs::Security& sec, const onixs::RecoveryEntryArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
onixs::PRICE price;
|
||||
onixs::Timestamp time;
|
||||
args.entry().entryPx(price);
|
||||
args.entry().tradingReferenceDate(time);
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
data->handle.update_settlement(
|
||||
utils::TimeStamp::now(),
|
||||
double_of_price(price, display_factor),
|
||||
date_of_timestamp(time));
|
||||
}
|
||||
}
|
||||
void MDP3Listener::onOpenInterest(onixs::Handler&, const onixs::Security& sec, const onixs::DailyStatisticsArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
onixs::PRICE price;
|
||||
args.entry().entryPx(price);
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
data->handle.update_open_interest(utils::TimeStamp::now(), double_of_price(price, display_factor));
|
||||
}
|
||||
}
|
||||
void MDP3Listener::onOpenInterest(onixs::Handler&, const onixs::Security& sec, const onixs::RecoveryEntryArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
onixs::PRICE price;
|
||||
args.entry().entryPx(price);
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
data->handle.update_open_interest(utils::TimeStamp::now(), double_of_price(price, display_factor));
|
||||
}
|
||||
}
|
||||
void MDP3Listener::onOpeningPrice(onixs::Handler&, const onixs::Security& sec, const onixs::SessionStatisticsArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
onixs::PRICE price = args.entry().entryPx();
|
||||
onixs::Timestamp time = args.message().transactTime();
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
data->handle.update_opening(
|
||||
utils::TimeStamp::now(),
|
||||
double_of_price(price, display_factor),
|
||||
date_of_timestamp(time));
|
||||
}
|
||||
}
|
||||
void MDP3Listener::onOpeningPrice(onixs::Handler&, const onixs::Security& sec, const onixs::RecoveryEntryArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
onixs::PRICE price;
|
||||
args.entry().entryPx(price);
|
||||
onixs::Timestamp time;
|
||||
args.entry().tradingReferenceDate(time);
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
data->handle.update_opening(
|
||||
utils::TimeStamp::now(),
|
||||
double_of_price(price, display_factor),
|
||||
date_of_timestamp(time));
|
||||
}
|
||||
}
|
||||
void MDP3Listener::onHighTradePrice(onixs::Handler&, const onixs::Security& sec, const onixs::SessionStatisticsArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
data->handle.update_session_high(
|
||||
utils::TimeStamp::now(),
|
||||
double_of_price(args.entry().entryPx(), display_factor));
|
||||
}
|
||||
}
|
||||
void MDP3Listener::onHighTradePrice(onixs::Handler&, const onixs::Security& sec, const onixs::RecoveryEntryArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
onixs::PRICE price;
|
||||
args.entry().entryPx(price);
|
||||
data->handle.update_session_high(
|
||||
utils::TimeStamp::now(),
|
||||
double_of_price(price, display_factor));
|
||||
}
|
||||
}
|
||||
void MDP3Listener::onLowTradePrice(onixs::Handler&, const onixs::Security& sec, const onixs::SessionStatisticsArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
data->handle.update_session_low(
|
||||
utils::TimeStamp::now(),
|
||||
double_of_price(args.entry().entryPx(), display_factor));
|
||||
}
|
||||
}
|
||||
void MDP3Listener::onLowTradePrice(onixs::Handler&, const onixs::Security& sec, const onixs::RecoveryEntryArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
onixs::PRICE price;
|
||||
args.entry().entryPx(price);
|
||||
data->handle.update_session_low(
|
||||
utils::TimeStamp::now(),
|
||||
double_of_price(price, display_factor));
|
||||
}
|
||||
}
|
||||
void MDP3Listener::onHighestBid(onixs::Handler&, const onixs::Security& sec, const onixs::SessionStatisticsArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
data->handle.update_session_high_bid(
|
||||
utils::TimeStamp::now(),
|
||||
double_of_price(args.entry().entryPx(), display_factor));
|
||||
}
|
||||
}
|
||||
void MDP3Listener::onLowestOffer(onixs::Handler&, const onixs::Security& sec, const onixs::SessionStatisticsArgs& args) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
data->handle.update_session_low_offer(
|
||||
utils::TimeStamp::now(),
|
||||
double_of_price(args.entry().entryPx(), display_factor));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
void onWarning(onixs::Handler&, const onixs::WarningArgs&) override;
|
||||
void onInstrumentRecovery(onixs::Handler&) override;
|
||||
void onEndOfInstrumentRecovery(onixs::Handler&, const onixs::RecoveryCompletionArgs&) override;
|
||||
// void onGap(onixs::Handler&, const Security&, unsigned) override;
|
||||
|
||||
//
|
||||
// Gap Recovery
|
||||
@@ -59,6 +60,7 @@ public:
|
||||
|
||||
//
|
||||
// RFQ
|
||||
void onQuoteRequest(onixs::Handler&, const onixs::Security&, const onixs::QuoteRequestRelatedSymArgs&) override;
|
||||
|
||||
//
|
||||
// Volume
|
||||
@@ -66,6 +68,20 @@ public:
|
||||
|
||||
//
|
||||
// Misc
|
||||
void onSettlementPrice(onixs::Handler&, const onixs::Security&, const onixs::DailyStatisticsArgs&) override;
|
||||
void onSettlementPrice(onixs::Handler&, const onixs::Security&, const onixs::RecoveryEntryArgs&) override;
|
||||
void onOpenInterest(onixs::Handler&, const onixs::Security&, const onixs::DailyStatisticsArgs&) override;
|
||||
void onOpenInterest(onixs::Handler&, const onixs::Security&, const onixs::RecoveryEntryArgs&) override;
|
||||
void onOpeningPrice(onixs::Handler&, const onixs::Security&, const onixs::SessionStatisticsArgs&) override;
|
||||
void onOpeningPrice(onixs::Handler&, const onixs::Security&, const onixs::RecoveryEntryArgs&) override;
|
||||
void onHighTradePrice(onixs::Handler&, const onixs::Security&, const onixs::SessionStatisticsArgs&) override;
|
||||
void onHighTradePrice(onixs::Handler&, const onixs::Security&, const onixs::RecoveryEntryArgs&) override;
|
||||
void onLowTradePrice(onixs::Handler&, const onixs::Security&, const onixs::SessionStatisticsArgs&) override;
|
||||
void onLowTradePrice(onixs::Handler&, const onixs::Security&, const onixs::RecoveryEntryArgs&) override;
|
||||
|
||||
void onHighestBid(onixs::Handler&, const onixs::Security&, const onixs::SessionStatisticsArgs&) override;
|
||||
void onLowestOffer(onixs::Handler&, const onixs::Security&, const onixs::SessionStatisticsArgs&) override;
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
@@ -300,7 +300,7 @@ unique_ptr<onixs::Handler> MDP3Main::prepare_handler(const string& channel_id) {
|
||||
return handler;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
LOG(MarketData,Error,"{}", e.what());
|
||||
LOG(MarketData,Error,"{}", std::string(e.what()));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ void printhelp() {
|
||||
cout << help() << endl;
|
||||
}
|
||||
|
||||
void md_tool(std::vector<std::string>& args) {
|
||||
void md_tool(std::vector<std::string> const &args) {
|
||||
const string& cmd = args.empty() ? "" : args[0];
|
||||
if (args.empty()) printhelp();
|
||||
else if (cmd == "record") run_record(args.size() > 1 ? args[1] : "");
|
||||
|
||||
@@ -6,6 +6,6 @@ namespace bts {
|
||||
namespace md {
|
||||
|
||||
void run_market_datapublishers();
|
||||
void md_tool(std::vector<std::string>& args);
|
||||
void md_tool(std::vector<std::string> const& args);
|
||||
|
||||
}}
|
||||
}}
|
||||
@@ -352,7 +352,8 @@ const char* NativeOrderMan::state_name(State state)
|
||||
void NativeOrderMan::transition(State new_state)
|
||||
{
|
||||
LOG(OrderMan,Info,"Transitioning NativeOrderMan from {} to {}",
|
||||
state_name(me->state),state_name(new_state));
|
||||
std::string(state_name(me->state)),
|
||||
std::string(state_name(new_state)));
|
||||
me->state = new_state;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include "lib/domain_model/common.h"
|
||||
|
||||
namespace bts {
|
||||
@@ -12,6 +13,8 @@ class ISecurityDB
|
||||
public:
|
||||
virtual ~ISecurityDB() {};
|
||||
virtual api::Security const *resolve(SecurityKey const&k) = 0;
|
||||
using SecurityMap = std::map<SecurityKey::Value,api::Security const*> ;
|
||||
virtual SecurityMap retrieve_all() const = 0;
|
||||
};
|
||||
|
||||
}}
|
||||
@@ -40,6 +40,7 @@ struct SecurityDB::PImpl
|
||||
TimeStamp last_scan;
|
||||
};
|
||||
|
||||
|
||||
SecurityDB::SecurityDB () : me (new PImpl())
|
||||
{
|
||||
auto all = me->store->retrieve_all()[sec_ns];
|
||||
@@ -98,6 +99,14 @@ api::Security const *SecurityDB::resolve(SecurityKey const&k)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SecurityDB::SecurityMap SecurityDB::retrieve_all() const {
|
||||
SecurityMap result;
|
||||
std::lock_guard<std::mutex> l(me->lock);
|
||||
for (auto const &kvp : me->known_securities)
|
||||
result[kvp.first] = kvp.second.get();
|
||||
return result;
|
||||
}
|
||||
|
||||
void SecurityDB::do_work()
|
||||
{
|
||||
auto now = Timer::now();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include "server/sparkd/securities/ISecurityDB.h"
|
||||
|
||||
namespace bts {
|
||||
@@ -12,6 +13,7 @@ public:
|
||||
SecurityDB();
|
||||
~SecurityDB();
|
||||
api::Security const *resolve(SecurityKey const&k) override;
|
||||
SecurityMap retrieve_all() const override;
|
||||
void do_work();
|
||||
private:
|
||||
void store_if_new(api::Security const&sec);
|
||||
|
||||
@@ -6,7 +6,7 @@ call %~dp0\ensure_lhome.cmd
|
||||
cd %~dp0\..
|
||||
docker run --rm -i ^
|
||||
-p 8000:8000 -p 8001:8001 -p 2000:22 %* ^
|
||||
--security-opt seccomp=unconfined ^
|
||||
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined ^
|
||||
-v %linuxhome%:/root/ ^
|
||||
-v %cd%:/bts ^
|
||||
-h %COMPUTERNAME%_spark ^
|
||||
|
||||
@@ -27,11 +27,29 @@ cd clang_release
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ ../..
|
||||
cd ..
|
||||
|
||||
rm -rf ninja_debug
|
||||
mkdir ninja_debug
|
||||
cd ninja_debug
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=g++ ../..
|
||||
cd ..
|
||||
|
||||
rm -rf ninja_release
|
||||
mkdir ninja_release
|
||||
cd ninja_release
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=g++ ../..
|
||||
cd ..
|
||||
|
||||
if hash rtags 2>/dev/null; then
|
||||
rm -rf rtags
|
||||
mkdir rtags
|
||||
cd rtags
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=rtags ../..
|
||||
cd ..
|
||||
|
||||
rm -rf rtags_ninja
|
||||
mkdir rtags_ninja
|
||||
cd rtags_ninja
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=rtags ../..
|
||||
cd ..
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
mkdir %userprofile%\.vscode\extensions\ms-vscode.csharp-1.12.1\.omnisharp\msbuild\Bin 2>NUL
|
||||
copy /y %userprofile%\.vscode\extensions\ms-vscode.csharp-1.12.1\.omnisharp\msbuild\Microsoft.CSharp.targets %userprofile%\.vscode\extensions\ms-vscode.csharp-1.12.1\.omnisharp\msbuild\Bin
|
||||
@@ -0,0 +1,6 @@
|
||||
@setlocal
|
||||
@echo off
|
||||
cd %~dp0\..
|
||||
"c:\program files\git\usr\bin\ssh.exe" -p 2000 -o StrictHostKeyChecking=no root@localhost "cd /bts/build/gcc_debug && make -j4"
|
||||
|
||||
|
||||
Reference in new issue
Block a user