/// <summary>
        /// 获取港股交易费用
        /// </summary>
        /// <param name="request">港股委托</param>
        /// <returns>港股交易费用结果</returns>
        public static HKCostResult ComputeHKCost(HKOrderRequest request)
        {
            int?         bc     = MCService.CommonPara.GetBreedClassIdByCommodityCode(request.Code, Types.BreedClassTypeEnum.HKStock);
            HKCostResult result = null;

            if (!bc.HasValue)
            {
                return(null);
            }
            int breedClassID = bc.Value;

            HK_SpotCosts cost = MCService.HKTradeRulesProxy.GetSpotCostsByBreedClassID(breedClassID);

            if (cost == null)
            {
                return(null);
            }
            try
            {
                result = InternalComputeHKCost(request, cost);
            }
            catch (Exception ex)
            {
                string      errCode   = "GT-1701";
                string      errMsg    = "无法获取港股交易费用。";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception);
                throw exception;
            }

            return(result);
        }
        /// <summary>
        /// 根据港股委托单和港股交易费用规则统计交易费用实体
        /// </summary>
        /// <param name="request">委托单</param>
        /// <param name="cost">交易费用规则</param>
        /// <returns>返回港股交易费统计实体</returns>
        private static HKCostResult InternalComputeHKCost(HKOrderRequest request, HK_SpotCosts cost)
        {
            CM_BreedClass breedClass = MCService.CommonPara.GetBreedClassByCommodityCode(request.Code, Types.BreedClassTypeEnum.HKStock);

            HKCostResult result = new HKCostResult();

            result.Code = request.Code;

            decimal orderPrice = (decimal)request.OrderPrice;

            decimal scale = MCService.GetTradeUnitScale(Types.BreedClassTypeEnum.HKStock, request.Code, request.OrderUnitType);
            //以计价单位计算的委托量
            var orderAmount = (decimal)request.OrderAmount * scale;

            //成交额
            var dealAmount = orderPrice * orderAmount;

            #region 1.印花税
            /// 1.印花税
            decimal stamp = cost.StampDuty.Value / 100;

            decimal stampStart = cost.StampDutyStartingpoint.Value;

            if (cost.StampDutyTypeID.HasValue)
            {
                int stampType = cost.StampDutyTypeID.Value;

                decimal stampVal = stamp * dealAmount;
                if (stampVal < stampStart)
                {
                    stampVal = stampStart;
                }
                stampVal = Utils.Round(stampVal);

                switch ((Types.GetValueTypeEnum)stampType)
                {
                case Types.GetValueTypeEnum.Single:
                    break;

                case Types.GetValueTypeEnum.Scope:
                    break;

                case Types.GetValueTypeEnum.Turnover:
                    break;

                case Types.GetValueTypeEnum.Thigh:
                    break;

                case Types.GetValueTypeEnum.SingleBuy:
                    if (request.BuySell == Types.TransactionDirection.Buying)
                    {
                        result.StampDuty = stampVal;
                    }
                    break;

                case Types.GetValueTypeEnum.SingleSell:
                    if (request.BuySell == Types.TransactionDirection.Selling)
                    {
                        result.StampDuty = stampVal;
                    }
                    break;

                case Types.GetValueTypeEnum.TwoEdge:
                    result.StampDuty = stampVal;
                    break;

                case Types.GetValueTypeEnum.No:
                    break;

                default:
                    break;
                }
            }
            #endregion

            #region 2.佣金
            /// 2.佣金
            if (cost.Commision.HasValue)
            {
                decimal comm      = cost.Commision.Value / 100;
                decimal commVal   = comm * dealAmount;
                decimal commStart = 0;
                if (cost.CommisionStartingpoint.HasValue)
                {
                    commStart = cost.CommisionStartingpoint.Value;
                }
                if (commVal < commStart)
                {
                    commVal = commStart;
                }
                commVal          = Utils.Round(commVal);
                result.Commision = commVal;
            }
            #endregion

            #region 过户费
            /// 3.过户费
            if (cost.TransferToll.HasValue)
            {
                decimal transVal = cost.TransferToll.Value / 100;
                transVal            = Utils.Round(transVal);
                result.TransferToll = transVal;
            }
            #endregion

            #region 4.交易手续费
            #region old code
            ///// 4.交易手续费
            ////public decimal PoundageSingleValue { get; set; }
            //if (cost.GetValueTypeID.HasValue)
            //{
            //    int poundType = cost.GetValueTypeID.Value;

            //    //交易手续费单值 single double
            //    switch (poundType)
            //    {
            //        case (int)Types.GetValueTypeEnum.Single:
            //            decimal pound = cost.PoundageValue.Value / 100;
            //            decimal poundValue = pound * dealAmount;
            //            poundValue = Utils.Round(poundValue);
            //            result.PoundageSingleValue = poundValue;
            //            break;
            //        case (int)Types.GetValueTypeEnum.Scope:
            //            IList<XH_SpotRangeCost> costs =
            //                MCService.SpotTradeRules.GetSpotRangeCostByBreedClassID(breedClass.BreedClassID);

            //            foreach (XH_SpotRangeCost spotRangeCost in costs)
            //            {
            //                int fieldRangeID = spotRangeCost.FieldRangeID;
            //                decimal pound2 = spotRangeCost.Value.Value;
            //                pound2 = Utils.Round(pound2);

            //                CM_FieldRange fieldRange = MCService.GetFieldRange(fieldRangeID);

            //                //是否在当前字段范围内
            //                bool isExist = MCService.CheckFieldRange(dealAmount, fieldRange);
            //                if (isExist)
            //                {
            //                    result.PoundageSingleValue = pound2;
            //                    break;
            //                }
            //            }
            //            break;
            //    }
            //}
            #endregion

            decimal pound      = cost.PoundageValue.Value / 100;
            decimal poundValue = dealAmount * pound;
            poundValue = Utils.Round(poundValue);
            result.PoundageSingleValue = poundValue;

            #endregion

            #region  5.监管费
            /// 5.监管费
            //public decimal MonitoringFee { get; set; }
            if (cost.MonitoringFee.HasValue)
            {
                decimal monitor    = cost.MonitoringFee.Value / 100;
                decimal monitorVal = monitor * dealAmount;
                monitorVal = Utils.Round(monitorVal);

                result.MonitoringFee = monitorVal;
            }
            #endregion

            #region  6.结算费(无)
            /// 6.结算费
            result.ClearingFees = 0;
            #endregion

            #region 7.交易系统使用费
            /// 7.交易系统使用费
            if (cost.SystemToll.HasValue)
            {
                result.TradeSystemFees = cost.SystemToll.Value;
            }
            #endregion

            string format = "港股费用计算[代码={0},价格={1},数量={2},单位={3},方向={4}]";
            string desc   = string.Format(format, request.Code, request.OrderPrice, request.OrderAmount,
                                          request.OrderUnitType, request.BuySell);
            LogHelper.WriteDebug(desc + result);
            return(result);
        }