Merged master
This commit is contained in:
commit
c024095f75
9 files changed
+92
-49
No files matched your search
@@ -4,6 +4,14 @@ weight = 3
|
||||
sort_by = "weight"
|
||||
insert_anchor_links = "right"
|
||||
+++
|
||||
## 2.2.0
|
||||
### User Visible Changes
|
||||
- Made our orders easier to spot in MBO display
|
||||
|
||||
## 2.1.4
|
||||
### User Visible Changes
|
||||
- Fixed handling of cancel button in security picker
|
||||
|
||||
## 2.1.3
|
||||
### User Visible Changes
|
||||
- Fixed a simulator bug in the handling of 0 sized orders
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -27,7 +27,8 @@ cat << EOF > $sparkdata_dir/conf/spark.conf
|
||||
syslog { default_level: "Error" }
|
||||
file { default_level: "Error" }
|
||||
}
|
||||
}
|
||||
}
|
||||
MarketDataConfig { value { use_onixs: false; } }
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ cat << EOF > $sparkdata_dir/conf/spark.conf
|
||||
syslog { default_level: "Error" }
|
||||
file { default_level: "Error" }
|
||||
}
|
||||
}
|
||||
}
|
||||
MarketDataConfig { value { use_onixs: false; } }
|
||||
EOF
|
||||
|
||||
nohup ./sparkd run &
|
||||
|
||||
@@ -60,25 +60,28 @@ say_verbose() {
|
||||
fi
|
||||
}
|
||||
|
||||
is_merge_with_md_on() {
|
||||
# is_merge_with_md_on() {
|
||||
# eval $invocation
|
||||
|
||||
# if [ $(./sparkd configcheck ExchangeSim | grep merge_with_md: | cut -d " " -f 2) == "false" ]; then
|
||||
# return 0
|
||||
# else
|
||||
# return 1
|
||||
# fi
|
||||
# }
|
||||
|
||||
set_config() {
|
||||
eval $invocation
|
||||
|
||||
if [ $(./sparkd configcheck ExchangeSim | grep merge_with_md: | cut -d " " -f 2) == "false" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
set_merge_with_md_off() {
|
||||
eval $invocation
|
||||
[ ! -d "$sparkdata_dir/conf" ] && mkdir $sparkdata_dir/conf/
|
||||
[ -f "$spark_conf" ] && mv $spark_conf $spark_conf_bak
|
||||
|
||||
if [ -f $config_file_path ]; then
|
||||
say_verbose "config file exists ... removing"
|
||||
rm $config_file_path
|
||||
fi
|
||||
|
||||
echo "$merge_with_md_key" >> $config_file_path && test_config_file_created=true
|
||||
echo "$test_conf" >> $config_file_path && test_config_file_created=true
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -97,14 +100,6 @@ get_tests_in_class() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Start sparkd
|
||||
nohup ./sparkd run &
|
||||
pid=$!
|
||||
echo "sparkd pid: " $pid
|
||||
echo "sleeping for 120 seconds..."
|
||||
sleep 120
|
||||
|
||||
|
||||
# args
|
||||
# class_name - $1
|
||||
run_bts_test() {
|
||||
@@ -125,27 +120,43 @@ run_bts_test() {
|
||||
|
||||
test_script_name=$(basename "$0")
|
||||
verbose=true
|
||||
spark_conf=$sparkdata_dir/conf/spark.conf
|
||||
spark_conf_bak=$sparkdata_dir/conf/spark.conf.bak
|
||||
config_file_path="$sparkdata_dir/conf/test_join_algo_tests.conf"
|
||||
test_config_file_created=false
|
||||
merge_with_md_key=$(/bin/cat <<'END_HEREDOC'
|
||||
test_conf=$(/bin/cat <<'END_HEREDOC'
|
||||
ExchangeSim {
|
||||
value {
|
||||
merge_with_md: false
|
||||
}
|
||||
}
|
||||
MarketDataConfig {
|
||||
value {
|
||||
use_onixs: false;
|
||||
}
|
||||
}
|
||||
END_HEREDOC
|
||||
)
|
||||
|
||||
if is_merge_with_md_on; then
|
||||
set_merge_with_md_off
|
||||
if is_merge_with_md_on; then
|
||||
say_err "Could not turn off merge_with_md"
|
||||
say_err "Please investigate manually"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
say_verbose "merge with md is already off"
|
||||
fi
|
||||
# Start sparkd
|
||||
set_config
|
||||
nohup ./sparkd run &
|
||||
pid=$!
|
||||
echo "sparkd pid: " $pid
|
||||
echo "sleeping for 60 seconds..."
|
||||
sleep 60
|
||||
|
||||
|
||||
# if is_merge_with_md_on; then
|
||||
# set_config
|
||||
# if is_merge_with_md_on; then
|
||||
# say_err "Could not turn off merge_with_md"
|
||||
# say_err "Please investigate manually"
|
||||
# exit 1
|
||||
# fi
|
||||
# else
|
||||
# say_verbose "merge with md is already off"
|
||||
# fi
|
||||
|
||||
run_bts_test "JoinAlgoTests"
|
||||
|
||||
@@ -153,6 +164,8 @@ if [ "$test_config_file_created" = true ]; then
|
||||
rm $config_file_path
|
||||
fi
|
||||
|
||||
[ -f "$spark_conf_bak" ] && mv $spark_conf_bak $spark_conf
|
||||
|
||||
# Kill sparkd
|
||||
pkill -P $$
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ cat << EOF > $sparkdata_dir/conf/spark.conf
|
||||
syslog { default_level: "Error" }
|
||||
file { default_level: "Error" }
|
||||
}
|
||||
}
|
||||
}
|
||||
MarketDataConfig { value { use_onixs: false; } }
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,11 +304,12 @@ void DynamicJoin::on_child_change(OrderKey, ChildState const &st) {
|
||||
}
|
||||
}
|
||||
|
||||
// This is called by the spark daemon at startup. In this call we
|
||||
// describe our algo's parameters and register a factory function to
|
||||
// create an instance of the algo.
|
||||
extern "C" void init_spark_plugin(bts::SparkServices &serv) {
|
||||
using namespace bts;
|
||||
|
||||
// Describe our new algo order so that Spark can generate a GUI for
|
||||
// it.
|
||||
DynamicOrderDescriptor join_desc;
|
||||
|
||||
// Start by naming our order type
|
||||
|
||||
Reference in new issue
Block a user