/// <summary> /// 构建港股成交回报 /// </summary> /// <param name="tet"></param> /// <param name="sdbe"></param> /// <param name="xhcr"></param> /// <param name="dealCapital"></param> /// <param name="tm"></param> /// <returns></returns> public static HK_TodayTradeInfo BuildHKDealRpt(HK_TodayEntrustInfo tet, HKDealBackEntity sdbe, HKCostResult xhcr, decimal dealCapital, ReckoningTransaction tm) { string result = string.Empty; //成交回报实体 var hkDealRpt = new HK_TodayTradeInfo(); //xhDealrpt.TradeNumber = this.BuildXHDealOrderNo(); hkDealRpt.TradeNumber = sdbe.ID; //不再自己构建id,使用成交回报的id,一一对应 //成交时间 hkDealRpt.TradeTime = sdbe.DealTime; //成交价 hkDealRpt.TradePrice = sdbe.DealPrice; //成交单位 hkDealRpt.TradeUnitId = tet.TradeUnitID; //成交量 hkDealRpt.TradeAmount = Convert.ToInt32(sdbe.DealAmount); //股东代码 hkDealRpt.HoldAccount = tet.HoldAccount; //资金帐户 hkDealRpt.CapitalAccount = tet.CapitalAccount; //成交回报类型 hkDealRpt.TradeTypeId = (int)Types.DealRptType.DRTDealed; //现货名称 hkDealRpt.Code = tet.Code; //印花税 hkDealRpt.StampTax = xhcr.StampDuty; //佣金 hkDealRpt.Commission = xhcr.Commision; //过户费 hkDealRpt.TransferAccountFee = xhcr.TransferToll; //交易系统使用费 hkDealRpt.TradingSystemUseFee = xhcr.TradeSystemFees; //交易手续费用(只有港股才有) hkDealRpt.TradeProceduresFee = xhcr.PoundageSingleValue; //监管费 hkDealRpt.MonitoringFee = xhcr.MonitoringFee; //结算费 hkDealRpt.ClearingFee = xhcr.ClearingFees; //委托价格 hkDealRpt.EntrustPrice = tet.EntrustPrice; //成交金额 hkDealRpt.TradeCapitalAmount = dealCapital; // xhDealrpt.TradePrice*xhDealrpt.TradeAmount;//TODO:是否正确?没有算比例 //投组标识 hkDealRpt.PortfolioLogo = tet.PortfolioLogo; //货币类型 hkDealRpt.CurrencyTypeId = tet.CurrencyTypeID; //买卖方向 hkDealRpt.BuySellTypeId = tet.BuySellTypeID; hkDealRpt.EntrustNumber = tet.EntrustNumber; HK_TodayTradeDal hkTodayTradeDal = new HK_TodayTradeDal(); if (hkTodayTradeDal.Exists(hkDealRpt.TradeNumber)) { string format = "BuildHKDealRpt数据库已经存在TradeNumber={0}"; string desc = string.Format(format, hkDealRpt.TradeNumber); LogHelper.WriteDebug(desc); //xhDealrpt = xhTodayTradeTableDal.GetModel(xhDealrpt.TradeNumber); return(null); } try { hkTodayTradeDal.Add(hkDealRpt, tm); } catch (Exception ex) { LogHelper.WriteError(ex.Message, ex); hkDealRpt = null; } return(hkDealRpt); }
/// <summary> /// 计算预成交金额和预成交费用 /// </summary> /// <param name="strMessage">错误信息</param> /// <param name="predealCapital">预成交金额</param> /// <param name="predealCost">预成交费用</param> /// <returns>计算是否成功</returns> private bool PO_ComputePreCapital(ref string strMessage, ref decimal predealCapital, ref decimal predealCost) { bool result = false; predealCapital = 0; predealCost = 0; //如果量为0,直接返回0 if (Request.OrderAmount == 0) { return(true); } try { HKCostResult xhcr = null; //计价单位与交易单位倍数 //update 李健华 2009-10-26 //decimal unitMultiple = MCService.GetTradeUnitScale(Request.Code, Request.OrderUnitType); decimal unitMultiple = MCService.GetTradeUnitScale(Types.BreedClassTypeEnum.HKStock, Request.Code, Request.OrderUnitType); //========= //float orderPrice = 0; //成本计算器 xhcr = MCService.ComputeHKCost(Request); //预成交总金额 委托量 * 计价单位与交易单位倍数 * 委托价 predealCapital = Convert.ToDecimal(Request.OrderAmount) * unitMultiple * Convert.ToDecimal(Request.OrderPrice); //预成交费用 predealCost = xhcr.CoseSum; result = true; #region 旧逻辑-港股无市价单,必须有价格 /* * //市价委托(TODO:待重写) * if (Request.OrderWay == Types.HKPriceType.LO) * { * decimal orderPriceD = (decimal) Request.OrderPrice; * var highLowRange = MCService.HLRangeProcessor.GetHighLowRangeValueByCommodityCode(Request.Code, * orderPriceD); * if (highLowRange != null) * { * if (highLowRange.RangeType == Types.HighLowRangeType.HongKongPrice) //港股类型处理 * { * var hkrv = highLowRange.HongKongRangeValue; * if (Request.BuySell == Types.TransactionDirection.Buying) * { * orderPrice = Convert.ToSingle(hkrv.BuyHighRangeValue); * } * else * { * orderPrice = Convert.ToSingle(hkrv.SellHighRangeValue); * } * } * else //其它类型处理 * { * orderPrice = Convert.ToSingle(highLowRange.HighRangeValue); * } * * //以计价单位计算的委托量 * int orderAmount = Convert.ToInt32(Request.OrderAmount); //*Convert.ToDouble(unitMultiple)); * * //预成交总金额 委托量 * 计价单位与交易单位倍数 * 委托价 * predealCapital = orderAmount*Convert.ToDecimal(orderPrice)*unitMultiple; * //预成交费用 * xhcr = MCService.ComputeHKCost(Request.Code, orderPrice, orderAmount, * Request.OrderUnitType, Request.BuySell); * //预成交费用 * predealCost = xhcr.CoseSum; * result = true; * } * else * { * strMessage = "GT-2415:[港股委托持久化]商品无涨跌幅设置"; * } * } * else //限价委托计算( 委托价*委托量 + 费用) * { * //成本计算器 * xhcr = MCService.ComputeHKCost(Request); * //预成交总金额 委托量 * 计价单位与交易单位倍数 * 委托价 * predealCapital = Convert.ToDecimal(Request.OrderAmount)*unitMultiple* * Convert.ToDecimal(Request.OrderPrice); * //预成交费用 * predealCost = xhcr.CoseSum; * result = true; * } * * */ #endregion } catch (Exception ex) { if (ex is VTException) { strMessage = ex.ToString(); } else { strMessage = "GT-2416:[港股委托持久化]成交金额及费用计算异常."; } LogHelper.WriteError(ex.Message, ex); } return(result); }