added atm_line setting to Ladder, defaults to bid

This commit is contained in:
John Colvin committed 2018-02-14 14:21:32 -05:00
1 parent 6920738f0c
commit 0e1be68093
3 files changed
+16 -10

No files matched your search

+12 -1
View File
@@ -24,7 +24,10 @@ namespace mbts.spark {
public static double mid_tick(ContractSpecificationImmutable spec, double bid, double ask) {
double raw_mid;
if (double.IsNaN(bid)) { raw_mid = ask; }
if (double.IsNaN(bid)) {
if (double.IsNaN(ask)) return double.NaN;
raw_mid = ask;
}
else if (double.IsNaN(ask)) { raw_mid = bid; }
else { raw_mid = (bid + ask) / 2.0; }
double tick_size = spec.ticksize(raw_mid);
@@ -33,6 +36,14 @@ namespace mbts.spark {
return mid;
}
public static double atm_tick(ContractSpecificationImmutable spec, double bid, double ask, ATMLine atm_line) {
switch (atm_line) {
case ATMLine.Bid: return double.IsNaN(bid) ? ask : bid;
case ATMLine.Ask: return double.IsNaN(ask) ? bid : ask;
case ATMLine.Mid:
default: return mid_tick(spec, bid, ask);
}
}
public static double tickup(this ContractSpecificationImmutable contract, double value) { return get_regional_ticks(contract).tickup(value); }
public static double tickup(this ContractSpecificationImmutable contract, double value, int count) { return get_regional_ticks(contract).tickup(value, (uint)count); }
@@ -225,7 +225,7 @@ namespace mbts.spark {
private void tick() {
if (_settings != null) {
if (_vm.md.get_depth(ref _prices_updated, ref _bids, ref _asks)) {
var mid = TickUtils.mid_tick(_spec, _bids[0].price, _asks[0].price);
var mid = TickUtils.atm_tick(_spec, _bids[0].price, _asks[0].price, _settings.atm_line);
if (_price_dirty) {
_price_list = LadderRender.render_prices(_pricevis, mid, _rowcount, _settings.row_height, _settings.price_column, _spec);
_ordershost.update_settings(_price_list, _settings.row_height, _settings.orders_column);
@@ -1,11 +1,8 @@
using ProtoBuf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace mbts.spark {
public enum ATMLine { Bid, Ask, Mid }
[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
public class LadderColumnSettings {
@@ -16,15 +13,13 @@ namespace mbts.spark {
public string font_family { get; set; } = "Segoe UI Semibold";
public double font_size { get; set; } = 10;
}
[ProtoContract(ImplicitFields = ImplicitFields.AllPublic)]
public class LadderSettings {
public double row_height { get; set; } = 20;
public UInt32 grid_line_color { get; set; } = 0x535353;
public ATMLine atm_line { get; set; } = ATMLine.Bid;
// Column settings
@@ -68,4 +63,4 @@ namespace mbts.spark {
public bool animate_recenter { get; set; } = true;
}
}
}