/// <summary> /// 验证限价单定单信息的有效性 /// </summary> /// <param name="newInfo">新挂单的详细信息</param> /// <param name="selectedProduct">选中下单的商品</param> /// <param name="operateClient">该市价单定单对应的某个用户</param> /// <returns>验证结果</returns> private ValidationResult PendingOrderInfoValidation(NewPendingOrderInfo newInfo, ProductInformation selectedProduct, ClientAccount operateClient) { double priceDeviation = selectedProduct.PendingOrderSpread * selectedProduct.SpreadBaseValue; double minPriceCaps = newInfo.RealTimePrice - priceDeviation;//最小价格上限 double maxPriceLows = newInfo.RealTimePrice + priceDeviation;//最大价格下限 if (newInfo.PendingOrdersPrice > minPriceCaps && newInfo.PendingOrdersPrice < maxPriceLows) { string msg = string.Format("无效的订单价!\r\n订单价必须大于等于:{0}\t或\t小于等于:{1}", maxPriceLows, minPriceCaps); return new ValidationResult(false, msg); } return OrderInfoBaseValidation(newInfo, selectedProduct, operateClient); }
/// <summary> /// 用新的限价挂单的详细参数信息和选中的某个商品实例化限价单消息参数实例 /// </summary> /// <param name="info">新限价挂单的详细参数信息</param> /// <param name="selectedProduct">选中的某个商品</param> public PendingOrderEventArgs( NewPendingOrderInfo info, ProductInformation selectedProduct ) { NewOrderInfo = info; SelectedProduct = selectedProduct; }
/// <summary> /// 限价挂单定单 /// </summary> /// <param name="loginID">登陆标识</param> /// <param name="clientAccountName">要下单的客户账户名</param> /// <param name="userType">用户类型,0:交易用户,1:管理员,2:金商</param> /// <param name="newOrderInfo">下单的定单信息</param> /// <returns>ErrType</returns> public ErrType PendingOrder(string loginID, string clientAccountName, int userType, NewPendingOrderInfo newOrderInfo) { try { OrdersLncoming orderLn = TradeConverter.ToOrdersLncoming(loginID, clientAccountName, userType, newOrderInfo); Orders result = TradeService.GetOrders(orderLn); if (!result.Result) return new ErrType(ERR.SERVICE, result.Desc); //这里还应进行账户资金方面的处理 return GeneralErr.Success; } catch (TimeoutException te) { FileLog.WriteLog("", Assembly.GetExecutingAssembly().GetName().Name, this.GetType().Name, new StackTrace().GetFrame(0).GetMethod().Name, te.Message); return new ErrType(ERR.EXEPTION, ErrorText.TimeoutException); } catch (Exception ex) { FileLog.WriteLog("", Assembly.GetExecutingAssembly().GetName().Name, this.GetType().Name, new StackTrace().GetFrame(0).GetMethod().Name, ex.Message); return new ErrType(ERR.EXEPTION, ErrorText.OperationError); } }
public PendingOrderWindow( ) { InitializeComponent( ); _newOrderInfo = new NewPendingOrderInfo( ); }
internal static OrdersLncoming ToOrdersLncoming( string loginID, string clientAccountName, int userType, NewPendingOrderInfo newOrderInfo ) { return new OrdersLncoming { CurrentTime = newOrderInfo.RealTimeTime, HoldPrice = newOrderInfo.PendingOrdersPrice, LoginID = loginID, LossPrice = newOrderInfo.StopLossPrice, Mac = newOrderInfo.MAC, OrderMoney = newOrderInfo.PercentageOfDeposit, OrderType = ( ( int )newOrderInfo.OrderType ).ToString( CultureInfo.InvariantCulture ), ProductCode = newOrderInfo.ProductCode, ProfitPrice = newOrderInfo.StopProfitPrice, Quantity = newOrderInfo.Count, RtimePrices = newOrderInfo.RealTimePrice, ValidTime = newOrderInfo.DueDate, TradeAccount = clientAccountName, //Todo:用户类型待处理 //UserType = userType, }; }