Merge branch 'master' of bitbucket.org:bluetradesys/spark into fix
This commit is contained in:
commit
feab3cbb89
43 files changed
+757
-310
No files matched your search
@@ -1,4 +1,25 @@
|
||||
# Release Notes
|
||||
## 1.4.8
|
||||
### Marketdata
|
||||
- Additional trade details for CME ticker
|
||||
|
||||
## 1.4.7
|
||||
### Bug Fixes
|
||||
- Corrected FIX tag 1028, ManualOrderIndicator, when orders are triggered by algos
|
||||
|
||||
## 1.4.6
|
||||
### Ladder Usability Improvements
|
||||
- The ladder can now be zoomed in/out according to a user's preference
|
||||
- The zoom slider can be enabled from Ladder Form -> Settings button -> Left Pane tab -> check Zoom Slider checkbox
|
||||
- The zoom functionality can also be performed via hotkey and mouse wheel combinations
|
||||
- Zoom In = CTRL + Mouse wheel up
|
||||
- Zoom Out = CTRL + Mouse wheel down
|
||||
- Reset zoom = CTRL + Mouse wheel click or double click on the zoom slider
|
||||
### Exchange simulator
|
||||
- Improved the exchange simulator to track real market data more closely
|
||||
### Bug Fixes
|
||||
- Fixed a UI crash in some cases when attempting to sort the order book by time
|
||||
|
||||
## 1.4.5
|
||||
- Fixed entitlement validation for ICS spreads
|
||||
- Tuned performance logging
|
||||
|
||||
@@ -31,7 +31,9 @@ namespace mbts.ui {
|
||||
}
|
||||
|
||||
private static ImageSource load_resource_and_freeze(string resource_name) {
|
||||
return ((DrawingImage)_resources[resource_name]).frozen();
|
||||
lock (_resources) {
|
||||
return ((DrawingImage)_resources[resource_name]).frozen();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
@@ -152,7 +154,10 @@ namespace mbts.ui {
|
||||
}
|
||||
|
||||
static IEnumerable<string> _get_geometric_path(string geometric_path_key) {
|
||||
object obj = _resources[geometric_path_key];
|
||||
object obj;
|
||||
lock (_resources) {
|
||||
obj = _resources[geometric_path_key];
|
||||
}
|
||||
if (obj is string path) {
|
||||
if (string.IsNullOrEmpty(path)) {
|
||||
Log.Api.error($"Resource lookup of '{geometric_path_key}' did not return a valid string.", nameof(geometric_path_key));
|
||||
|
||||
@@ -210,36 +210,28 @@ namespace mbts.spark {
|
||||
var order = _orders_model.factory.order(security);
|
||||
switch (col) {
|
||||
case MarketViewView.Columns.Bid:
|
||||
order.Side = Side.Sell;
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, bid_price, 0u));
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, 0u));
|
||||
break;
|
||||
case MarketViewView.Columns.BidMergedSize:
|
||||
order.Side = Side.Sell;
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, bid_price, bid_merged_size));
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_merged_size));
|
||||
break;
|
||||
case MarketViewView.Columns.BidDirectSize:
|
||||
order.Side = Side.Sell;
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, bid_price, bid_direct_size));
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_direct_size));
|
||||
break;
|
||||
case MarketViewView.Columns.BidImpliedSize:
|
||||
order.Side = Side.Sell;
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, bid_price, bid_implied_size));
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_implied_size));
|
||||
break;
|
||||
case MarketViewView.Columns.Ask:
|
||||
order.Side = Side.Buy;
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, ask_price, 0u));
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Buy), ask_price, 0u));
|
||||
break;
|
||||
case MarketViewView.Columns.AskMergedSize:
|
||||
order.Side = Side.Buy;
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, ask_price, ask_merged_size));
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Buy), ask_price, ask_merged_size));
|
||||
break;
|
||||
case MarketViewView.Columns.AskDirectSize:
|
||||
order.Side = Side.Sell;
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, ask_price, ask_direct_size));
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), ask_price, ask_direct_size));
|
||||
break;
|
||||
case MarketViewView.Columns.AskImpliedSize:
|
||||
order.Side = Side.Sell;
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, ask_price, ask_implied_size));
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), ask_price, ask_implied_size));
|
||||
break;
|
||||
case MarketViewView.Columns.Last:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, last_price, 0u));
|
||||
|
||||
@@ -97,8 +97,11 @@ namespace mbts.spark {
|
||||
public IEnumerable<TradeInfo> read_trades() {
|
||||
var copy = _securities;
|
||||
foreach (var tm in _channel.read_trades(ref _cursor)) {
|
||||
if (copy.TryGetValue(tm.Key, out SecurityImmutable sec))
|
||||
yield return new TradeInfo(sec, tm);
|
||||
if (tm != null) {
|
||||
if (copy.TryGetValue(tm.Key, out SecurityImmutable sec)) {
|
||||
yield return new TradeInfo(sec, new TradeMessageImmutable(tm));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace mbts.spark {
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<uint?> create_synthetic(SecurityImmutable synthetic) {
|
||||
var result = await _service.create_synthetic_async(synthetic);
|
||||
public async Task<uint?> create_synthetic(SecurityImmutable? synthetic) {
|
||||
var result = await _service.create_synthetic_async(synthetic.Value);
|
||||
return _error.handle_error(result, "Error creating synthetic: {0}", r => r.Error, e => e == CreateResult.Types.Error.Ok, r => new uint?(r.Key), () => null).result;
|
||||
}
|
||||
|
||||
|
||||
@@ -294,9 +294,9 @@ namespace mbts.spark {
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
static string _deduce_symbol(SecurityImmutable security) {
|
||||
if (!string.IsNullOrWhiteSpace(security.Symbol)) return security.Symbol;
|
||||
if (security.Synthetic.Legs.Count() > 0) return security.Synthetic.Legs.First().Security.Symbol;
|
||||
static string _deduce_symbol(SecurityImmutable? security) {
|
||||
if (!string.IsNullOrWhiteSpace(security?.Symbol)) return security?.Symbol;
|
||||
if (security?.Synthetic.Legs.Count() > 0) return security?.Synthetic.Legs.First().Security.Symbol;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace mbts.spark {
|
||||
} else return model.on_fill_tuples;
|
||||
}
|
||||
|
||||
static IConnectableObservable<IIncrementalUpdate<FillTuple, FillTupleKey>> _get_observable(IBus bus, OrdersModel model, IObservable<StartupData> state) =>
|
||||
static IConnectableObservable<IIncrementalUpdate<FillTuple, FillTupleKey>> _get_observable(IBus bus, OrdersModel model, IObservable<StartupData> state) =>
|
||||
state.SelectManyInSeries(s => _get_observable(bus, model, s));
|
||||
|
||||
public class Row : SecurityRow, IEquatable<Row>, IRowVM {
|
||||
@@ -186,7 +186,7 @@ namespace mbts.spark {
|
||||
readonly FillImmutable _fill;
|
||||
readonly OrderRecordImmutable _order;
|
||||
|
||||
public Row(FillTuple fill_tuple, OrdersModel model) : base(fill_tuple.security_md.HasValue ? fill_tuple.security_md.Value.security : SecurityDataHelper.Defaults.Security) {
|
||||
public Row(FillTuple fill_tuple, OrdersModel model) : base(fill_tuple.security_md.HasValue ? fill_tuple.security_md.Value.security : SecurityDataHelper.Defaults.SecurityImmutable) {
|
||||
_fill = fill_tuple.fill;
|
||||
_order = fill_tuple.order ?? OrderDataHelper.Defaults.OrderRecordImmutable;
|
||||
_model = model;
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace mbts.spark {
|
||||
class OrderBookRowCollection : ObservableCollection<OrderBookRowVM> {
|
||||
static readonly IEqualityComparer<INode<OrderBookRowVM>> _node_equality_comparer = EqualityComparer.Create<INode<OrderBookRowVM>, uint>(n => n.value.order_key);
|
||||
readonly Func<OrderRecordTuple, OrderBookRowVM> _row_factory;
|
||||
/// Critical: Any and all row mutations <see cref="OrderBookRowVM"/> must be executed through <see cref="SortedTree{T, TKey}.TryReplace(TKey, Func{T, T})"/>.
|
||||
/// Mutations can change the sort-position of a row, and <see cref="_tree"/> will be broken if its elements aren't properly sorted (it relies heavily on binary-search logic).
|
||||
SortedTree<OrderBookRowVM, uint> _tree;
|
||||
IComparer<OrderBookRowVM> _comparer;
|
||||
Func<OrderRecordTuple, bool> _filter;
|
||||
|
||||
@@ -139,13 +139,13 @@ namespace mbts.spark {
|
||||
tif => time_in_forces.Contains(tif));
|
||||
_dispose = Disposable.Create(() => _order_type.Changed -= on_selected_order_type_changed);
|
||||
// local methods
|
||||
IOrderTypeVM create_order_type_vm(CustomOrderDefinitionImmutable cd, string id, string display_name) {
|
||||
IOrderTypeVM create_order_type_vm(CustomOrderDefinitionImmutable? cd, string id, string display_name) {
|
||||
IOrderTypeVM vm = null;
|
||||
if(cd.CustomCase == CustomOrderDefinition.CustomOneofCase.Dynamic)
|
||||
vm = OrderTypeVMFactory.create(cd.CustomCase, id, display_name, model, security_md_source, cd.Dynamic.DynamicOrderType);
|
||||
if(cd?.CustomCase == CustomOrderDefinition.CustomOneofCase.Dynamic)
|
||||
vm = OrderTypeVMFactory.create(cd.Value.CustomCase, id, display_name, model, security_md_source, cd.Value.Dynamic.DynamicOrderType);
|
||||
else
|
||||
vm = OrderTypeVMFactory.create(cd.CustomCase, id, display_name, model, security_md_source);
|
||||
vm.load_from(cd);
|
||||
vm = OrderTypeVMFactory.create(cd.Value.CustomCase, id, display_name, model, security_md_source);
|
||||
vm.load_from(cd.Value);
|
||||
return vm;
|
||||
}
|
||||
InlineUserProperty<IOrderTypeVM> get_order_type_vm_prop(InlineOrderProperties p) {
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace mbts.spark {
|
||||
var so = model.factory.spreader_order();
|
||||
so.Security = s.CloneToMutable();
|
||||
so.ExecutionStrategy = strategy.CloneToMutable();
|
||||
return new InlineUserProperty<SpreaderOrderDefinitionImmutable>(so, true);
|
||||
var soi = new SpreaderOrderDefinitionImmutable(so);
|
||||
return new InlineUserProperty<SpreaderOrderDefinitionImmutable>(soi, true);
|
||||
})), id, display_name) { }
|
||||
|
||||
public SpreaderOrderVM(
|
||||
|
||||
@@ -93,10 +93,13 @@ namespace mbts.spark {
|
||||
#endregion
|
||||
|
||||
#region Input
|
||||
public async Task<uint?> send_order(OrderDefinitionImmutable order, double price, uint size) {
|
||||
var result = (await send_order_get_error(order, price, size));
|
||||
_activity.on_send_order(order, price, size, result.key, result.error);
|
||||
return result.key;
|
||||
public async Task<uint?> send_order(OrderDefinitionImmutable? order, double price, uint size) {
|
||||
if (order.HasValue) {
|
||||
var result = (await send_order_get_error(order.Value, price, size));
|
||||
_activity.on_send_order(order.Value, price, size, result.key, result.error);
|
||||
return result.key;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
async Task<(uint? key, string error)> send_order_get_error(OrderDefinitionImmutable order, double price, uint size) {
|
||||
|
||||
@@ -34,9 +34,11 @@ namespace bts.view.controls {
|
||||
private void any_button_click(object sender, RoutedEventArgs e) {
|
||||
Close();
|
||||
}
|
||||
internal static void Show(ErrorReportService srv, ErrorReport report) {
|
||||
var window = new SupportRequestWindow(new SupportRequestVM(srv, report));
|
||||
window.Show();
|
||||
internal static void Show(ErrorReportService srv, ErrorReportImmutable? report) {
|
||||
if (report.HasValue) {
|
||||
var window = new SupportRequestWindow(new SupportRequestVM(srv, report.Value));
|
||||
window.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace mbts.spark {
|
||||
return intpart + floatpart;
|
||||
}
|
||||
|
||||
public static RegionalTickFactors get_regional_ticks(ContractSpecificationImmutable spec) =>
|
||||
public static RegionalTickFactors get_regional_ticks(ContractSpecificationImmutable? spec) =>
|
||||
TickStore.get(spec);
|
||||
|
||||
public static RegionalTickFactors get_regional_ticks(SecurityImmutable security) =>
|
||||
@@ -177,8 +177,14 @@ namespace mbts.spark {
|
||||
public static RegionalTickFactors get(ContractSpecification spec) =>
|
||||
_exchange_ticks.GetOrAdd(new SpecKey(spec), _create_rtf);
|
||||
|
||||
public static RegionalTickFactors get(ContractSpecificationImmutable spec) =>
|
||||
_exchange_ticks.GetOrAdd(new SpecKey(spec), _create_rtf);
|
||||
public static RegionalTickFactors get(ContractSpecificationImmutable? spec) {
|
||||
if (spec.HasValue) {
|
||||
return _exchange_ticks.GetOrAdd(new SpecKey(spec.Value), _create_rtf);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static RegionalTickFactors get(SecurityImmutable security) =>
|
||||
security.HasContractSpec ? get(security.ContractSpec) : default_rtf;
|
||||
|
||||
@@ -181,6 +181,7 @@ namespace mbts.spark {
|
||||
[ProtoContract]
|
||||
class LadderSettings : IEquatable<LadderSettings> {
|
||||
const double _default_order_entry_panel_width = 110.0;
|
||||
const double _default_zoom_factor = 1.0;
|
||||
|
||||
// Default proto constructor
|
||||
// Added this so that when clients upgrade to a version with new settings,
|
||||
@@ -203,6 +204,7 @@ namespace mbts.spark {
|
||||
auto_clear_visible = true;
|
||||
clear_visible = true;
|
||||
order_entry_panel_initial_width = _default_order_entry_panel_width;
|
||||
zoom_factor = _default_zoom_factor;
|
||||
use_defaults = true;
|
||||
}
|
||||
|
||||
@@ -260,7 +262,9 @@ namespace mbts.spark {
|
||||
cancel_all_visible = true,
|
||||
auto_clear_visible = true,
|
||||
clear_visible = true,
|
||||
order_entry_panel_initial_width = _default_order_entry_panel_width
|
||||
order_entry_panel_initial_width = _default_order_entry_panel_width,
|
||||
zoom_slider_visible = false,
|
||||
zoom_factor = _default_zoom_factor,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -357,10 +361,19 @@ namespace mbts.spark {
|
||||
public bool clear_visible { get; set; }
|
||||
//
|
||||
[ProtoMember(43), DefaultValue(_default_order_entry_panel_width)]
|
||||
public double order_entry_panel_initial_width { get; set; }
|
||||
public double order_entry_panel_initial_width { get; set; }
|
||||
|
||||
[ProtoMember(44), DefaultValue(true)]
|
||||
public bool use_defaults { get; set; }
|
||||
|
||||
// the zoom slider is the first new widget on the panel
|
||||
// since our initial general release, so its enablement
|
||||
// will be opt-in (default not visible)
|
||||
[ProtoMember(45)]
|
||||
public bool zoom_slider_visible { get; set; }
|
||||
[ProtoMember(46), DefaultValue(_default_zoom_factor)]
|
||||
public double zoom_factor { get; set; }
|
||||
|
||||
public bool Equals(LadderSettings other) =>
|
||||
other != null &&
|
||||
row_height == other.row_height &&
|
||||
@@ -403,6 +416,8 @@ namespace mbts.spark {
|
||||
auto_clear_visible == other.auto_clear_visible &&
|
||||
clear_visible == other.clear_visible &&
|
||||
order_entry_panel_initial_width == other.order_entry_panel_initial_width &&
|
||||
zoom_slider_visible == other.zoom_slider_visible &&
|
||||
zoom_factor == other.zoom_factor &&
|
||||
use_defaults == other.use_defaults;
|
||||
|
||||
public override bool Equals(object obj) => Equals(obj as LadderSettings);
|
||||
@@ -449,16 +464,18 @@ namespace mbts.spark {
|
||||
auto_clear_visible.GetHashCode(),
|
||||
clear_visible.GetHashCode(),
|
||||
order_entry_panel_initial_width.GetHashCode(),
|
||||
zoom_slider_visible.GetHashCode(),
|
||||
zoom_factor.GetHashCode(),
|
||||
use_defaults.GetHashCode());
|
||||
|
||||
public struct WindowSpecifics {
|
||||
public readonly double order_entry_panel_width;
|
||||
public readonly double order_entry_panel_width, zoom_factor;
|
||||
public readonly uint orders_column_width, bid_column_width, price_column_width, ask_column_width, last_column_width, volume_column_width;
|
||||
|
||||
public WindowSpecifics(LadderSettings s)
|
||||
: this(s.order_entry_panel_initial_width, s.orders_column.width, s.bid_column.width, s.price_column.width, s.ask_column.width, s.last_column.width, s.volume_column.general.width) { }
|
||||
: this(s.order_entry_panel_initial_width, s.orders_column.width, s.bid_column.width, s.price_column.width, s.ask_column.width, s.last_column.width, s.volume_column.general.width, s.zoom_factor) { }
|
||||
|
||||
public WindowSpecifics(double order_entry_panel_width, uint orders_column_width, uint bid_column_width, uint price_column_width, uint ask_column_width, uint last_column_width, uint volume_column_width) {
|
||||
public WindowSpecifics(double order_entry_panel_width, uint orders_column_width, uint bid_column_width, uint price_column_width, uint ask_column_width, uint last_column_width, uint volume_column_width, double zoom_factor) {
|
||||
this.order_entry_panel_width = order_entry_panel_width;
|
||||
this.orders_column_width = orders_column_width;
|
||||
this.bid_column_width = bid_column_width;
|
||||
@@ -466,6 +483,7 @@ namespace mbts.spark {
|
||||
this.ask_column_width = ask_column_width;
|
||||
this.last_column_width = last_column_width;
|
||||
this.volume_column_width = volume_column_width;
|
||||
this.zoom_factor = zoom_factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -496,6 +514,7 @@ namespace mbts.spark {
|
||||
source.ask_column.width = specifics.ask_column_width;
|
||||
source.last_column.width = specifics.last_column_width;
|
||||
source.volume_column.general.width = specifics.volume_column_width;
|
||||
source.zoom_factor = specifics.zoom_factor;
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace mbts.spark {
|
||||
readonly Property<LadderSettings.BadgeStyle> _badge_style;
|
||||
readonly Property<uint> _alternate_order_size;
|
||||
readonly DelegateProperty<double> _row_height;
|
||||
Func<double> _get_order_entry_panel_width;
|
||||
Func<double> _get_order_entry_panel_width, _get_zoom_factor;
|
||||
LadderSettings _current;
|
||||
LadderColumnSettingsVM
|
||||
_orders = new OrdersColumnSettingsVM(),
|
||||
@@ -34,6 +34,7 @@ namespace mbts.spark {
|
||||
_session_high_mkt_line = new LadderMarketBreakLineVM("Session High", 2, 1, false),
|
||||
_session_range_fill = new LadderMarketBreakLineVM("Session Range", 0, 0, false);
|
||||
OrderEntryPanelItemVisibilityVM
|
||||
_zoom_slider_visbility = new OrderEntryPanelItemVisibilityVM("Zoom Slider"),
|
||||
_day_visibility = new OrderEntryPanelItemVisibilityVM("Day Change"),
|
||||
_high_visibility = new OrderEntryPanelItemVisibilityVM("High"),
|
||||
_low_visibility = new OrderEntryPanelItemVisibilityVM("Low"),
|
||||
@@ -51,7 +52,7 @@ namespace mbts.spark {
|
||||
_cancel_sells_visibility = new OrderEntryPanelItemVisibilityVM("Cancel Sells"),
|
||||
_cancel_all_visibility = new OrderEntryPanelItemVisibilityVM("Cancel All");
|
||||
|
||||
public LadderSettingsVM(bool is_synthetic, Func<double> get_left_panel_width) {
|
||||
public LadderSettingsVM(bool is_synthetic, Func<double> get_left_panel_width, Func<double> get_zoom_factor) {
|
||||
this.is_synthetic = is_synthetic;
|
||||
size_presets = new ObservableEditableCollection<IMutableValueWrapperVM<uint>>(_create_size_preset_vm);
|
||||
size_presets.CollectionChanged += (s, e) => RaisePropertyChanged(nameof(size_presets_text));
|
||||
@@ -59,6 +60,7 @@ namespace mbts.spark {
|
||||
_badge_style.Changed += _badge_style_Changed;
|
||||
_alternate_order_size = backing<uint>(nameof(alternate_order_size));
|
||||
_get_order_entry_panel_width = get_left_panel_width;
|
||||
_get_zoom_factor = get_zoom_factor;
|
||||
// be sure to initialize backings before this measure_row_height call
|
||||
_row_height = backing(nameof(row_height), () => LadderRender.measure_row_height(get_result()));
|
||||
_orders.font_size_changed += on_font_size_changed;
|
||||
@@ -130,6 +132,7 @@ namespace mbts.spark {
|
||||
|
||||
public IEnumerable<OrderEntryPanelItemVisibilityVM> order_entry_panel_items {
|
||||
get {
|
||||
yield return _zoom_slider_visbility;
|
||||
yield return _day_visibility;
|
||||
yield return _high_visibility;
|
||||
yield return _low_visibility;
|
||||
@@ -169,6 +172,7 @@ namespace mbts.spark {
|
||||
_session_low_mkt_line.assign_from(_current.session_low_line);
|
||||
_session_high_mkt_line.assign_from(_current.session_high_line);
|
||||
_session_range_fill.assign_from(_current.session_range_fill);
|
||||
_zoom_slider_visbility.show = settings.zoom_slider_visible;
|
||||
_day_visibility.show = settings.day_visible;
|
||||
_high_visibility.show = settings.high_visible;
|
||||
_low_visibility.show = settings.low_visible;
|
||||
@@ -227,6 +231,8 @@ namespace mbts.spark {
|
||||
clone.cancel_sells_visible = _cancel_sells_visibility.show;
|
||||
clone.cancel_all_visible = _cancel_all_visibility.show;
|
||||
clone.order_entry_panel_initial_width = _get_order_entry_panel_width();
|
||||
clone.zoom_slider_visible = _zoom_slider_visbility.show;
|
||||
clone.zoom_factor = _get_zoom_factor();
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,13 @@ namespace mbts.spark {
|
||||
|
||||
readonly IBus _bus;
|
||||
readonly LadderModel _model;
|
||||
readonly Property<double> _high, _low, _change, _open, _settlement, _position, _left_panel_width;
|
||||
readonly Property<double> _high, _low, _change, _open, _settlement, _position, _left_panel_width, _zoom_factor;
|
||||
//readonly Property<double> _window_width, _window_height;
|
||||
readonly Property<uint> _orders_column_width, _bid_column_width, _price_column_width, _ask_column_width, _last_column_width, _volume_column_width;
|
||||
readonly Property<ulong> _volume;
|
||||
readonly Property<bool> _auto_clear, _show_day, _show_high, _show_low, _show_open, _show_settle, _show_volume, _show_account,
|
||||
_show_tif, _show_order_type, _show_account_position, _show_size_preset, _show_auto_clear, _show_clear, _show_cancel_buys,
|
||||
_show_cancel_sells, _show_cancel_all;
|
||||
_show_cancel_sells, _show_cancel_all, _show_zoom;
|
||||
readonly Property<Brush> _bid_background, _bid_foreground, _ask_background, _ask_foreground;
|
||||
IWindowSettingsManager<LadderSettings> _settings_manager;
|
||||
ulong _misc_time = 0;
|
||||
@@ -58,6 +59,7 @@ namespace mbts.spark {
|
||||
_last_column_width = backing(nameof(last_column_width), ws.last_column_width);
|
||||
_volume_column_width = backing(nameof(volume_column_width), ws.volume_column_width);
|
||||
_left_panel_width = backing(nameof(left_panel_width), ws.order_entry_panel_width);
|
||||
_zoom_factor = backing(nameof(zoom_factor), ws.zoom_factor);
|
||||
// remember: account_positions needs to subscribe to selected_account; both the sub and account_positions need to be disposed
|
||||
var account_positions = new KeyDrivenObservableSeries<string, double>(a => _model.order_gateway.security_total_position(security.Id, a));
|
||||
_position = backing(nameof(position), account_positions.OnDispatcher());
|
||||
@@ -89,11 +91,14 @@ namespace mbts.spark {
|
||||
_show_cancel_buys = bool_prop(nameof(show_cancel_buys), s => s.cancel_buys_visible);
|
||||
_show_cancel_sells = bool_prop(nameof(show_cancel_sells), s => s.cancel_sells_visible);
|
||||
_show_cancel_all = bool_prop(nameof(show_cancel_all), s => s.cancel_all_visible);
|
||||
_show_zoom = bool_prop(nameof(show_zoom), s => s.zoom_slider_visible);
|
||||
|
||||
Property<bool> bool_prop(string name, Func<LadderSettings, bool> get_bool) =>
|
||||
backing(name, settings_manager.subscribe_current().OnDispatcher(), get_bool);
|
||||
|
||||
//
|
||||
//_window_height = backing(nameof(window_height), settings_manager.subscribe_current().OnDispatcher().Select(s => s.zoom_factor), (scale) => scale * 600);
|
||||
//_window_width = backing(nameof(window_width), settings_manager.subscribe_current().OnDispatcher().Select(s => s.zoom_factor), (scale) => scale * 420);
|
||||
position_click_command = new DelegateCommand(() => size_calculator.value = DoubleHelper.safe_convert_to_uint(Math.Abs(position)));
|
||||
send_order_command = new DelegateCommand<(double price, Side? side, bool size_from_alternate)>(send_order);
|
||||
cancel_command = new AsyncCommand<LadderModel.CancelType>(_model.cancel_orders, true);
|
||||
@@ -103,7 +108,7 @@ namespace mbts.spark {
|
||||
var vm = new WindowSettingsDialogVM<LadderSettings, LadderSettingsVM>(
|
||||
settings_manager, s => s.ladder, UserSettings.FileExtensions.LADDER,
|
||||
s => {
|
||||
var svm = new LadderSettingsVM(security.ContractCase == Security.ContractOneofCase.Synthetic, () => left_panel_width);
|
||||
var svm = new LadderSettingsVM(security.ContractCase == Security.ContractOneofCase.Synthetic, () => left_panel_width, () => zoom_factor);
|
||||
svm.load(s);
|
||||
return svm;
|
||||
}, s => s.with_window_specifics(get_save_state().get_window_specifics()));
|
||||
@@ -284,7 +289,11 @@ namespace mbts.spark {
|
||||
public bool show_cancel_buys { get => _show_cancel_buys.Value; set => _show_cancel_buys.set(value); }
|
||||
public bool show_cancel_sells { get => _show_cancel_sells.Value; set => _show_cancel_sells.set(value); }
|
||||
public bool show_cancel_all { get => _show_cancel_all.Value; set => _show_cancel_all.set(value); }
|
||||
public bool show_zoom { get => _show_zoom.Value; set => _show_zoom.set(value); }
|
||||
public double left_panel_width { get => _left_panel_width.Value; set => _left_panel_width.set(value); }
|
||||
public double zoom_factor { get => _zoom_factor.Value; set => _zoom_factor.set(value); }
|
||||
//public double window_height { get => _window_height.Value; set => _window_height.set(value); }
|
||||
//public double window_width { get => _window_width.Value; set => _window_width.set(value); }
|
||||
public uint orders_column_width { get => _orders_column_width.Value; set => _orders_column_width.set(value); }
|
||||
public uint bid_column_width { get => _bid_column_width.Value; set => _bid_column_width.set(value); }
|
||||
public uint price_column_width { get => _price_column_width.Value; set => _price_column_width.set(value); }
|
||||
@@ -296,7 +305,7 @@ namespace mbts.spark {
|
||||
|
||||
public LadderSettings get_save_state() {
|
||||
var state = _settings_manager.current_settings();
|
||||
state = state.with_window_specifics(new LadderSettings.WindowSpecifics(left_panel_width, orders_column_width, bid_column_width, price_column_width, ask_column_width, last_column_width, volume_column_width));
|
||||
state = state.with_window_specifics(new LadderSettings.WindowSpecifics(left_panel_width, orders_column_width, bid_column_width, price_column_width, ask_column_width, last_column_width, volume_column_width, zoom_factor));
|
||||
state.use_defaults = _settings_manager.instance_settings == null;
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
xmlns:uag="clr-namespace:mbts.ui.spark.algo"
|
||||
xmlns:converters="clr-namespace:mbts.ui.converters"
|
||||
xmlns:txt="clr-namespace:mbts.ui.utility.text"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
Height="600"
|
||||
Width="420"
|
||||
Background="{x:Static mbts:BTSColors.common_background_brush}"
|
||||
@@ -273,10 +274,18 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<sys:Double x:Key="MaxZoomFactor">1.5</sys:Double>
|
||||
<sys:Double x:Key="MinZoomFactor">0.5</sys:Double>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<AdornerDecorator>
|
||||
<Grid x:Name="_root">
|
||||
<Grid.LayoutTransform>
|
||||
<ScaleTransform CenterX="0" CenterY="0"
|
||||
ScaleX="{Binding ElementName=_ui_scaler, Path=Value}"
|
||||
ScaleY="{Binding ElementName=_ui_scaler, Path=Value}"
|
||||
/>
|
||||
</Grid.LayoutTransform>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding left_panel_width, Mode=TwoWay, Converter={StaticResource GridLengthPixelConverter}}"
|
||||
MinWidth="60" MaxWidth="150"/>
|
||||
@@ -298,6 +307,13 @@
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<StackPanel x:Name="_slider_stack_panel" Margin="5,5,5,0">
|
||||
<Slider x:Name="_ui_scaler" Value="{Binding zoom_factor}"
|
||||
Minimum="{StaticResource MinZoomFactor}"
|
||||
Maximum="{StaticResource MaxZoomFactor}"
|
||||
Width="{Binding Path=ActualWidth, ElementName=_slider_stack_panel}"
|
||||
Visibility="{Binding show_zoom, Converter={StaticResource BooleanToVisibilityConverter}}"/>
|
||||
</StackPanel>
|
||||
<Grid Margin="2,4,2,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
|
||||
@@ -5,9 +5,12 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class LadderView : UserControl {
|
||||
readonly double _max_zoom, _min_zoom;
|
||||
|
||||
internal LadderView(LadderVM vm) {
|
||||
InitializeComponent();
|
||||
_column_headers_presenter.Columns = new GridViewColumnCollection();
|
||||
@@ -16,8 +19,58 @@ namespace mbts.spark {
|
||||
this.vm = vm;
|
||||
DataContext = vm;
|
||||
DataContextChanged += datacontext_changed;
|
||||
if (TryFindResource("MaxZoomFactor") is double found_max) {
|
||||
_max_zoom = found_max;
|
||||
} else {
|
||||
// is there a better way of not specifying the constant twice ?
|
||||
// once in the resource dictionary here and again in the xaml, seems like there has to be a better way
|
||||
_max_zoom = 1.5;
|
||||
}
|
||||
// ditto
|
||||
if (TryFindResource("MinZoomFactor") is double found_min) {
|
||||
_min_zoom = found_min;
|
||||
} else {
|
||||
_min_zoom = 0.5;
|
||||
}
|
||||
_ui_scaler.MouseDoubleClick += _ui_scaler_MouseDoubleClick;
|
||||
this.PreviewMouseWheel += LadderView_PreviewMouseWheel;
|
||||
this.PreviewMouseDown += LadderView_PreviewMouseDown;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// (Left|Right) CTRL + Wheel to zoom
|
||||
// This is neat b/c the user doesn't even need to have the slider visible to zoom
|
||||
private void LadderView_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e) {
|
||||
base.OnPreviewMouseWheel(e);
|
||||
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) {
|
||||
var delta = (e.Delta > 0) ? 0.1 : -0.1;
|
||||
var proposed_scaler_value = _ui_scaler.Value + delta;
|
||||
// Here we enforce the same contraints that are on the gui slider regarding min and max
|
||||
if (_min_zoom < proposed_scaler_value && proposed_scaler_value < _max_zoom) {
|
||||
_ui_scaler.Value = proposed_scaler_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// (Left|Right) CTRL + Wheel Click to reset
|
||||
private void LadderView_PreviewMouseDown(object sender, MouseButtonEventArgs e) {
|
||||
base.OnPreviewMouseDown(e);
|
||||
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) {
|
||||
if (e.MiddleButton == MouseButtonState.Pressed) {
|
||||
_ui_scaler_MouseDoubleClick(_ui_scaler, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Double click on scaler itself to reset
|
||||
private void _ui_scaler_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) {
|
||||
if (sender is Slider _the_slider) {
|
||||
_the_slider.Value = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void datacontext_changed(object sender, DependencyPropertyChangedEventArgs e) {
|
||||
this.vm = DataContext as LadderVM;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,8 @@ namespace mbts.spark.utilities {
|
||||
}
|
||||
#endregion
|
||||
|
||||
public OrderDefinition order(SecurityImmutable security) => order(security, _admin_model.get_default_account());
|
||||
public OrderDefinitionImmutable order(SecurityImmutable security) =>
|
||||
new OrderDefinitionImmutable(order(security, _admin_model.get_default_account()));
|
||||
public OrderDefinition order(SecurityImmutable security, AccountTuple? account) {
|
||||
var rv = new OrderDefinition {
|
||||
SecurityKey = security.Id,
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace bts.md
|
||||
{
|
||||
foreach (var v in values)
|
||||
{
|
||||
var smd = new SecurityMD(v.security, v.handle);
|
||||
var smd = new SecurityMD(new SecurityImmutable(v.security), v.handle);
|
||||
_exchange_sec_map.AddOrUpdate(smd.security.Id, smd, (_, __) => smd);
|
||||
}
|
||||
_version += 1;
|
||||
|
||||
@@ -37,17 +37,17 @@ namespace bts.api {
|
||||
$"{symbol}{DateFormatter.Format(future.ExpirationYear, future.ExpirationMonth, future.ExpirationDay, DateFormat.MonthCodeLastDigitYear)}" :
|
||||
exch_desc;
|
||||
|
||||
static string _format(SecurityImmutable security) {
|
||||
switch (security.ContractCase) {
|
||||
case ContractOneofCase.Future: return format_future(security.Symbol, security.glbx_desc(), security.Future);
|
||||
static string _format(SecurityImmutable? security) {
|
||||
switch (security?.ContractCase) {
|
||||
case ContractOneofCase.Future: return format_future(security?.Symbol, security?.glbx_desc(), security.Value.Future);
|
||||
case ContractOneofCase.Spread:
|
||||
if (security.HasGlbx) {
|
||||
if (security?.HasGlbx == true) {
|
||||
// In case we ever bring it back, pretty printed spread names can be found here:
|
||||
// GlbxSecurityFormatter.FormatSpread(security, out string result)
|
||||
return security.Glbx.SecurityDesc;
|
||||
return security?.Glbx.SecurityDesc;
|
||||
}
|
||||
return string.Join("", _format_future_legs(SecurityHelper.get_flat_future_legs(security.Spread.Legs)));
|
||||
case ContractOneofCase.Synthetic: return security.Synthetic.Name;
|
||||
return string.Join("", _format_future_legs(SecurityHelper.get_flat_future_legs(security?.Spread.Legs)));
|
||||
case ContractOneofCase.Synthetic: return security?.Synthetic.Name;
|
||||
default: return "Unknown-security";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,24 +66,10 @@ namespace bts.api {
|
||||
public static readonly IComparer<SecurityImmutable> InstanceImmutable = Comparer<SecurityImmutable>.Create(Compare);
|
||||
|
||||
public static int Compare(Security x, Security y) {
|
||||
if (x.ContractCase == ContractOneofCase.Future) return y.ContractCase == ContractOneofCase.Future ? Compare(x.Symbol, x.Future, y.Symbol, y.Future) : -1;
|
||||
else if (y.ContractCase == ContractOneofCase.Future) return 1;
|
||||
var xlegs = get_flat_future_legs(x).ToList();
|
||||
var ylegs = get_flat_future_legs(y).ToList();
|
||||
int max = Math.Min(xlegs.Count, ylegs.Count);
|
||||
for (int i = 0; i < max; i++) {
|
||||
int rv = Compare(xlegs[i].symbol, xlegs[i].future, ylegs[i].symbol, ylegs[i].future);
|
||||
if (rv != 0) return rv;
|
||||
}
|
||||
for (int i = 0; i < max; i++) {
|
||||
int rv = xlegs[i].quantity.CompareTo(ylegs[i].quantity);
|
||||
if (rv != 0) return rv;
|
||||
}
|
||||
for (int i = 0; i < max; i++) {
|
||||
int rv = xlegs[i].exchange.CompareTo(ylegs[i].exchange);
|
||||
if (rv != 0) return rv;
|
||||
}
|
||||
return xlegs.Count.CompareTo(ylegs.Count);
|
||||
if (ReferenceEquals(x, y)) return 0; // x ==y
|
||||
if (x == null) return 1; // y > x
|
||||
if (y == null) return -1; // x > y
|
||||
return Compare(new SecurityImmutable(x), new SecurityImmutable(y));
|
||||
}
|
||||
|
||||
public static int Compare(SecurityImmutable x, SecurityImmutable y) {
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace bts.collections {
|
||||
if (_nursery.TryPopValue(k, out SortedList<Node> children)) {
|
||||
// remove orphans from _tree (orphan-nodes must reside in the main _tree until parents arrive)
|
||||
foreach (var n in children)
|
||||
_tree.Remove(n);
|
||||
_assert_remove(_tree, n);
|
||||
node = new Node(item, children);
|
||||
} else node = new Node(item, _comparer);
|
||||
var pk = parent(item);
|
||||
@@ -84,13 +84,10 @@ namespace bts.collections {
|
||||
if (!_index.TryGetValue(k, out Node node)) {
|
||||
return false;
|
||||
} else {
|
||||
var newval = replace(node.value);
|
||||
Log.assert(id(newval).Equals(k));
|
||||
_replace(node, newval);
|
||||
_replace(node, replace);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Remove(T item) => Remove(id(item));
|
||||
|
||||
@@ -185,44 +182,97 @@ namespace bts.collections {
|
||||
}
|
||||
}
|
||||
|
||||
void _replace(Node node, T newval) {
|
||||
TKey pk = parent(newval);
|
||||
TKey old_pk = parent(node.value);
|
||||
if (pk.Equals(old_pk)) {
|
||||
SortedList<Node> node_list;
|
||||
if (pk.Equals(_root_id))
|
||||
node_list = _tree;
|
||||
else if (_index.TryGetValue(pk, out Node pnode)) {
|
||||
node_list = pnode.children;
|
||||
} else if (!_nursery.TryGetValue(pk, out node_list)) {
|
||||
throw new KeyNotFoundException($"Replace was called with a parent-key ({pk}) that was not found in _index or _nursery; item-key was ({id(newval)}).");
|
||||
}
|
||||
node_list.Remove(node);
|
||||
node.value = newval;
|
||||
node_list.Add(node);
|
||||
} else {
|
||||
if (old_pk.Equals(_root_id)) {
|
||||
_tree.Remove(node);
|
||||
} else {
|
||||
if (_index.TryGetValue(old_pk, out Node pnode))
|
||||
pnode.children.Remove(node);
|
||||
else {
|
||||
_remove_from_nursery(old_pk, node);
|
||||
}
|
||||
}
|
||||
node.value = newval;
|
||||
if (pk.Equals(_root_id)) {
|
||||
void _replace(Node node, T new_value) =>
|
||||
_replace(node, _ => new_value);
|
||||
|
||||
void _replace(Node node, Func<T, T> replace_value) {
|
||||
/// STEPS (outline)
|
||||
/// 1) remove node with current value
|
||||
/// 2) replace node.value
|
||||
/// 3) re-insert node with new value
|
||||
|
||||
/// Implementation (details):
|
||||
/// there are 3 scenarios in which step 1 (remove node...) may occur
|
||||
/// a) node is a root node
|
||||
/// - remove it from <see cref="_tree"/>.
|
||||
/// b) node is a child node who's parent is present
|
||||
/// - remove it from the parent <see cref="Node.children"/>
|
||||
/// c) the node is a child node who's parent is NOT present
|
||||
/// - remove it from <see cref="_nursery"/> AND <see cref="_tree"/>.
|
||||
/// In each scenario, after the node is removed, the new parent will be assigned (<see cref="new_pk"/>).
|
||||
/// If the parent has NOT changed, assign the node back to the same list(s), then return.
|
||||
/// If the parent HAS changed, determine the list(s) in which the node needs to be inserted, insert the node, then return.
|
||||
TKey old_pk = parent(node.value), new_pk;
|
||||
if (old_pk.Equals(_root_id)) {
|
||||
// a)
|
||||
_assert_remove(_tree, node);
|
||||
_assert_replace(ref node, replace_value);
|
||||
new_pk = parent(node.value);
|
||||
if (new_pk.Equals(old_pk)) {
|
||||
// the parent has NOT changed; re-insert the node, then return.
|
||||
_tree.Add(node);
|
||||
} else if (_index.TryGetValue(pk, out Node pnode)) {
|
||||
pnode.children.Add(node);
|
||||
} else {
|
||||
if (!_nursery.TryGetValue(pk, out SortedList<Node> nursery_list)) {
|
||||
_nursery.Add(pk, nursery_list = new SortedList<Node>(_comparer));
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (_index.TryGetValue(old_pk, out Node old_pnode)) {
|
||||
// b)
|
||||
_assert_remove(old_pnode.children, node);
|
||||
_assert_replace(ref node, replace_value);
|
||||
new_pk = parent(node.value);
|
||||
if (new_pk.Equals(old_pk)) {
|
||||
// the parent has NOT changed; re-insert the node, then return.
|
||||
old_pnode.children.Add(node);
|
||||
return;
|
||||
}
|
||||
} else if (_nursery.TryGetValue(old_pk, out SortedList<Node> nursery_list)) {
|
||||
// c)
|
||||
_assert_remove(nursery_list, node);
|
||||
_assert_remove(_tree, node);
|
||||
_assert_replace(ref node, replace_value);
|
||||
new_pk = parent(node.value);
|
||||
if (new_pk.Equals(old_pk)) {
|
||||
// the parent has NOT changed; re-insert the node, then return.
|
||||
nursery_list.Add(node);
|
||||
_tree.Add(node);
|
||||
return;
|
||||
} else {
|
||||
// the parent HAS changed; if the old nursery_list is empty, remove it.
|
||||
if (nursery_list.Count == 0)
|
||||
_nursery.Remove(old_pk);
|
||||
}
|
||||
} else {
|
||||
// error)
|
||||
throw new InvalidOperationException($"Unknown parent key '{old_pk}'.");
|
||||
}
|
||||
// the parent HAS changed. Determine the list(s) in which the node needs to inserted.
|
||||
if (new_pk.Equals(_root_id)) {
|
||||
_tree.Add(node);
|
||||
} else if (_index.TryGetValue(new_pk, out Node new_pnode)) {
|
||||
new_pnode.children.Add(node);
|
||||
} else {
|
||||
if (!_nursery.TryGetValue(new_pk, out SortedList<Node> new_nursery_list)) {
|
||||
_nursery.Add(new_pk, new_nursery_list = new SortedList<Node>(_comparer));
|
||||
}
|
||||
new_nursery_list.Add(node);
|
||||
_tree.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to removes the node from the list <see cref="SortedList{T}.Remove"/> and throws an exception if it does not succeed.
|
||||
/// </summary>
|
||||
static void _assert_remove(SortedList<Node> list, Node node) {
|
||||
if (!list.Remove(node))
|
||||
throw new InvalidOperationException("Failed to remove node.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces <see cref="Node.value"/> using the specified delegate, and throws an exception if the new value's id is different from the old value's id.
|
||||
/// </summary>
|
||||
void _assert_replace(ref Node node, Func<T, T> replace_value) {
|
||||
TKey old_key = id(node.value);
|
||||
node.value = replace_value(node.value);
|
||||
if (!id(node.value).Equals(old_key))
|
||||
throw new InvalidOperationException("Replace op changed Node's id.");
|
||||
}
|
||||
|
||||
void _remove_from_nursery(TKey pk, Node node) {
|
||||
|
||||
@@ -12,9 +12,10 @@ namespace bts.mcore
|
||||
class SecurityTests {
|
||||
[Test]
|
||||
public void test_security_equal() {
|
||||
SecurityImmutable a = new Security() { Id = 42 };
|
||||
SecurityImmutable b = new Security() { Id = 42 };
|
||||
SecurityImmutable c = new Security() { Id = 4 };
|
||||
|
||||
SecurityImmutable a = new SecurityImmutable(new Security() { Id = 42 });
|
||||
SecurityImmutable b = new SecurityImmutable(new Security() { Id = 42 });
|
||||
SecurityImmutable c = new SecurityImmutable(new Security() { Id = 4 });
|
||||
|
||||
Assert.IsTrue(a == b);
|
||||
Assert.IsTrue(a.Equals(b));
|
||||
|
||||
@@ -25,9 +25,9 @@ namespace bts.tests {
|
||||
parent_id = parent;
|
||||
}
|
||||
|
||||
public char name { get; }
|
||||
public char name { get; set; }
|
||||
public int id { get; }
|
||||
public int parent_id { get; }
|
||||
public int parent_id { get; set; }
|
||||
|
||||
public override bool Equals(object obj) {
|
||||
Order other = (Order)obj;
|
||||
@@ -133,6 +133,9 @@ namespace bts.tests {
|
||||
/// 2) Insert - all items are properly added via <see cref="SortedTree{T, TKey}.Insert(T)"/>
|
||||
/// 3) Reset - all items are properly added via <see cref="SortedTree{T, TKey}.Reset(IEnumerable{T})"/>
|
||||
/// 4) Replace - all items are properly updated with a new value and/or parent via <see cref="SortedTree{T, TKey}.TryReplace(TKey, Func{T, T})"/>
|
||||
/// a) delegate returns new value
|
||||
/// b) delegate mutates existing value
|
||||
/// - failing to account for this usage led to a bug in the OrderBook ca. 12/20/2018 (https://bluetradesys.atlassian.net/browse/SPARK-1903)
|
||||
|
||||
// 1) Constructor Initialization
|
||||
var tree_asc = new SortedTree<Order, int>(Order.name_asc, id, pid, input);
|
||||
@@ -154,6 +157,7 @@ namespace bts.tests {
|
||||
// 4) Replace
|
||||
tree_asc.Reset(input);
|
||||
tree_desc.Reset(input);
|
||||
//// a) delegate returns new value
|
||||
var modified_input = _randomize_values(input);
|
||||
foreach (var v in modified_input) {
|
||||
Assert.IsTrue(tree_asc.TryReplace(id(v), _ => v));
|
||||
@@ -162,7 +166,31 @@ namespace bts.tests {
|
||||
// verify asc/desc
|
||||
assert_state_then_clear(tree_asc, modified_input, Order.name_asc);
|
||||
assert_state_then_clear(tree_desc, modified_input, Order.name_desc);
|
||||
|
||||
// reset with modified_input since we are mutating next ('input' is essentially a global variable, shared across the test iterations).
|
||||
tree_asc.Reset(modified_input);
|
||||
tree_desc.Reset(modified_input);
|
||||
//// b) delegate mutates existing value
|
||||
for (int i = 0; i < modified_input.Count; i++) {
|
||||
var a = modified_input[i];
|
||||
var b = modified_input[modified_input.Count - i - 1];
|
||||
var swap_name = _swap_name_del(b.name);
|
||||
var swap_parent = _swap_parent_del(b.parent_id);
|
||||
var swap_both = _swap_name_and_parent_del(b.name, b.parent_id);
|
||||
var reset = _swap_name_and_parent_del(a.name, a.parent_id);
|
||||
foreach (var tree in new[] { tree_asc, tree_desc }) {
|
||||
Assert.IsTrue(tree.TryReplace(id(a), swap_name));
|
||||
Assert.IsTrue(tree.TryReplace(id(a), swap_parent));
|
||||
// reset 'a' so swap_both will actually change values (we already swapped name and parent individually above).
|
||||
Assert.IsTrue(tree.TryReplace(id(a), reset));
|
||||
Assert.IsTrue(tree.TryReplace(id(a), swap_both));
|
||||
// reset 'a' to finish. Since tree_asc/desc share the same actual orders, this protects the other tree from becoming unsorted as a result of the mutations.
|
||||
Assert.IsTrue(tree.TryReplace(id(a), reset));
|
||||
}
|
||||
}
|
||||
// verify asc/desc
|
||||
assert_state_then_clear(tree_asc, modified_input, Order.name_asc);
|
||||
assert_state_then_clear(tree_desc, modified_input, Order.name_desc);
|
||||
// local methods
|
||||
void assert_state_then_clear(SortedTree<Order, int> tree, IEnumerable<Order> vals, IComparer<Order> comp) {
|
||||
Assert.IsTrue(tree.SequenceEqual(_hierarchically_sorted_list(vals, comp)));
|
||||
clear_action(tree);
|
||||
@@ -265,6 +293,20 @@ namespace bts.tests {
|
||||
return reshuffled;
|
||||
}
|
||||
|
||||
Func<Order, Order> _swap_name_del(char name) => o => {
|
||||
o.name = name;
|
||||
return o;
|
||||
};
|
||||
Func<Order, Order> _swap_parent_del(int parent) => o => {
|
||||
o.parent_id = parent;
|
||||
return o;
|
||||
};
|
||||
Func<Order, Order> _swap_name_and_parent_del(char name, int parent) => o => {
|
||||
o.name = name;
|
||||
o.parent_id = parent;
|
||||
return o;
|
||||
};
|
||||
|
||||
void _write_tree_to_console(SortedTree<Order, int> tree) {
|
||||
foreach (var str in _fmt_output(tree.RootNodes))
|
||||
Console.WriteLine(str);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/* -------------------------------------------------------------------------------- */
|
||||
/* Main tables */
|
||||
/* -------------------------------------------------------------------------------- */
|
||||
create table if not exists
|
||||
session (
|
||||
version TEXT,
|
||||
@@ -5,6 +8,7 @@ session (
|
||||
build_type TEXT,
|
||||
session_start TIMESTAMP PRIMARY KEY
|
||||
);
|
||||
create index if not exists session_idx on session(session_start);
|
||||
|
||||
create table if not exists
|
||||
trace (
|
||||
@@ -20,55 +24,46 @@ trace (
|
||||
sn INTEGER,
|
||||
uint32_1 INTEGER
|
||||
);
|
||||
|
||||
drop view if exists recent_trace;
|
||||
create view recent_trace as
|
||||
select * from trace order by rowid desc limit 140123;
|
||||
|
||||
create index if not exists trace_idx on trace(session_start,channel,sn,ts);
|
||||
create index if not exists trace_t_idx on trace(session_start,ts);
|
||||
|
||||
drop view if exists ordered_trace;
|
||||
create view ordered_trace as
|
||||
select
|
||||
recent_trace.*,
|
||||
row_number() over (order by session_start,ts) entry_rank
|
||||
from
|
||||
recent_trace;
|
||||
/* -------------------------------------------------------------------------------- */
|
||||
/* Main Views */
|
||||
/* -------------------------------------------------------------------------------- */
|
||||
|
||||
drop view if exists delta_trace;
|
||||
create view delta_trace as
|
||||
/* An ordered view of the traces, with extra columns for the delta
|
||||
betwen consecutive traces as well as the delta between related
|
||||
(scoped) traces */
|
||||
drop view if exists log_view;
|
||||
create view log_view as
|
||||
select
|
||||
current.*,
|
||||
(current.ts - previous.ts) / 1000.0 delta
|
||||
from
|
||||
ordered_trace current,
|
||||
ordered_trace previous
|
||||
where
|
||||
current.entry_rank = previous.entry_rank+1;
|
||||
|
||||
drop view if exists log;
|
||||
create view log as
|
||||
select
|
||||
delta_trace.*,
|
||||
trace.*,
|
||||
trace.rowid entry_id,
|
||||
(ts-lag(ts) over by_session_ts)/1000.0 delta,
|
||||
case cor_event>0 when 1 then (ts-cor_event)/1000.0 else 0 end scope_delta,
|
||||
case cor_event>0 when 1 then "end of " || entry_kind else entry_kind end scoped_entry
|
||||
from
|
||||
delta_trace;
|
||||
|
||||
drop view if exists events;
|
||||
create view events as
|
||||
trace
|
||||
window
|
||||
by_session_ts as (order by session_start,ts);
|
||||
|
||||
/* A view identifying each high level event (requote or hedge) and
|
||||
annotating it with its latency */
|
||||
drop view if exists event_view;
|
||||
create view event_view as
|
||||
select
|
||||
fix_reads.session_start,
|
||||
"hedge" event_type,
|
||||
fix_reads.hts hts_start,
|
||||
fix_reads.entry_id event_id,
|
||||
fix_reads.ts start,
|
||||
fix_writes.ts stop,
|
||||
(fix_writes.ts - fix_reads.ts) / 1000.0 duration,
|
||||
row_number() over (order by fix_reads.session_start,fix_reads.ts,fix_writes.ts) event_rank ,
|
||||
fix_reads.channel,
|
||||
fix_reads.sn
|
||||
from
|
||||
(select session_start, channel, sn, ts from recent_trace where entry_kind='fix_msg_r') fix_reads,
|
||||
(select session_start, channel, sn, ts from recent_trace where entry_kind='before_fix_socket_w') fix_writes
|
||||
(select session_start, channel, sn, hts,ts,rowid entry_id from trace where entry_kind='fix_msg_r') fix_reads,
|
||||
(select session_start, channel, sn, hts,ts,rowid entry_id from trace where entry_kind='before_fix_socket_w') fix_writes
|
||||
where
|
||||
fix_reads.session_start = fix_writes.session_start and
|
||||
fix_reads.channel = fix_writes.channel and
|
||||
@@ -77,35 +72,168 @@ union
|
||||
select
|
||||
md_reads.session_start,
|
||||
"requote" event_type,
|
||||
md_reads.hts hts_start,
|
||||
md_reads.entry_id event_id,
|
||||
md_reads.ts start,
|
||||
fix_writes.ts stop,
|
||||
(fix_writes.ts - md_reads.ts) / 1000.0 duration,
|
||||
row_number() over (order by md_reads.session_start,md_reads.ts,fix_writes.ts) event_rank ,
|
||||
md_reads.channel,
|
||||
md_reads.sn
|
||||
from
|
||||
(select session_start, channel, sn, ts from recent_trace where entry_kind='md') md_reads,
|
||||
(select session_start, channel, sn, ts from recent_trace where entry_kind='before_fix_socket_w') fix_writes
|
||||
(select session_start, channel, sn, hts,ts,rowid entry_id from trace where entry_kind='md') md_reads,
|
||||
(select session_start, channel, sn, hts,ts,rowid entry_id from trace where entry_kind='before_fix_socket_w') fix_writes
|
||||
where
|
||||
md_reads.session_start = fix_writes.session_start and
|
||||
md_reads.channel = fix_writes.channel and
|
||||
md_reads.sn = fix_writes.sn;
|
||||
|
||||
drop view if exists event_log;
|
||||
create view event_log as
|
||||
|
||||
/* A view on hedge events, identifying each order sent as part of the event*/
|
||||
drop view if exists hedge_trace_view;
|
||||
create view hedge_trace_view as
|
||||
select
|
||||
log.*,
|
||||
event_type,
|
||||
event_rank,
|
||||
events.duration event_duration,
|
||||
events.start event_start,
|
||||
events.stop event_stop
|
||||
session.version,
|
||||
session.host,
|
||||
session.build_type,
|
||||
session.session_start,
|
||||
trace.hts trace_time,
|
||||
uint64_1 order_key,
|
||||
duration total,
|
||||
event_id
|
||||
from
|
||||
log,
|
||||
events
|
||||
event_view,
|
||||
trace,
|
||||
session
|
||||
where
|
||||
log.session_start = events.session_start and
|
||||
log.ts >= events.start and log.ts <= events.stop;
|
||||
session.session_start = trace.session_start and
|
||||
session.session_start = event_view.session_start and
|
||||
event_view.channel=trace.channel and event_view.sn=trace.sn and
|
||||
event_type='hedge' and
|
||||
entry_kind='NativeOrder::on_activate' and
|
||||
cor_event=0;
|
||||
|
||||
/* A view on requote events, identifying each order sent as part of the event*/
|
||||
drop view if exists requote_trace_view;
|
||||
create view requote_trace_view as
|
||||
select
|
||||
session.version,
|
||||
session.host,
|
||||
session.build_type,
|
||||
session.session_start,
|
||||
trace.hts trace_time,
|
||||
uint64_1 order_key,
|
||||
duration total,
|
||||
event_id
|
||||
from
|
||||
event_view,
|
||||
trace,
|
||||
session
|
||||
where
|
||||
session.session_start = trace.session_start and
|
||||
session.session_start = event_view.session_start and
|
||||
event_view.channel=trace.channel and event_view.sn=trace.sn and
|
||||
event_type='requote' and
|
||||
entry_kind='NativeOrder::on_update' and
|
||||
cor_event=0;
|
||||
|
||||
/* -------------------------------------------------------------------------------- */
|
||||
/* Archive tables/view */
|
||||
/* -------------------------------------------------------------------------------- */
|
||||
|
||||
/* Auxiliary tables and views, used to archive the results of the main
|
||||
views to speed up analysis as data accumulates */
|
||||
|
||||
create table if not exists
|
||||
event_archive (
|
||||
session_start TIMESTAMP,
|
||||
event_type TEXT,
|
||||
hts_start TIMESTAMP,
|
||||
event_id INTEGER,
|
||||
start INTEGER,
|
||||
stop INTEGER,
|
||||
duration float,
|
||||
channel TEXT,
|
||||
sn INTEGER
|
||||
);
|
||||
create index if not exists event_archive_idx on event_archive(session_start,start,stop);
|
||||
|
||||
create table if not exists
|
||||
log_archive(
|
||||
session_start TIMESTAMP,
|
||||
ts INTEGER,
|
||||
hts timestamp,
|
||||
channel TEXT,
|
||||
entry_kind TEXT,
|
||||
txt_1 TEXT,
|
||||
uint64_1 INTEGER,
|
||||
thread TEXT,
|
||||
cor_event INTEGER,
|
||||
sn INTEGER,
|
||||
uint32_1 INTEGER,
|
||||
entry_id INTEGER,
|
||||
delta float,
|
||||
scope_delta float,
|
||||
scoped_entry TEXT
|
||||
);
|
||||
create index if not exists log_archive_idx on log_archive(session_start,ts);
|
||||
|
||||
create table if not exists
|
||||
hedge_trace_archive (
|
||||
version TEXT,
|
||||
host TEXT,
|
||||
build_type TEXT,
|
||||
session_start TIMESTAMP,
|
||||
trace_time TIMESTAMP,
|
||||
order_key INTEGER,
|
||||
total float,
|
||||
event_id integer
|
||||
);
|
||||
drop view if exists hedge_trace;
|
||||
create view hedge_trace as
|
||||
select * from hedge_trace_view union select * from hedge_trace_archive;
|
||||
|
||||
create table if not exists
|
||||
requote_trace_archive (
|
||||
version TEXT,
|
||||
host TEXT,
|
||||
build_type TEXT,
|
||||
session_start TIMESTAMP,
|
||||
trace_time TIMESTAMP,
|
||||
order_key INTEGER,
|
||||
total float,
|
||||
event_id integer
|
||||
);
|
||||
drop view if exists requote_trace;
|
||||
create view requote_trace as
|
||||
select * from requote_trace_view union select * from requote_trace_archive;
|
||||
|
||||
|
||||
/* a synthetis of the log and events, focusing only on traces that are
|
||||
part of hedge/requote events */
|
||||
create table if not exists
|
||||
event_log_archive (
|
||||
session_start TIMESTAMP,
|
||||
ts INTEGER,
|
||||
hts timestamp,
|
||||
channel TEXT,
|
||||
entry_kind TEXT,
|
||||
txt_1 TEXT,
|
||||
uint64_1 INTEGER,
|
||||
thread TEXT,
|
||||
cor_event INTEGER,
|
||||
sn INTEGER,
|
||||
uint32_1 INTEGER,
|
||||
entry_id INTEGER,
|
||||
delta float,
|
||||
scope_delta float,
|
||||
scoped_entry TEXT,
|
||||
event_type TEXT,
|
||||
event_id INTEGER,
|
||||
event_duration float,
|
||||
hts_start TIMESTAMP,
|
||||
event_start INTEGER,
|
||||
event_stop INTEGER
|
||||
);
|
||||
create index if not exists event_log_archive_idx on event_log_archive(session_start);
|
||||
|
||||
drop view if exists pretty_log;
|
||||
create view pretty_log as
|
||||
@@ -115,69 +243,81 @@ select
|
||||
scope_delta ,
|
||||
event_duration,
|
||||
event_type,
|
||||
event_rank,
|
||||
event_id,
|
||||
hts,
|
||||
ts,
|
||||
session_start,
|
||||
entry_rank
|
||||
entry_id
|
||||
from
|
||||
event_log;
|
||||
event_log_archive;
|
||||
|
||||
drop view if exists last_pretty_log;
|
||||
create view last_pretty_log as
|
||||
select * from pretty_log where session_start=(select max(session_start) from session);
|
||||
select
|
||||
*
|
||||
from
|
||||
pretty_log
|
||||
where
|
||||
session_start=(select max(session_start) from session);
|
||||
|
||||
-- drop view if exists summary;
|
||||
-- create view summary as
|
||||
-- select session_start,event_type,count(*) count, avg(duration) avg, max(duration) max, min(duration) min, median(duration) median, stdev(duration) stdev from events group by session_start,event_type;
|
||||
/*
|
||||
drop view if exists event_stats;
|
||||
create view event_stats as
|
||||
select
|
||||
session_start,
|
||||
event_type,
|
||||
count(*) count,
|
||||
avg(duration) avg,
|
||||
max(duration) max,
|
||||
min(duration) min,
|
||||
median(duration) median,
|
||||
stdev(duration) stdev
|
||||
from
|
||||
event_archive
|
||||
group by
|
||||
session_start,
|
||||
event_type;
|
||||
*/
|
||||
|
||||
drop view if exists event_log_aux;
|
||||
create view event_log_aux as
|
||||
select
|
||||
log_archive.*,
|
||||
event_type,
|
||||
event_id,
|
||||
event_archive.duration event_duration,
|
||||
event_archive.hts_start hts_start,
|
||||
event_archive.start event_start,
|
||||
event_archive.stop event_stop
|
||||
from
|
||||
log_archive,
|
||||
event_archive
|
||||
where
|
||||
log_archive.session_start = event_archive.session_start and
|
||||
log_archive.ts >= event_archive.start and log_archive.ts <= event_archive.stop;
|
||||
|
||||
begin transaction;
|
||||
insert into hedge_trace_archive select * from hedge_trace_view;
|
||||
insert into requote_trace_archive select * from requote_trace_view;
|
||||
insert into event_archive select * from event_view;
|
||||
insert into log_archive select * from log_view;
|
||||
insert into event_log_archive select * from event_log_aux;
|
||||
|
||||
drop view if exists hedge_trace;
|
||||
create view hedge_trace as
|
||||
select
|
||||
session.version,
|
||||
session.host,
|
||||
session.build_type,
|
||||
session.session_start,
|
||||
recent_trace.hts trace_time,
|
||||
recent_trace.uint64_1 order_key,
|
||||
hedge_events.duration total,
|
||||
hedge_events.event_rank rank
|
||||
from
|
||||
recent_trace,
|
||||
(select * from events where event_type='hedge') hedge_events,
|
||||
session
|
||||
where
|
||||
entry_kind='NativeOrder::on_activate' and
|
||||
recent_trace.cor_event = 0 and
|
||||
recent_trace.channel = hedge_events.channel and
|
||||
recent_trace.session_start = hedge_events.session_start and
|
||||
recent_trace.sn = hedge_events.sn and
|
||||
recent_trace.session_start = session.session_start;
|
||||
delete from trace;
|
||||
|
||||
drop view if exists requote_trace;
|
||||
create view requote_trace as
|
||||
select
|
||||
session.version,
|
||||
session.host,
|
||||
session.build_type,
|
||||
session.session_start,
|
||||
recent_trace.hts trace_time,
|
||||
recent_trace.uint64_1 order_key,
|
||||
requote_events.duration total,
|
||||
requote_events.event_rank rank
|
||||
from
|
||||
recent_trace,
|
||||
(select * from events where event_type='requote') requote_events,
|
||||
session
|
||||
where
|
||||
entry_kind='NativeOrder::on_update' and
|
||||
recent_trace.cor_event = 0 and
|
||||
recent_trace.channel = requote_events.channel and
|
||||
recent_trace.session_start = requote_events.session_start and
|
||||
recent_trace.sn = requote_events.sn and
|
||||
recent_trace.session_start = session.session_start ;
|
||||
delete from event_log_archive where
|
||||
rowid in (select rowid from event_log_archive order by rowid desc limit -1 offset 10000123);
|
||||
|
||||
delete from trace where
|
||||
rowid in (select rowid from trace order by rowid desc limit -1 offset 10000123);
|
||||
delete from hedge_trace_archive where
|
||||
rowid in (select rowid from hedge_trace_archive order by rowid desc limit -1 offset 10000123);
|
||||
|
||||
delete from requote_trace_archive where
|
||||
rowid in (select rowid from requote_trace_archive order by rowid desc limit -1 offset 10000123);
|
||||
|
||||
delete from log_archive where
|
||||
rowid in (select rowid from log_archive order by rowid desc limit -1 offset 10000123);
|
||||
|
||||
delete from event_log_archive where
|
||||
rowid in (select rowid from event_log_archive order by rowid desc limit -1 offset 10000123);
|
||||
commit;
|
||||
|
||||
@@ -1 +1 @@
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/services/AdminService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGateway.cpp;jetfix/gateway/Session.cpp;jetfix/store/FIXFileStore.cpp;jetfix/store/session_name.cpp;jetfix/tests/async_reader_tests.cpp;jetfix/tests/decoding_tests.cpp;jetfix/tests/fix_encoding_stream_tests.cpp;jetfix/tests/fix_fragment_tests.cpp;jetfix/tests/jetfix_performance_tests.cpp;jetfix/tests/sample_fix.cpp;jetfix/tests/store_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;mercury/actors/IPollableActor.cpp;mercury/broker/Broker.cpp;mercury/broker/BrokerProxy.cpp;mercury/broker/ILocalBroker.cpp;mercury/broker/IRemoteBroker.cpp;mercury/common/mercury_common.cpp;mercury/events/TimerEvent.cpp;mercury/executor/Executor.cpp;mercury/topics/Topic.cpp;metrics/metrics.cpp;metrics/system_metrics.cpp;orderman/actors/AsyncFactory.cpp;orderman/actors/ExecutionGateway.cpp;orderman/actors/FillStore.cpp;orderman/actors/MDSupplementarySource.cpp;orderman/actors/OrderStore.cpp;orderman/actors/SODPosition.cpp;orderman/actors/SecuritySrc.cpp;orderman/actors/ServiceBridge.cpp;orderman/actors/order_manager/OrderBuilder.cpp;orderman/actors/order_manager/OrderManager.cpp;orderman/actors/order_manager/OrderServicesData.cpp;orderman/events/CancelRejectEvent.cpp;orderman/events/NewExecutionReportEvent.cpp;orderman/limiter/LimitStore.cpp;orderman/limiter/Limiter.cpp;orderman/limiter/ProductLimitNode.cpp;orderman/limiter/ProductLimitTree.cpp;orderman/limiter/SecurityLimitNode.cpp;orderman/limiter/SecurityLimitTree.cpp;orderman/limiter/tests/limit_tests.cpp;orderman/order_factory/DynaLine truncated
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/services/AdminService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp)
|
||||
@@ -31,8 +31,9 @@ namespace {{package}} {
|
||||
public {{name}} CloneToMutable() { return _impl.Clone(); }
|
||||
|
||||
// Implicit conversion operator
|
||||
public static implicit operator {{name}}Immutable({{name}} other) {
|
||||
return new {{name}}Immutable(other, false);
|
||||
public static implicit operator Nullable<{{name}}Immutable>({{name}} other) {
|
||||
if (other == null) return null;
|
||||
else return new {{name}}Immutable(other, false);
|
||||
}
|
||||
|
||||
public override bool Equals(object other) {
|
||||
|
||||
@@ -110,6 +110,7 @@ message CMEOptions
|
||||
|
||||
// Prevents parsing trades/rfqs/doing anything not required for quoting
|
||||
optional bool quoter_mode = 6;
|
||||
optional bool verbose_ticker = 7 [default=false];
|
||||
}
|
||||
|
||||
message RecordOptions {
|
||||
@@ -123,8 +124,8 @@ message RecordOptions {
|
||||
//
|
||||
message ReplayOptions {
|
||||
optional string host = 1 [default = "mdreplay"];
|
||||
optional string base_path = 2 [default = "/md"];
|
||||
optional string file_name = 3 [default = "options.coconut"];
|
||||
optional string base_path = 2 [default = "/spark"];
|
||||
optional string file_name = 3 [default = "futures.coconut"];
|
||||
|
||||
// 2.0 = double speed, 0.5 = half speed
|
||||
optional double speed = 11 [default = 1.0];
|
||||
|
||||
@@ -3,7 +3,6 @@ package bts.config;
|
||||
|
||||
message PerfLogCfg {
|
||||
optional bool active = 1 [default=true];
|
||||
optional uint32 recent_traces_size = 2 [default=140123];
|
||||
optional uint32 max_rows = 3 [default=10000123];
|
||||
optional uint32 entry_batch_size = 4 [default=200];
|
||||
}
|
||||
@@ -109,7 +109,8 @@ int SocketConnection::write(WriteVec const &vec, size_t vec_size,
|
||||
_perf_log.log(trace,"before_fix_socket_w");
|
||||
auto result = ::writev(_fd, iv, (int)vec_size);
|
||||
_perf_log.log(trace,"after_fix_socket_w");
|
||||
_perf_log.flush();
|
||||
if (trace.sn)
|
||||
_perf_log.flush();
|
||||
|
||||
if (_log && result > 0) {
|
||||
for (size_t i = 0; i < vec_size; i++)
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "lib/utils/TimeStamp.h"
|
||||
#include "lib/utils/Dispatcher.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/config/protos/system.pb.h"
|
||||
#include "lib/utils/thread_manager.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -72,6 +74,7 @@ std::string print_book(
|
||||
<< e.security->id() << ","
|
||||
<< seq << ","
|
||||
<< (ambiguous ? "true," : "false,")
|
||||
<< (e.handle.status() == co2::COCONUTSECURITYSTATUS_OK ? "OK," : "GAP,")
|
||||
<< twrite.to_uint64() << ","
|
||||
<< tread.to_uint64() << ",";
|
||||
for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) {
|
||||
@@ -138,7 +141,7 @@ void write_header(PrintFormat format, long seq_mod, const std::vector<Entry>& en
|
||||
}
|
||||
else {
|
||||
// CSV header
|
||||
std::cout << "Symbol,Id,Sequence,Ambiguous,TWrite,TRead,BidBook,AskBook";
|
||||
std::cout << "Symbol,Id,Sequence,Ambiguous,Status,TWrite,TRead,BidBook,AskBook";
|
||||
// for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) {
|
||||
// std::cout << "," << "Bid" << x << ", DirectBidSize" << x << ", ImpliedBidSize" << x;
|
||||
// }
|
||||
@@ -149,7 +152,11 @@ void write_header(PrintFormat format, long seq_mod, const std::vector<Entry>& en
|
||||
}
|
||||
}
|
||||
|
||||
void run_periodic_dumper(const std::set<UserSymbol>& symbols, uint32_t seq_mod, PrintFormat format) {
|
||||
void run_periodic_dumper(const std::set<UserSymbol>& symbols, uint32_t seq_mod, PrintFormat format, bool monitor_all) {
|
||||
|
||||
auto qualifier = config::get<config::System>().qualifier();
|
||||
auto thread_name = "tail-" + qualifier;
|
||||
threading::configure_current_thread(thread_name);
|
||||
|
||||
MDConsumer consumer(symbols, nullptr);
|
||||
|
||||
@@ -159,7 +166,9 @@ void run_periodic_dumper(const std::set<UserSymbol>& symbols, uint32_t seq_mod,
|
||||
entries.push_back({ 0, handle, std::make_unique<api::Security>(sec) });
|
||||
});
|
||||
|
||||
entries = filter_entries(entries);
|
||||
if (!monitor_all) {
|
||||
entries = filter_entries(entries);
|
||||
}
|
||||
|
||||
write_header(format, seq_mod, entries);
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ enum class PrintFormat {
|
||||
CSV
|
||||
};
|
||||
|
||||
void run_periodic_dumper(const std::set<UserSymbol>&, uint32_t seq_mod, PrintFormat format);
|
||||
|
||||
void run_periodic_dumper(const std::set<UserSymbol>&, uint32_t seq_mod, PrintFormat format, bool monitor_all);
|
||||
|
||||
|
||||
}}//ns
|
||||
@@ -25,8 +25,10 @@ class OrderStateUpdateEvent : public mercury::Event<OrderStateUpdateEvent> {
|
||||
last_price = state.last_price();
|
||||
avg_price = state.avg_price();
|
||||
last_msg = state.last_msg();
|
||||
display_status = state.display_status();
|
||||
|
||||
custom = state.custom_case();
|
||||
|
||||
|
||||
auto native_state = get_native_state(state);
|
||||
if (native_state) {
|
||||
exchange_order_id = native_state->exchange_order_id();
|
||||
@@ -50,7 +52,8 @@ class OrderStateUpdateEvent : public mercury::Event<OrderStateUpdateEvent> {
|
||||
double last_price;
|
||||
double avg_price;
|
||||
std::string last_msg;
|
||||
|
||||
api::orderman::OrderState::DisplayStatus display_status;
|
||||
|
||||
trace::CorID trace;
|
||||
api::orderman::OrderState::CustomCase custom;
|
||||
|
||||
@@ -74,7 +77,8 @@ class OrderStateUpdateEvent : public mercury::Event<OrderStateUpdateEvent> {
|
||||
result.set_last_price(last_price);
|
||||
result.set_avg_price(avg_price);
|
||||
result.set_last_msg(last_msg);
|
||||
|
||||
result.set_display_status(display_status);
|
||||
|
||||
switch (custom) {
|
||||
case api::orderman::OrderState::kMarket:
|
||||
rebuild_native_state(result.mutable_market()->mutable_native_state());
|
||||
|
||||
@@ -72,8 +72,22 @@ Order &OrderFactory::create(OrderKey parent,
|
||||
auto k = gen_order_id();
|
||||
auto pk = parent;
|
||||
auto &order = allocate(k, pk, def);
|
||||
order.on_init_new(def,
|
||||
PreActivationOrderServices{me->sec_db, *this, me->router});
|
||||
|
||||
// For non native orders we force the ManalOrderIndicator to be 'N'
|
||||
// since all non native order are algos and we would rather not
|
||||
// rely on the order creator (be it shell or another algo) to set
|
||||
// this correctly for every single algo.
|
||||
if (dynamic_cast<NativeOrder *>(&order) == nullptr &&
|
||||
def.manual_order_indicator() ==
|
||||
api::orderman::MANUAL_ORDER_INDICATOR_YES) {
|
||||
auto corrected_def = def;
|
||||
corrected_def.set_manual_order_indicator(
|
||||
api::orderman::MANUAL_ORDER_INDICATOR_NO);
|
||||
order.on_init_new(corrected_def, PreActivationOrderServices{
|
||||
me->sec_db, *this, me->router});
|
||||
} else
|
||||
order.on_init_new(
|
||||
def, PreActivationOrderServices{me->sec_db, *this, me->router});
|
||||
return order;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ fi
|
||||
|
||||
SQLLITE=../../../../externals/linux/bin/sqlite3
|
||||
SQLITE_EXT=../../../../externals/linux/bin/libsqlitefunctions
|
||||
DB=file:$HOME/sparkdata/data/databases/perf_log/perf_log.sqlite?mode=ro
|
||||
DB=file:$HOME/sparkdata/data/databases/perf_log/perf_log.sqlite
|
||||
|
||||
if [ $# -eq 1 ]
|
||||
then
|
||||
@@ -28,6 +28,19 @@ else
|
||||
SESSION=\'$2\'
|
||||
fi
|
||||
|
||||
echo Generating stats...
|
||||
$SQLLITE $DB<<EOF
|
||||
begin transaction;
|
||||
insert into hedge_trace_archive select * from hedge_trace_view;
|
||||
insert into requote_trace_archive select * from requote_trace_view;
|
||||
insert into event_archive select * from event_view;
|
||||
insert into log_archive select * from log_view;
|
||||
insert into event_log_archive select * from event_log_aux;
|
||||
delete from trace;
|
||||
commit;
|
||||
EOF
|
||||
echo Done
|
||||
|
||||
if [ $1 == "log" ]; then
|
||||
$SQLLITE $DB<<EOF
|
||||
.mode column
|
||||
@@ -52,15 +65,23 @@ $SQLLITE $DB<<EOF
|
||||
.mode column
|
||||
.headers on
|
||||
.load $SQLITE_EXT
|
||||
select
|
||||
session_start,event_type,count(*) count, avg(duration) avg,
|
||||
max(duration) max, min(duration) min, median(duration) median,
|
||||
stdev(duration) stdev
|
||||
from events where session_start=$SESSION group by session_start,event_type;
|
||||
select
|
||||
session_start,
|
||||
event_type,
|
||||
count(*) count,
|
||||
avg(duration) avg,
|
||||
max(duration) max,
|
||||
min(duration) min,
|
||||
median(duration) median,
|
||||
stdev(duration) stdev
|
||||
from
|
||||
event_archive
|
||||
where
|
||||
session_start=$SESSION
|
||||
group by
|
||||
event_type
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
help()
|
||||
|
||||
|
||||
+55
-33
@@ -3,9 +3,10 @@
|
||||
#include "lib/config/protos/perflog_cfg.pb.h"
|
||||
#include "lib/config/protos/system.pb.h"
|
||||
#include "lib/persistence/persistence_utils.h"
|
||||
#include "lib/utils/bts_array_size.h"
|
||||
#include "lib/utils/datetime.h"
|
||||
#include "lib/utils/stats.h"
|
||||
#include "lib/utils/bts_array_size.h"
|
||||
#include "lib/utils/thread_manager.h"
|
||||
|
||||
#include <SQLiteCpp/SQLiteCpp.h>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
@@ -81,6 +82,8 @@ struct PerfLog::PImpl {
|
||||
std::string session_start;
|
||||
boost::circular_buffer<PerfLogEntry> entry_batch;
|
||||
std::mutex lock;
|
||||
std::thread init_thread;
|
||||
std::atomic<bool> init_completed;
|
||||
};
|
||||
|
||||
PerfLog::PerfLog() : _pending(), _disabled(false), me() {
|
||||
@@ -98,38 +101,56 @@ PerfLog::PerfLog() : _pending(), _disabled(false), me() {
|
||||
|
||||
try {
|
||||
me = std::make_unique<PImpl>(loc);
|
||||
init_db();
|
||||
|
||||
me->insert_trace_statement =
|
||||
std::make_unique<SQLite::Statement>(me->db, insert_trace);
|
||||
me->insert_session_statement =
|
||||
std::make_unique<SQLite::Statement>(me->db, insert_session);
|
||||
me->requote_query_statement =
|
||||
std::make_unique<SQLite::Statement>(me->db, requote_query);
|
||||
me->hedge_query_statement =
|
||||
std::make_unique<SQLite::Statement>(me->db, hedge_query);
|
||||
me->session_start = datetime::FIX_timestamp(datetime::local_now());
|
||||
|
||||
me->insert_session_statement->bind(
|
||||
":version", config::get<config::System>().version());
|
||||
me->insert_session_statement->bind(
|
||||
":host", config::get<config::System>().host_name());
|
||||
#ifdef DEBUG
|
||||
me->insert_session_statement->bind(":build_type", "debug");
|
||||
#else
|
||||
me->insert_session_statement->bind(":build_type", "release");
|
||||
#endif
|
||||
me->insert_session_statement->bind(":session_start", me->session_start);
|
||||
me->insert_session_statement->exec();
|
||||
me->insert_session_statement->reset();
|
||||
} catch (SQLite::Exception const &e) {
|
||||
LOG(persist, Error, "Error initializing perf_trace DB {}. Error: {}", loc,
|
||||
std::string(e.getErrorStr()));
|
||||
_disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
me->init_completed = false;
|
||||
me->init_thread = threading::make_thread("perf_log_ini", [loc,this]() {
|
||||
try {
|
||||
LOG(persist,Info, "Started initialization of perf_log db");
|
||||
init_db();
|
||||
|
||||
me->insert_trace_statement =
|
||||
std::make_unique<SQLite::Statement>(me->db, insert_trace);
|
||||
me->insert_session_statement =
|
||||
std::make_unique<SQLite::Statement>(me->db, insert_session);
|
||||
me->requote_query_statement =
|
||||
std::make_unique<SQLite::Statement>(me->db, requote_query);
|
||||
me->hedge_query_statement =
|
||||
std::make_unique<SQLite::Statement>(me->db, hedge_query);
|
||||
me->session_start = datetime::FIX_timestamp(datetime::local_now());
|
||||
|
||||
me->insert_session_statement->bind(
|
||||
":version", config::get<config::System>().version());
|
||||
me->insert_session_statement->bind(
|
||||
":host", config::get<config::System>().host_name());
|
||||
#ifdef DEBUG
|
||||
me->insert_session_statement->bind(":build_type", "debug");
|
||||
#else
|
||||
me->insert_session_statement->bind(":build_type", "release");
|
||||
#endif
|
||||
me->insert_session_statement->bind(":session_start",
|
||||
me->session_start);
|
||||
me->insert_session_statement->exec();
|
||||
me->insert_session_statement->reset();
|
||||
} catch (SQLite::Exception const &e) {
|
||||
LOG(persist, Error,
|
||||
"Error initializing perf_trace DB (2) {}. Error: {}", loc,
|
||||
std::string(e.getErrorStr()));
|
||||
_disabled = true;
|
||||
}
|
||||
LOG(persist,Info, "Finished initialization of perf_log db");
|
||||
me->init_completed = true;
|
||||
});
|
||||
}
|
||||
|
||||
PerfLog::~PerfLog() {}
|
||||
PerfLog::~PerfLog() {
|
||||
me->init_thread.join();
|
||||
}
|
||||
|
||||
std::string PerfLog::init_storage_location() {
|
||||
auto loc = persistence::storage_location("perf_log");
|
||||
@@ -145,7 +166,7 @@ std::string PerfLog::init_storage_location() {
|
||||
}
|
||||
|
||||
size_t PerfLog::store_log_entries() {
|
||||
if (_disabled) {
|
||||
if (!me->init_completed || _disabled) {
|
||||
_pending.clear();
|
||||
return 0;
|
||||
}
|
||||
@@ -167,9 +188,6 @@ void PerfLog::init_db() {
|
||||
std::string str((std::istreambuf_iterator<char>(f)),
|
||||
(std::istreambuf_iterator<char>()));
|
||||
config::PerfLogCfg defaults;
|
||||
boost::replace_all(
|
||||
str, std::to_string(defaults.recent_traces_size()),
|
||||
std::to_string(config::get<config::PerfLogCfg>().recent_traces_size()));
|
||||
boost::replace_all(
|
||||
str, std::to_string(defaults.max_rows()),
|
||||
std::to_string(config::get<config::PerfLogCfg>().max_rows()));
|
||||
@@ -187,7 +205,9 @@ std::string encode_number(SQLite::Column const &c) {
|
||||
std::vector<std::map<std::string, std::string>>
|
||||
PerfLog::get_latest_requote_traces(size_t n) {
|
||||
std::vector<std::map<std::string, std::string>> result;
|
||||
|
||||
if (!me->init_completed)
|
||||
return result;
|
||||
|
||||
std::lock_guard<std::mutex> l(me->lock);
|
||||
try {
|
||||
me->requote_query_statement->bind(1, (long long)n);
|
||||
@@ -221,7 +241,9 @@ PerfLog::get_latest_requote_traces(size_t n) {
|
||||
std::vector<std::map<std::string, std::string>>
|
||||
PerfLog::get_latest_hedge_traces(size_t n) {
|
||||
std::vector<std::map<std::string, std::string>> result;
|
||||
|
||||
if (!me->init_completed)
|
||||
return result;
|
||||
|
||||
std::lock_guard<std::mutex> l(me->lock);
|
||||
try {
|
||||
me->hedge_query_statement->bind(1, (long long)n);
|
||||
@@ -276,7 +298,7 @@ size_t PerfLog::flush_current_batch_to_disk() {
|
||||
me->insert_trace_statement->bind(":cor_event",
|
||||
(long long)ev.cor_event.to_uint64());
|
||||
char tn[17];
|
||||
pthread_getname_np(ev.thread_id, tn, BTS_ARRAYSIZE(tn)-1);
|
||||
pthread_getname_np(ev.thread_id, tn, BTS_ARRAYSIZE(tn) - 1);
|
||||
me->insert_trace_statement->bind(":thread", tn);
|
||||
me->insert_trace_statement->exec();
|
||||
count++;
|
||||
|
||||
@@ -95,7 +95,6 @@ convert(const FIX::ManualOrderIndicator &moi) {
|
||||
struct ExchangeSimApplication::MDConsumerRec {
|
||||
api::Security security;
|
||||
utils::TimeStamp last_read;
|
||||
Book previous_md_book;
|
||||
};
|
||||
|
||||
struct ExchangeSimApplication::PImpl {
|
||||
@@ -456,6 +455,8 @@ void ExchangeSimApplication::update_md(std::string const &sec_desc) {
|
||||
|
||||
auto book = matcher.get_book();
|
||||
|
||||
LOG(ExSim, Diag, "Current book {}:\n {}", sec_desc,book);
|
||||
|
||||
auto price_factor = pow(10, handle.security().display_factor);
|
||||
|
||||
const auto cmax = md::COCONUT_MAX_DEPTH;
|
||||
@@ -525,7 +526,7 @@ void ExchangeSimApplication::on_new_security(api::Security const &s) {
|
||||
me->md_producer_handles.insert(make_pair(sec_desc, handle));
|
||||
me->md_consumer_recs.insert(
|
||||
make_pair(s.glbx().security_desc(),
|
||||
MDConsumerRec{s2, utils::TimeStamp::now(), Book()}));
|
||||
MDConsumerRec{s2, utils::TimeStamp::now()}));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -545,6 +546,7 @@ void ExchangeSimApplication::on_depth(
|
||||
md::PriceSize asks[md::COCONUT_MAX_DEPTH],
|
||||
std::array<md::PriceSize, md::COCONUT_MAX_IMPLIED_DEPTH>* implied_bids,
|
||||
std::array<md::PriceSize, md::COCONUT_MAX_IMPLIED_DEPTH>* implied_asks) {
|
||||
|
||||
std::lock_guard<std::mutex> l(me->lock);
|
||||
|
||||
if (sec.has_synthetic())
|
||||
@@ -556,8 +558,8 @@ void ExchangeSimApplication::on_depth(
|
||||
auto it = me->md_consumer_recs.find(sec.glbx().security_desc());
|
||||
bts_assert(it != me->md_consumer_recs.end());
|
||||
|
||||
// cache previous Book so we can update it place
|
||||
Book previous_md_book = it->second.previous_md_book;
|
||||
auto &matcher = me->matchers[get_sim_sec_desc(sec)];
|
||||
Book previous_md_book = matcher.get_book();
|
||||
|
||||
// populate Book structure with new bids, asks coming from outside
|
||||
Book current_md_book;
|
||||
@@ -572,9 +574,6 @@ void ExchangeSimApplication::on_depth(
|
||||
current_md_book.asks[a] = Quantity(asks[i].size());
|
||||
}
|
||||
|
||||
// update the indexed Book structure with the latest values
|
||||
it->second.previous_md_book = current_md_book;
|
||||
|
||||
// from the differences between current_md_book and previous_md_book
|
||||
// we generate a set of orders that we apply to our order book
|
||||
merge_with_order_book(it->second.security.glbx().security_desc(),
|
||||
@@ -597,6 +596,9 @@ void ExchangeSimApplication::merge_with_order_book(std::string const &sec_desc,
|
||||
auto src_book = matcher.get_book();
|
||||
auto transform = compute_book_transform(src, dest);
|
||||
|
||||
|
||||
LOG(ExSim, Diag, "Book transformation for {}\n source:\n {} dest:\n{}", sec_desc,src,dest);
|
||||
|
||||
for (auto const &op : transform) {
|
||||
|
||||
LOG(ExSim, Diag, "Adding synthetic book operation for {}. {} {} {}@{}",
|
||||
|
||||
@@ -19,6 +19,7 @@ MDP3Listener::MDP3Listener(
|
||||
const std::vector<MDProducerChannel> channels) :
|
||||
_index(index),
|
||||
_producer(producer),
|
||||
_verbose_ticker(config::get<CMEOptions>().verbose_ticker()),
|
||||
_packet_arrived(),
|
||||
_latest_sequence(0),
|
||||
// _settlement_recorder(settles),
|
||||
|
||||
@@ -182,6 +182,7 @@ private:
|
||||
|
||||
CMESecurityIndex& _index;
|
||||
MDProducer& _producer;
|
||||
bool _verbose_ticker;
|
||||
utils::TimeStamp _packet_arrived;
|
||||
uint32_t _latest_sequence;
|
||||
// co2::SettlementRecorder& _settlement_recorder;
|
||||
@@ -416,7 +417,17 @@ void MDP3Listener::onTradeSummary(const onixs::Security& sec, const TradeSummary
|
||||
onixs::Decimal price = arg.entry().entryPx();
|
||||
onixs::AggressorSide::Enum agside = onixs::AggressorSide::NoAggressor;
|
||||
arg.entry().aggressorSide(agside);
|
||||
on_trade(data, price, size, agside, arg.message().transactTime());
|
||||
if (_verbose_ticker) {
|
||||
const auto& details = arg.orderIds();
|
||||
auto sz = details.size();
|
||||
for (size_t x = 0; x < sz; ++x) {
|
||||
const auto& d = details[x];
|
||||
on_trade(data, price, d.lastQty(), agside, arg.message().transactTime());
|
||||
}
|
||||
}
|
||||
else {
|
||||
on_trade(data, price, size, agside, arg.message().transactTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +453,6 @@ void MDP3Listener::onSettlementPrice(const onixs::Security& sec, const Statistic
|
||||
onixs::Timestamp time;
|
||||
args.entry().entryPx(price);
|
||||
args.entry().tradingReferenceDate(time);
|
||||
// args.entry().
|
||||
auto display_factor = data->handle.security().display_factor;
|
||||
data->handle.update_settlement(
|
||||
utils::TimeStamp::now(),
|
||||
@@ -454,19 +464,16 @@ void MDP3Listener::onSettlementPrice(const onixs::Security& sec, const Statistic
|
||||
template <typename SessionArgs>
|
||||
void MDP3Listener::onSessionOpeningPrice(const onixs::Security& sec, const SessionArgs& args) {
|
||||
tracepoint (bts_trace,trace_order,(char*) "onOpeningPrice.session", _latest_sequence, (uint16_t) _latest_sequence, 0);
|
||||
// auto type = args.entry().settlPriceType();
|
||||
// if (type.final() && type.actual()) {
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
onixs::Decimal 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));
|
||||
}
|
||||
//
|
||||
auto* data = _index.get_security(sec.id());
|
||||
if (data != nullptr) {
|
||||
onixs::Decimal 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));
|
||||
}
|
||||
}
|
||||
template <typename RecoveryArgs>
|
||||
void MDP3Listener::onRecoveryOpeningPrice(const onixs::Security& sec, const RecoveryArgs& args) {
|
||||
|
||||
@@ -269,7 +269,10 @@ unique_ptr<onixs::Handler> MDP3Main::prepare_handler(const string& channel_id) {
|
||||
// Misc settings
|
||||
|
||||
settings.bookManagement().updateNotification(onixs::BookUpdateNotification::OnEndOfEvent);
|
||||
settings.tradeProcessing(onixs::TradeProcessing::SummaryLevel);
|
||||
settings.tradeProcessing(
|
||||
config::get<CMEOptions>().verbose_ticker() ?
|
||||
onixs::TradeProcessing::OrderDetails :
|
||||
onixs::TradeProcessing::SummaryLevel);
|
||||
|
||||
//
|
||||
// Logging
|
||||
|
||||
@@ -252,14 +252,17 @@ void dump_db(const vector<string>& args) {
|
||||
void run_tail(const vector<string>& args) {
|
||||
std::set<UserSymbol> products;
|
||||
auto conf = parse_md_args(args);
|
||||
bool monitor_all = false;
|
||||
for (const auto& b : args) { if (b=="all") monitor_all = true; }
|
||||
|
||||
PlatformConfig config;
|
||||
config.set_type(api::SecurityType_Name(api::SECURITYTYPE_FUTURE));
|
||||
if (!monitor_all) config.set_type(api::SecurityType_Name(api::SECURITYTYPE_FUTURE));
|
||||
config.set_platform(co2::Platform_Name(conf.platform));
|
||||
get_system_md_symbols(config, products);
|
||||
auto mod = conf.number > 0 ? conf.number : 1000;
|
||||
PrintFormat fmt = PrintFormat::CSV;
|
||||
for (const auto& a : args) { if (a == "longform") fmt = PrintFormat::Human; }
|
||||
md::run_periodic_dumper(products, mod, fmt);
|
||||
md::run_periodic_dumper(products, mod, fmt, monitor_all);
|
||||
}
|
||||
|
||||
void run_channels() {
|
||||
|
||||
@@ -1 +1 @@
|
||||
set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../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/AuthService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.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;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs;ui/src/obj/Debug/netstandard2.0/ui.AssemblyInfo.fs)
|
||||
set(sources ../../externals/linux/include/google/protobuf/descriptor.proto;../../externals/linux/include/google/protobuf/timestamp.proto;../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/AuthService.proto;../lib/api/services/ErrorReportService.proto;../lib/api/services/HelloService.proto;../lib/api/services/MarketDataAuxiliaryService.proto;../lib/api/services/MarketDataRelay.proto;../lib/api/services/OrderService.proto;../lib/api/services/OutOfProcessURLListener.proto;../lib/api/services/PersistenceService.proto;../lib/api/services/PositionService.proto;../lib/api/services/ShellDiagnosticService.proto;../lib/api/services/ShellLatencyService.proto;../lib/api/services/SyntheticSecurityService.proto;../lib/domain_model/Security.proto;../lib/md/protos/co2.proto;../lib/sparkproto/SparkProtos.proto;api/build.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;api/src/DynamicService.ts;api/src/ServiceContext.ts;api/src/bts_assert.ts;ui/src/Access.fs;ui/src/Accounts/ClipLimits.fs;ui/src/Accounts/ProductLimits.fs;ui/src/Accounts/SecurityLimits.fs;ui/src/Accounts/State.fs;ui/src/Accounts/Types.fs;ui/src/Accounts/View.fs;ui/src/App.fs;ui/src/Cmd.fs;ui/src/Controls/Button.fs;ui/src/Controls/DataGrid.fs;ui/src/Controls/Fields.fs;ui/src/Controls/Modal.fs;ui/src/Controls/ReactGrid.fs;ui/src/Controls/Table.fs;ui/src/Controls/nbsp.fs;ui/src/Global.fs;ui/src/Imports.fs;ui/src/Lens.fs;ui/src/Login/Login.fs;ui/src/Nav.fs;ui/src/State.fs;ui/src/Types.fs;ui/src/Users/State.fs;ui/src/Users/Types.fs;ui/src/Users/View.fs;ui/src/Util/EnumUtils.fs;ui/src/Util/JSMap.fs;ui/src/obj/Debug/netstandard2.0/ui.AssemblyInfo.fs)
|
||||
Reference in new issue
Block a user