public void UpdateStopLimit(BitmexOrderData order, double bidPrice, double askPrice) { int idx = MainWnd.ContainsOrder <StopOrderModel>(gridStops, order); if (idx != -1) { var newModel = StopOrderModel.ToModel(order, MainWnd.Controller, bidPrice, askPrice); if (newModel.StopPx.HasValue) { // TODO: ?? //var lbItem = GetListBoxItem<StopOrderModel>(lbStopOrders, order); //lbItem.StopPx = newModel.StopPx.Value; } var model = (StopOrderModel)gridStops.Items[idx]; MainWindow.HandleException(() => { var msg = model.Sync(newModel, MainWnd.Controller); if (msg != null) { order.Message = String.Format("Update Stop{0} ID{1}", msg, order.OrderId.GetOrderId()); MainWnd.LogOrderEvent(order.Message); MainWnd.UpdateOrder <StopOrderModel>(gridStops, order, model, idx); } }); } }
internal void CreateStopOrder(BitmexOrderData order, double bidPrice, double askPrice) { var model = StopOrderModel.ToModel(order, MainWnd.Controller, bidPrice, askPrice); MainWnd.InsertOrder <StopOrderModel>(gridStops, model, null, lbStopOrders); //if (order.PegOffsetValue.HasValue) //{ // MainWnd.ChangeControl(() => btnCancelTrail.IsEnabled = true); //!! may be send event // _trailingStopId = order.OrderId; //} MainWindow.HandleException(() => { var price = MainWnd.Controller.ToStringPrice(order.StopPx.Value, order.Symbol); var orderId = order.OrderId.GetOrderId(); order.Message = String.Format("Stop Px={0} {1} ID{2}", price, order.Symbol, orderId); MainWnd.LogOrderEvent(order.Message); }); }