Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
447d3303d1 | ||
|
|
5693fc4444 | ||
|
|
8896066e2c | ||
|
|
4992f4e0cf | ||
|
|
3503946011 | ||
|
|
d31d8648f1 | ||
|
|
2c15f83c85 | ||
|
|
f9dfb04fca | ||
|
|
680b19b6fb | ||
|
|
f790b8f59b |
No files matched your search
@@ -114,6 +114,8 @@ namespace bts.shell {
|
||||
public static QuoteInsideMarketDistanceWithTravel QuoteInsideMarketDistanceWithTravel => new QuoteInsideMarketDistanceWithTravel { Priority = RulePriority };
|
||||
public static QuoteInsideMarketDistance QuoteInsideMarketDistance => new QuoteInsideMarketDistance { Priority = RulePriority };
|
||||
public static QuoteInsideMarketDistanceThrottle QuoteInsideMarketDistanceThrottle => new QuoteInsideMarketDistanceThrottle();
|
||||
|
||||
public static QuoteTimeBasedThrottle QuoteTimeBasedThrottle => new QuoteTimeBasedThrottle { DelayToImprove = 0, DelayToRun = 0 };
|
||||
#endregion
|
||||
|
||||
#region PreHedge
|
||||
|
||||
@@ -10,13 +10,13 @@ namespace mbts.spark {
|
||||
public override string man_page { get; } = string.Empty;
|
||||
|
||||
public override bool get_value(LegSpreaderParamsTuple leg_tup) =>
|
||||
leg_tup.leg_params.EnableHedging;
|
||||
leg_tup.leg_params.SendHedge is null || leg_tup.leg_params.SendHedge.Val;
|
||||
|
||||
public override void set_value(LegSpreaderParamsTuple leg_tup, bool value) =>
|
||||
leg_tup.leg_params.EnableHedging = value;
|
||||
|
||||
public override bool has_errors(IReadOnlyCollection<LegSpreaderParamsTuple> leg_tups) =>
|
||||
!leg_tups.Any(lt => lt.leg_params.EnableHedging);
|
||||
public override void set_value(LegSpreaderParamsTuple leg_tup, bool value) {
|
||||
if (leg_tup.leg_params.SendHedge is null)
|
||||
leg_tup.leg_params.SendHedge = new bts.spark.NullableBoolean();
|
||||
leg_tup.leg_params.SendHedge.Val = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using mbts.ui.spark;
|
||||
using System;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class SyntheticEditorVM {
|
||||
class LeanOffsetTicksModel : RowModelBase<int> {
|
||||
public override string display_name { get; } = "Lean Offset Ticks";
|
||||
public override string help_text { get; } = "Improvement (in ticks) to the lean market";
|
||||
public override string man_page { get; } = string.Empty;
|
||||
|
||||
public override int get_value(LegSpreaderParamsTuple leg_tup) =>
|
||||
leg_tup.leg_params.QuoteParams?.LeanOffsetTicks ?? 0;
|
||||
|
||||
public override void set_value(LegSpreaderParamsTuple leg_tup, int value) {
|
||||
if (leg_tup.leg_params.QuoteParams is null)
|
||||
leg_tup.leg_params.QuoteParams = new bts.spark.QuoteParams();
|
||||
leg_tup.leg_params.QuoteParams.LeanOffsetTicks = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using mbts.ui.spark;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class SyntheticEditorVM {
|
||||
class QuoteTimeThrottleDelayToImproveModel : RowModelBase<uint> {
|
||||
readonly IDictionary<int, uint> _value_store = new Dictionary<int, uint>();
|
||||
|
||||
public override string display_name { get; } = "Delay to Improve (ms)";
|
||||
public override string help_text { get; } = string.Empty;
|
||||
public override string man_page { get; } = string.Empty;
|
||||
public override ParameterSection[] section_path { get; } = new[] { Sections.Quote, Subsections.TimeThrottle };
|
||||
|
||||
public void apply_value(LegSpreaderParamsTuple leg_tup) =>
|
||||
_get_throttle(leg_tup).DelayToImprove = _value_from_store(leg_tup);
|
||||
|
||||
public override uint get_value(LegSpreaderParamsTuple leg_tup) =>
|
||||
_get_throttle(leg_tup) is QuoteTimeBasedThrottle throttle ?
|
||||
throttle.DelayToImprove :
|
||||
_value_from_store(leg_tup);
|
||||
|
||||
public override void set_value(LegSpreaderParamsTuple leg_tup, uint value) {
|
||||
_value_store[leg_tup.id] = value;
|
||||
if (_get_throttle(leg_tup) is QuoteTimeBasedThrottle throttle)
|
||||
throttle.DelayToImprove = value;
|
||||
}
|
||||
|
||||
protected override bool _get_enabled(LegSpreaderParamsTuple leg_tup) =>
|
||||
_get_throttle(leg_tup) != null;
|
||||
|
||||
QuoteTimeBasedThrottle _get_throttle(LegSpreaderParamsTuple leg_tup) =>
|
||||
leg_tup.leg_params.QuoteParams.TimeBasedThrottle;
|
||||
|
||||
uint _value_from_store(LegSpreaderParamsTuple leg_tup) =>
|
||||
_value_store.GetValueOrDefault(leg_tup.id, _ => SyntheticDataHelper.Defaults.QuoteTimeBasedThrottle.DelayToImprove);
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using mbts.ui.spark;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class SyntheticEditorVM {
|
||||
class QuoteTimeThrottleDelayToRunModel : RowModelBase<uint> {
|
||||
readonly IDictionary<int, uint> _value_store = new Dictionary<int, uint>();
|
||||
|
||||
public override string display_name { get; } = "Delay To Run (ms)";
|
||||
public override string help_text { get; } = string.Empty;
|
||||
public override string man_page { get; } = string.Empty;
|
||||
public override ParameterSection[] section_path { get; } = new[] { Sections.Quote, Subsections.TimeThrottle };
|
||||
|
||||
public void apply_value(LegSpreaderParamsTuple leg_tup) =>
|
||||
_get_throttle(leg_tup).DelayToRun = _value_from_store(leg_tup);
|
||||
|
||||
public override uint get_value(LegSpreaderParamsTuple leg_tup) =>
|
||||
_get_throttle(leg_tup) is QuoteTimeBasedThrottle throttle ?
|
||||
throttle.DelayToRun :
|
||||
_value_from_store(leg_tup);
|
||||
|
||||
public override void set_value(LegSpreaderParamsTuple leg_tup, uint value) {
|
||||
_value_store[leg_tup.id] = value;
|
||||
if (_get_throttle(leg_tup) is QuoteTimeBasedThrottle throttle)
|
||||
throttle.DelayToRun = value;
|
||||
}
|
||||
|
||||
protected override bool _get_enabled(LegSpreaderParamsTuple leg_tup) =>
|
||||
_get_throttle(leg_tup) != null;
|
||||
|
||||
QuoteTimeBasedThrottle _get_throttle(LegSpreaderParamsTuple leg_tup) =>
|
||||
leg_tup.leg_params.QuoteParams.TimeBasedThrottle;
|
||||
|
||||
uint _value_from_store(LegSpreaderParamsTuple leg_tup) =>
|
||||
_value_store.GetValueOrDefault(leg_tup.id, _ => SyntheticDataHelper.Defaults.QuoteTimeBasedThrottle.DelayToRun);
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
using bts.shell;
|
||||
using mbts.ui.spark;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class SyntheticEditorVM {
|
||||
class QuoteTimeThrottleEnabledModel : RowModelBase<bool> {
|
||||
readonly QuoteTimeThrottleDelayToRunModel _delay_to_run;
|
||||
readonly QuoteTimeThrottleDelayToImproveModel _delay_to_improve;
|
||||
|
||||
public QuoteTimeThrottleEnabledModel(QuoteTimeThrottleDelayToRunModel delay_to_run, QuoteTimeThrottleDelayToImproveModel delay_to_improve) {
|
||||
_delay_to_run = delay_to_run;
|
||||
_delay_to_improve = delay_to_improve;
|
||||
}
|
||||
|
||||
public override string display_name { get; } = string.Empty;
|
||||
public override string help_text { get; } = string.Empty;
|
||||
public override string man_page { get; } = string.Empty;
|
||||
public override ParameterSection[] section_path { get; } = new[] { Sections.Quote, Subsections.TimeThrottle };
|
||||
|
||||
public override bool get_value(LegSpreaderParamsTuple leg_tup) =>
|
||||
leg_tup.leg_params.QuoteParams.TimeBasedThrottle != null;
|
||||
|
||||
public override void set_value(LegSpreaderParamsTuple leg_tup, bool value) {
|
||||
if (value) {
|
||||
if (leg_tup.leg_params.QuoteParams.TimeBasedThrottle == null) {
|
||||
leg_tup.leg_params.QuoteParams.TimeBasedThrottle = SyntheticDataHelper.Defaults.QuoteTimeBasedThrottle;
|
||||
_delay_to_run.apply_value(leg_tup);
|
||||
_delay_to_improve.apply_value(leg_tup);
|
||||
}
|
||||
} else {
|
||||
leg_tup.leg_params.QuoteParams.TimeBasedThrottle = null;
|
||||
}
|
||||
_delay_to_run.set_enabled(leg_tup, value);
|
||||
_delay_to_improve.set_enabled(leg_tup, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,10 @@ namespace mbts.spark {
|
||||
"Reduces re-quoting updates by defining a region on either side " +
|
||||
"of the working quoting order, inside which quote updates will not be sent.");
|
||||
|
||||
public static ParameterSection TimeThrottle =>
|
||||
new ParameterSection("Time Throttle", true,
|
||||
"Reduces re-quoting updates by requiring a minimum amount of time to elapse between quotes.");
|
||||
|
||||
public static ParameterSection Conditional =>
|
||||
new ParameterSection("Conditional", true,
|
||||
"Reduces re-quoting updates by only quoting if N ticks away from the opposite " +
|
||||
|
||||
@@ -196,6 +196,9 @@ namespace mbts.spark {
|
||||
var quote_throttle_outside_ticks = new QuoteThrottleOutsideTicksModel();
|
||||
var quote_throttle_inside_ticks = new QuoteThrottleInsideTicksModel();
|
||||
|
||||
var quote_time_throttle_delay_to_run = new QuoteTimeThrottleDelayToRunModel();
|
||||
var quote_time_throttle_delay_to_improve = new QuoteTimeThrottleDelayToImproveModel();
|
||||
|
||||
var conditional_quoting_ticks = new ConditionalQuotingTicksModel();
|
||||
var conditional_quoting_price_type = new ConditionalQuotingPriceTypeModel();
|
||||
|
||||
@@ -223,17 +226,24 @@ namespace mbts.spark {
|
||||
_quantity_model,
|
||||
_price_mult_model,
|
||||
is_quote_model,
|
||||
//new EnableHedgeModel(), //TAHA_SPREADER
|
||||
new EnableHedgeModel(), //TAHA_SPREADER
|
||||
new HedgeRatioModel(),
|
||||
//new MinLeanQtyModel(), //TAHA_SPREADER
|
||||
new LeanOffsetTicksModel(),
|
||||
//new QuoteHiddenModel(),
|
||||
new QuoteQueueHolderModel(),
|
||||
new MarketDataTypeModel(),
|
||||
new ShowQuantityEnabledModel(show_quantity_quantity),
|
||||
show_quantity_quantity,
|
||||
// Throttle
|
||||
new QuoteThrottleEnabledModel(quote_throttle_inside_ticks, quote_throttle_outside_ticks),
|
||||
quote_throttle_inside_ticks,
|
||||
quote_throttle_outside_ticks,
|
||||
// Time Throttle
|
||||
new QuoteTimeThrottleEnabledModel(quote_time_throttle_delay_to_run, quote_time_throttle_delay_to_improve),
|
||||
quote_time_throttle_delay_to_run,
|
||||
quote_time_throttle_delay_to_improve,
|
||||
|
||||
new ConditionalQuoteEnabledModel(conditional_quoting_ticks, conditional_quoting_price_type),
|
||||
conditional_quoting_ticks,
|
||||
//conditional_quoting_price_type,
|
||||
|
||||
@@ -166,6 +166,10 @@ namespace mbts.spark {
|
||||
|
||||
[ProtoContract]
|
||||
class LadderMarketBreakLine : IEquatable<LadderMarketBreakLine> {
|
||||
public enum RefreshMode {
|
||||
Auto,
|
||||
Manual
|
||||
}
|
||||
// this class is 100% mutable (there are literally 0 readonly members),
|
||||
// so GetHashCode must return the same hash for every instance.
|
||||
static readonly int _type_hash = typeof(LadderMarketBreakLine).GetHashCode();
|
||||
@@ -173,6 +177,8 @@ namespace mbts.spark {
|
||||
public bool show { get; set; }
|
||||
[ProtoMember(2)]
|
||||
public uint color { get; set; }
|
||||
[ProtoMember(3)]
|
||||
public RefreshMode refresh_mode { get; set; }
|
||||
|
||||
public uint? color_nullable {
|
||||
get {
|
||||
@@ -185,7 +191,8 @@ namespace mbts.spark {
|
||||
public bool Equals(LadderMarketBreakLine other) =>
|
||||
other != null &&
|
||||
other.show == show &&
|
||||
other.color == color;
|
||||
other.color == color &&
|
||||
other.refresh_mode == refresh_mode;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as LadderMarketBreakLine);
|
||||
|
||||
@@ -61,9 +61,9 @@ namespace mbts.spark {
|
||||
_bid_mkt_line = new LadderMarketBreakLineVM("Bid"),
|
||||
_ask_mkt_line = new LadderMarketBreakLineVM("Ask"),
|
||||
_mid_mkt_line = new LadderMarketBreakLineVM("Mid"),
|
||||
_session_low_mkt_line = new LadderMarketBreakLineVM("Session Low", 2, 1),
|
||||
_session_high_mkt_line = new LadderMarketBreakLineVM("Session High", 2, 1, false),
|
||||
_session_range_fill = new LadderMarketBreakLineVM("Session Range", 0, 0, false);
|
||||
_session_low_mkt_line = new LadderMarketBreakLineVM("Session Low", 2, 1, can_edit_refresh_mode: false),
|
||||
_session_high_mkt_line = new LadderMarketBreakLineVM("Session High", 2, 1, false, can_edit_refresh_mode: false),
|
||||
_session_range_fill = new LadderMarketBreakLineVM("Session Range", 0, 0, false, can_edit_refresh_mode: false);
|
||||
OrderEntryPanelItemVisibilityVM
|
||||
_zoom_slider_visbility = new OrderEntryPanelItemVisibilityVM("Zoom Slider"),
|
||||
_day_visibility = new OrderEntryPanelItemVisibilityVM("Day Change"),
|
||||
@@ -601,12 +601,14 @@ namespace mbts.spark {
|
||||
public class LadderMarketBreakLineVM : ViewModelBase {
|
||||
readonly Property<Color> _color;
|
||||
readonly Property<bool> _show;
|
||||
LadderMarketBreakLine.RefreshMode _refresh_mode;
|
||||
|
||||
public LadderMarketBreakLineVM(string name, int column_index = 0, int column_span = 5, bool show_session_range = true) {
|
||||
public LadderMarketBreakLineVM(string name, int column_index = 0, int column_span = 5, bool show_session_range = true, bool can_edit_refresh_mode = true) {
|
||||
this.name = name;
|
||||
this.column_index = column_index;
|
||||
this.column_span = column_span;
|
||||
this.show_session_range = show_session_range;
|
||||
this.can_edit_refresh_mode = can_edit_refresh_mode;
|
||||
palettes = new ObservableCollection<ColorPaletteVM>(ColorPalette.all_presets().Select(p => new ColorPaletteVM(p)));
|
||||
_color = backing(nameof(color), Colors.Black);
|
||||
_show = backing(nameof(show), false);
|
||||
@@ -618,17 +620,21 @@ namespace mbts.spark {
|
||||
public Color color { get => _color.Value; set => _color.Value = value; }
|
||||
public bool show { get => _show.Value; set => _show.Value = value; }
|
||||
public bool show_session_range { get; }
|
||||
public bool can_edit_refresh_mode { get; }
|
||||
public LadderMarketBreakLine.RefreshMode refresh_mode { get => _refresh_mode; set => Set(ref _refresh_mode, value); }
|
||||
public ObservableCollection<ColorPaletteVM> palettes { get; }
|
||||
|
||||
public void assign_from(LadderMarketBreakLine settings) {
|
||||
color = settings.color.rgb_color();
|
||||
show = settings.show;
|
||||
refresh_mode = settings.refresh_mode;
|
||||
}
|
||||
|
||||
public LadderMarketBreakLine get_settings() =>
|
||||
new LadderMarketBreakLine {
|
||||
color = new BTSColor(color).ToUint(),
|
||||
show = show
|
||||
show = show,
|
||||
refresh_mode = refresh_mode
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ using System.Windows.Media.Animation;
|
||||
namespace mbts.spark {
|
||||
partial class LadderGridHost : Control {
|
||||
const int _min_row_count = 501, _max_row_count = 2001;
|
||||
static readonly bool _show_scrollbar = config.Configuration.get<bts.config.LadderKnobs>().show_scrollbar;
|
||||
|
||||
int _row_count = _min_row_count;
|
||||
|
||||
@@ -82,6 +83,8 @@ namespace mbts.spark {
|
||||
_ordershost = new LadderOrdersHost(this) { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Stretch };
|
||||
var scrollViewerFactory = new FrameworkElementFactory(typeof(ScrollViewer));
|
||||
scrollViewerFactory.SetValue(FocusableProperty, false);
|
||||
if (!_show_scrollbar)
|
||||
scrollViewerFactory.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden);
|
||||
Template = new ControlTemplate() {
|
||||
VisualTree = scrollViewerFactory
|
||||
};
|
||||
@@ -713,8 +716,10 @@ namespace mbts.spark {
|
||||
// with meticulous attention to detail.
|
||||
_tick_sub = Disposable.Create(() => local_vm.on_tick -= _tick);
|
||||
_vm_sub = Disposable.Create(() => local_vm.request_recenter -= on_request_recenter);
|
||||
void on_request_recenter() =>
|
||||
void on_request_recenter() {
|
||||
RecenterCommand?.ExecuteIfCan(null);
|
||||
_refresh_frozen_mkt_lines();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -783,6 +788,14 @@ namespace mbts.spark {
|
||||
|
||||
#endregion
|
||||
|
||||
void _refresh_frozen_mkt_lines() {
|
||||
if (_price_list is null)
|
||||
return;
|
||||
_mkt_break_lines.refresh_frozen();
|
||||
_refresh_bid_mkt_break();
|
||||
_refresh_ask_mkt_break();
|
||||
_refresh_mid_mkt_break();
|
||||
}
|
||||
|
||||
void _on_vm_disposed(bool obj) =>
|
||||
_dispose_resources();
|
||||
@@ -814,6 +827,7 @@ namespace mbts.spark {
|
||||
} else {
|
||||
_scroll_to_row(_row_count / 2);
|
||||
}
|
||||
_refresh_frozen_mkt_lines();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -888,13 +902,28 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
void _refresh_bid_mkt_break() =>
|
||||
_render_mkt_break(_bid_mkt_break_vis, _mkt_break_lines.bid, _settings.bid_break_line.color);
|
||||
_render_mkt_break(
|
||||
_bid_mkt_break_vis,
|
||||
_settings.bid_break_line.refresh_mode == LadderMarketBreakLine.RefreshMode.Manual ?
|
||||
_mkt_break_lines.frozen_bid :
|
||||
_mkt_break_lines.bid,
|
||||
_settings.bid_break_line.color);
|
||||
|
||||
void _refresh_ask_mkt_break() =>
|
||||
_render_mkt_break(_ask_mkt_break_vis, _mkt_break_lines.ask, _settings.ask_break_line.color);
|
||||
_render_mkt_break(
|
||||
_ask_mkt_break_vis,
|
||||
_settings.ask_break_line.refresh_mode == LadderMarketBreakLine.RefreshMode.Manual ?
|
||||
_mkt_break_lines.frozen_ask :
|
||||
_mkt_break_lines.ask,
|
||||
_settings.ask_break_line.color);
|
||||
|
||||
void _refresh_mid_mkt_break() =>
|
||||
_render_mkt_break(_mid_mkt_break_vis, _mkt_break_lines.mid, _settings.mid_break_line.color);
|
||||
_render_mkt_break(
|
||||
_mid_mkt_break_vis,
|
||||
_settings.mid_break_line.refresh_mode == LadderMarketBreakLine.RefreshMode.Manual ?
|
||||
_mkt_break_lines.frozen_mid :
|
||||
_mkt_break_lines.mid,
|
||||
_settings.mid_break_line.color);
|
||||
|
||||
void _refresh_session_low_line() {
|
||||
if (_settings.session_low_line.show && _mkt_break_lines.low_render_index.HasValue)
|
||||
@@ -1170,6 +1199,7 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
}
|
||||
_refresh_frozen_mkt_lines();
|
||||
_visualHost.AddVisualChild(_mid_mkt_break_vis);
|
||||
_visualHost.AddVisualChild(_ask_mkt_break_vis);
|
||||
_visualHost.AddVisualChild(_bid_mkt_break_vis);
|
||||
@@ -1265,7 +1295,8 @@ namespace mbts.spark {
|
||||
// Note: The values contained here do NOT necessarily represent true data, as they will be NaN/null if their respective visual is hidden in LadderSettings
|
||||
class MarketBreakLines {
|
||||
readonly LadderGridHost _owner;
|
||||
double _bid, _ask, _mid, _origin, _session_low, _session_high;
|
||||
double _bid = double.NaN, _ask = double.NaN, _mid = double.NaN, _origin, _session_low, _session_high;
|
||||
double _frozen_bid = double.NaN, _frozen_ask = double.NaN, _frozen_mid = double.NaN, _frozen_origin = double.NaN;
|
||||
int? _low_index, _high_index;
|
||||
|
||||
public MarketBreakLines(LadderGridHost owner) =>
|
||||
@@ -1279,6 +1310,11 @@ namespace mbts.spark {
|
||||
public bool session_range_dirty => session_low_dirty || session_high_dirty;
|
||||
public bool origin_dirty { get; private set; }
|
||||
|
||||
public double frozen_bid => double.IsNaN(_frozen_bid) ? (_frozen_bid = _bid) : _frozen_bid;
|
||||
public double frozen_ask => double.IsNaN(_frozen_ask) ? (_frozen_ask = _ask) : _frozen_ask;
|
||||
public double frozen_mid => double.IsNaN(_frozen_mid) ? (_frozen_mid = _mid) : _frozen_mid;
|
||||
public double frozen_origin => double.IsNaN(_frozen_origin) ? (_frozen_origin = _origin) : _frozen_origin;
|
||||
|
||||
public double bid => _bid;
|
||||
public double ask => _ask;
|
||||
public double mid => _mid;
|
||||
@@ -1322,7 +1358,14 @@ namespace mbts.spark {
|
||||
|
||||
LadderSettings _settings => _owner._settings;
|
||||
|
||||
public void refresh_frozen() {
|
||||
_refresh(true);
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
_refresh(false);
|
||||
}
|
||||
void _refresh(bool update_frozen) {
|
||||
bid_dirty = ConvertUtils.update_value_type(ref _bid, _settings.bid_break_line.show ? _owner._get_bid_market_break() : double.NaN);
|
||||
ask_dirty = ConvertUtils.update_value_type(ref _ask, _settings.ask_break_line.show ? _owner._get_ask_market_break() : double.NaN);
|
||||
mid_dirty = ConvertUtils.update_value_type(ref _mid, _settings.mid_break_line.show ? _owner._get_mid_market_break() : double.NaN);
|
||||
@@ -1342,6 +1385,11 @@ namespace mbts.spark {
|
||||
if (double.IsNaN(new_origin))
|
||||
new_origin = _owner._get_bid_market_break();
|
||||
origin_dirty = ConvertUtils.update_value_type(ref _origin, new_origin);
|
||||
if (update_frozen) {
|
||||
_frozen_bid = _bid;
|
||||
_frozen_ask = _ask;
|
||||
_frozen_mid = _mid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,18 @@
|
||||
<cv:KeyValue Key="{u:Int 0}" Value="{u:Visibility Collapsed}"/>
|
||||
</cv:ValueMap>
|
||||
<c:BadgeTextLinesConverter x:Key="BadgeTextLinesConverter"/>
|
||||
<cv:ValueMap x:Key="RefreshModeToBooleanConverter">
|
||||
<cv:KeyValue Key="{x:Static Manual, MemberType={u:Nested sp:LadderMarketBreakLine.RefreshMode}}">
|
||||
<cv:KeyValue.Value>
|
||||
<sys:Boolean>false</sys:Boolean>
|
||||
</cv:KeyValue.Value>
|
||||
</cv:KeyValue>
|
||||
<cv:KeyValue Key="{x:Static Auto, MemberType={u:Nested sp:LadderMarketBreakLine.RefreshMode}}">
|
||||
<cv:KeyValue.Value>
|
||||
<sys:Boolean>true</sys:Boolean>
|
||||
</cv:KeyValue.Value>
|
||||
</cv:KeyValue>
|
||||
</cv:ValueMap>
|
||||
|
||||
<Style x:Key="ColumnBackground" TargetType="Rectangle">
|
||||
<Setter Property="Grid.RowSpan" Value="3"/>
|
||||
@@ -525,10 +537,12 @@
|
||||
<ColumnDefinition SharedSizeGroup="c2"/>
|
||||
<ColumnDefinition SharedSizeGroup="c3"/>
|
||||
<ColumnDefinition SharedSizeGroup="c4"/>
|
||||
<ColumnDefinition SharedSizeGroup="c5"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="1" HorizontalAlignment="Center" Margin="6,0" Text="Show" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="2" HorizontalAlignment="Center" Margin="6,0" Text="Color" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="3" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="6,0" Text="Sample" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="2" HorizontalAlignment="Center" Margin="6,0" Text="Auto Refresh" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="3" HorizontalAlignment="Center" Margin="6,0" Text="Color" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="4" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="6,0" Text="Sample" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
<ItemsControl Grid.Row="1" ItemsSource="{Binding mkt_break_items}" Margin="8,0">
|
||||
<ItemsControl.ItemTemplate>
|
||||
@@ -540,20 +554,28 @@
|
||||
<ColumnDefinition SharedSizeGroup="c2"/>
|
||||
<ColumnDefinition SharedSizeGroup="c3"/>
|
||||
<ColumnDefinition SharedSizeGroup="c4"/>
|
||||
<ColumnDefinition SharedSizeGroup="c5"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0" Background="{u:BTSColor header}" Padding="6,3">
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding name}" Foreground="{u:BTSColor header_text}"/>
|
||||
</Border>
|
||||
<CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding show}"/>
|
||||
<c:ColorPickerPopup
|
||||
<CheckBox
|
||||
Grid.Column="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
IsChecked="{Binding refresh_mode, Converter={StaticResource RefreshModeToBooleanConverter}, Mode=TwoWay}"
|
||||
IsEnabled="{Binding can_edit_refresh_mode}"
|
||||
/>
|
||||
<c:ColorPickerPopup
|
||||
Grid.Column="3"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="0"
|
||||
PopupPlacement="Left"
|
||||
Palettes="{Binding palettes}"
|
||||
SelectedColor="{Binding color}"
|
||||
/>
|
||||
<Grid Grid.Column="3" Grid.ColumnSpan="2" Height="27">
|
||||
<Grid Grid.Column="4" Grid.ColumnSpan="2" Height="27">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
@@ -623,7 +645,7 @@
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
<Rectangle Grid.Column="1" Grid.ColumnSpan="5" Fill="DimGray" Height="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
|
||||
<Rectangle Grid.Column="1" Grid.ColumnSpan="6" Fill="DimGray" Height="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
|
||||
@@ -15,7 +15,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Controls;
|
||||
@@ -410,11 +409,13 @@ namespace bts.shell.risk_management {
|
||||
res = res.with(security: sec_md.security);
|
||||
if (string.IsNullOrEmpty(res.account_name) && accounts.TryGetFirst(a => a?.id == res.account_key, out var acc))
|
||||
res = res.with(account: acc);
|
||||
if (_row_cache.TryGetValue(res.key, out var old_row))
|
||||
rows.RemoveSorted(old_row, row_comparer);
|
||||
var new_row = RiskLimitsVM.create_placeholder(res);
|
||||
_row_cache[res.key] = new_row;
|
||||
_imported_row_map[res.key] = new_row;
|
||||
if (new_row.account_key == selected_account?.id)
|
||||
rows.InsertOrReplaceSorted(new_row, row_comparer);
|
||||
rows.InsertSorted(new_row, row_comparer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ message LadderKnobs {
|
||||
optional bool open_algo_popup_on_select = 6 [default = false];
|
||||
optional bool use_algo_param_grid = 7 [default = true];
|
||||
optional uint32 max_mbo_orders = 8 [default = 200];
|
||||
optional bool show_scrollbar = 9 [default = false];
|
||||
}
|
||||
|
||||
message OrderBookOptions {
|
||||
|
||||
@@ -37,6 +37,14 @@ public:
|
||||
double size_multiplier() const { return _leg_contract.quantity(); }
|
||||
double tick_size() const { return _leg_contract.security().contract_spec().low_tick(); }
|
||||
bool is_active_quoting() const {return _leg_params.is_active_quoting();}
|
||||
bool send_hedge() const {
|
||||
// for backwards compat, if its unset, then hedges are sent
|
||||
return !_leg_params.has_send_hedge() || _leg_params.send_hedge().val();
|
||||
}
|
||||
// if both quoting and hedging are turned off, this results false, else true
|
||||
bool is_active_trading() const{
|
||||
return is_active_quoting() || send_hedge();
|
||||
}
|
||||
bool is_net_change() const{
|
||||
return _price_calc==bts::api::SyntheticContract::PRICECALC_NET_CHANGE;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ _hidden_order(this_leg_property.leg_params().has_quote_params() &&
|
||||
this_leg_property.leg_params().quote_params().has_quote_hidden()),
|
||||
_force_show_qty(this_leg_property.n_queue_holder_orders()==0 &&
|
||||
this_leg_property.has_show_qty()),
|
||||
_last_price_improve_time(google::protobuf::util::TimeUtil::GetEpoch()),
|
||||
_last_price_run_time(google::protobuf::util::TimeUtil::GetEpoch()),
|
||||
_is_permenantly_cancelled (false),
|
||||
_irrecoverable_error(false),
|
||||
_n_spreader_legs (n_spreader_legs),
|
||||
@@ -162,7 +164,8 @@ bool SingleLegQuoter::accept_modifications() const {
|
||||
_worker->state() == QuoterState::WORKING;
|
||||
}
|
||||
void SingleLegQuoter::_incorporate_other_leg_fill (size_t, Quantity hedge_reduction){
|
||||
_price_quantity_state.add_hedged_reduction (hedge_reduction);
|
||||
if(_this_leg_data.send_hedge())
|
||||
_price_quantity_state.add_hedged_reduction (hedge_reduction);
|
||||
}
|
||||
void SingleLegQuoter::_compute_quote(
|
||||
Quantity target_qty,
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/SpreaderChildOrderState.h"
|
||||
#include "lib/orderman/orders/spreader_orders/spreader/quoter/QuoteDriverSetHistory.h"
|
||||
#include <sstream>
|
||||
#include <google/protobuf/timestamp.pb.h>
|
||||
#include <google/protobuf/util/time_util.h>
|
||||
|
||||
|
||||
namespace bts {
|
||||
@@ -43,6 +45,8 @@ private:
|
||||
// if this is set to true, _compute_price_quantity
|
||||
// will use LegPropertyData::show_qty()
|
||||
const bool _force_show_qty;
|
||||
google::protobuf::Timestamp _last_price_improve_time,
|
||||
_last_price_run_time;
|
||||
bool _is_permenantly_cancelled;
|
||||
bool _irrecoverable_error;
|
||||
// this is a config constant. if the quoter
|
||||
@@ -177,6 +181,13 @@ private:
|
||||
_spreader.current_time());
|
||||
}
|
||||
void _modify_order (Price price, Quantity quantity) {
|
||||
auto now = google::protobuf::util::TimeUtil::GetCurrentTime();
|
||||
if(bts::securities::is_equal_or_better(_this_leg_data.trading_side(),
|
||||
price,
|
||||
_price_quantity_state.out_price()))
|
||||
_last_price_improve_time = now;
|
||||
else
|
||||
_last_price_run_time = now;
|
||||
_child_order_state.modify_order(price, quantity);
|
||||
}
|
||||
void _cancel_order () {_child_order_state.cancel_order();}
|
||||
|
||||
@@ -79,6 +79,8 @@ void SpreaderBookkeepingData::total_fills (Quantity& out_quantity,
|
||||
double avg_price = 0.0;
|
||||
double fills = std::numeric_limits<double>::max();
|
||||
for (const SpreaderLegData& leg_data : _leg_data){
|
||||
if(!leg_data.leg_property_data().is_active_trading())
|
||||
continue;
|
||||
Quantity leg_fill_qty; Price leg_fill_price;
|
||||
leg_data.total_fills(leg_fill_qty, leg_fill_price);
|
||||
double leg_normalized_qty = static_cast<double>(leg_fill_qty.value()) /
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "lib/api/services/OrderService.pb.h"
|
||||
#include "lib/orderman/actors/order_manager/OrderBuilder.h"
|
||||
#include "lib/os/os.h"
|
||||
#include <google/protobuf/timestamp.pb.h>
|
||||
#include <google/protobuf/util/time_util.h>
|
||||
#include <random>
|
||||
|
||||
namespace bts {
|
||||
@@ -290,6 +292,8 @@ public:
|
||||
const Book& qbook,
|
||||
api::Side quote_side,
|
||||
double tick_size,
|
||||
google::protobuf::Timestamp last_price_improve_time,
|
||||
google::protobuf::Timestamp last_price_run_time,
|
||||
const bts::spark::QuoteParams& quote_params){
|
||||
|
||||
bool reject =
|
||||
@@ -305,7 +309,16 @@ public:
|
||||
qbook.side(quote_side)[0].price(),
|
||||
quote_side,
|
||||
tick_size,
|
||||
quote_params.quote_inside_market_distance_throttle()));
|
||||
quote_params.quote_inside_market_distance_throttle())) ||
|
||||
(quote_params.has_time_based_throttle() &&
|
||||
is_time_throttle_reject(quote_side,
|
||||
current_price,
|
||||
new_price,
|
||||
last_price_improve_time,
|
||||
last_price_run_time,
|
||||
quote_params.time_based_throttle().delay_to_improve(),
|
||||
quote_params.time_based_throttle().delay_to_run()));
|
||||
|
||||
return reject;
|
||||
}
|
||||
|
||||
@@ -344,6 +357,32 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool is_time_throttle_reject(api::Side side,
|
||||
double current_price,
|
||||
double new_price,
|
||||
google::protobuf::Timestamp last_price_improve_time,
|
||||
google::protobuf::Timestamp last_price_run_time,
|
||||
uint32_t delay_to_improve,
|
||||
uint32_t delay_to_run){
|
||||
auto now = google::protobuf::util::TimeUtil::GetCurrentTime();
|
||||
if(bts::securities::is_equal_or_better(side,
|
||||
Price(new_price),
|
||||
Price(current_price))){
|
||||
// improvement
|
||||
int64_t ms_diff =
|
||||
google::protobuf::util::TimeUtil::TimestampToMilliseconds(now)-
|
||||
google::protobuf::util::TimeUtil::TimestampToMilliseconds(last_price_improve_time);
|
||||
return ms_diff < static_cast<int64_t>(delay_to_improve);
|
||||
}
|
||||
else{
|
||||
// run
|
||||
int64_t ms_diff =
|
||||
google::protobuf::util::TimeUtil::TimestampToMilliseconds(now)-
|
||||
google::protobuf::util::TimeUtil::TimestampToMilliseconds(last_price_run_time);
|
||||
return ms_diff < static_cast<int64_t>(delay_to_run);
|
||||
}
|
||||
}
|
||||
|
||||
static bool conditional_quoting(Price quoting_price,
|
||||
Quantity quoting_qty,
|
||||
@@ -727,6 +766,7 @@ public:
|
||||
Quantity hedge_qty;
|
||||
compute_driver(quote_target,quote_leg_data,hedge_leg_data,hedge_leg_book,
|
||||
hedge_price,hedge_qty,quote_qty);
|
||||
hedge_price = Price(offset_driver_price(hedge_price.value(),hedge_leg_data));
|
||||
double out_price = (target_spread_price.value() - hedge_price.value() * hedge_leg_data.price_multiplier())/quote_leg_data.price_multiplier();
|
||||
out_price = bts::securities::raw_round_to_quote_price (out_price, quote_leg_data.tick_size(), quote_leg_data.trading_side());
|
||||
quote_price = Price(out_price);
|
||||
@@ -784,6 +824,15 @@ public:
|
||||
out_driver_vector[idx].set (hedge_price, hedge_qty, quote_qty);
|
||||
}
|
||||
}
|
||||
static double offset_driver_price (double driver_price,
|
||||
const LegPropertyData& driver_lp){
|
||||
int offset_ticks = driver_lp.leg_params().quote_params().lean_offset_ticks();
|
||||
double offset_price = offset_ticks * driver_lp.tick_size();
|
||||
if(driver_lp.trading_side() == api::Side::SIDE_BUY)
|
||||
return driver_price + offset_price;
|
||||
else
|
||||
return driver_price - offset_price;
|
||||
}
|
||||
// computes the quoting price from the leg drivers
|
||||
// ie (spreader_price - sum (price_mult * price))/quoting_leg_mult
|
||||
static Price compute_quoting_price_from_drivers(Price target_spread_price,
|
||||
@@ -794,8 +843,11 @@ public:
|
||||
size_t n_legs = driver_vector.size();
|
||||
double sum = 0;
|
||||
for (size_t idx = 0; idx < n_legs; idx++)
|
||||
if (idx != quoting_leg_index)
|
||||
sum += driver_vector[idx].driver_price().value() * spreader.get_leg_data (idx).price_multiplier();
|
||||
if (idx != quoting_leg_index){
|
||||
double driver_price = driver_vector[idx].driver_price().value();
|
||||
driver_price = offset_driver_price(driver_price,spreader.get_leg_data(idx));
|
||||
sum += driver_price * spreader.get_leg_data(idx).price_multiplier();
|
||||
}
|
||||
double rv = (target_spread_price.value() - sum)/quoting_leg_data.price_multiplier();
|
||||
rv = bts::securities::raw_round_to_quote_price (rv, quoting_leg_data.tick_size(), quoting_leg_data.trading_side());
|
||||
return Price(rv);
|
||||
|
||||
+7
-3
@@ -16,10 +16,14 @@ void HedgerStartStateWorker::on_transition (){
|
||||
void HedgerStartStateWorker::init (Price price,
|
||||
Quantity quantity){
|
||||
_hedger->_price_quantity_state.re_init(price,quantity);
|
||||
if(quantity.value() > 0){
|
||||
_hedger->_place_order (price, quantity);
|
||||
_hedger->transform_to_WAITING_FOR_FIRST_ACK ();
|
||||
if(_hedger->_leg_property_data.send_hedge()){
|
||||
if(quantity.value() > 0){
|
||||
_hedger->_place_order (price, quantity);
|
||||
_hedger->transform_to_WAITING_FOR_FIRST_ACK ();
|
||||
}
|
||||
}
|
||||
else
|
||||
_hedger->cancel_hedge();
|
||||
}
|
||||
void HedgerStartStateWorker::on_order_update(const SpreaderChildOrderState&){
|
||||
bts_assert_msg (false, "HedgerStartStateWorker::on_order_update "
|
||||
|
||||
+4
-1
@@ -41,7 +41,8 @@ void QuoterWorkingStateWorker::cancel(){
|
||||
void QuoterWorkingStateWorker::terminate(){
|
||||
_quoter->_transform_to_END ();
|
||||
}
|
||||
void QuoterWorkingStateWorker::on_time(const TimeStamp&){
|
||||
void QuoterWorkingStateWorker::on_time(const TimeStamp&){
|
||||
_longpath_analyze_and_act();
|
||||
}
|
||||
void QuoterWorkingStateWorker::on_other_leg_quoter_fill (size_t leg_index,
|
||||
Quantity filled_quantity){
|
||||
@@ -92,6 +93,8 @@ void QuoterWorkingStateWorker::_longpath_analyze_and_act ()
|
||||
book,
|
||||
_quoter->_this_leg_data.trading_side(),
|
||||
_quoter->_this_leg_data.tick_size(),
|
||||
_quoter->_last_price_improve_time,
|
||||
_quoter->_last_price_run_time,
|
||||
_quoter->_this_leg_data.leg_params().quote_params());
|
||||
bool reprice = !throttle_reject;
|
||||
reprice = reprice && !(_quoter->_spreader.in_cache_warming_cycle());
|
||||
|
||||
@@ -19,6 +19,9 @@ message QuantityMeasure
|
||||
message NullableQuantity{
|
||||
uint32 quantity = 10;
|
||||
}
|
||||
message NullableBoolean{
|
||||
bool val = 10;
|
||||
}
|
||||
// /*************************************************************************************************/
|
||||
// /*************************************************************************************************/
|
||||
// /*************************************Spreader Parameters*****************************************/
|
||||
@@ -46,7 +49,8 @@ message LegSpreaderParams
|
||||
PreHedgeParams pre_hedge_params = 50;
|
||||
PostHedgeParams post_hedge_params = 60;
|
||||
MarketDataType market_data_type = 70;
|
||||
//reserve LegMarketDataCalculation leg_md_calc = 80;
|
||||
//reserve LegMarketDataCalculation leg_md_calc = 80;
|
||||
NullableBoolean send_hedge = 90;
|
||||
}
|
||||
|
||||
// /*************************************************************************************************
|
||||
@@ -76,6 +80,8 @@ message QuoteParams
|
||||
uint32 n_queue_holder_orders=2000;
|
||||
// this is the show quantity on the quoter order
|
||||
NullableQuantity show_quantity = 2010;
|
||||
int32 lean_offset_ticks = 2020;
|
||||
QuoteTimeBasedThrottle time_based_throttle = 2030;
|
||||
}
|
||||
|
||||
/*************************************Quote MuteZone***********************************
|
||||
@@ -134,7 +140,10 @@ message QuoteInsideMarketDistanceThrottle
|
||||
{
|
||||
uint32 on_toward_distance = 10;
|
||||
}
|
||||
|
||||
message QuoteTimeBasedThrottle{
|
||||
uint32 delay_to_run = 10;
|
||||
uint32 delay_to_improve = 20;
|
||||
}
|
||||
/*************************************Quote RepriceThrottled (unused)*******************************
|
||||
(Stellar's sensitivity)
|
||||
This parameter defines regions (wrt their distance from the inside market)
|
||||
|
||||
Reference in new issue
Block a user