Compare commits
61
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eb3299006 | ||
|
|
15b45b7494 | ||
|
|
d7a98a8a95 | ||
|
|
f0a144e786 | ||
|
|
c45f131dc0 | ||
|
|
b5a227f7aa | ||
|
|
b4f2de327a | ||
|
|
70a1f0305e | ||
|
|
6bb7348b54 | ||
|
|
1cfba93216 | ||
|
|
ba33d9a657 | ||
|
|
5b2a6215a7 | ||
|
|
9edb5625c1 | ||
|
|
a31ad90be4 | ||
|
|
bddebfc25b | ||
|
|
f184ec5ecf | ||
|
|
b0a1d4f448 | ||
|
|
5bcb75b15c | ||
|
|
24ce565051 | ||
|
|
d3aa696afb | ||
|
|
e33028669d | ||
|
|
81700b03c8 | ||
|
|
7be1b658b4 | ||
|
|
775ff3e2db | ||
|
|
06094f9ecb | ||
|
|
110ed184b9 | ||
|
|
7e4d447572 | ||
|
|
e3616e3514 | ||
|
|
3cc8921684 | ||
|
|
c9b3cd1560 | ||
|
|
5edd274144 | ||
|
|
596d800cfb | ||
|
|
7b7ae9d7e2 | ||
|
|
a1663c9d06 | ||
|
|
a8e043c600 | ||
|
|
d02fba8145 | ||
|
|
aacb19990b | ||
|
|
8686287def | ||
|
|
50232dec55 | ||
|
|
c236b30a50 | ||
|
|
7881601066 | ||
|
|
14990f2d8b | ||
|
|
1c97374e4d | ||
|
|
ef386080d9 | ||
|
|
21c9bfe910 | ||
|
|
cd053ee4db | ||
|
|
ecacafca5a | ||
|
|
e3361e53ee | ||
|
|
9c8024da29 | ||
|
|
16ddcb33a3 | ||
|
|
7ef89ef7c6 | ||
|
|
77e9c1b6de | ||
|
|
711302262b | ||
|
|
9ad3c5e34f | ||
|
|
253941d686 | ||
|
|
4413eb5ac6 | ||
|
|
4e9e25e883 | ||
|
|
cc2943494f | ||
|
|
859b9ac369 | ||
|
|
5365febd92 | ||
|
|
cdb40d5b3d |
No files matched your search
@@ -13,6 +13,7 @@ insert_anchor_links = "right"
|
||||
- Allowed composite algos that are attached to existing orders to identify fills that were already present prior to attachment
|
||||
- Added import facilities for GMI position files
|
||||
- Added the ability for risk managers to enter manual fills
|
||||
- Added "raw" P&L columns, that is columns that *do not* include spread legs in their accounting
|
||||
### Bug Fixes
|
||||
- Fixed the settings action menu (Load/Save/Reset to Factory)
|
||||
- Fixed the method used to determine if a security is expired to take into account the start of day time
|
||||
|
||||
@@ -5,12 +5,14 @@ using bts.spark;
|
||||
using mbts;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.spark;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using LadderSettings = mbts.spark.LadderSettings;
|
||||
|
||||
namespace bts.shell {
|
||||
@@ -30,16 +32,23 @@ namespace bts.shell {
|
||||
_error_reporter = error_reporter;
|
||||
_dispose = Disposable.Create(
|
||||
model.on_orders.OnDispatcher().Subscribe(o => _orders = o),
|
||||
bus.subscribe(SparkTags.SecuritiesTag).OnDispatcher().Subscribe(m =>_md_map = m),
|
||||
bus.subscribe(SparkTags.SecuritiesTag).OnDispatcher().Subscribe(m => _md_map = m),
|
||||
bus.subscribe(SparkTags.ShowOrderTicketFromSecurityTag).OnDispatcher().Subscribe(_show_order_ticket),
|
||||
bus.subscribe(SparkTags.ShowOrderTicketTag).OnDispatcher().Subscribe(_show_order_ticket),
|
||||
bus.subscribe(SparkTags.ShowModifyOrderTag).OnDispatcher().Subscribe(_show_modify_order)
|
||||
bus.subscribe(SparkTags.ShowModifyOrderTag).OnDispatcher().Subscribe(_show_modify_order),
|
||||
bus.subscribe(SparkTags.ShowOrderTicketAtPositionTag).OnDispatcher().Subscribe(_show_order_ticket_at_position)
|
||||
);
|
||||
}
|
||||
|
||||
public void Dispose() =>
|
||||
Disposable.dispose(ref _dispose);
|
||||
|
||||
void _show_order_window_at_position(Window window, Point window_start_position) {
|
||||
foreach (var kv in AlgoStudioModelUtils.get_dynamic_resources(_model.algo_model.ui_configuration))
|
||||
window.Resources[kv.Key] = kv.Value;
|
||||
window.ShowAtPosition(window_start_position, true);
|
||||
}
|
||||
|
||||
void _show_order_window(Window window) {
|
||||
foreach (var kv in AlgoStudioModelUtils.get_dynamic_resources(_model.algo_model.ui_configuration))
|
||||
window.Resources[kv.Key] = kv.Value;
|
||||
@@ -60,6 +69,14 @@ namespace bts.shell {
|
||||
});
|
||||
}
|
||||
|
||||
void _show_order_ticket_at_position((OrderDefinitionImmutable def, double price, uint size, Point window_start_position) ops) {
|
||||
if (_md_map.TryGetValue(ops.def.SecurityKey, out SecurityMD smd))
|
||||
_show_order_window_at_position(new OrderTicket {
|
||||
DataContext = new NewOrderTicketVM(_model, smd, ops.def, ops.price, ops.size,
|
||||
Observable.Return(LadderSettings.Default.calculator_buttons), true, ops.def.Side)
|
||||
}, ops.window_start_position);
|
||||
}
|
||||
|
||||
void _show_modify_order(uint order_key) {
|
||||
if (_orders.state.TryGetValue(order_key, out var ori) && ori.sec.HasValue
|
||||
&& (ori.order.HasDef && ori.order.Def.HasCustomDef && !(ori.order.Def.CustomDef.HasStop || ori.order.Def.CustomDef.HasStopLimit))) {
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace bts.shell
|
||||
class MarketShellModule : IShellModule
|
||||
{
|
||||
[ImportingConstructor]
|
||||
public MarketShellModule(IBus bus, MDConsumer consumer, UserSettingsHub settings_hub, OrdersModel orders_model, [Import(LoginContainer.Exports.UserName)]string user_name) {
|
||||
public MarketShellModule(IBus bus, IWindowManager wm, MDConsumer consumer, UserSettingsHub settings_hub, OrdersModel orders_model, [Import(LoginContainer.Exports.UserName)]string user_name) {
|
||||
_tsf = new TimeAndSalesWindowFactory(this, bus, consumer, settings_hub);
|
||||
_mvf = new MarketViewWindowFactory(this, bus, settings_hub, orders_model);
|
||||
_mvf = new MarketViewWindowFactory(this, bus, wm, settings_hub, orders_model);
|
||||
}
|
||||
|
||||
TimeAndSalesWindowFactory _tsf;
|
||||
|
||||
@@ -15,6 +15,7 @@ using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
using static mbts.ui.controls.DIYGrid;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class MarketViewVM {
|
||||
@@ -35,12 +36,15 @@ namespace mbts.spark {
|
||||
readonly CellProperty<string> _working_bids_text, _working_asks_text;
|
||||
readonly MyOrderSummarizer _order_summarizer = new MyOrderSummarizer();
|
||||
readonly MDDisplayHelper.SizeFormatter _size_formatter = MDDisplayHelper.get_formatter(MarketSizeDisplay.get_default());
|
||||
readonly MarketViewVM _owner;
|
||||
Property<uint> _bid_direct_size, _bid_merged_size, _ask_direct_size, _ask_merged_size;
|
||||
double _raw_day_position;
|
||||
string _bid_merged_size_text, _ask_merged_size_text;
|
||||
ulong _bbo_ref, _last_ref;
|
||||
|
||||
public Row(IBus bus, SecurityMD smd, OrdersModel orders_model) : base(smd) {
|
||||
public Row(IBus bus, SecurityMD smd, OrdersModel orders_model, MarketViewVM owner) : base(smd) {
|
||||
_bus = bus;
|
||||
_owner = owner;
|
||||
_orders_model = orders_model;
|
||||
_security_text = smd.security.ToString();
|
||||
_security_key_text = security_key.ToString();
|
||||
@@ -74,21 +78,22 @@ namespace mbts.spark {
|
||||
_working_asks_text = new CellProperty<string>(this, nameof(working_asks_text), string.Empty);
|
||||
//
|
||||
default_command = new DelegateCommand(_show_ladder);
|
||||
bid_price_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.Bid));
|
||||
bid_merged_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.BidMergedSize));
|
||||
bid_direct_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.BidDirectSize));
|
||||
bid_implied_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.BidImpliedSize));
|
||||
working_bids_click = new DelegateCommand(() => _show_order_book(MarketViewView.Columns.WorkingBids));
|
||||
ask_price_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.Ask));
|
||||
ask_merged_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.AskMergedSize));
|
||||
ask_direct_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.AskDirectSize));
|
||||
ask_implied_size_click = new DelegateCommand(() => _show_order_ticket(MarketViewView.Columns.AskImpliedSize));
|
||||
working_asks_click = new DelegateCommand(() => _show_order_book(MarketViewView.Columns.WorkingAsks));
|
||||
bid_price_click = new DelegateCommand<(Side side, HyperlinkCell hlc)>((args) => _show_order_ticket(MarketViewView.Columns.Bid, args), (args) => args.side != Side.Undefined && args.hlc != null);
|
||||
bid_merged_size_click = new DelegateCommand<(Side side, HyperlinkCell hlc)>((args) => _show_order_ticket(MarketViewView.Columns.BidMergedSize, args), (args) => args.side != Side.Undefined && args.hlc != null);
|
||||
bid_direct_size_click = new DelegateCommand<(Side side, HyperlinkCell hlc)>((args) => _show_order_ticket(MarketViewView.Columns.BidDirectSize, args), (args) => args.side != Side.Undefined && args.hlc != null);
|
||||
bid_implied_size_click = new DelegateCommand<(Side side, HyperlinkCell hlc)>((args) => _show_order_ticket(MarketViewView.Columns.BidImpliedSize, args), (args) => args.side != Side.Undefined && args.hlc != null);
|
||||
working_bids_click = new DelegateCommand(() => _show_order_book(MarketViewView.Columns.WorkingBids), () => working_bids_text != string.Empty);
|
||||
ask_price_click = new DelegateCommand<(Side side, HyperlinkCell hlc)>((args) => _show_order_ticket(MarketViewView.Columns.Ask, args), (args) => args.side != Side.Undefined && args.hlc != null);
|
||||
ask_merged_size_click = new DelegateCommand<(Side side, HyperlinkCell hlc)>((args) => _show_order_ticket(MarketViewView.Columns.AskMergedSize, args), (args) => args.side != Side.Undefined && args.hlc != null);
|
||||
ask_direct_size_click = new DelegateCommand<(Side side, HyperlinkCell hlc)>((args) => _show_order_ticket(MarketViewView.Columns.AskDirectSize, args), (args) => args.side != Side.Undefined && args.hlc != null);
|
||||
ask_implied_size_click = new DelegateCommand<(Side side, HyperlinkCell hlc)>((args) => _show_order_ticket(MarketViewView.Columns.AskImpliedSize, args), (args) => args.side != Side.Undefined && args.hlc != null);
|
||||
working_asks_click = new DelegateCommand(() => _show_order_book(MarketViewView.Columns.WorkingAsks), () => working_asks_text != string.Empty);
|
||||
_animation.AnimationsChanged += on_animations_changed;
|
||||
void on_animations_changed() => RaisePropertyChanged(nameof(animations));
|
||||
_dispose = Disposable.Create(
|
||||
_orders_model.on_security_root_orders(security.Id).OnDispatcher().Subscribe(_on_orders),
|
||||
_position.OnDispatcher().Subscribe(v => _animation.animate_position(v.newval > v.oldval)),
|
||||
_orders_model.on_security_positions(security.Id).OnDispatcher().Subscribe(t => Set(ref _raw_day_position, t.state.Values.Sum(p => p.Item2.raw_day_pos()), nameof(raw_day_position))),
|
||||
_inside_bids.OnDispatcher().Subscribe(v => _animation.animate_working_bids_inside(v.newval)),
|
||||
_inside_asks.OnDispatcher().Subscribe(v => _animation.animate_working_asks_inside(v.newval)),
|
||||
_day_change.OnDispatcher().Subscribe(v => _animation.animate_day_change(v.newval > v.oldval)),
|
||||
@@ -102,6 +107,7 @@ namespace mbts.spark {
|
||||
public bool inside_bids => _inside_bids.value;
|
||||
public bool inside_asks => _inside_asks.value;
|
||||
public int position => _position.value;
|
||||
public double raw_day_position => _raw_day_position;
|
||||
public double last_price => _last_price.Value;
|
||||
public uint last_size => _last_size.value;
|
||||
public double bid_price => _bid_price.Value;
|
||||
@@ -214,38 +220,39 @@ namespace mbts.spark {
|
||||
_bus.post(SparkTags.ShowOrderBookTag, ob_settings);
|
||||
}
|
||||
|
||||
void _show_order_ticket(MarketViewView.Columns col) {
|
||||
void _show_order_ticket(MarketViewView.Columns col, (Side side, HyperlinkCell hlc) args) {
|
||||
var order = _orders_model.factory.order(security);
|
||||
|
||||
switch (col) {
|
||||
case MarketViewView.Columns.Bid:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, 0u));
|
||||
_owner._raise_open_order_ticket_at_position((order.with(side: args.side), security, bid_price, 0u, args.hlc));
|
||||
break;
|
||||
case MarketViewView.Columns.BidMergedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_merged_size));
|
||||
_owner._raise_open_order_ticket_at_position((order.with(side: args.side), security, bid_price, bid_merged_size, args.hlc));
|
||||
break;
|
||||
case MarketViewView.Columns.BidDirectSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_direct_size));
|
||||
_owner._raise_open_order_ticket_at_position((order.with(side: args.side), security, bid_price, bid_direct_size, args.hlc));
|
||||
break;
|
||||
case MarketViewView.Columns.BidImpliedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), bid_price, bid_implied_size));
|
||||
_owner._raise_open_order_ticket_at_position((order.with(side: args.side), security, bid_price, bid_implied_size, args.hlc));
|
||||
break;
|
||||
case MarketViewView.Columns.Ask:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Buy), ask_price, 0u));
|
||||
_owner._raise_open_order_ticket_at_position((order.with(side: args.side), security, ask_price, 0u, args.hlc));
|
||||
break;
|
||||
case MarketViewView.Columns.AskMergedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Buy), ask_price, ask_merged_size));
|
||||
_owner._raise_open_order_ticket_at_position((order.with(side: args.side), security, ask_price, ask_merged_size, args.hlc));
|
||||
break;
|
||||
case MarketViewView.Columns.AskDirectSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), ask_price, ask_direct_size));
|
||||
_owner._raise_open_order_ticket_at_position((order.with(side: args.side), security, ask_price, ask_direct_size, args.hlc));
|
||||
break;
|
||||
case MarketViewView.Columns.AskImpliedSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order.with(side:Side.Sell), ask_price, ask_implied_size));
|
||||
_owner._raise_open_order_ticket_at_position((order.with(side: args.side), security, ask_price, ask_implied_size, args.hlc));
|
||||
break;
|
||||
case MarketViewView.Columns.Last:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, last_price, 0u));
|
||||
_owner._raise_open_order_ticket_at_position((order.with(side: args.side), security, last_price, 0u, args.hlc));
|
||||
break;
|
||||
case MarketViewView.Columns.LastSize:
|
||||
_bus.post(SparkTags.ShowOrderTicketTag, (order, last_price, last_size));
|
||||
_owner._raise_open_order_ticket_at_position((order.with(side: args.side), security, last_price, last_size, args.hlc));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.collections;
|
||||
using bts.proto;
|
||||
using bts.utils;
|
||||
using mbts.persist;
|
||||
using mbts.spark.filters;
|
||||
@@ -11,7 +11,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using static bts.shell.MarketViewWindowFactory;
|
||||
@@ -24,6 +23,9 @@ namespace mbts.spark {
|
||||
readonly OrdersModel _orders_model;
|
||||
IWindowSettingsManager<GridSettings> _settings_manager;
|
||||
|
||||
public event Action<(OrderDefinitionImmutable order_def, SecurityImmutable security, double price, uint size, HyperlinkCell hlc)> open_order_ticket_at_position;
|
||||
internal void _raise_open_order_ticket_at_position((OrderDefinitionImmutable order_def, SecurityImmutable security, double price, uint size, HyperlinkCell hlc) args) => open_order_ticket_at_position?.Invoke(args);
|
||||
|
||||
public MarketViewVM(IBus bus, OrdersModel orders_model, IObservable<StartupData> state, IWindowSettingsManager<GridSettings> settings_manager )
|
||||
: this(bus, orders_model, state, state.SelectManyInSeries(s => s.security_criteria.subscribe_md(bus)), settings_manager) { }
|
||||
|
||||
@@ -43,16 +45,17 @@ namespace mbts.spark {
|
||||
add_col(Columns.Last, "Last", r => r.format_price(r.last_price), nameof(Row.last_price), DefaultColumnWidths.Price, last_price_filter, DataGridFilterKnownTemplates.DoubleMinMax);
|
||||
add_col(Columns.LastSize, merged_size_col_header, r => r.last_size.ToString(), nameof(Row.last_size), DefaultColumnWidths.Size, last_size_filter, DataGridFilterKnownTemplates.UIntMinMax, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.Position, "Pos", r => r.position.ToString(), nameof(Row.position), DefaultColumnWidths.Size, position_filter, DataGridFilterKnownTemplates.IntMinMax, true, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_working_orders_col(Columns.WorkingBids, working_col_header, nameof(Row.working_bids_text), nameof(Row.working_best_bid), nameof(Row.working_bids_click), working_bid_volume_filter, BTSColors.MarketData.bid, System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_working_orders_col(Columns.WorkingBids, working_col_header, nameof(Row.working_bids_text), nameof(Row.working_best_bid), nameof(Row.working_bids_click), working_bid_volume_filter, BTSColors.MarketData.bid, Side.Buy, System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.RawDayPosition, "Raw Day Pos", r => SparkUtils.fmt_position(r.raw_day_position), nameof(Row.raw_day_position), DefaultColumnWidths.Size, raw_day_position_filter, DataGridFilterKnownTemplates.DoubleMinMax, true, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.BidImpliedSize, implied_size_col_header, r => r.bid_implied_size.ToString(), nameof(Row.bid_implied_size), DefaultColumnWidths.ImpliedDirectMergedSize, bid_implied_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.BidDirectSize, direct_size_col_header, r => r.bid_direct_size.ToString(), nameof(Row.bid_direct_size), DefaultColumnWidths.ImpliedDirectMergedSize, bid_direct_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_merged_size_col(Columns.BidMergedSize, merged_size_col_header, nameof(Row.bid_merged_size), nameof(Row.bid_merged_size_text), nameof(Row.bid_merged_size_click), bid_merged_size_filter, BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_price_col(Columns.Bid, "Bid", nameof(Row.bid_price), nameof(Row.bid_price_click), bid_price_filter, BTSColors.header_text, BTSColors.MarketData.bid, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_price_col(Columns.Ask, "Ask", nameof(Row.ask_price), nameof(Row.ask_price_click), ask_price_filter, BTSColors.header_text, BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_merged_size_col(Columns.AskMergedSize, merged_size_col_header, nameof(Row.ask_merged_size), nameof(Row.ask_merged_size_text), nameof(Row.ask_merged_size_click), ask_merged_size_filter, BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_merged_size_col(Columns.BidMergedSize, merged_size_col_header, nameof(Row.bid_merged_size), nameof(Row.bid_merged_size_text), nameof(Row.bid_merged_size_click), bid_merged_size_filter, BTSColors.MarketData.bid, Side.Buy, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_price_col(Columns.Bid, "Bid", nameof(Row.bid_price), nameof(Row.bid_price_click), bid_price_filter, BTSColors.header_text, BTSColors.MarketData.bid, Side.Buy, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_price_col(Columns.Ask, "Ask", nameof(Row.ask_price), nameof(Row.ask_price_click), ask_price_filter, BTSColors.header_text, BTSColors.MarketData.ask, Side.Sell, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_merged_size_col(Columns.AskMergedSize, merged_size_col_header, nameof(Row.ask_merged_size), nameof(Row.ask_merged_size_text), nameof(Row.ask_merged_size_click), ask_merged_size_filter, BTSColors.MarketData.ask, Side.Sell, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.AskDirectSize, direct_size_col_header, r => r.ask_direct_size.ToString(), nameof(Row.ask_direct_size), DefaultColumnWidths.ImpliedDirectMergedSize, ask_direct_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.AskImpliedSize, implied_size_col_header, r => r.ask_implied_size.ToString(), nameof(Row.ask_implied_size), DefaultColumnWidths.ImpliedDirectMergedSize, ask_implied_size_filter, DataGridFilterKnownTemplates.UIntMinMax, font_color: BTSColors.MarketData.ask, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_working_orders_col(Columns.WorkingAsks, working_col_header, nameof(Row.working_asks_text), nameof(Row.working_best_ask), nameof(Row.working_asks_click), working_ask_volume_filter, BTSColors.MarketData.ask, System.Windows.HorizontalAlignment.Right);
|
||||
add_hl_working_orders_col(Columns.WorkingAsks, working_col_header, nameof(Row.working_asks_text), nameof(Row.working_best_ask), nameof(Row.working_asks_click), working_ask_volume_filter, BTSColors.MarketData.ask, Side.Sell, System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.Settlement, "Settlement", r => r.format_price(r.settlement), nameof(Row.settlement), DefaultColumnWidths.Settlement, settlement_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.DayChange, "Change", r => r.format_price(r.day_change), nameof(Row.day_change), DefaultColumnWidths.Price, day_change_filter, DataGridFilterKnownTemplates.DoubleMinMax, true, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
add_col(Columns.SessionLow, "Low", r => r.format_price(r.session_low), nameof(Row.session_low), DefaultColumnWidths.Price, session_low_filter, DataGridFilterKnownTemplates.DoubleMinMax, h_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
@@ -78,20 +81,20 @@ namespace mbts.spark {
|
||||
horizontal_alignment = h_alignment
|
||||
});
|
||||
|
||||
void add_hl_price_col(Columns col_key, string header, string prop, string command_prop, IDataGridColumnFilter filter, Color foreground, Color? background, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, price_binding(prop), prop, command_prop, filter, DataGridFilterKnownTemplates.DoubleMinMax, DefaultColumnWidths.MViewPrice, foreground, background, h_alignment);
|
||||
void add_hl_price_col(Columns col_key, string header, string prop, string command_prop, IDataGridColumnFilter filter, Color foreground, Color? background, Side market_side, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, price_binding(prop), prop, command_prop, filter, DataGridFilterKnownTemplates.DoubleMinMax, DefaultColumnWidths.MViewPrice, foreground, background, market_side, h_alignment);
|
||||
|
||||
void add_hl_merged_size_col(Columns col_key, string header, string sort_prop, string text_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.UIntMinMax, DefaultColumnWidths.ImpliedDirectMergedSize, foreground, null, h_alignment);
|
||||
void add_hl_merged_size_col(Columns col_key, string header, string sort_prop, string text_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, Side market_side, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.UIntMinMax, DefaultColumnWidths.ImpliedDirectMergedSize, foreground, null, market_side, h_alignment);
|
||||
|
||||
void add_hl_working_orders_col(Columns col_key, string header, string text_prop, string sort_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.IntMinMax, working_orders_col_width, foreground, null, h_alignment);
|
||||
void add_hl_working_orders_col(Columns col_key, string header, string text_prop, string sort_prop, string command_prop, IDataGridColumnFilter filter, Color foreground, Side market_side, System.Windows.HorizontalAlignment h_alignment) =>
|
||||
add_hl_col(col_key, header, new Binding(text_prop), sort_prop, command_prop, filter, DataGridFilterKnownTemplates.IntMinMax, working_orders_col_width, foreground, null, market_side, h_alignment);
|
||||
|
||||
void add_hl_col(
|
||||
Columns col_key, string header, BindingBase binding, string prop, string command_prop,
|
||||
IDataGridColumnFilter filter, string filter_template, double width, Color foreground, Color? background, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) =>
|
||||
columns.Add(new HyperlinkElementColumn<Row, Columns>(
|
||||
col_key, binding, new Binding(command_prop), filter, filter_template) {
|
||||
IDataGridColumnFilter filter, string filter_template, double width, Color foreground, Color? background, Side market_side, System.Windows.HorizontalAlignment h_alignment = System.Windows.HorizontalAlignment.Left) =>
|
||||
columns.Add(new MarketViewHyperlinkElementColumn(
|
||||
col_key, binding, new Binding(command_prop), filter, filter_template, market_side) {
|
||||
// it's necessary to have this id populated for grid settings
|
||||
id = bts.shell.MarketViewWindowFactory.col_id(col_key),
|
||||
Header = header,
|
||||
@@ -145,6 +148,7 @@ namespace mbts.spark {
|
||||
session_low_filter.load_state(filters.session_low);
|
||||
session_high_filter.load_state(filters.session_high);
|
||||
position_filter.load_state(filters.position);
|
||||
raw_day_position_filter.load_state(filters.raw_day_position);
|
||||
working_bid_volume_filter.load_state(filters.working_bid_volume);
|
||||
working_ask_volume_filter.load_state(filters.working_ask_volume);
|
||||
volume_filter.load_state(filters.volume);
|
||||
@@ -156,7 +160,7 @@ namespace mbts.spark {
|
||||
bid_price_filter, bid_merged_size_filter, bid_direct_size_filter, bid_implied_size_filter,
|
||||
ask_price_filter, ask_merged_size_filter, ask_direct_size_filter, ask_implied_size_filter,
|
||||
last_price_filter, last_size_filter, day_change_filter, settlement_filter,
|
||||
session_low_filter, session_high_filter, position_filter, working_bid_volume_filter, working_ask_volume_filter, volume_filter, security_key_filter),
|
||||
session_low_filter, session_high_filter, position_filter, raw_day_position_filter, working_bid_volume_filter, working_ask_volume_filter, volume_filter, security_key_filter),
|
||||
settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager),
|
||||
WorkLoop.Start("MarketView", _refresh)
|
||||
);
|
||||
@@ -224,6 +228,7 @@ namespace mbts.spark {
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> session_low_filter { get; } = new DoubleMinMax<Row>(r => r.session_low, nameof(Row.session_low));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> session_high_filter { get; } = new DoubleMinMax<Row>(r => r.session_high, nameof(Row.session_high));
|
||||
public IDataGridColumnPersistentFilter<Row, IntMinMaxState> position_filter { get; } = new IntMinMax<Row>(r => r.position, nameof(Row.position));
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> raw_day_position_filter { get; } = new DoubleMinMax<Row>(r => r.raw_day_position, nameof(Row.raw_day_position));
|
||||
public IDataGridColumnPersistentFilter<Row, IntMinMaxState> working_bid_volume_filter { get; } = new IntMinMax<Row>(r => r.working_bid_volume, nameof(Row.working_bid_volume));
|
||||
public IDataGridColumnPersistentFilter<Row, IntMinMaxState> working_ask_volume_filter { get; } = new IntMinMax<Row>(r => r.working_ask_volume, nameof(Row.working_ask_volume));
|
||||
public IDataGridColumnPersistentFilter<Row, ULongMinMaxState> volume_filter { get; } = new ULongMinMax<Row>(r => r.volume, nameof(Row.volume));
|
||||
@@ -255,6 +260,7 @@ namespace mbts.spark {
|
||||
session_low = session_low_filter.get_state(),
|
||||
session_high = session_high_filter.get_state(),
|
||||
position = position_filter.get_state(),
|
||||
raw_day_position = raw_day_position_filter.get_state(),
|
||||
working_bid_volume = working_bid_volume_filter.get_state(),
|
||||
working_ask_volume = working_ask_volume_filter.get_state(),
|
||||
volume = volume_filter.get_state(),
|
||||
@@ -269,7 +275,7 @@ namespace mbts.spark {
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override Row row_factory(SecurityMD smd) => new Row(_bus, smd, _orders_model);
|
||||
protected override Row row_factory(SecurityMD smd) => new Row(_bus, smd, _orders_model, this);
|
||||
protected override void on_row_removed(Row row) => row.Dispose();
|
||||
protected override IEnumerable<SortingCriteria> get_default_sorting() { yield return new SortingCriteria(nameof(Row.security), true); }
|
||||
|
||||
|
||||
@@ -8,8 +8,34 @@ namespace mbts.ui.spark {
|
||||
/// Interaction logic for MarketSheetsView.xaml
|
||||
/// </summary>
|
||||
partial class MarketViewView : UserControl {
|
||||
public enum Columns { Security, Volume, Last, LastSize, Position, WorkingBids, Bid, BidMergedSize, BidDirectSize, BidImpliedSize, Ask, AskMergedSize, AskDirectSize, AskImpliedSize, WorkingAsks, Settlement, DayChange, SessionLow, SessionHigh, SecurityKey,
|
||||
MarketDescription, ClearedAlias, ProductDescription, HubAlias, StripName, MicCode
|
||||
public enum Columns {
|
||||
Security,
|
||||
Volume,
|
||||
Last,
|
||||
LastSize,
|
||||
Position,
|
||||
RawDayPosition,
|
||||
WorkingBids,
|
||||
Bid,
|
||||
BidMergedSize,
|
||||
BidDirectSize,
|
||||
BidImpliedSize,
|
||||
Ask,
|
||||
AskMergedSize,
|
||||
AskDirectSize,
|
||||
AskImpliedSize,
|
||||
WorkingAsks,
|
||||
Settlement,
|
||||
DayChange,
|
||||
SessionLow,
|
||||
SessionHigh,
|
||||
SecurityKey,
|
||||
MarketDescription,
|
||||
ClearedAlias,
|
||||
ProductDescription,
|
||||
HubAlias,
|
||||
StripName,
|
||||
MicCode
|
||||
}
|
||||
|
||||
public MarketViewView() {
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace mbts.spark {
|
||||
readonly OrdersModel _orders_model;
|
||||
readonly AllowOnce _init_guard = new AllowOnce("MarketView");
|
||||
readonly IWindowSettingsManager<GridSettings> _settings_manager;
|
||||
readonly IWindowManager _wm;
|
||||
MarketViewVM _vm;
|
||||
MarketViewView _view;
|
||||
MarketViewWindowFactory.StartupData _state;
|
||||
@@ -33,11 +34,12 @@ namespace mbts.spark {
|
||||
_selected_security_criteria_backing,
|
||||
_sorted_selected_security_criteria_backing;
|
||||
|
||||
public MarketViewWindow(MarketViewWindowFactory factory, IBus bus, OrdersModel orders_model, MarketViewWindowFactory.StartupData state, WindowSettingsManager<GridSettings> settings_manager)
|
||||
public MarketViewWindow(MarketViewWindowFactory factory, IBus bus, OrdersModel orders_model, MarketViewWindowFactory.StartupData state, IWindowSettingsManager<GridSettings> settings_manager, IWindowManager wm)
|
||||
: base("Market View", bus, factory, SparkCommands.ShowMarketView.icon) {
|
||||
_orders_model = orders_model;
|
||||
_state = state;
|
||||
_settings_manager = settings_manager;
|
||||
_wm = wm;
|
||||
Icon.Freeze();
|
||||
thread_id = config.Configuration.get<bts.config.MultiThreadedWindows>().market_view ? "MarketView" : null;
|
||||
}
|
||||
@@ -104,6 +106,20 @@ namespace mbts.spark {
|
||||
var state_src = Observable.FromEvent<Action<MarketViewWindowFactory.StartupData>, MarketViewWindowFactory.StartupData>(cb => _state_changed += cb, cb => _state_changed -= cb).StartWith(_state);
|
||||
_vm = new MarketViewVM(_bus, _orders_model, state_src, _settings_manager);
|
||||
_view = new MarketViewView { DataContext = _vm };
|
||||
|
||||
var tab_height = Application.Current.TryFindResource("TabHeight") as Double? ?? 30;
|
||||
_vm.open_order_ticket_at_position += (args) => {
|
||||
if (_view.try_find_ancestor_of_type<System.Windows.Controls.Grid>(out var grid) && grid.Name == "_grid") {
|
||||
var pos = Application.Current.Dispatcher.Invoke(() => _wm.GetPosition(this));
|
||||
var coords = args.hlc.TranslatePoint(new Point(0, 0), grid);
|
||||
/* X = (Floating Window left pos) + (Floating Window BorderThickness) + (window_border left border) */
|
||||
coords.X += pos.left + 1 + 7;
|
||||
/* Y = (Floating Window top pos) + (Floating Window BorderThickness) + (window_border top border) + tab height + row_height */
|
||||
coords.Y += pos.top + 1 + 1 + tab_height + args.hlc.ActualHeight;
|
||||
|
||||
_bus.post(SparkTags.ShowOrderTicketAtPositionTag, (args.order_def, args.price, args.size, coords));
|
||||
}
|
||||
};
|
||||
_view._grid.Sorting += on_grid_sorting;
|
||||
/// The 'CanExecute' plumbing for the cmds below is designed to avoid potentially costly .ToList() operations on the selected_rows/securities.
|
||||
/// Some of the cmds post ITags with data that is, or has, a SecurityCriteria member; the SecurityCriteria constructor creates a new List of the specified securities.
|
||||
@@ -153,7 +169,7 @@ namespace mbts.spark {
|
||||
s => _vm.grid_settings_manager.create_vm(
|
||||
// we need to get the most up to date GridSettings when launching b/c users may
|
||||
// have changed some settings on the grid directly, like column widths.
|
||||
MarketViewWindowFactory.StartupData.sanitize(s).with(_vm.columns.Select(c => c.create()))
|
||||
s.with(_vm.columns.Select(c => c.create()))
|
||||
)
|
||||
);
|
||||
vm.SubscribeDisposed(literal_title_source.OnDispatcher().Subscribe(t => vm.title = t));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using bts.api;
|
||||
using bts.proto;
|
||||
using bts.settings;
|
||||
using mbts.persist;
|
||||
using mbts.spark;
|
||||
using mbts.spark.filters;
|
||||
@@ -8,6 +9,7 @@ using mbts.ui.settings;
|
||||
using ProtoBuf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -19,10 +21,12 @@ namespace bts.shell {
|
||||
readonly IBus _bus;
|
||||
readonly OrdersModel _orders_model;
|
||||
readonly UserSettingsHub _settings_hub;
|
||||
readonly IWindowManager _wm;
|
||||
|
||||
|
||||
public MarketViewWindowFactory(MarketShellModule module, IBus bus, UserSettingsHub settings_hub, OrdersModel orders_model) : base(module, "MarketView") {
|
||||
public MarketViewWindowFactory(MarketShellModule module, IBus bus, IWindowManager wm, UserSettingsHub settings_hub, OrdersModel orders_model) : base(module, "MarketView") {
|
||||
_bus = bus;
|
||||
_wm = wm;
|
||||
_orders_model = orders_model;
|
||||
_settings_hub = settings_hub;
|
||||
_dispose = bus.subscribe(SparkTags.ShowMarketViewTag).OnDispatcher().Subscribe(_show);
|
||||
@@ -36,13 +40,8 @@ namespace bts.shell {
|
||||
void _show(SecurityCriteria criteria) =>
|
||||
_bus.post(SparkTags.ShowWindow, _create(StartupData.Default(criteria)));
|
||||
|
||||
IShellWindow _create(StartupData state) {
|
||||
var settings_manager = new WindowSettingsManager<GridSettings>(_settings_hub,
|
||||
StartupData.sanitize(state.grid),
|
||||
get: us => StartupData.sanitize(us.market_view_grid),
|
||||
set: (us, gs) => us.with(provided_market_view_gridsettings: gs));
|
||||
return new MarketViewWindow(this, _bus, _orders_model, state, settings_manager);
|
||||
}
|
||||
IShellWindow _create(StartupData state) =>
|
||||
new MarketViewWindow(this, _bus, _orders_model, state, _settings_hub.create_mview_settings_manager(state.grid), _wm);
|
||||
|
||||
[ProtoContract]
|
||||
public class StartupData {
|
||||
@@ -105,6 +104,7 @@ namespace bts.shell {
|
||||
public static GridColumnSettings last => new GridColumnSettings(col_id(Columns.Last), DefaultColumnHeaders.Last, width: DefaultColumnWidths.Price);
|
||||
public static GridColumnSettings last_size => new GridColumnSettings(col_id(Columns.LastSize), DefaultColumnHeaders.Size, width: DefaultColumnWidths.Size, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings position => new GridColumnSettings(col_id(Columns.Position), DefaultColumnHeaders.Pos, width: DefaultColumnWidths.Size, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings raw_day_position => new GridColumnSettings(col_id(Columns.RawDayPosition), DefaultColumnHeaders.RawDayPos, width: DefaultColumnWidths.Size, horizontal_alignment: System.Windows.HorizontalAlignment.Right, is_visible: false);
|
||||
public static GridColumnSettings working_bids => new GridColumnSettings(col_id(Columns.WorkingBids), DefaultColumnHeaders.Working, font_color_override: BTSColors.MarketData.bid, width: DefaultColumnWidths.Working, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings bid_implied_size => new GridColumnSettings(col_id(Columns.BidImpliedSize), DefaultColumnHeaders.ImpliedSize, font_color_override: BTSColors.MarketData.bid, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings bid_direct_size => new GridColumnSettings(col_id(Columns.BidDirectSize), DefaultColumnHeaders.DirectSize, font_color_override: BTSColors.MarketData.bid, width: DefaultColumnWidths.ImpliedDirectMergedSize, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
@@ -142,6 +142,7 @@ namespace bts.shell {
|
||||
yield return last;
|
||||
yield return last_size;
|
||||
yield return position;
|
||||
yield return raw_day_position;
|
||||
yield return working_bids;
|
||||
yield return bid_implied_size;
|
||||
yield return bid_direct_size;
|
||||
@@ -196,6 +197,8 @@ namespace bts.shell {
|
||||
public DoubleMinMaxState session_high;
|
||||
[ProtoMember(12)]
|
||||
public IntMinMaxState position;
|
||||
[ProtoMember(27)]
|
||||
public DoubleMinMaxState raw_day_position;
|
||||
[ProtoMember(13)]
|
||||
public IntMinMaxState working_bid_volume;
|
||||
[ProtoMember(14)]
|
||||
@@ -225,5 +228,46 @@ namespace bts.shell {
|
||||
[ProtoMember(26)]
|
||||
public string mic_code;
|
||||
}
|
||||
|
||||
// migration rules
|
||||
[Export(typeof(IMarketViewGridSettingsMigrationRule))]
|
||||
class AddMissingColumnsMigrationRule : IMarketViewGridSettingsMigrationRule {
|
||||
public bool apply(GridSettings settings, out GridSettings new_settings) =>
|
||||
settings.add_missing_columns(StartupData.DefaultGridSettings.columns, out new_settings);
|
||||
}
|
||||
|
||||
[Export(typeof(IMarketViewGridSettingsMigrationRule))]
|
||||
class InitBidAskBackgroundOverrideMigrationRule : IMarketViewGridSettingsMigrationRule {
|
||||
public bool apply(GridSettings s, out GridSettings new_settings) {
|
||||
var columns = s.columns.ToList();
|
||||
var bid_col_index = columns.FindIndex(x => x.id == col_id(Columns.Bid));
|
||||
var ask_col_index = columns.FindIndex(x => x.id == col_id(Columns.Ask));
|
||||
bool applied = false;
|
||||
if (bid_col_index > -1 && ask_col_index > -1) {
|
||||
if (!columns[bid_col_index].background_color_override.HasValue) {
|
||||
columns[bid_col_index] = columns[bid_col_index].with(background_color_override: new NullableColorProto(BTSColors.MarketData.bid.ToUint()));
|
||||
applied = true;
|
||||
}
|
||||
if (!columns[ask_col_index].background_color_override.HasValue) {
|
||||
columns[ask_col_index] = columns[ask_col_index].with(background_color_override: new NullableColorProto(BTSColors.MarketData.ask.ToUint()));
|
||||
applied = true;
|
||||
}
|
||||
}
|
||||
new_settings = applied ? s.with(columns) : default;
|
||||
return applied;
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(IMarketViewGridSettingsMigrationRule))]
|
||||
class InitBackgroundOverrideMigrationRule : IMarketViewGridSettingsMigrationRule {
|
||||
public bool apply(GridSettings settings, out GridSettings new_settings) {
|
||||
if (!settings.enable_background_color) {
|
||||
new_settings = settings.with(enable_background_color: true);
|
||||
return true;
|
||||
}
|
||||
new_settings = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -450,6 +450,8 @@ namespace mbts.spark {
|
||||
public bool account_position_visible { get; set; }
|
||||
[ProtoMember(50), DefaultValue(true)]
|
||||
public bool day_position_visible { get; set; }
|
||||
[ProtoMember(56)]
|
||||
public bool raw_day_position_visible { get; set; }
|
||||
[ProtoMember(37), DefaultValue(true)]
|
||||
public bool size_presets_visible { get; set; }
|
||||
[ProtoMember(38), DefaultValue(true)]
|
||||
@@ -570,6 +572,7 @@ namespace mbts.spark {
|
||||
order_type_visible == other.order_type_visible &&
|
||||
account_position_visible == other.account_position_visible &&
|
||||
day_position_visible == other.day_position_visible &&
|
||||
raw_day_position_visible == other.raw_day_position_visible &&
|
||||
size_presets_visible == other.size_presets_visible &&
|
||||
cancel_buys_visible == other.cancel_buys_visible &&
|
||||
cancel_sells_visible == other.cancel_sells_visible &&
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace mbts.spark {
|
||||
_order_type_visibility = new OrderEntryPanelItemVisibilityVM("Order Type"),
|
||||
_account_position_visibility = new OrderEntryPanelItemVisibilityVM("Account Position"),
|
||||
_day_position_visibility = new OrderEntryPanelItemVisibilityVM("Day Position"),
|
||||
_raw_day_position_visibility = new OrderEntryPanelItemVisibilityVM("Raw Day Position"),
|
||||
_size_preset_visibility = new OrderEntryPanelItemVisibilityVM("Size Presets"),
|
||||
_auto_clear_visibility = new OrderEntryPanelItemVisibilityVM("Auto Clear"),
|
||||
_clear_visibility = new OrderEntryPanelItemVisibilityVM("Clear"),
|
||||
@@ -239,6 +240,7 @@ namespace mbts.spark {
|
||||
yield return _order_type_visibility;
|
||||
yield return _account_position_visibility;
|
||||
yield return _day_position_visibility;
|
||||
yield return _raw_day_position_visibility;
|
||||
yield return _size_preset_visibility;
|
||||
yield return _clear_visibility;
|
||||
yield return _auto_clear_visibility;
|
||||
@@ -281,6 +283,7 @@ namespace mbts.spark {
|
||||
yield return _order_type_visibility;
|
||||
yield return _account_position_visibility;
|
||||
yield return _day_position_visibility;
|
||||
yield return _raw_day_position_visibility;
|
||||
yield return _size_preset_visibility;
|
||||
yield return _auto_clear_visibility;
|
||||
yield return _clear_visibility;
|
||||
@@ -343,6 +346,7 @@ namespace mbts.spark {
|
||||
_order_type_visibility.show = settings.order_type_visible;
|
||||
_account_position_visibility.show = settings.account_position_visible;
|
||||
_day_position_visibility.show = settings.day_position_visible;
|
||||
_raw_day_position_visibility.show = settings.raw_day_position_visible;
|
||||
_size_preset_visibility.show = settings.size_presets_visible;
|
||||
_clear_visibility.show = settings.clear_visible;
|
||||
_auto_clear_visibility.show = settings.auto_clear_visible;
|
||||
@@ -415,6 +419,7 @@ namespace mbts.spark {
|
||||
clone.order_type_visible = _order_type_visibility.show;
|
||||
clone.account_position_visible = _account_position_visibility.show;
|
||||
clone.day_position_visible = _day_position_visibility.show;
|
||||
clone.raw_day_position_visible = _raw_day_position_visibility.show;
|
||||
clone.size_presets_visible = _size_preset_visibility.show;
|
||||
clone.auto_clear_visible = _auto_clear_visibility.show;
|
||||
clone.clear_visible = _clear_visibility.show;
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace mbts.spark {
|
||||
_show_cancel_sells, _show_cancel_all, _show_zoom;
|
||||
readonly PropertyAutoWrapper<LadderSettings, Brush> _bid_background, _bid_foreground, _ask_background, _ask_foreground;
|
||||
readonly HashSet<AlgoKey> _sticky_algos = new HashSet<AlgoKey>();
|
||||
double _position, _day_position;
|
||||
bool _show_account_position, _show_day_position;
|
||||
double _position, _day_position, _raw_day_position;
|
||||
bool _show_account_position, _show_day_position, _show_raw_day_position;
|
||||
ulong _misc_time = 0;
|
||||
ulong _last_trade_time = 0;
|
||||
IEqualityComparer<double> _equality;
|
||||
@@ -109,7 +109,10 @@ namespace mbts.spark {
|
||||
(_show_cancel_all = bool_prop(nameof(show_cancel_all), s => s.cancel_all_visible)).set,
|
||||
(_show_zoom = bool_prop(nameof(show_zoom), s => s.zoom_slider_visible)).set,
|
||||
s => {
|
||||
if (Set(ref _show_account_position, s.account_position_visible, nameof(show_account_position)) | Set(ref _show_day_position, s.day_position_visible, nameof(show_day_position))) {
|
||||
if (
|
||||
Set(ref _show_account_position, s.account_position_visible, nameof(show_account_position)) |
|
||||
Set(ref _show_day_position, s.day_position_visible, nameof(show_day_position)) |
|
||||
Set(ref _show_raw_day_position, s.raw_day_position_visible, nameof(show_raw_day_position))) {
|
||||
RaisePropertyChanged(nameof(position_display_text));
|
||||
}
|
||||
size_calculator.buttons = s.calculator_buttons;
|
||||
@@ -232,14 +235,19 @@ namespace mbts.spark {
|
||||
}),
|
||||
order_properties_vm,
|
||||
position_src.OnDispatcher().Subscribe(pos => {
|
||||
double total, day;
|
||||
double total, day, raw_day;
|
||||
if (pos.HasValue) {
|
||||
total = pos.Value.total_pos();
|
||||
day = pos.Value.day_pos();
|
||||
raw_day = pos.Value.raw_day_pos();
|
||||
} else {
|
||||
total = day = double.NaN;
|
||||
total = day = raw_day = double.NaN;
|
||||
}
|
||||
if ((Set(ref _position, total, nameof(position)) | Set(ref _day_position, day, nameof(day_position))) && (show_day_position || show_account_position))
|
||||
if ((
|
||||
Set(ref _position, total, nameof(position)) |
|
||||
Set(ref _day_position, day, nameof(day_position)) |
|
||||
Set(ref _raw_day_position, raw_day, nameof(raw_day_position))
|
||||
) && (show_day_position || show_account_position || show_raw_day_position))
|
||||
RaisePropertyChanged(nameof(position_display_text));
|
||||
}));
|
||||
}
|
||||
@@ -290,6 +298,7 @@ namespace mbts.spark {
|
||||
public double settlement => _settlement.Value;
|
||||
public double position => _position;
|
||||
public double day_position => _day_position;
|
||||
public double raw_day_position => _raw_day_position;
|
||||
public ulong volume => _volume.Value;
|
||||
public bool auto_clear { get => _auto_clear.Value; set => _auto_clear.set(value); }
|
||||
public CalculatorLogic size_calculator { get; } = new CalculatorLogic(0);
|
||||
@@ -316,6 +325,7 @@ namespace mbts.spark {
|
||||
public bool show_order_type => _show_order_type.view;
|
||||
public bool show_account_position => _show_account_position;
|
||||
public bool show_day_position => _show_day_position;
|
||||
public bool show_raw_day_position => _show_raw_day_position;
|
||||
public bool show_size_preset => _show_size_preset.view;
|
||||
public bool show_auto_clear => _show_auto_clear.view;
|
||||
public bool show_clear => _show_clear.view;
|
||||
@@ -327,12 +337,18 @@ namespace mbts.spark {
|
||||
public double zoom_factor { get => _zoom_factor.Value; set => _zoom_factor.set(value); }
|
||||
public string position_display_text {
|
||||
get {
|
||||
if (show_day_position) {
|
||||
string day_pos_text = SparkUtils.fmt_position(day_position);
|
||||
return show_account_position ? $"{day_pos_text} ({SparkUtils.fmt_position(position)})" : day_pos_text;
|
||||
} else if (show_account_position) {
|
||||
return SparkUtils.fmt_position(position);
|
||||
} else return string.Empty;
|
||||
string rv = null;
|
||||
if (show_day_position)
|
||||
rv = SparkUtils.fmt_position(day_position);
|
||||
if (show_raw_day_position) {
|
||||
var raw_day_text = SparkUtils.fmt_position(raw_day_position);
|
||||
rv = rv == null ? raw_day_text : $"{rv} / {raw_day_text}";
|
||||
}
|
||||
if (show_account_position) {
|
||||
var acc_text = SparkUtils.fmt_position(position);
|
||||
rv = rv == null ? SparkUtils.fmt_position(position) : $"{rv} ({acc_text})";
|
||||
}
|
||||
return rv ?? "";
|
||||
}
|
||||
}
|
||||
//public double window_height { get => _window_height.Value; set => _window_height.set(value); }
|
||||
|
||||
@@ -476,6 +476,7 @@
|
||||
</converters:MultiValueConverterPipe>
|
||||
</MultiBinding.Converter>
|
||||
<Binding Path="show_day_position"/>
|
||||
<Binding Path="show_raw_day_position"/>
|
||||
<Binding Path="show_account_position"/>
|
||||
</MultiBinding>
|
||||
</Button.Visibility>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.settings;
|
||||
using bts.spark;
|
||||
using mbts.persist;
|
||||
using mbts.spark;
|
||||
using mbts.spark.filters;
|
||||
using mbts.ui;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.spark;
|
||||
using ProtoBuf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -40,13 +40,14 @@ namespace bts.shell {
|
||||
_bus.post(SparkTags.ShowWindow, w);
|
||||
}
|
||||
|
||||
IShellWindow _create(PAndLStartupData state) {
|
||||
var settings_manager = new WindowSettingsManager<GridSettings>(_settings_hub,
|
||||
state.grid,
|
||||
get: us => us.pnl_grid,
|
||||
set: (us, gs) => us.with(provided_pnl_gridsettings: gs));
|
||||
return new PAndLWindow(_orders_model, this, _bus, state, SparkCommands.ShowPAndL.icon, settings_manager);
|
||||
}
|
||||
IShellWindow _create(PAndLStartupData state) =>
|
||||
new PAndLWindow(
|
||||
_orders_model,
|
||||
this,
|
||||
_bus,
|
||||
state,
|
||||
SparkCommands.ShowPAndL.icon,
|
||||
_settings_hub.create_pandl_settings_manager(state.grid));
|
||||
|
||||
[ProtoContract]
|
||||
public class PAndLStartupData {
|
||||
@@ -81,7 +82,7 @@ namespace bts.shell {
|
||||
[ProtoMember(25)]
|
||||
public GridSettings grid;
|
||||
|
||||
static class DefaultColumns {
|
||||
public static class DefaultColumns {
|
||||
|
||||
public static GridColumnSettings account => new GridColumnSettings(col_id(Columns.Account), DefaultColumnHeaders.Account, width: DefaultColumnWidths.Account);
|
||||
public static GridColumnSettings exchange => new GridColumnSettings(col_id(Columns.Exchange), DefaultColumnHeaders.Exchange, false, width: DefaultColumnWidths.Exchange);
|
||||
@@ -92,10 +93,12 @@ namespace bts.shell {
|
||||
public static GridColumnSettings start_pnl => new GridColumnSettings(col_id(Columns.StartPNL), DefaultColumnHeaders.StartPnL, false, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings day_long_pnl => new GridColumnSettings(col_id(Columns.DayLong), DefaultColumnHeaders.DayLong, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings day_short_pnl => new GridColumnSettings(col_id(Columns.DayShort), DefaultColumnHeaders.DayShort, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings raw_day_net_position => new GridColumnSettings(col_id(Columns.RawDayPos), DefaultColumnHeaders.RawDayPos, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right, is_visible: false);
|
||||
public static GridColumnSettings day_pnl => new GridColumnSettings(col_id(Columns.DayPNL), DefaultColumnHeaders.DayPnL, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings total_net_pos => new GridColumnSettings(col_id(Columns.TotalNetPos), DefaultColumnHeaders.TotalNetPos, false, width: DefaultColumnWidths.Total_Net_Pos, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings total_pnl => new GridColumnSettings(col_id(Columns.TotalPNL), DefaultColumnHeaders.TotalPnL, false, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings pnl_price => new GridColumnSettings(col_id(Columns.PNLPrice), DefaultColumnHeaders.PnLPrice, width: DefaultColumnWidths.PnL_Generic, horizontal_alignment: System.Windows.HorizontalAlignment.Right);
|
||||
public static GridColumnSettings has_day_trades => new GridColumnSettings(col_id(Columns.TradedToday), "Traded Today", width: 100, horizontal_alignment: System.Windows.HorizontalAlignment.Center);
|
||||
|
||||
public static IEnumerable<SortingCriteria> default_sorting_criterion {
|
||||
get {
|
||||
@@ -117,10 +120,12 @@ namespace bts.shell {
|
||||
yield return start_pnl;
|
||||
yield return day_long_pnl;
|
||||
yield return day_short_pnl;
|
||||
yield return raw_day_net_position;
|
||||
yield return day_pnl;
|
||||
yield return total_net_pos;
|
||||
yield return total_pnl;
|
||||
yield return pnl_price;
|
||||
yield return has_day_trades;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +150,8 @@ namespace bts.shell {
|
||||
public UIntMinMaxState day_long_pos;
|
||||
[ProtoMember(8)]
|
||||
public UIntMinMaxState day_short_pos;
|
||||
[ProtoMember(16)]
|
||||
public DoubleMinMaxState raw_day_net_pos;
|
||||
[ProtoMember(9)]
|
||||
public DoubleMinMaxState day_pnl;
|
||||
[ProtoMember(10)]
|
||||
@@ -162,7 +169,11 @@ namespace bts.shell {
|
||||
public bool[] has_day_trades;
|
||||
}
|
||||
|
||||
// migration rules
|
||||
[Export(typeof(IPAndLGridSettingsMigrationRule))]
|
||||
class AddMissingColumnsMigrationRule : IPAndLGridSettingsMigrationRule {
|
||||
public bool apply(GridSettings settings, out GridSettings new_settings) =>
|
||||
settings.add_missing_columns(PAndLStartupData.DefaultGridSettings.columns, out new_settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -31,9 +31,16 @@ namespace mbts.spark {
|
||||
|
||||
class NewOrderTicketVM : DisposableViewModelBase, IRequestViewClose {
|
||||
readonly Property<SecurityImmutable> _security;
|
||||
readonly bool _is_broker_mode;
|
||||
|
||||
public NewOrderTicketVM(OrdersModel model, SecurityMD security_md, OrderDefinitionImmutable def, double price, uint size, IObservable<int[]> calculator_buttons)
|
||||
: this(model, Observable.Return(security_md), Observable.Return(new InlineOrderTicketProperties(model, def, price, size)), calculator_buttons) { }
|
||||
readonly Property<bool> _buy_is_visible;
|
||||
// need this one too b/c the determination is made off of _is_broker_mode as well
|
||||
readonly Property<bool> _sell_is_visible;
|
||||
readonly Property<Side> _broker_mode_side;
|
||||
|
||||
|
||||
public NewOrderTicketVM(OrdersModel model, SecurityMD security_md, OrderDefinitionImmutable def, double price, uint size, IObservable<int[]> calculator_buttons, bool is_broker_mode = false, Side broker_mode_side = Side.Undefined)
|
||||
: this(model, Observable.Return(security_md), Observable.Return(new InlineOrderTicketProperties(model, def, price, size)), calculator_buttons, is_broker_mode, broker_mode_side) { }
|
||||
|
||||
public NewOrderTicketVM(
|
||||
OrdersModel model,
|
||||
@@ -45,9 +52,15 @@ namespace mbts.spark {
|
||||
OrdersModel model,
|
||||
IObservable<SecurityMD> security_md_source,
|
||||
IObservable<InlineOrderTicketProperties> props_source,
|
||||
IObservable<int[]> calculator_buttons
|
||||
IObservable<int[]> calculator_buttons,
|
||||
bool is_broker_mode = false,
|
||||
Side init_broker_mode_side = Side.Undefined
|
||||
) {
|
||||
_security = backing(nameof(security), security_md_source.Select(smd => smd.security), SecurityDataHelper.Defaults.SecurityImmutable);
|
||||
_is_broker_mode = is_broker_mode;
|
||||
_broker_mode_side = backing(nameof(broker_mode_side), () => init_broker_mode_side);
|
||||
_buy_is_visible = backing(nameof(buy_is_visible), () => !is_broker_mode || (is_broker_mode && broker_mode_side == Side.Buy), nameof(broker_mode_side));
|
||||
_sell_is_visible = backing(nameof(sell_is_visible), () => !is_broker_mode || (is_broker_mode && broker_mode_side == Side.Sell), nameof(broker_mode_side));
|
||||
properties_vm = new OrderPropertiesEditorVM(model, security_md_source, props_source.Select(p => p.order_props));
|
||||
bbo = new BBOVM();
|
||||
send_order = new DelegateCommand<Side>(side => {
|
||||
@@ -58,6 +71,17 @@ namespace mbts.spark {
|
||||
}
|
||||
});
|
||||
set_price_command = new DelegateCommand<double>(set_price);
|
||||
set_price_and_side_command = new DelegateCommand<Tuple<double, Side>>((pair) => {
|
||||
(price, broker_mode_side) = pair;
|
||||
RaisePropertyChanged(nameof(price));
|
||||
});
|
||||
set_size_and_price_and_side_command = new DelegateCommand<Tuple<uint, double, Side>>((triplet) =>
|
||||
{
|
||||
size_calculator.set_value_command?.Execute(triplet.Item1);
|
||||
price = triplet.Item2;
|
||||
RaisePropertyChanged(nameof(price));
|
||||
broker_mode_side = triplet.Item3;
|
||||
});
|
||||
_dispose = Disposable.Create(
|
||||
bbo,
|
||||
security_md_source.OnDispatcher().Subscribe(smd => bbo.security_md = smd),
|
||||
@@ -86,6 +110,12 @@ namespace mbts.spark {
|
||||
public BBOVM bbo { get; }
|
||||
public ICommand send_order { get; }
|
||||
public ICommand set_price_command { get; }
|
||||
public ICommand set_price_and_side_command { get; }
|
||||
public ICommand set_size_and_price_and_side_command { get; }
|
||||
public bool buy_is_visible { get => _buy_is_visible.Value; private set => _buy_is_visible.Value = value; }
|
||||
public bool sell_is_visible { get => _sell_is_visible.Value; private set => _sell_is_visible.Value = value; }
|
||||
public bool is_broker_mode => _is_broker_mode;
|
||||
public Side broker_mode_side { get => _broker_mode_side.Value; private set => _broker_mode_side.Value = value; }
|
||||
|
||||
bool _validate_price() {
|
||||
if (DoubleHelper.IsNaNOrInfinity(price)) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<UserControl x:Class="mbts.ui.spark.OrderModificationControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:msys="clr-namespace:bts.api;assembly=spark_api"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
@@ -86,7 +87,14 @@
|
||||
CommitOnEnter="True"
|
||||
Focusable="False"
|
||||
Value="{Binding size_calculator.value}"
|
||||
/>
|
||||
>
|
||||
<c:TickUpDownNullableUInt.Resources>
|
||||
<Style TargetType="{x:Type TextBox}">
|
||||
<Setter Property="u:TextBoxBehavior.FocusOnLoaded" Value="True"/>
|
||||
<Setter Property="u:TextBoxBehavior.IncrementDecrementOnMouseClick" Value="True" />
|
||||
</Style>
|
||||
</c:TickUpDownNullableUInt.Resources>
|
||||
</c:TickUpDownNullableUInt>
|
||||
</Grid>
|
||||
<Grid Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -94,17 +102,29 @@
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalSpacing}}"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Command="{Binding set_price_command}" CommandParameter="{Binding bbo.bid}" Foreground="{u:BTSColor MarketData.bid}" FontWeight="Bold">
|
||||
<Button Command="{Binding set_price_and_side_command}" Tag="{u:Enum Buy, Type=msys:Side}" Foreground="{u:BTSColor MarketData.bid}" FontWeight="Bold">
|
||||
<MultiBinding Converter="{StaticResource TickDisplayConverter}">
|
||||
<Binding Path="bbo.bid"/>
|
||||
<Binding Path="security.ContractSpec"/>
|
||||
</MultiBinding>
|
||||
<Button.CommandParameter>
|
||||
<MultiBinding Converter="{StaticResource TupleConverter}">
|
||||
<Binding Path="bbo.bid"/>
|
||||
<Binding Path="Tag" RelativeSource="{RelativeSource Self}"/>
|
||||
</MultiBinding>
|
||||
</Button.CommandParameter>
|
||||
</Button>
|
||||
<Button Grid.Column="2" Command="{Binding set_price_command}" CommandParameter="{Binding bbo.ask}" Foreground="{u:BTSColor MarketData.ask}" FontWeight="Bold">
|
||||
<Button Grid.Column="2" Command="{Binding set_price_and_side_command}" Tag="{u:Enum Sell, Type=msys:Side}" Foreground="{u:BTSColor MarketData.ask}" FontWeight="Bold">
|
||||
<MultiBinding Converter="{StaticResource TickDisplayConverter}">
|
||||
<Binding Path="bbo.ask"/>
|
||||
<Binding Path="security.ContractSpec"/>
|
||||
</MultiBinding>
|
||||
<Button.CommandParameter>
|
||||
<MultiBinding Converter="{StaticResource TupleConverter}">
|
||||
<Binding Path="bbo.ask"/>
|
||||
<Binding Path="Tag" RelativeSource="{RelativeSource Self}"/>
|
||||
</MultiBinding>
|
||||
</Button.CommandParameter>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid Grid.Row="2" Grid.Column="2">
|
||||
@@ -114,15 +134,36 @@
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
Content="{Binding bbo.bid_size}" Command="{Binding size_calculator.set_value_command}"
|
||||
CommandParameter="{Binding bbo.bid_size}" Foreground="{u:BTSColor MarketData.bid}"
|
||||
/>
|
||||
Content="{Binding bbo.bid_size}" Command="{Binding set_size_and_price_and_side_command}"
|
||||
Foreground="{u:BTSColor MarketData.bid}">
|
||||
<Button.CommandParameter>
|
||||
<MultiBinding Converter="{StaticResource TupleConverter}">
|
||||
<Binding Path="bbo.bid_size"/>
|
||||
<Binding Path="bbo.bid"/>
|
||||
<Binding>
|
||||
<Binding.Source>
|
||||
<msys:Side>Buy</msys:Side>
|
||||
</Binding.Source>
|
||||
</Binding>
|
||||
</MultiBinding>
|
||||
</Button.CommandParameter>
|
||||
</Button>
|
||||
<Button
|
||||
Grid.Column="2"
|
||||
Content="{Binding bbo.ask_size}" Command="{Binding size_calculator.set_value_command}"
|
||||
CommandParameter="{Binding bbo.ask_size}"
|
||||
Foreground="{u:BTSColor MarketData.ask}"
|
||||
/>
|
||||
Content="{Binding bbo.ask_size}" Command="{Binding set_size_and_price_and_side_command}"
|
||||
Foreground="{u:BTSColor MarketData.ask}">
|
||||
<Button.CommandParameter>
|
||||
<MultiBinding Converter="{StaticResource TupleConverter}">
|
||||
<Binding Path="bbo.ask_size"/>
|
||||
<Binding Path="bbo.ask"/>
|
||||
<Binding>
|
||||
<Binding.Source>
|
||||
<msys:Side>Sell</msys:Side>
|
||||
</Binding.Source>
|
||||
</Binding>
|
||||
</MultiBinding>
|
||||
</Button.CommandParameter>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid Grid.Row="4" Grid.RowSpan="3">
|
||||
<Grid.RowDefinitions>
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
u:WindowStyle.SizeToContent="WidthAndHeight"
|
||||
u:WindowStyle.TitleContent="{Binding bbo, Mode=OneWay}"
|
||||
Style="{StaticResource BTSWindowTitleTemplate}">
|
||||
Style="{StaticResource BTSWindowTitleTemplate}"
|
||||
Title="Order Ticket">
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
@@ -23,9 +24,12 @@
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="Visibility" Value="{Binding sell_is_visible, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<Setter Property="Grid.Column" Value="2" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
<Setter Property="Content">
|
||||
<Setter.Value>
|
||||
<TextBlock VerticalAlignment="Center" Foreground="{u:BTSColor UI.alternate_text}">Sell</TextBlock>
|
||||
<Setter.Value>
|
||||
<TextBlock VerticalAlignment="Center" Foreground="{u:BTSColor UI.alternate_text}">Sell</TextBlock>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
@@ -56,6 +60,16 @@
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding is_broker_mode}" Value="True" />
|
||||
<Condition Binding="{Binding sell_is_visible}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Grid.ColumnSpan" Value="3" />
|
||||
<Setter Property="Grid.Column" Value="0" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="BuyButton" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Setter Property="Background" Value="{u:BTSColor MarketData.bid}" />
|
||||
@@ -64,6 +78,8 @@
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="Visibility" Value="{Binding buy_is_visible, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
||||
<Setter Property="Content">
|
||||
<Setter.Value>
|
||||
<TextBlock VerticalAlignment="Center" Foreground="{u:BTSColor UI.alternate_text}">Buy</TextBlock>
|
||||
@@ -97,6 +113,15 @@
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding is_broker_mode}" Value="True" />
|
||||
<Condition Binding="{Binding buy_is_visible}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Grid.ColumnSpan" Value="3" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
@@ -115,9 +140,9 @@
|
||||
<ColumnDefinition MinWidth="120"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<usp:OrderModificationControl Grid.ColumnSpan="3" />
|
||||
<Button Grid.Row="2" Style="{StaticResource BuyButton}" Command="{Binding send_order}" CommandParameter="{u:Enum Buy, Type=msys:Side}" />
|
||||
<Button Grid.Row="2" Grid.Column="2" Style="{StaticResource SellButton}" Command="{Binding send_order}" CommandParameter="{u:Enum Sell, Type=msys:Side}" />
|
||||
</Grid>
|
||||
<Button Grid.Row="2" Style="{StaticResource BuyButton}" Command="{Binding send_order}" CommandParameter="{u:Enum Buy, Type=msys:Side}" />
|
||||
<Button Grid.Row="2" Style="{StaticResource SellButton}" Command="{Binding send_order}" CommandParameter="{u:Enum Sell, Type=msys:Side}" />
|
||||
</Grid>
|
||||
<u:WindowStyle.TitleContentTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock>
|
||||
|
||||
@@ -330,6 +330,13 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
|
||||
public static Side opposite(this Side side) {
|
||||
switch (side) {
|
||||
case Side.Buy: return Side.Sell;
|
||||
case Side.Sell: return Side.Buy;
|
||||
default: return Side.Undefined;
|
||||
}
|
||||
}
|
||||
public static AggressorSide to_aggressor(this Side side) {
|
||||
switch (side) {
|
||||
case Side.Buy: return AggressorSide.Buy;
|
||||
|
||||
@@ -8,7 +8,7 @@ using mbts.ui;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using static mbts.spark.SparkBusData;
|
||||
using System.Windows;
|
||||
|
||||
namespace mbts.spark
|
||||
{
|
||||
@@ -30,6 +30,7 @@ namespace mbts.spark
|
||||
public static ITag<uint> ShowModifyOrderTag { get; } = new SparkTag<uint>(nameof(ShowModifyOrderTag));
|
||||
public static ITag<SecurityMD> ShowOrderTicketFromSecurityTag = new SparkTag<SecurityMD>(nameof(ShowOrderTicketFromSecurityTag));
|
||||
public static ITag<(OrderDefinitionImmutable def, double price, uint size)> ShowOrderTicketTag = new SparkTag<(OrderDefinitionImmutable def, double price, uint size)>(nameof(ShowOrderTicketTag));
|
||||
public static ITag<(OrderDefinitionImmutable def, double price, uint size, Point window_start_position)> ShowOrderTicketAtPositionTag = new SparkTag<(OrderDefinitionImmutable def, double price, uint size, Point window_start_position)>(nameof(ShowOrderTicketAtPositionTag));
|
||||
#endregion
|
||||
|
||||
#region Selection/Utility
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using mbts.ui.shell;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
@@ -10,6 +11,7 @@ namespace mbts.ui {
|
||||
void remove(IShellWindow window);
|
||||
bool contains(IShellWindow window);
|
||||
void clear();
|
||||
WindowPosition GetPosition(IShellWindow shell_window);
|
||||
|
||||
// Bring to front of window stack and z-order
|
||||
void MakeVisible(IShellWindow window);
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
using mbts.ui.settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace bts.settings {
|
||||
interface ISettingsMigrationRule<T> {
|
||||
bool apply(T settings, out T new_settings);
|
||||
}
|
||||
|
||||
// Migration rules of type ISettingsMigrationRule<T>, where 'T' is a common type, such as GridSettings,
|
||||
// should be exposed through explicitly named interfaces that inherit ISettingsMigrationRule<T>.
|
||||
// This avoids magic const names in the MEF import/export contracts, which would otherwise be needed to
|
||||
// determine the various windows to which such rules apply.
|
||||
interface IPAndLGridSettingsMigrationRule : ISettingsMigrationRule<GridSettings> { }
|
||||
interface IMarketViewGridSettingsMigrationRule : ISettingsMigrationRule<GridSettings> { }
|
||||
|
||||
static class SettingsMigrationHelper {
|
||||
public static bool apply<T>(T settings, IEnumerable<ISettingsMigrationRule<T>> migration_rules, out T new_settings) {
|
||||
bool applied = false;
|
||||
foreach (var r in migration_rules) {
|
||||
if (r.apply(settings, out var migrated)) {
|
||||
settings = migrated;
|
||||
applied = true;
|
||||
}
|
||||
}
|
||||
new_settings = applied ? settings : default;
|
||||
return applied;
|
||||
}
|
||||
|
||||
public static void apply_quiet<T>(ref T settings, IEnumerable<ISettingsMigrationRule<T>> migration_rules) {
|
||||
if (apply(settings, migration_rules, out var new_settings))
|
||||
settings = new_settings;
|
||||
}
|
||||
|
||||
public static ISettingsMigrationRule<T> merge<T>(this IEnumerable<ISettingsMigrationRule<T>> rules) =>
|
||||
new MergeWrapper<T>(rules);
|
||||
|
||||
public static ISettingsMigrationRule<TOuter> wrap<TInner, TOuter>(this ISettingsMigrationRule<TInner> rule, Func<TOuter, TInner> get, Func<TOuter, TInner, TOuter> set) =>
|
||||
new SelectorWrapper<TInner, TOuter>(rule, get, set);
|
||||
|
||||
class MergeWrapper<T> : ISettingsMigrationRule<T> {
|
||||
readonly IEnumerable<ISettingsMigrationRule<T>> _rules;
|
||||
|
||||
public MergeWrapper(IEnumerable<ISettingsMigrationRule<T>> rules) =>
|
||||
_rules = rules;
|
||||
|
||||
public bool apply(T settings, out T new_settings) {
|
||||
bool applied = false;
|
||||
foreach (var r in _rules) {
|
||||
if (r.apply(settings, out var migrated)) {
|
||||
settings = migrated;
|
||||
applied = true;
|
||||
}
|
||||
}
|
||||
new_settings = applied ? settings : default;
|
||||
return applied;
|
||||
}
|
||||
}
|
||||
|
||||
class SelectorWrapper<TInner, TOuter> : ISettingsMigrationRule<TOuter> {
|
||||
readonly ISettingsMigrationRule<TInner> _rule;
|
||||
readonly Func<TOuter, TInner> _get;
|
||||
readonly Func<TOuter, TInner, TOuter> _set;
|
||||
|
||||
public SelectorWrapper(ISettingsMigrationRule<TInner> rule, Func<TOuter, TInner> get, Func<TOuter, TInner, TOuter> set) {
|
||||
_rule = rule;
|
||||
_get = get;
|
||||
_set = set;
|
||||
}
|
||||
|
||||
public bool apply(TOuter settings, out TOuter new_settings) {
|
||||
var ival = _get(settings);
|
||||
if (_rule.apply(ival, out var new_ival)) {
|
||||
new_settings = _set(settings, new_ival);
|
||||
return true;
|
||||
}
|
||||
new_settings = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using bts;
|
||||
using bts.settings;
|
||||
using bts.utils;
|
||||
using mbts.spark;
|
||||
using mbts.ui.settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
@@ -22,16 +24,30 @@ namespace mbts.persist {
|
||||
UserSettings _default_settings;
|
||||
readonly BehaviorSubject<UserSettings> _default_settings_subject = new BehaviorSubject<UserSettings>(UserSettings.factory_defaults);
|
||||
readonly object _default_settings_lock = new object();
|
||||
readonly IEnumerable<IPAndLGridSettingsMigrationRule> _pandl_migration_rules;
|
||||
readonly IEnumerable<IMarketViewGridSettingsMigrationRule> _mview_migration_rules;
|
||||
|
||||
[ImportingConstructor]
|
||||
public UserSettingsHub(IUserPersist persist) {
|
||||
public UserSettingsHub(
|
||||
IUserPersist persist,
|
||||
[ImportMany]IEnumerable<IPAndLGridSettingsMigrationRule> pandl_migration_rules,
|
||||
[ImportMany]IEnumerable<IMarketViewGridSettingsMigrationRule> mview_migration_rules) {
|
||||
//
|
||||
_persist = persist;
|
||||
_pandl_migration_rules = pandl_migration_rules ?? Enumerable.Empty<IPAndLGridSettingsMigrationRule>();
|
||||
_mview_migration_rules = mview_migration_rules ?? Enumerable.Empty<IMarketViewGridSettingsMigrationRule>();
|
||||
init();
|
||||
async void init() {
|
||||
UserSettings s;
|
||||
try {
|
||||
s = await _persist.get<UserSettings>(NAME_SPACE, DEFAULT_KEY);
|
||||
if (s != null) {
|
||||
var wrapped_rules = new[] {
|
||||
_pandl_migration_rules.merge().wrap<GridSettings, UserSettings>(us => us.pnl_grid, (us, gs) => us.with(provided_pnl_gridsettings: gs)),
|
||||
_mview_migration_rules.merge().wrap<GridSettings, UserSettings>(us => us.market_view_grid, (us, gs) => us.with(provided_market_view_gridsettings: gs))
|
||||
};
|
||||
SettingsMigrationHelper.apply_quiet(ref s, wrapped_rules);
|
||||
// TODO: move ladder sanitization logic into ISettingsMigrationRule
|
||||
s.ladder.sanitize();
|
||||
// ensure valid named ladder set (w/ distinct, non-zero ids)
|
||||
var ladder_profile_map = new Dictionary<uint, LadderSettingsProfile>();
|
||||
@@ -78,6 +94,20 @@ namespace mbts.persist {
|
||||
}
|
||||
}
|
||||
|
||||
public IWindowSettingsManager<GridSettings> create_pandl_settings_manager(GridSettings instance_settings) =>
|
||||
_create_settings_manager(
|
||||
instance_settings,
|
||||
_pandl_migration_rules,
|
||||
us => us.pnl_grid,
|
||||
(us, gs) => us.with(provided_pnl_gridsettings: gs));
|
||||
|
||||
public IWindowSettingsManager<GridSettings> create_mview_settings_manager(GridSettings instance_settings) =>
|
||||
_create_settings_manager(
|
||||
instance_settings,
|
||||
_mview_migration_rules,
|
||||
us => us.market_view_grid,
|
||||
(us, gs) => us.with(provided_market_view_gridsettings: gs));
|
||||
|
||||
public async Task save_default(UserSettings value) {
|
||||
// notify observers before persisting so the changes are reflected immediately in the ui
|
||||
lock (_default_settings_lock) {
|
||||
@@ -86,6 +116,12 @@ namespace mbts.persist {
|
||||
await _persist_async();
|
||||
}
|
||||
|
||||
IWindowSettingsManager<T> _create_settings_manager<T>(T instance_settings, IEnumerable<ISettingsMigrationRule<T>> migration_rules, Func<UserSettings, T> get, Func<UserSettings, T, UserSettings> set) where T : class {
|
||||
if (instance_settings != null && migration_rules.merge().apply(instance_settings, out var new_settings))
|
||||
instance_settings = new_settings;
|
||||
return new WindowSettingsManager<T>(this, instance_settings, get, set);
|
||||
}
|
||||
|
||||
async Task _persist_async() {
|
||||
try {
|
||||
await _persist.set(NAME_SPACE, DEFAULT_KEY, _default_settings);
|
||||
|
||||
@@ -12,6 +12,9 @@ using FontFamily = System.Windows.Media.FontFamily;
|
||||
namespace mbts.ui.controls {
|
||||
partial class DIYGrid {
|
||||
public class HyperlinkCell : FrameworkElement, ICommandSource {
|
||||
static Brush _hover_background_highlight = new SolidColorBrush(Colors.Yellow) { Opacity = 0.5 }.frozen();
|
||||
static Brush _hover_foreground_brush = new SolidColorBrush(Colors.Black).frozen();
|
||||
static Pen _hover_underline_pen = new Pen(_hover_foreground_brush, 1);
|
||||
// these fields each represent properties that are accessed frequently,
|
||||
// they are stored locally to reduce repetative DependencyProperty lookups
|
||||
Thickness _padding;
|
||||
@@ -49,12 +52,14 @@ namespace mbts.ui.controls {
|
||||
_font_size = FontSize;
|
||||
_text = Text;
|
||||
_glyph_context = GlyphContext.create(FontFamily, FontWeight);
|
||||
AddHandler(MouseDownEvent, new RoutedEventHandler(on_hyperlink_click_command), true);
|
||||
IsMouseDirectlyOverChanged += (s, e) => {
|
||||
if (_is_mouse_over_text != IsMouseDirectlyOver)
|
||||
_toggle_mouse_over_text();
|
||||
_toggle_mouse_cursor();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Background
|
||||
public static readonly DependencyProperty BackgroundProperty =
|
||||
WPFHelper.create_dp<Brush, HyperlinkCell>(
|
||||
@@ -221,32 +226,53 @@ namespace mbts.ui.controls {
|
||||
|
||||
#endregion
|
||||
|
||||
#region EnableHoverEffect
|
||||
public static readonly DependencyProperty EnableHoverEffectProperty =
|
||||
WPFHelper.create_dp<bool, HyperlinkCell>(nameof(EnableHoverEffect), false);
|
||||
|
||||
public bool EnableHoverEffect {
|
||||
get => (bool)GetValue(EnableHoverEffectProperty);
|
||||
set => SetValue(EnableHoverEffectProperty, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Paraphrased/Simplified from https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/Documents/Hyperlink.cs
|
||||
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) {
|
||||
base.OnMouseLeftButtonDown(e);
|
||||
// Note that OnMouseDown doesn't appear to fire when used in a MarketViewHyperlinkElementColumn due to the
|
||||
// InputBindings, we think, setting e.Handled to true.
|
||||
// Instead, we AddHandler to the MouseDownEvent in the constructor and use the
|
||||
// callback below, on_hyperlink_click_command, to reset Handled
|
||||
// so that it continues propagating down to the ListBoxItem. This in turn,
|
||||
// causes the ListBoxItem to be selected, which is then reflected in the
|
||||
// RowSelectionAdorner.
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e) {
|
||||
base.OnMouseDown(e);
|
||||
_check_mouse_over_text(e);
|
||||
if (_is_mouse_over_text) {
|
||||
// Hyperlink should take focus when left mouse button is clicked on it
|
||||
// This is consistent with all ButtonBase controls and current Win32 behavior
|
||||
Focus();
|
||||
|
||||
// It is possible that the mouse state could have changed during all of
|
||||
// the call-outs that have happened so far.
|
||||
if (e.ButtonState == MouseButtonState.Pressed) {
|
||||
// Capture the mouse, and make sure we got it.
|
||||
CaptureMouse();
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
// It is possible that the mouse state could have changed during all of
|
||||
// the call-outs that have happened so far.
|
||||
if (e.ButtonState == MouseButtonState.Pressed) {
|
||||
// Capture the mouse, and make sure we got it.
|
||||
CaptureMouse();
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) {
|
||||
base.OnMouseLeftButtonUp(e);
|
||||
private void on_hyperlink_click_command(object sender, RoutedEventArgs e) {
|
||||
e.Handled = false;
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseButtonEventArgs e) {
|
||||
base.OnMouseUp(e);
|
||||
_check_mouse_over_text(e);
|
||||
if (IsMouseCaptured)
|
||||
ReleaseMouseCapture();
|
||||
if (_can_execute && _is_mouse_over_text)
|
||||
if (_can_execute)
|
||||
CommandHelper.ExecuteCommandSource(this);
|
||||
e.Handled = true;
|
||||
}
|
||||
@@ -279,12 +305,21 @@ namespace mbts.ui.controls {
|
||||
var rs = RenderSize;
|
||||
var rect = new Rect(0, 0, rs.Width, rs.Height);
|
||||
var bg = Background;
|
||||
if (bg != null)
|
||||
drawingContext.DrawRectangle(bg, null, rect);
|
||||
if (bg != null) {
|
||||
if (_glyph_run != null && IsMouseDirectlyOver && EnableHoverEffect) {
|
||||
drawingContext.DrawRectangle(_hover_background_highlight, null, rect);
|
||||
} else {
|
||||
drawingContext.DrawRectangle(bg, null, rect);
|
||||
}
|
||||
}
|
||||
if (_glyph_run != null) {
|
||||
drawingContext.PushClip(new RectangleGeometry(rect));
|
||||
drawingContext.DrawGlyphRun(_foreground, _glyph_run);
|
||||
if (_is_mouse_over_text) {
|
||||
if (IsMouseDirectlyOver) {
|
||||
if (EnableHoverEffect) {
|
||||
drawingContext.DrawGlyphRun(_hover_foreground_brush, _glyph_run);
|
||||
} else {
|
||||
drawingContext.DrawGlyphRun(_foreground, _glyph_run);
|
||||
}
|
||||
// draw underline
|
||||
Point pt;
|
||||
switch (_horizontal_alignment) {
|
||||
@@ -299,9 +334,15 @@ namespace mbts.ui.controls {
|
||||
pt = new Point(0.5 * (ActualWidth - _glyph_width), 0.5 * (ActualHeight + _font_size) + 1);
|
||||
break;
|
||||
}
|
||||
drawingContext.DrawLine(_underline_pen, pt, new Point(pt.X + _glyph_width, pt.Y));
|
||||
|
||||
if (EnableHoverEffect) {
|
||||
drawingContext.DrawLine(_hover_underline_pen, pt, new Point(pt.X + _glyph_width, pt.Y));
|
||||
} else {
|
||||
drawingContext.DrawLine(_underline_pen, pt, new Point(pt.X + _glyph_width, pt.Y));
|
||||
}
|
||||
} else {
|
||||
drawingContext.DrawGlyphRun(_foreground, _glyph_run);
|
||||
}
|
||||
|
||||
drawingContext.Pop();
|
||||
}
|
||||
}
|
||||
@@ -331,10 +372,15 @@ namespace mbts.ui.controls {
|
||||
|
||||
void _toggle_mouse_over_text() {
|
||||
_is_mouse_over_text = !_is_mouse_over_text;
|
||||
if (_is_mouse_over_text)
|
||||
_toggle_mouse_cursor();
|
||||
}
|
||||
|
||||
void _toggle_mouse_cursor() {
|
||||
if (_glyph_run != null && IsMouseDirectlyOver) {
|
||||
SetCurrentValue(CursorProperty, Cursors.Hand);
|
||||
else
|
||||
} else {
|
||||
ClearValue(CursorProperty);
|
||||
}
|
||||
InvalidateVisual();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ namespace mbts.ui.controls {
|
||||
StartPnL = "Start PnL",
|
||||
DayLong = "Day Long",
|
||||
DayShort = "Day Short",
|
||||
RawDayPos = "Raw Day Pos",
|
||||
DayPnL = "Day PnL",
|
||||
TotalNetPos = "Total Net Pos",
|
||||
TotalPnL = "Total PnL",
|
||||
|
||||
+41
-7
@@ -1,9 +1,11 @@
|
||||
using mbts.spark.filters;
|
||||
using mbts.ui.converters;
|
||||
using bts.api;
|
||||
using mbts.spark;
|
||||
using mbts.spark.filters;
|
||||
using mbts.ui.spark;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Input;
|
||||
using static mbts.ui.controls.DIYGrid;
|
||||
|
||||
namespace mbts.ui.controls {
|
||||
partial class DIYGrid {
|
||||
@@ -12,19 +14,21 @@ namespace mbts.ui.controls {
|
||||
readonly BindingBase _binding, _command_binding;
|
||||
|
||||
public HyperlinkElementColumn(
|
||||
TKey key, BindingBase binding, BindingBase command_binding, IDataGridColumnFilter filter, string filter_template) : base(key) {
|
||||
TKey key, BindingBase binding, BindingBase command_binding, IDataGridColumnFilter filter, string filter_template, bool enable_hover_effect = false) : base(key) {
|
||||
this.filter = filter;
|
||||
this.filter_template = filter_template;
|
||||
_binding = binding;
|
||||
_command_binding = command_binding;
|
||||
this.enable_hover_effect = enable_hover_effect;
|
||||
}
|
||||
|
||||
public IDataGridColumnFilter filter { get; }
|
||||
public string filter_template { get; }
|
||||
public Thickness padding { get; set; } = _default_padding;
|
||||
|
||||
public bool enable_hover_effect { get; set; }
|
||||
|
||||
public override FrameworkElement view_factory() {
|
||||
var hl = new HyperlinkCell { Padding = padding };
|
||||
var hl = new HyperlinkCell { Padding = padding, EnableHoverEffect = enable_hover_effect };
|
||||
hl.SetBinding(HyperlinkCell.ForegroundProperty, new Binding(nameof(font_brush)) { Source = this });
|
||||
hl.SetBinding(HyperlinkCell.TextProperty, _binding);
|
||||
hl.SetBinding(HyperlinkCell.FontFamilyProperty, new Binding(nameof(font_family)) { Source = this });
|
||||
@@ -36,5 +40,35 @@ namespace mbts.ui.controls {
|
||||
return hl;
|
||||
}
|
||||
}
|
||||
|
||||
internal class MarketViewHyperlinkElementColumn : HyperlinkElementColumn<MarketViewVM.Row, MarketViewView.Columns> {
|
||||
|
||||
readonly Side _market_side;
|
||||
|
||||
public MarketViewHyperlinkElementColumn(MarketViewView.Columns key, BindingBase binding, BindingBase command_binding, IDataGridColumnFilter filter, string filter_template, Side market_side) : base(key, binding, command_binding, filter, filter_template, true) {
|
||||
_market_side = market_side;
|
||||
}
|
||||
|
||||
public override FrameworkElement view_factory() {
|
||||
var hl = base.view_factory();
|
||||
hl.InputBindings.Add(new MouseBinding(HyperLinkRoutedCommands.rc, new MouseGesture(MouseAction.LeftClick)) { CommandParameter = _market_side });
|
||||
hl.InputBindings.Add(new MouseBinding(HyperLinkRoutedCommands.rc, new MouseGesture(MouseAction.RightClick)) { CommandParameter = _market_side.opposite() });
|
||||
hl.CommandBindings.Add(new CommandBinding(HyperLinkRoutedCommands.rc, HyperLinkRoutedCommands.create_command_with_coordinates<Side>()));
|
||||
return hl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class HyperLinkRoutedCommands {
|
||||
|
||||
public static RoutedCommand rc = new RoutedCommand();
|
||||
public static ExecutedRoutedEventHandler create_command_with_coordinates<T>() =>
|
||||
(s, e) => {
|
||||
if (s is HyperlinkCell hl && e.Parameter is T orig_param) {
|
||||
hl.Command.TryExecuteIfCan((orig_param, hl));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.proto;
|
||||
using bts.collections;
|
||||
using bts.proto;
|
||||
using bts.utils;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.converters;
|
||||
@@ -6,6 +7,7 @@ using ProtoBuf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
@@ -163,4 +165,32 @@ namespace mbts.ui.settings {
|
||||
background_color.GetHashCode(),
|
||||
enable_background_color.GetHashCode());
|
||||
}
|
||||
|
||||
static class GridSettingsExtensions {
|
||||
public static bool add_missing_columns(this GridSettings grid, IEnumerable<GridColumnSettings> required_columns, out GridSettings result) {
|
||||
var col_lookup = new Lazy<ILookup<string, GridColumnSettings>>(() => required_columns.ToLookup(c => c.id));
|
||||
return add_missing_columns(grid, required_columns.Select(c => c.id), id => col_lookup.Value.TryGetValue(id, out var matches) ? matches.FirstOrDefault() : null, out result);
|
||||
}
|
||||
|
||||
public static bool add_missing_columns(this GridSettings grid, IEnumerable<string> col_ids, Func<string, GridColumnSettings> col_factory, out GridSettings result) {
|
||||
// add the new column (RawDayPos), if absent.
|
||||
var cols_to_add = new List<GridColumnSettings>(0);
|
||||
foreach (var col_id in col_ids) {
|
||||
if (!grid.columns.Any(c => c.id == col_id)) {
|
||||
var default_col = col_factory(col_id);
|
||||
if (default_col != null)
|
||||
cols_to_add.Add(default_col);
|
||||
}
|
||||
}
|
||||
if (cols_to_add.Count > 0) {
|
||||
var col_list = grid.columns.ToList();
|
||||
col_list.AddRange(cols_to_add);
|
||||
grid = grid.with(col_list);
|
||||
result = grid;
|
||||
return true;
|
||||
}
|
||||
result = grid;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,9 @@
|
||||
u:TextBoxBehavior.EnableArrowKeyTraverse="True"
|
||||
BorderThickness="0"
|
||||
>
|
||||
<TextBox.ContextMenu>
|
||||
<ContextMenu Visibility="Collapsed" />
|
||||
</TextBox.ContextMenu>
|
||||
<TextBox.CommandBindings>
|
||||
<CommandBinding Command="{x:Static u:TextBoxBehavior.SelectAllCommand}" Executed="{x:Static u:TextBoxBehavior.SelectAllCommandExecutedHandler}"/>
|
||||
</TextBox.CommandBindings>
|
||||
|
||||
@@ -429,7 +429,11 @@
|
||||
Name="PART_TextBox"
|
||||
u:TextBoxBehavior.EnableArrowKeyTraverse="True"
|
||||
BorderThickness="0"
|
||||
/>
|
||||
>
|
||||
<TextBox.ContextMenu>
|
||||
<ContextMenu Visibility="Collapsed" />
|
||||
</TextBox.ContextMenu>
|
||||
</TextBox>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace mbts.ui.converters {
|
||||
public string Format { get; set; }
|
||||
public string NaNText { get; set; } = string.Empty;
|
||||
|
||||
public static string convert(double value, string format, string nan_text = "-") =>
|
||||
double.IsNaN(value) ? nan_text : value.ToString(format);
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
|
||||
var text = (value as string ?? string.Empty).Trim().ToLower();
|
||||
if (text == string.Empty || text == "nan" || text == NaNText) return double.NaN;
|
||||
|
||||
@@ -312,5 +312,17 @@ namespace mbts.ui {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static IDisposable ShowAtPosition(this Window window, Point coords, bool dispose_vm_on_close = false) {
|
||||
if (dispose_vm_on_close) window.Closed += (s, e) => (window.DataContext as IDisposable)?.Dispose();
|
||||
window.set_position(new WindowPosition() { top = (int)coords.Y, left = (int)coords.X });
|
||||
window.Show();
|
||||
return Disposable.Create(() => {
|
||||
// not very elegant, but safe and effective
|
||||
if (window != null) {
|
||||
try { window.Close(); } catch { }
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,10 @@ namespace mbts.spark {
|
||||
public static double sod_pos(this PositionUnitImmutable position_unit) => position_unit.SodLongPos - position_unit.SodShortPos;
|
||||
public static double day_pos(this PositionUnitImmutable position_unit) => position_unit.DayLongPos - position_unit.DayShortPos;
|
||||
public static double total_pos(this PositionUnitImmutable position_unit) => position_unit.sod_pos() + position_unit.day_pos();
|
||||
// raw day
|
||||
public static double raw_day_long_pos(this PositionUnitImmutable position_unit) => position_unit.HasRawDay ? position_unit.RawDay.LongPos : double.NaN;
|
||||
public static double raw_day_short_pos(this PositionUnitImmutable position_unit) => position_unit.HasRawDay ? position_unit.RawDay.ShortPos : double.NaN;
|
||||
public static double raw_day_pos(this PositionUnitImmutable position_unit) => position_unit.HasRawDay ? position_unit.RawDay.LongPos - position_unit.RawDay.ShortPos : double.NaN;
|
||||
|
||||
public static void lazy_assert(bool test, Func<string> get_msg) {
|
||||
if (!test)
|
||||
|
||||
@@ -65,6 +65,8 @@ namespace mbts.spark {
|
||||
grouping.Where(y => y.fill.FillKind != Fill.Types.FillKind.Sod).Sum(y => (uint)y.sell_quantity),
|
||||
grouping.Sum(y => (int)(y.buy_quantity - y.sell_quantity)),
|
||||
grouping.Where(y => y.fill.FillKind == Fill.Types.FillKind.Sod).Sum(y => (int)(y.buy_quantity - y.sell_quantity)),
|
||||
double.NaN,
|
||||
double.NaN,
|
||||
grouping.weighted_average(y => y.fill.LastPrice, y => y.buy_quantity),
|
||||
grouping.weighted_average(y => y.fill.LastPrice, y => y.sell_quantity),
|
||||
grouping.Select(i => i.fill),
|
||||
@@ -95,6 +97,8 @@ namespace mbts.spark {
|
||||
(uint)pos.DayShortPos,
|
||||
(int)pos.total_pos(),
|
||||
(int)pos.sod_pos(),
|
||||
pos.raw_day_long_pos(),
|
||||
pos.raw_day_short_pos(),
|
||||
pos.DayLongAvgPrice,
|
||||
pos.DayShortAvgPrice,
|
||||
null,
|
||||
@@ -104,7 +108,7 @@ namespace mbts.spark {
|
||||
|
||||
// remove rows for which there is no net pos or no day pos
|
||||
summary_position_rows = summary_position_rows.Where(r =>
|
||||
!(r.start_net_position == 0 && r.day_long_quantity == 0 && r.day_short_quantity == 0)
|
||||
!(r.start_net_position == 0 && r.day_long_quantity == 0 && r.day_short_quantity == 0 && r.raw_day_long_position == 0 && r.raw_day_short_position == 0)
|
||||
);
|
||||
_pnl_data.sync_with(summary_position_rows);
|
||||
_last_pnl_update_time = DateTime.Now;
|
||||
@@ -124,6 +128,7 @@ namespace mbts.spark {
|
||||
start_pnl_filter.load_state(fs.start_pnl);
|
||||
day_long_quantity_filter.load_state(fs.day_long_pos);
|
||||
day_short_quantity_filter.load_state(fs.day_short_pos);
|
||||
raw_day_net_position_filter.load_state(fs.raw_day_net_pos);
|
||||
day_pnl_filter.load_state(fs.day_pnl);
|
||||
total_net_position_filter.load_state(fs.total_net_pos);
|
||||
total_pnl_filter.load_state(fs.total_pnl);
|
||||
@@ -146,6 +151,8 @@ namespace mbts.spark {
|
||||
add_col(Columns.StartPNL, DefaultColumnHeaders.StartPnL, r => r.start_pnl_text, nameof(PnLSummaryRow.start_pnl), DefaultColumnWidths.PnL_Generic, start_pnl_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right, r => r.start_pnl_background);
|
||||
add_col(Columns.DayLong, DefaultColumnHeaders.DayLong, r => r.day_long_quantity.ToString(), nameof(PnLSummaryRow.day_long_quantity), DefaultColumnWidths.PnL_Generic, day_long_quantity_filter, DataGridFilterKnownTemplates.UIntMinMax, HorizontalAlignment.Right);
|
||||
add_col(Columns.DayShort, DefaultColumnHeaders.DayShort, r => r.day_short_quantity.ToString(), nameof(PnLSummaryRow.day_short_quantity), DefaultColumnWidths.PnL_Generic, day_short_quantity_filter, DataGridFilterKnownTemplates.UIntMinMax, HorizontalAlignment.Right);
|
||||
// convert nan to 0 so text is consistent with other position columns
|
||||
add_col(Columns.RawDayPos, DefaultColumnHeaders.RawDayPos, r => SparkUtils.fmt_position(r.raw_day_net_position), nameof(PnLSummaryRow.raw_day_net_position), DefaultColumnWidths.PnL_Generic, raw_day_net_position_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right);
|
||||
add_col(Columns.DayPNL, DefaultColumnHeaders.DayPnL, r => r.day_pnl_text, nameof(PnLSummaryRow.day_pnl), 90, day_pnl_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right, r => r.day_pnl_background);
|
||||
add_col(Columns.TradedToday, "Traded Today", r => r.has_day_trades_text, nameof(PnLSummaryRow.has_day_trades), 100, has_day_trades_filter, DataGridFilterKnownTemplates.YesNo, HorizontalAlignment.Center);
|
||||
add_col(Columns.TotalNetPos, DefaultColumnHeaders.TotalNetPos, r => r.total_net_position.ToString(), nameof(PnLSummaryRow.total_net_position), DefaultColumnWidths.Total_Net_Pos, total_net_position_filter, DataGridFilterKnownTemplates.DoubleMinMax, HorizontalAlignment.Right);
|
||||
@@ -188,6 +195,7 @@ namespace mbts.spark {
|
||||
start_pnl_filter,
|
||||
day_long_quantity_filter,
|
||||
day_short_quantity_filter,
|
||||
raw_day_net_position_filter,
|
||||
day_pnl_filter,
|
||||
total_net_position_filter,
|
||||
total_pnl_filter,
|
||||
@@ -311,6 +319,7 @@ namespace mbts.spark {
|
||||
public IDataGridColumnPersistentFilter<PnLSummaryRow, DoubleMinMaxState> start_pnl_filter { get; } = new DoubleMinMax<PnLSummaryRow>(r => r.start_pnl, nameof(PnLSummaryRow.start_pnl));
|
||||
public IDataGridColumnPersistentFilter<PnLSummaryRow, UIntMinMaxState> day_long_quantity_filter { get; } = new UIntMinMax<PnLSummaryRow>(r => r.day_long_quantity, nameof(PnLSummaryRow.day_long_quantity));
|
||||
public IDataGridColumnPersistentFilter<PnLSummaryRow, UIntMinMaxState> day_short_quantity_filter { get; } = new UIntMinMax<PnLSummaryRow>(r => r.day_short_quantity, nameof(PnLSummaryRow.day_short_quantity));
|
||||
public IDataGridColumnPersistentFilter<PnLSummaryRow, DoubleMinMaxState> raw_day_net_position_filter { get; } = new DoubleMinMax<PnLSummaryRow>(r => r.raw_day_net_position, nameof(PnLSummaryRow.raw_day_net_position));
|
||||
public IDataGridColumnPersistentFilter<PnLSummaryRow, DoubleMinMaxState> day_pnl_filter { get; } = new DoubleMinMax<PnLSummaryRow>(r => r.day_pnl, nameof(PnLSummaryRow.day_pnl));
|
||||
public IDataGridColumnPersistentFilter<PnLSummaryRow, IntMinMaxState> total_net_position_filter { get; } = new IntMinMax<PnLSummaryRow>(r => r.total_net_position, nameof(PnLSummaryRow.total_net_position));
|
||||
public IDataGridColumnPersistentFilter<PnLSummaryRow, DoubleMinMaxState> total_pnl_filter { get; } = new DoubleMinMax<PnLSummaryRow>(r => r.total_pnl, nameof(PnLSummaryRow.total_pnl));
|
||||
@@ -329,6 +338,7 @@ namespace mbts.spark {
|
||||
start_pnl = start_pnl_filter.get_state(),
|
||||
day_long_pos = day_long_quantity_filter.get_state(),
|
||||
day_short_pos = day_short_quantity_filter.get_state(),
|
||||
raw_day_net_pos = raw_day_net_position_filter.get_state(),
|
||||
day_pnl = day_pnl_filter.get_state(),
|
||||
total_net_pos = total_net_position_filter.get_state(),
|
||||
total_pnl = total_pnl_filter.get_state(),
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Windows.Controls;
|
||||
|
||||
namespace mbts.spark {
|
||||
internal partial class PAndLView : UserControl {
|
||||
public enum Columns { Account, Exchange, Symbol, Security, SecurityType, StartNetPos, StartPNL, DayLong, DayShort, DayPNL, TotalNetPos, TotalPNL, PNLPrice, TradedToday }
|
||||
public enum Columns { Account, Exchange, Symbol, Security, SecurityType, StartNetPos, StartPNL, DayLong, DayShort, DayPNL, TotalNetPos, TotalPNL, PNLPrice, TradedToday, RawDayPos }
|
||||
|
||||
public PAndLView(PAndLVM vm) {
|
||||
InitializeComponent();
|
||||
|
||||
@@ -24,7 +24,8 @@ namespace mbts.spark {
|
||||
PAndLWindowFactory _factory;
|
||||
IReadOnlyList<SparkCommand> _commands;
|
||||
|
||||
public PAndLWindow(OrdersModel orders_model, PAndLWindowFactory factory, IBus bus, PAndLWindowFactory.PAndLStartupData startup_data, ImageSource Icon, WindowSettingsManager<GridSettings> settings_manager) : base("P&L", bus, factory, SparkCommands.ShowPAndL.icon) {
|
||||
public PAndLWindow(OrdersModel orders_model, PAndLWindowFactory factory, IBus bus, PAndLWindowFactory.PAndLStartupData startup_data, ImageSource Icon, IWindowSettingsManager<GridSettings> settings_manager)
|
||||
: base("P&L", bus, factory, SparkCommands.ShowPAndL.icon) {
|
||||
_orders_model = orders_model;
|
||||
_factory = factory;
|
||||
_startup_data = startup_data;
|
||||
|
||||
@@ -30,7 +30,16 @@ namespace mbts.spark {
|
||||
|
||||
public PnLSummaryRow(pnl_calc_type calc_type,
|
||||
(string, Venue?, string, SecurityImmutable?, SecurityMD?, SecurityType?) key,
|
||||
uint day_buy_quant, uint day_sell_quant, int net_pos, int sod_pos, double wavg_buy, double wavg_sell, IEnumerable<FillImmutable> fills, PositionUnitImmutable? pu) {
|
||||
uint day_buy_quant,
|
||||
uint day_sell_quant,
|
||||
int net_pos,
|
||||
int sod_pos,
|
||||
double raw_day_long,
|
||||
double raw_day_short,
|
||||
double wavg_buy,
|
||||
double wavg_sell,
|
||||
IEnumerable<FillImmutable> fills,
|
||||
PositionUnitImmutable? pu) {
|
||||
this.key = key;
|
||||
_start_pnl = new PnLDoubleBrushCell(this, nameof(start_pnl));
|
||||
_day_pnl = new PnLDoubleBrushCell(this, nameof(day_pnl));
|
||||
@@ -39,6 +48,8 @@ namespace mbts.spark {
|
||||
day_short_quantity = day_sell_quant;
|
||||
total_net_position = net_pos;
|
||||
start_net_position = sod_pos;
|
||||
raw_day_long_position = raw_day_long;
|
||||
raw_day_short_position = raw_day_short;
|
||||
_pnl_price = new CellProperty<double>(this, nameof(pnl_price), price => this.security.spec_or_default().format(price), 0);
|
||||
_weighted_average_buy = new CellProperty<double>(this, nameof(weighted_average_buy), price => this.security.spec_or_default().format(price), wavg_buy);
|
||||
_weighted_average_sell = new CellProperty<double>(this, nameof(weighted_average_sell), price => this.security.spec_or_default().format(price), wavg_sell);
|
||||
@@ -136,6 +147,8 @@ namespace mbts.spark {
|
||||
key.symbol == other.symbol &&
|
||||
day_long_quantity == other.day_long_quantity &&
|
||||
day_short_quantity == other.day_short_quantity &&
|
||||
raw_day_long_position.Equals(other.raw_day_long_position) &&
|
||||
raw_day_short_position.Equals(other.raw_day_short_position) &&
|
||||
total_pnl == other.total_pnl;
|
||||
}
|
||||
|
||||
@@ -166,6 +179,9 @@ namespace mbts.spark {
|
||||
public int total_net_position { get; }
|
||||
public uint day_long_quantity { get; }
|
||||
public uint day_short_quantity { get; }
|
||||
public double raw_day_long_position { get; }
|
||||
public double raw_day_short_position { get; }
|
||||
public double raw_day_net_position => raw_day_long_position - raw_day_short_position;
|
||||
// start pnl
|
||||
public double start_pnl => _start_pnl.value;
|
||||
public string start_pnl_text => _start_pnl.text;
|
||||
|
||||
@@ -223,8 +223,8 @@ message ProRataOrderDefinition {
|
||||
uint32 chase_ticks = 2;
|
||||
spark.QuantityMeasure fill_limit = 5;
|
||||
spark.QuantityMeasure stay_in_threshold = 6;
|
||||
bool enable_scratch_on_overfill = 7;
|
||||
bool enable_stay_in = 8;
|
||||
bool scratch_on_overfill = 7;
|
||||
bool stay_in = 8;
|
||||
|
||||
CustomOrderDefinition child = 10;
|
||||
CustomOrderDefinition hedge = 20;
|
||||
|
||||
@@ -194,10 +194,12 @@ void DormanAlgo::on_book(SecurityKey key, const Book& book) {
|
||||
auto target = Quantity {0};
|
||||
if (available > 0) {
|
||||
for (const auto& entry : me->params.steps.step_table) {
|
||||
target = Quantity { std::get<1>(entry) };
|
||||
if (std::get<0>(entry) > available) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
target = Quantity { std::get<1>(entry) };
|
||||
}
|
||||
}
|
||||
}
|
||||
target = Quantity { std::min(target.value(), me->params.steps.maximum) };
|
||||
|
||||
@@ -42,8 +42,8 @@ struct ProRataAlgo::PImpl
|
||||
Price chase_diff;
|
||||
Quantity fill_limit;
|
||||
Quantity stay_in_threshold;
|
||||
bool enable_scratch_on_overfill;
|
||||
bool enable_stay_in;
|
||||
bool scratch_on_overfill;
|
||||
bool stay_in;
|
||||
|
||||
ChildTemplate *child_template = nullptr;
|
||||
ChildTemplate *hedge_template = nullptr;
|
||||
@@ -162,7 +162,7 @@ void ProRataAlgo::check_overfill()
|
||||
{
|
||||
if(me->is_overfilled && me->status != Status::GETTING_OUT)
|
||||
{
|
||||
if(me->enable_stay_in)
|
||||
if(me->stay_in)
|
||||
{
|
||||
auto my_side = algo().definition().side();
|
||||
auto other_side = securities::other_side(my_side);
|
||||
@@ -202,7 +202,7 @@ void ProRataAlgo::get_out()
|
||||
{
|
||||
me->status = Status::GETTING_OUT;
|
||||
algo().cancel_child(me->child_key);
|
||||
if(me->enable_scratch_on_overfill)
|
||||
if(me->scratch_on_overfill)
|
||||
{
|
||||
for(auto& h : me->overfill_hedges)
|
||||
scratch(h);
|
||||
@@ -369,8 +369,8 @@ void ProRataAlgo::set_parameters(IBeforeLaunchAlgoServices &serv, const api::ord
|
||||
return;
|
||||
}
|
||||
me->stay_in_threshold = SpreaderUtils::_quantity_threshold(prorata.stay_in_threshold(), algo().quantity());
|
||||
me->enable_scratch_on_overfill = prorata.enable_scratch_on_overfill();
|
||||
me->enable_stay_in = prorata.enable_stay_in();
|
||||
me->scratch_on_overfill = prorata.scratch_on_overfill();
|
||||
me->stay_in = prorata.stay_in();
|
||||
}
|
||||
|
||||
void ProRataAlgo::check_terminate()
|
||||
|
||||
@@ -189,7 +189,6 @@ size_t count_status(const std::vector<ChildOrder>& child_orders, ChildStatus sta
|
||||
return match;
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("dorman_order_size", "[algo][dorman]") {
|
||||
// create a table of various sizes
|
||||
// send market state to the algo
|
||||
@@ -211,13 +210,14 @@ TEST_CASE("dorman_order_size", "[algo][dorman]") {
|
||||
|
||||
SECTION("initial size vs market") {
|
||||
std::vector<ExpectedSize> test_sizes {
|
||||
{ 10, 250 },
|
||||
{ 200, 250 },
|
||||
{ 250, 250 },
|
||||
{ 500, 400 },
|
||||
{ 999, 400 },
|
||||
{ 2500, 750 },
|
||||
{ 9999, 800 }
|
||||
{ 10, 0 },
|
||||
{ 200, 0 },
|
||||
{ 250, 0 },
|
||||
{ 500, 250 },
|
||||
{ 999, 250 },
|
||||
{ 2500, 600 },
|
||||
{ 9999, 750 },
|
||||
{ 20002, 800 },
|
||||
};
|
||||
|
||||
for (auto& s : test_sizes)
|
||||
@@ -244,10 +244,10 @@ TEST_CASE("dorman_order_size", "[algo][dorman]") {
|
||||
state.update_book(book);
|
||||
REQUIRE(state.before_launch().ok());
|
||||
state.launch();
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(400));
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(250));
|
||||
|
||||
// Check that orders were created
|
||||
REQUIRE(400 == count_exposed(state.child_orders()));
|
||||
REQUIRE(250 == count_exposed(state.child_orders()));
|
||||
for(const auto& ch : state.child_orders()) {
|
||||
REQUIRE(ch.cstate.quantity == state.quantity());
|
||||
}
|
||||
@@ -255,9 +255,9 @@ TEST_CASE("dorman_order_size", "[algo][dorman]") {
|
||||
// Reduce market
|
||||
book.bid()[0] = { some_price, 405 };
|
||||
state.update_book(book);
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(250));
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(0));
|
||||
REQUIRE(
|
||||
250 == count_exposed(state.child_orders()));
|
||||
0 == count_exposed(state.child_orders()));
|
||||
}
|
||||
|
||||
SECTION("Increase qty w/ delay when market grows") {
|
||||
@@ -268,28 +268,28 @@ TEST_CASE("dorman_order_size", "[algo][dorman]") {
|
||||
state.update_book(book);
|
||||
REQUIRE(state.before_launch().ok());
|
||||
state.launch();
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(400));
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(250));
|
||||
|
||||
// Check that orders were created
|
||||
REQUIRE(
|
||||
400 == count_exposed(state.child_orders()));
|
||||
250 == count_exposed(state.child_orders()));
|
||||
|
||||
// INCREASE market
|
||||
book.bid()[0] = { some_price, 1001 };
|
||||
state.update_book(book);
|
||||
// NOTE: that the orders do not follow the market instantly
|
||||
// so this is still 400
|
||||
// so this is still 250
|
||||
REQUIRE(
|
||||
400 == count_exposed(state.child_orders()));
|
||||
250 == count_exposed(state.child_orders()));
|
||||
|
||||
// Still 400 after the timer ticks but not enough time has passed
|
||||
// Still 250 after the timer ticks but not enough time has passed
|
||||
state.advance_time(std::chrono::seconds());
|
||||
REQUIRE(
|
||||
400 == count_exposed(state.child_orders()));
|
||||
250 == count_exposed(state.child_orders()));
|
||||
|
||||
state.advance_time(std::chrono::seconds(input.steps.trail_seconds));
|
||||
REQUIRE(
|
||||
600 == count_exposed(state.child_orders()));
|
||||
400 == count_exposed(state.child_orders()));
|
||||
|
||||
}
|
||||
SECTION("Respect maximum") {
|
||||
@@ -336,7 +336,7 @@ TEST_CASE("Dorman fills", "[algo][dorman]") {
|
||||
state.update_book(book);
|
||||
REQUIRE(state.before_launch().ok());
|
||||
state.launch();
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(450));
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(250));
|
||||
|
||||
for (const auto& order : state.child_orders()) {
|
||||
state.fill(order.key, price, order.cstate.quantity);
|
||||
@@ -360,7 +360,7 @@ TEST_CASE("Dorman fills", "[algo][dorman]") {
|
||||
state.update_book(book);
|
||||
REQUIRE(state.before_launch().ok());
|
||||
state.launch();
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(650));
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(450));
|
||||
REQUIRE(state.quantity() == Quantity {500});
|
||||
|
||||
// Fill 400
|
||||
@@ -405,7 +405,7 @@ TEST_CASE("Dorman overfill", "[algo][dorman]") {
|
||||
state.update_book(book);
|
||||
REQUIRE(state.before_launch().ok());
|
||||
state.launch();
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(650));
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(450));
|
||||
REQUIRE(state.quantity() == Quantity {100});
|
||||
REQUIRE(state.child_orders().size() == 1);
|
||||
|
||||
@@ -467,7 +467,7 @@ TEST_CASE("Dorman profit-orders", "[algo][dorman]") {
|
||||
state.update_book(book);
|
||||
REQUIRE(state.before_launch().ok());
|
||||
state.launch();
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(650));
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(450));
|
||||
REQUIRE(state.quantity() == Quantity {100});
|
||||
REQUIRE(state.child_orders().size() == 1);
|
||||
|
||||
@@ -714,26 +714,26 @@ TEST_CASE("Dorman market move up then back down", "[algo][dorman]") {
|
||||
auto secid = SecurityKey(state.security().id());
|
||||
|
||||
Book book(secid);
|
||||
book.bid()[0] = { some_price, 350 };
|
||||
book.bid()[0] = { some_price, 1350 };
|
||||
state.update_book(book);
|
||||
REQUIRE(state.before_launch().ok());
|
||||
state.launch();
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(250));
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(450));
|
||||
REQUIRE(state.child_orders().size() == 1);
|
||||
state.advance_time(std::chrono::seconds(1));
|
||||
|
||||
// Update book sets future quantity = 450
|
||||
book.bid()[0] = { some_price, 999 };
|
||||
// Update book sets future quantity = 650
|
||||
book.bid()[0] = { some_price, 2219 };
|
||||
state.update_book(book);
|
||||
state.advance_time(std::chrono::seconds(10));
|
||||
// Algo does not increase exposure after 10 second
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(250));
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(450));
|
||||
|
||||
book.bid()[0] = { some_price, 425 };
|
||||
book.bid()[0] = { some_price, 1425 };
|
||||
state.update_book(book);
|
||||
state.advance_time(std::chrono::seconds(40));
|
||||
// Algo does not increase exposure after trail_seconds
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(250));
|
||||
REQUIRE(state.algo().exposed_qty() == Quantity(450));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ It will:
|
||||
The prorata order works the child until the Fill Limit is breached.
|
||||
Once the fill limit is breached, the algo will begin the 'get out process'
|
||||
Unless:
|
||||
- If "Enable Stay In" is checked, AND
|
||||
- If "Stay In" is checked, AND
|
||||
a) The opposite inside market (at inception) doesn't move against us AND
|
||||
b) The same side quantity remains ABOVE the "Stay in Threshold"
|
||||
If "Enable Stay In" is not checked, 'get out process' begins right away
|
||||
If "Stay In" is not checked, 'get out process' begins right away
|
||||
|
||||
"Get Out Process" means
|
||||
1) Cancel the child order
|
||||
2) Scratch the overfill hedges if and only if the "Enable Scratch on Overfill" is checked
|
||||
2) Scratch the overfill hedges if and only if the "Scratch on Overfill" is checked
|
||||
-Scratches are done "Chase Ticks" through the original opposite market
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ ExchangeSim {
|
||||
(if there are no markets use the M View and the ticket to enter, if you already had left over
|
||||
orders cancel them)
|
||||
|
||||
2. Create the bid side of the market by sending 50 lot buy limit orders at 2830.75 through 2831.50.
|
||||
2. Create the bid side of the market by sending 50 lot buy limit orders at 2830.75 through 2831.25.
|
||||
You should have no orders at 2831.50, 2831.75 and 2832.
|
||||
|
||||
Basics:
|
||||
@@ -47,8 +47,8 @@ Basics:
|
||||
Chase Ticks = 1
|
||||
Fill Limit = Absolute:5
|
||||
Stay in Threshold = Absolute:21
|
||||
Enable Scratch on Overfill = true
|
||||
Enable Stay In = true
|
||||
Scratch on Overfill = true
|
||||
Stay In = true
|
||||
|
||||
Verify that the Prorata order along with the Child order shows up.
|
||||
|
||||
@@ -62,22 +62,22 @@ Next put a 50 lot buy limit order on top of your prorata at 2831.50
|
||||
6) Fill one more 1 lot.
|
||||
|
||||
7) Again cancel the 50 lot limit at 2831.50. You should see:
|
||||
- The remainder of the 20 lot should cancel
|
||||
- The remainder of the 20 lot limit order child should cancel (the remainder will be 14, with 6 already filled)
|
||||
- 1 lot of your hedges should scratch to sell at 2831.25
|
||||
- The parent order should stay in
|
||||
- The parent algo order should stay in (the badge will still be there)
|
||||
- You should still be working 5 sales for hedges
|
||||
|
||||
8) Fill the 5 sells, it should cancel the parent.
|
||||
|
||||
9) Repeat 3-8, but this time set Enable Scratch on Overfill = false, Enable Stay In = true
|
||||
9) Repeat 3-8, but this time set Scratch on Overfill = false, Stay In = true
|
||||
- You should see the same results in 7, except the 1 lot scratch won't happen so you'll still have 6 working hedges
|
||||
|
||||
9) Repeat 3-6, but this time set Enable Scratch on Overfill = false, Enable Stay In = false
|
||||
9) Repeat 3-6, but this time set Scratch on Overfill = false, Stay In = false
|
||||
- After filling your last lot in 1 you should see your working order cancel, with 6 hedges working
|
||||
- The ladder may deceive you here, check the OB
|
||||
- Cancel your hedges, this should cancel the whole chain
|
||||
|
||||
9) Repeat 3-6, but this time set Enable Scratch on Overfill = true, Enable Stay In = false
|
||||
9) Repeat 3-6, but this time set Scratch on Overfill = true, Stay In = false
|
||||
- After filling your last lot in 1 you should see your working order cancel, one hedge scratch (at 2831.50), and 5 hedges working
|
||||
- The ladder may deceive you here, check the OB
|
||||
- Cancel your hedges, this should cancel the whole chain
|
||||
|
||||
@@ -33,14 +33,15 @@ Basics:
|
||||
|
||||
Verify that the Scratch order along with the Child order shows up
|
||||
|
||||
4) Now cancel the 50 lot sell at 2832.25, you should see the 20 lot scratch pay 2832.50 on 20
|
||||
4) Now cancel the 50 lot sell at 2832.25, you should see the 20 lot scratch pay 2832.50 on 20
|
||||
(here you'll be filled at 2832.5 but the child limit order will have a price of 2832.75)
|
||||
|
||||
5) Repeat 3, now cancel the 50 lot buy at 2831.50, you should again see scratch pay 2832.50 on 20.
|
||||
Put the 50 lot buy back in.
|
||||
Put the 50 lot buy at 2831.50 back in (make sure it's a limit, not a Scratch).
|
||||
|
||||
6) Repeat 3, put an offer in at 2832.25, cancel it; nothing should happen. Cancel the Scratch Algo
|
||||
|
||||
7) This time enter the algo with Max Chase = 0, cancel the 50 lot offer at 2832.75 and 2833. Nothing should happen. Now cancel the 2832.5 offer, you should see the algo pay up to 2832.5, but not fill.
|
||||
7) This time repeat 3 but enter the algo with Max Chase = 0, cancel the 50 lot offer at 2832.75 and 2833. Nothing should happen. Now cancel the 2832.5 offer, you should see the algo pay up to 2832.5, but not fill.
|
||||
|
||||
8) Cancel the last offer at 2833.25. Nothing should happen.
|
||||
|
||||
|
||||
@@ -15,3 +15,73 @@ Now update securities to add an exchange listed spread
|
||||
Double click each of the security cells and verify a ladder comes up
|
||||
Right click in the grid and bring up each form, close them
|
||||
Test each Spark Menu (toolbar) item other than update securities with a security row selected, make sure context from the selected row is respected if applicable
|
||||
|
||||
=== "broker mode" functionality test steps circa Sep 2019 (MV and corresponding OrderTicket)
|
||||
|
||||
-- MV Hyperlink cell highlighting --
|
||||
|
||||
Bid/Ask column test - Verify price columns reflect a hover effect when the mouse is over their cells
|
||||
The background will change to yellow
|
||||
The foreground hyperlink cell text will change to black
|
||||
The cursor changes to a hand anywhere within the cell (not only over the hyperlink text itself)
|
||||
|
||||
Qty (M) column test - Verify the Qty (Merged) column reflect a hover effect
|
||||
same as above
|
||||
|
||||
Working column test - Verify the Working columns reflect a hover effect
|
||||
Note: the hover effect should only occur over cell that actually have text
|
||||
Clicking on an empty working column cell should *not* launch an OrderBook
|
||||
|
||||
-- broker mode OrderTicket --
|
||||
|
||||
"Broker mode" general notes:
|
||||
Order Tickets should appear immediately below the cell from which they were clicked
|
||||
The qty box has focus an is ready to be typed into immediately
|
||||
The qty box has the same left/right mouse behavior as the ladder qty for quick increment/decrement
|
||||
There is only 1 big Buy/Sell button on the bottom
|
||||
|
||||
Mousebutton action to join/cross
|
||||
Left click on a bid price cell
|
||||
A buy-only ticket launches (i.e. your intent is to join the bid)
|
||||
Right click on a bid price cell
|
||||
A sell-only ticket launches (i.e. your intent is to cross the bid)
|
||||
Left click on a ask price cell
|
||||
A sell-only ticket launches (i.e. your intent is to join the ask)
|
||||
Right click on a sell price cell
|
||||
A buy-only ticket launches (i.e. your intent is to cross the ask)
|
||||
|
||||
Order Ticket price buttons
|
||||
Launch a buy order ticket by joining a bid
|
||||
Click on the Ask Price button
|
||||
The price field should update to reflect the ask price at the time the button was clicked
|
||||
The single Buy button is replaced with a Sell button
|
||||
Now, click the "1" qty button
|
||||
Click Sell
|
||||
Verify a Sell Order was actually sent at the appropriate price and size
|
||||
Now, click on the Bid Price button
|
||||
The price field should update to reflect the bid price at the time the button was clicked
|
||||
The single Ask button is replaced with a Buy button
|
||||
Click Buy
|
||||
Verify a Buy Order was actually sent at the appropriate price and size
|
||||
Close the ticket
|
||||
Extra credit - repeat the above test by first lauching a sell order and swap everything else
|
||||
|
||||
Order Ticket size buttons
|
||||
Launch a buy order ticket by joining a bid
|
||||
Click on the Ask Size button
|
||||
The price field should update to reflect the ask price at the time the button was clicked
|
||||
The size field should update to reflect the ask size at the time the button was clicked
|
||||
The single Buy button is replaced with a Sell button
|
||||
Click Sell
|
||||
Verify a Sell order was sent at the appropriate price and size
|
||||
Now, click on the Bid Size button
|
||||
The price field should update to reflect the bid price at the time the button was clicked
|
||||
The size field should update to reflect the bid size at the time the button was clicked
|
||||
The single Sell button is replaced with a Buy button
|
||||
Click Buy
|
||||
Verify a Buy order was actually sent at the appopriate price and size
|
||||
Close the ticket
|
||||
Extra credit - repeat the above test by first lauching a sell order and swap everything else
|
||||
|
||||
|
||||
|
||||
@@ -5,13 +5,10 @@ The badges coming out in 1.2 have had their functionality greatly enhanced. Plea
|
||||
1. Qty Filled text
|
||||
2. Total Qty text
|
||||
3. Badge will use buy/sell side color as fill
|
||||
4. On child orders, a rectangle will be displayed with the first character of the root algo, along with the color of the root algo
|
||||
4. On child orders, the Sub type will be displayed on the right side
|
||||
5. On single order badges (no parent-child relationship), we'll put a border around the badge representing the order type
|
||||
6. not pictured / tba
|
||||
7. A dot will be painted in the upper right region of the badge on exchange orders: Limit, Market, Stop, StopLimit types
|
||||
8. Not pictured, but some orders will indicate they should not appear in a badge depending on their state. Trigger orders that have been triggered will not be shown.
|
||||
9. A triagle in the lower right corner of the badge will mean there are multiple orders at this level. In this multiple order state, all other badge widgets will be hidden.
|
||||
10. A vertical line will be drawn on the left side of the badge from top to bottom to indicate this is a hedging order
|
||||
9. A triangle in the lower right corner of the badge will mean there are multiple orders at this level. In this multiple order state, all other badge widgets will be hidden.
|
||||
|
||||
|
||||
Test Steps
|
||||
@@ -19,54 +16,39 @@ Test Steps
|
||||
|
||||
Test 1
|
||||
-------
|
||||
This will test characteristics 1,2,3,5,7,9
|
||||
This will test characteristics 1,2,3,5,9
|
||||
|
||||
1. Pull up your favorite product a work a limit order above the ask, you should see
|
||||
0/qty working (1,2)
|
||||
the badge should be filled in with a lighter ask background color (red) (3)
|
||||
the badge will have a green border, depicting the single-order limit order type (5)
|
||||
the badge will have a dot in the upper right hand corner (7)
|
||||
|
||||
2. Now place another limit order at the same level:
|
||||
the badge now has a triangle in the lower right, indicating we have multiple working orders (9)
|
||||
the green border and dot have gone away (5, 7)
|
||||
the green border has gone away (5)
|
||||
|
||||
Now place another limit below the bid:
|
||||
Now place another limit order below the bid:
|
||||
|
||||
3. Outcome similar to 1, except the background color is lighter bid background color (blue)
|
||||
|
||||
Now place an a Buy Iceberg at the same level with a sufficiently large qty, say 200, as your working ask
|
||||
Now place a Buy Iceberg at the same level with a sufficiently large qty, say 200, as your working ask
|
||||
|
||||
4. Outcome similar to 1, except the background color is purple to indicate a buy and sell are at the same level
|
||||
4. Outcome similar to 1
|
||||
|
||||
|
||||
Test 2
|
||||
------
|
||||
This will test characteristics 4,10
|
||||
This will test characteristics 4
|
||||
|
||||
1. Create a spreader comprised 1 quoting leg and 1 hedging leg of your favorite instruments and place a spread order
|
||||
2. Pull up the spreader ladder and place a sell order above the market
|
||||
3. Pull up the quoting leg's ladder and observe the badge; it may be helpful to pull up the Orderbook to find the price at which the leg is being quoted.
|
||||
The badge should have a rectangle filled in with the Spreader algo's color
|
||||
there should be an S in the rectangle denoting it's root parent is Spreader algo
|
||||
it should have a dot in the upper right denoting it's an exchange order (limit)
|
||||
1. Create a cover order (set hedge ticks to 1)
|
||||
2. The badge should have the algo's border color and the letters CV on the left to indicate it is a cover order.
|
||||
3. Fill the order, hedge orders should be placed one tick above and below the cover order's price
|
||||
4. The badges should display H on the right to indicate they are hedge orders.
|
||||
it should be surrounded by a green border (limit)
|
||||
4. Work a sell limit at the same level of this order
|
||||
4. Work a sell limit at the same level as the sell hedge
|
||||
The multi-order triangle will appear and all other badge widgets will disappear.
|
||||
5. Cancel that limit.
|
||||
6. I'm not sure how to get a Hedge order working w/o filling immediately; assume it just works for now
|
||||
|
||||
Test 3
|
||||
------
|
||||
This will test characteristic 8
|
||||
|
||||
1. Put in a Price Type Bid trigger order with Trigger Action Limit at a fixed price somewhere way outside of the market so it will work.
|
||||
When your trigger is hit, the trigger should disappear from the ladder but the triggered order should be visible and working. (Trigger orders may not behave this way in sim)
|
||||
The badge for the triggered order should show a rectangle filled in w/ the Trigger order color and letter
|
||||
The badge for the triggered order should have a green border (limit)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
Ladder UI Test
|
||||
|
||||
Start a ladder (Trading->Ladder)
|
||||
Start a ladder (Trading->Ladder)
|
||||
|
||||
Select a security and launch
|
||||
Test basic ladder functionality
|
||||
@@ -22,8 +22,5 @@ Test a market order, do a buy and a sell and make sure they fill at market price
|
||||
Test Stop and Stop limit orders. Put a Stop Buy above the market and a Stop Sell below
|
||||
|
||||
Test ICEBerg Orders
|
||||
Select ICEBerg and then specify limit as subtype via the left arrow. Set show quantity = 1
|
||||
Select ICEBerg; use the left arrow to Set show quantity = 1
|
||||
Now select a size greater than 1 in the main ladder, place buys and sells in the ladder.'
|
||||
|
||||
Test TimeBox
|
||||
Enter any time in the future and a reasonable end time. Enter two orders. Cross one of the orders during the specified time window with a limit order and verify it was filled correctly. Verify the other order cancels after the end time.
|
||||
@@ -10,7 +10,7 @@ General Stuff to Look For:
|
||||
- The MBO popup is 'live' and should update as the market moves.
|
||||
- The MBO popup should increase in size if more orders are added while it is open.
|
||||
- The MBO popup should not shrink when orders are removed. It only grows.
|
||||
- The scale of the bars is based on the largest order seen by the popup.
|
||||
- The scale of the bars is based on the largest order seen by the popup.
|
||||
- If a larger order shows up it will scale down the other orders.
|
||||
- When the large order goes away it should *not* expand the other bars. The scale only increases while the popup is open.
|
||||
- For example:
|
||||
@@ -26,9 +26,9 @@ General Stuff to Look For:
|
||||
Part 1:
|
||||
-------
|
||||
- Find a security with a non-empty market that isn't moving too fast. Cert can be temperamental so open the market view and filter for Qty > 0.
|
||||
- Open settings and turn on the PIQ column (settings -> column settings)
|
||||
- Choose a price near the top of the book and middle click the price column to show the MBO popup.
|
||||
- Add up the sizes in the popup and make sure they agree with the total size in the bid or ask column on the ladder.
|
||||
- Open settings and turn on the PIQ column (settings -> Ladder Columns)
|
||||
- Choose a price near the top of the book and shift + middle click the price column to show the MBO popup. (There must be a size for the popup to show)
|
||||
- Add up the sizes in the popup and make sure they agree with the total size in the bid or ask column on the ladder.
|
||||
- Test both sides of the market near the top and away from the top.
|
||||
- Enter an order.
|
||||
- The PIQ column should reflect the number of orders ahead of you in the queue. The size in the bid/ask column is how many orders were there when you entered your order so you should expect the PIQ to be the size from before you entered your order.
|
||||
@@ -52,6 +52,6 @@ Part 3:
|
||||
- Find a security with enough orders to cause scrolling by either
|
||||
- Connect to a demo system with production md and look at a ZN spread (i.e. ZNM9 - ZNU9)
|
||||
- Enter a bunch of orders at the level on cert.
|
||||
- If you try this on sim (you're not a very good listener, are you?) It will cap out at ExchangeSim.orders_per_level (default:10)
|
||||
- If you try this on sim (you're not a very good listener, are you?) It will cap out at ExchangeSim.orders_per_level (default:10)
|
||||
- Make sure that scrolling works.
|
||||
|
||||
@@ -38,17 +38,17 @@ Row edit mode behavior
|
||||
Repeat for price
|
||||
Repeat for both
|
||||
Verify that pressing enter and/or clicking the check button only commits the current row
|
||||
Clicking the update button will put the row in edit mode and bring up an additonal popup that will also allow for price and size modifications (for now)
|
||||
Clicking the update button will put the row in edit mode and bring up an additonal popup that will also allow for price and size modifications (update is only enabled for algo orders)
|
||||
Change the qty in the update popup and verify the row's qty textbox updates to reflect the changed-to value and that the the check button is still disabled (i.e. the Update popup has committed the change already, so there is *not* any additional pending change)
|
||||
Change the price in the update popup and the row will disappear from the miniob since the order is now at a different price
|
||||
|
||||
A(attach)/D(etach) buttons
|
||||
Click on the A button brings and bring up the attach popup
|
||||
Attach a limit to an IB
|
||||
Verify the limit row's A button has changed to a D
|
||||
Verify the limit row's attach button has changed to a detach button
|
||||
Verify the limit row is now a child to an IB order row
|
||||
Click on D button on the limit order
|
||||
Verify the limit row's D button has now changed to an A
|
||||
Click on detach button on the limit order
|
||||
Verify the limit row's detach button has now changed to an attach
|
||||
Verify the limit row is no longer a child to the IB
|
||||
Verify the IB order is now canceled
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ SODTime{
|
||||
Day Short 0
|
||||
Day PnL 0
|
||||
Total Net Pos -1
|
||||
Total PnL -12.5
|
||||
Total PnL -37.5
|
||||
PnL Price 14.0125 (displayed as 14.015)
|
||||
ACC A1:
|
||||
Start Net Pos 1
|
||||
@@ -133,8 +133,8 @@ Buy a 1 lot at the current bid in ACCA via Trading -> Manual Fills
|
||||
ACC A:
|
||||
Start Net Pos -1 (no change)
|
||||
Start PnL -37.5
|
||||
Day Long 0
|
||||
Day Short 0
|
||||
Day Long 1
|
||||
Day Short 1
|
||||
Day PnL 0
|
||||
Total Net Pos -1
|
||||
Total PnL -37.5
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# Trade Alerts Test (20 min)
------------------------------
###Preparation
- Put the following in spark.conf on the server (we need complete control over the system trades, i.e., those in the trade ticker): `ExchangeSim { value { merged_with_md: false } }`
- Make sure your volume is turned up.
- Open the Global Alerts Dialog (Settings -> Alerts).
- [Optional] Open the trade ticker (with all securities), to serve as a visual aid to identify expected/unexpected sound-alerts, or lack thereof.
---
###How To
#####Add an Alert:
1. In the Global Alerts Dialog, select the 'Trade Alerts' tab, if not already selected.
- Use the 'Click to Add..' hyperlink to add an alert.
- Expectations:
- a new alert row should be added to the grid
- it should have the following defaults (not all columns have explicit defaults):
- On/Off switch: 'On'
- Security: 'None'
- Price Condition: 'None'
- Size Condition: 'None'
- Side: 'Buy & Sell'
- Use the controls inside of each cell to define the alert conditions/criteria.
- In the Sound cell, click the play button to hear a preview (perhaps it would be better if the play button were removed, and the sound played upon selection).
#####Delete an Alert:
1. In the Global Alerts Dialog, select the 'Trade Alerts' tab, if not already selected.
- Click the 'X' button on the left side the [alert]row you wish to delete.
#####Force a Trade:
1. Enter an order for the appropriate security (use a 1 lot unless otherwise specified, as this eliminates the potential for orders to continue working after a trade is triggered).
- Enter an order for the same security on the opposite side, at the same price to cause a trade (use the same size as the first order unless otherwise specified).
##
- Note: the aggressor side is the side that triggered the trade. If both orders are placed at the same price, the second order is the aggressor. The alert's 'Side' condition refers to the aggressor side.
---
###Test Steps
#####PART I: Security Condition (3 min)
1. Delete all alerts.
2. Add an alert with the following conditions:
- Security: a specific security. This security will be referred to as 'A'
- Click 'Apply' to save the new alert.
- Force a trade to happen for 'A':
- Expectation: the appropriate sound is played.
- Return to the Global Alerts Dialog, remove the 'A,' and replace it with a different one. This new security will be referred to as 'B.'
- Force a trade to happen for the 'A.'
- Expectation: no sound is played.
- Force a trade to happen for 'B.'
- Expectation: the appropriate sound is played.
- Return to the Global Alerts Dialog, select a different sound, then click 'Apply.'
- Force a trade to happen for 'B.'
- Expectation: the appropriate sound is played.
##### PART II: Symbol Condition (3 min)
1. Delete all alerts.
2. Add an alert with the following conditions:
- Security: a specific symbol with 2 or more securities. This symbol will be referred to as 'A.'
3. Force a trade to happen for 2 different securities of this symbol.
- Expectations: the appropriate sound is played for both trades
4. Force a trade to happen for a security that is not of this symbol.
- Expectations: no sound is played.
#####PART III: Price Condition (4 min)
1. Execute the following steps for each price condition mode:
- Greater Than
- Less Than
- Between
- Not Between
- Delete all alerts.
- Add an alert with the following conditions:
- Security: all (add each exchange to enable for all securities)
- Price: a condition with the mode you aim to test.
- Any real number will suffice for Greater/Less Than modes.
- For the 'Between/Not Between' modes, the first number is the exclusive minimum, and must be less or equal to the second number, which is the exclusive maximum.
- Note: for certain combinations of security-ticks and min/max values, the min/max may to behave inclusively due to rounding errors. We should address this soon, but is not a showstopper at the moment.
- Force a trade to happen that satisfies the price condition (remember to use a security with the appropriate symbol).
- Expectations: the appropriate sound is played.
- Force a trade to happen that does NOT satisfy the price condition
- Expectations: no sound is played.
#####PART IV: Size Condition (4 min)
1. Execute the following steps for each size condition mode:
- Greater Than
- Less Than
- Between
- Not Between
- Delete all alerts.
- Add an alert with the following conditions:
- Security: all (add each exchange to enable for all securities)
- Size: a condition with the mode you aim to test.
- Any real number will suffice for Greater/Less Than modes.
- For the 'Between/Not Between' modes, the first number is the inclusive minimum, and must be less or equal to the second number, which is the inclusive maximum.
- Force a trade to happenLine truncated
|
||||
@@ -1,5 +1,5 @@
|
||||
Test Author: Kevin
|
||||
If it breaks: Kevin
|
||||
If it breaks: Kevin
|
||||
|
||||
This will test our ability to compute and enforce span margin at CME
|
||||
|
||||
@@ -20,10 +20,10 @@ SpanMargin {
|
||||
|
||||
You should see a value of around 6300 in maintenance margin after a minute or two
|
||||
|
||||
4) If not already zero, set your cash balance to zero.
|
||||
4) If not already zero, set your cash balance to zero and set leverage factor to 1
|
||||
|
||||
5) Try to trade an ES in ACC A, you should be blocked by a limit breach
|
||||
|
||||
6) Increase your cash balance to 10,000 and set leverage factor to 1.0
|
||||
6) Increase your cash balance to 10,000 (or higher, your Excess Liquidity should be positive)
|
||||
|
||||
7) Try to trade again, you should be able to.
|
||||
@@ -2,20 +2,22 @@ This test verifies that fractional hedges work. That is, when a fill in a quotin
|
||||
not equate to one full contract in the hedging leg, we accumulate the unhedged
|
||||
delta, until we can send one or more hedging contracts.
|
||||
|
||||
1. Create a new synthetic spread. For the legs choose SIF9 and SIH9 (if you don't
|
||||
0. This needs sim with replay turned off (see step 0 in common_setup_1), so we can create our own markets.
|
||||
|
||||
1. Create a new synthetic spread. For the legs choose SIF1 and SIH1 (if you don't
|
||||
have these contracts, other contracts can be chosen too) and for the quantities choose 1 and -1.5
|
||||
respectively (and same for the Price multiplier).
|
||||
Enable quoting for SIH9, and disable all quoting, pre-hedge and post-hedge parameters.
|
||||
Name the synthetic SIF9-1.5SIH9.
|
||||
Enable quoting for SIH1, and disable all quoting, pre-hedge and post-hedge parameters.
|
||||
Name the synthetic SIF1-1.5SIH1.
|
||||
|
||||
1. Bring up the ladder for the synthetic and for the 2 legs.
|
||||
|
||||
2. Enter a 10 lot sell order at 20.0 for SIF9 (If the ladder is showing blanks use the market view
|
||||
2. Enter a 10 lot sell order at 20.0 for SIF1 (If the ladder is showing blanks use the market view
|
||||
to enter orders). The quoting order will lean against this.
|
||||
|
||||
3. Enter a 10 lot buy order for the synthetic at -9.900.
|
||||
|
||||
4. Verify that a 15 lot quoting order is sent for SIH9 at 19.935.
|
||||
4. Verify that a 15 lot quoting order is sent for SIH1 at 19.935.
|
||||
|
||||
5. Now we will start filling the quoting order and verify the hedges. A 1 lot fill in the
|
||||
quoting leg means a 2/3 contract in the hedging leg. Since we can not send 2/3 contracts,
|
||||
@@ -32,14 +34,14 @@ happening on the order sent in step 2 (or look at the hedges in the orderbook).
|
||||
------------------------------------------------------------------------------
|
||||
quoting fill unhedged_delta hedge_order_sent remaining_unhedged_delta
|
||||
------------------------------------------------------------------------------
|
||||
1 2/3 0 2/3
|
||||
1 4/3 1 1/3
|
||||
1 1 1 0
|
||||
4 8/3 2 2/3
|
||||
5 4 4 0
|
||||
2 4/3 1 1/3
|
||||
1 1 1 0
|
||||
1 2/3 0 2/3
|
||||
1 4/3 1 1/3
|
||||
1 1 1 0
|
||||
4 8/3 2 2/3
|
||||
5 4 4 0
|
||||
2 4/3 1 1/3
|
||||
1 1 1 0
|
||||
|
||||
6. At the end of this, the whole order should be filled. Check the order book
|
||||
to make sure the fill price is -9.900, there are 10 total fills in SIF9 and
|
||||
15 fills in SIH9.
|
||||
to make sure the fill price is -9.900, there are 10 total fills in SIF1 and
|
||||
15 fills in SIH1.
|
||||
@@ -10,7 +10,7 @@ ExchangeSim {
|
||||
}
|
||||
}
|
||||
|
||||
1. Open up the mview and find a security with with both direct and implied markets, on the ask side.
|
||||
1. Open up the market view and find a security with with both direct and implied markets, on the ask side.
|
||||
Make sure those markets are stable and you can rely on them.
|
||||
|
||||
2. Create a synthetic with the security in 1. being the hedge leg (buy) and choose a quoting
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
This test verifies the pecularities of the spreader with > 1 quoting leg.
|
||||
This test verifies the peculiarities of the spreader with > 1 quoting leg.
|
||||
|
||||
0. This needs sim with replay turned off (see step 0 in common_setup_1), so we can create our own markets.
|
||||
|
||||
@@ -9,14 +9,14 @@ well. Disable all Quote, Pre-Hedge and Post-Hedge parameters.
|
||||
market of 20 at 1.00 should show up.
|
||||
|
||||
3. Now enter a 5 lot synthetic buy order at 0.70. Since both legs are quoting GCM2 uses GCZ2 (19.50 bid)
|
||||
to quote its bid at 19.50+0.7=20.2, and GCZ2 uses GCM2 (20.05) to quote its offer at 20.5-0.70=19.8. Verify
|
||||
these quoting prices
|
||||
to quote its bid at 19.50+0.7=20.2, and GCZ2 uses GCM2 (20.05) to quote its offer at 20.5-0.70=19.8. Verify
|
||||
these quoting prices
|
||||
(remember, for quoting prices:
|
||||
leg_1=leg_2_bid_market+spreader_price
|
||||
leg_2=leg_2_bid_market-spreader_price
|
||||
)
|
||||
|
||||
4. Move the markets a few times (without crossing and causing any fills) and make sure the quoting prices
|
||||
4. Move the markets a few times (without crossing and causing any fills) and make sure the quoting prices
|
||||
are correct, and bring them back to where they were in 2.
|
||||
|
||||
5. Now force a 1 lot fill on the GCZ2 quoting order, by sending a 1 lot buy against it. This should send
|
||||
|
||||
Reference in new issue
Block a user