SPARK-975 - StopLimits and disallow both price and size changes

This commit is contained in:
Jake Norbut committed 2018-05-09 12:49:32 -05:00
1 parent 18f77215f0
commit eaa09435c8
4 files changed
+30 -9

No files matched your search

@@ -57,7 +57,8 @@ namespace bts.shell {
}
void _show_modify_order(uint order_key) {
if (_orders.state.TryGetValue(order_key, out OrderRecordImmutable ori) && _md_map.TryGetValue(ori.Def.SecurityKey, out SecurityMD smd))
if (_orders.state.TryGetValue(order_key, out OrderRecordImmutable ori) && _md_map.TryGetValue(ori.Def.SecurityKey, out SecurityMD smd)
&& (ori.HasDef && ori.Def.HasCustomDef && !(ori.Def.CustomDef.HasStop || ori.Def.CustomDef.HasStopLimit)))
_show_order_window(new OrderModificationDialog {
DataContext = new ExistingOrderTicketVM(_model,
Observable.Return(new OrderRecordTuple(ori, smd)),
@@ -72,10 +72,16 @@ namespace mbts.spark {
hoverbackground = mkbrush(dark, _darkbg, completion);
border = new SolidColorBrush(color);
_real_price = _order.State.Price;
if (_order.Def.HasCustomDef && _order.Def.CustomDef.HasStop) {
// if the stop order has been submitted but hasn't been triggered
// we draw the badge at the stop/trigger price, else the price price
if (_order.State.FilledQuantity == 0) { _real_price = _order.Def.CustomDef.Stop.StopPrice; }
if (_order.Def.HasCustomDef) {
if (_order.Def.CustomDef.HasStop) {
// if the stop order has been submitted but hasn't been triggered
// we draw the badge at the stop/trigger price, else the price price
if (_order.State.FilledQuantity == 0) { _real_price = _order.Def.CustomDef.Stop.StopPrice; }
}
if (_order.Def.CustomDef.HasStopLimit) {
// consistent behavior as Stop order above.
if (_order.State.FilledQuantity == 0) { _real_price = _order.Def.CustomDef.StopLimit.StopPrice; }
}
}
}
@@ -265,8 +265,12 @@ namespace mbts.spark {
Disposable.dispose(ref _drag_init);
_drag_view = order_view;
if (_drag_view.DataContext is LadderOrderVM vm) {
using (new DropIndicatorAdorner(_orders_host))
DragDrop.DoDragDrop(_orders_host, vm, DragDropEffects.Move);
// for now, don't allow stop or stop limit to be moved in ladder
// bc sparkd will assert
if (vm.order.HasDef && vm.order.Def.HasCustomDef && !(vm.order.Def.CustomDef.HasStop || vm.order.Def.CustomDef.HasStopLimit)) {
using (new DropIndicatorAdorner(_orders_host))
DragDrop.DoDragDrop(_orders_host, vm, DragDropEffects.Move);
}
}
}
}
+12 -2
View File
@@ -138,8 +138,18 @@ namespace mbts.spark {
size_calculator.flash_error();
} else {
var order = order_properties_vm.create(args.side.Value);
if (order.CustomDef != null && order.CustomDef.Stop != null) {
order.CustomDef.Stop.StopPrice = args.price;
if (order.CustomDef != null) {
if (order.CustomDef.Stop != null) {
order.CustomDef.Stop.StopPrice = args.price;
}
if (order.CustomDef.StopLimit != null) {
// swap the prices here so that the level clicked
// in the ladder is the StopPrice (trigger) and the Price
// is what was specificed in the extra parameter box
double temp_price = order.CustomDef.StopLimit.StopPrice;
order.CustomDef.StopLimit.StopPrice = args.price;
args.price = temp_price;
}
}
uint size = (uint)Math.Abs(size_calculator.value.Value);
await _model.order_gateway.send_order(order, args.price, size);