Merged in SOM-ticks (pull request #320)
SPARK-1715 Handle fractional numerator tick sizes Approved-by: Kevin Darby <kevin.darby@bluetradesys.com>
This commit is contained in:
commit
43fd07dcfa
2 files changed
+21
-1
No files matched your search
@@ -197,6 +197,7 @@ namespace mbts.spark {
|
||||
static class TickStore {
|
||||
public static readonly RegionalTickFactors default_rtf = new RegionalTickFactors(new TickFactors(1000, 1), new TickFactors(1000, 1), double.MaxValue);
|
||||
static readonly ConcurrentDictionary<SpecKey, RegionalTickFactors> _exchange_ticks = new ConcurrentDictionary<SpecKey, RegionalTickFactors>();
|
||||
static readonly bool _som_ticks_fix_enabled = config.Configuration.get<bts.config.toggles.SOMTicksFix>().enabled;
|
||||
|
||||
public static RegionalTickFactors get(ContractSpecification spec) =>
|
||||
_exchange_ticks.GetOrAdd(new SpecKey(spec), _create_rtf);
|
||||
@@ -249,8 +250,23 @@ namespace mbts.spark {
|
||||
var tf = _try_create_tf(tick_size, tick_base);
|
||||
if (tf != null && display_digits_override > 0) {
|
||||
int display_digit_diff = (int)display_digits_override - tf.display_digits();
|
||||
if (display_digit_diff != 0)
|
||||
if (_som_ticks_fix_enabled) {
|
||||
// we can always add display_digits (i.e. dislpay_digit_diff > 0), of course the ticks can be expressed precisely with extra 0s.
|
||||
// but if we are going to remove display_digits (i.e display_digit_diff < 0), we must make sure the tick_unit is large enough to be expressed precisely with that many fewer digits
|
||||
// - "-display_digit_diff <= Math.Ceiling(Math.Log10(tf.tick_unit))" will tell us if the digits can be removed without compromising precision
|
||||
// - unfortunately, we cannot rely on the exchange's ContractSpec for this, there is 1 known case where the data they give us is incorrect
|
||||
// SOM spreads ContractSpec (from the exchange):
|
||||
// LowTick: 0.0025 (aka 1/400, or 2/800)
|
||||
// MainFraction: 8
|
||||
// SubFraction: 0
|
||||
// PriceDisplayFormat: 1
|
||||
// - as you can see, this cannot possibly be formatted with 1 display digit, it ticks in increments of 1/400
|
||||
// - in practice, to maintain the '8' base, we format this in increments of 2/800 (e.g. 1-000, 1-002, 1-004, and so on up to 1-778, 2-000)
|
||||
if (display_digit_diff > 0 || (display_digit_diff < 0 && -display_digit_diff <= Math.Ceiling(Math.Log10(tf.tick_unit))))
|
||||
tf = _inflate_to_base(tf, tf.tick_base * Math.Pow(10, display_digit_diff));
|
||||
} else if (display_digit_diff != 0) {
|
||||
tf = _inflate_to_base(tf, tf.tick_base * Math.Pow(10, display_digit_diff));
|
||||
}
|
||||
}
|
||||
return tf;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,10 @@ message RejectStopAndStopLimitOrders {
|
||||
optional bool enabled = 1 [default = true];
|
||||
}
|
||||
|
||||
message SOMTicksFix {
|
||||
optional bool enabled = 1 [default = true];
|
||||
}
|
||||
|
||||
message EnsureOnScreenWithWorkAreaRect {
|
||||
// Defaulting to false bc this is near the end of the cycle (04/27/2019),
|
||||
// and the new ensure_onscreen code has only been tested with a single monitor arrangement.
|
||||
|
||||
Reference in new issue
Block a user