Merged in SPARK-2472 (pull request #242)
RTM: 🏭 SPARK-2472 - our orders are hard to identify Approved-by: Michael Harding <michael.harding@bluetradesys.com> Approved-by: Jake Norbut <jake.norbut@bluetradesys.com>
This commit is contained in:
commit
942dc1640e
3 files changed
+32
-14
No files matched your search
@@ -44,7 +44,7 @@ namespace mbts.spark {
|
||||
readonly MBOService _mbo;
|
||||
readonly SecurityImmutable _security;
|
||||
readonly MBOSecurityQueryImmutable _query;
|
||||
readonly Dictionary<string, FormattedText> _cache;
|
||||
readonly Dictionary<(string,bool), FormattedText> _cache;
|
||||
int _max_order_size = 1;
|
||||
double _height = 0;
|
||||
double _number_width = 0;
|
||||
@@ -60,17 +60,17 @@ namespace mbts.spark {
|
||||
Enumerable.Range(1, 1+(int)default_query.Limit)
|
||||
.AsParallel()
|
||||
.Select(i => TextUtils.GetFormattedText(i.ToString(), font_size))
|
||||
.ToDictionary(ft => ft.Text);
|
||||
.ToDictionary(ft => (ft.Text,false));
|
||||
}
|
||||
|
||||
FormattedText format_text(string s, bool bold=false) {
|
||||
// cache FormattedText for the life of the popup
|
||||
if (_cache.TryGetValue(s, out FormattedText ft)) {
|
||||
var key = (s, bold);
|
||||
if (_cache.TryGetValue(key, out FormattedText ft)) {
|
||||
return ft;
|
||||
}
|
||||
else
|
||||
ft = bold ? TextUtils.GetFormattedTextBold(s, font_size) : TextUtils.GetFormattedText(s, font_size);
|
||||
_cache.TryAdd(s, ft);
|
||||
_cache.TryAdd(key, ft);
|
||||
return ft;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,8 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ismine(OrderPositionImmutable op) => op.OrderId != 0;
|
||||
|
||||
public MBOPopupDrawParams compute_layout(MBOPopupData p) {
|
||||
var pdp = new MBOPopupDrawParams { data = p };
|
||||
pdp.header = format_text(
|
||||
@@ -106,9 +108,9 @@ namespace mbts.spark {
|
||||
var margin = MBOPopupDrawParams.margin;
|
||||
var text_margin = margin.Left + margin.Right;
|
||||
|
||||
pdp.row_numbers = p.orders.Select((o, i) => format_text((i+1).ToString())).ToList();
|
||||
pdp.row_numbers = p.orders.Select((o, i) => format_text((i+1).ToString(), ismine(o))).ToList();
|
||||
pdp.numbers_width = _number_width = Math.Max(_number_width, (int)pdp.row_numbers.Max(r => r.Width) + text_margin);
|
||||
pdp.row_labels = p.orders.Select(o => format_text(o.Size.ToString())).ToList();
|
||||
pdp.row_labels = p.orders.Select(o => format_text(o.Size.ToString(), ismine(o))).ToList();
|
||||
var max_label_width = pdp.row_labels.Max(l => l.Width) + text_margin;
|
||||
|
||||
var available_width = pdp.width - pdp.numbers_width - max_label_width;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
static Brush brush_for(Side side, OrderPositionImmutable order) {
|
||||
if (order.OrderId != 0) return Brushes.Black;
|
||||
if (MBOPopupModel.ismine(order)) return Brushes.Black;
|
||||
switch (side) {
|
||||
case Side.Buy: return BTSColors.MarketData.bid_brush;
|
||||
case Side.Sell: return BTSColors.MarketData.ask_brush;
|
||||
|
||||
@@ -5,6 +5,7 @@ using bts.api.core;
|
||||
using bts.md;
|
||||
using CommandLine;
|
||||
using System.Linq;
|
||||
using bts.test;
|
||||
|
||||
namespace bts {
|
||||
|
||||
@@ -26,17 +27,32 @@ namespace bts {
|
||||
static void dump_mbo(uint key, api.Side side) {
|
||||
using (var ctx = new ServiceContext()) {
|
||||
var mbo = ctx.locate<MBOService>();
|
||||
var data = mbo.get_orders_for_security(new MBOSecurityQuery { SecurityId = key });
|
||||
var data = mbo.get_orders_for_security(new MBOSecurityQuery { SecurityId = key, PriceLevel = double.NaN });
|
||||
|
||||
Console.WriteLine($"Order data for {data.SecurityId}");
|
||||
var price = 0.0;
|
||||
foreach(var e in data.Bid.Concat(data.Ask)) {
|
||||
if (e.Price != price) {
|
||||
price = e.Price;
|
||||
Console.WriteLine("================");
|
||||
var color = Console.ForegroundColor;
|
||||
if (side == api.Side.Sell || side == api.Side.Undefined) {
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
foreach(var e in data.Ask.Reverse()) {
|
||||
if (e.Price != price) {
|
||||
price = e.Price;
|
||||
Console.WriteLine("================");
|
||||
}
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
if (side == api.Side.Buy || side == api.Side.Undefined) {
|
||||
Console.ForegroundColor = ConsoleColor.Blue;
|
||||
foreach(var e in data.Bid) {
|
||||
if (e.Price != price) {
|
||||
price = e.Price;
|
||||
Console.WriteLine("================");
|
||||
}
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
Console.ForegroundColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user