/// <summary> /// 获取现货交易费用 /// </summary> /// <param name="request">现货委托</param> /// <returns>现货交易费用结果</returns> public static XHCostResult ComputeXHCost(StockOrderRequest request) { int?bc = MCService.CommonPara.GetBreedClassIdByCommodityCode(request.Code); XHCostResult result = null; if (!bc.HasValue) { return(null); } int breedClassID = bc.Value; XH_SpotCosts cost = MCService.SpotTradeRules.GetSpotCostsByBreedClassID(breedClassID); if (cost == null) { return(null); } try { result = InternalComputeXHCost(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); }
private static XHCostResult InternalComputeXHCost(StockOrderRequest request, XH_SpotCosts cost) { CM_BreedClass breedClass = MCService.CommonPara.GetBreedClassByCommodityCode(request.Code); XHCostResult result = new XHCostResult(); result.Code = request.Code; decimal orderPrice = (decimal)request.OrderPrice; //期货合约乘数300 decimal scale = MCService.GetTradeUnitScale(request.Code, request.OrderUnitType); //以计价单位计算的委托量 var orderAmount = (decimal)request.OrderAmount * scale; //成交额 var dealAmount = orderPrice * orderAmount; /// 1.印花税 decimal stamp = cost.StampDuty / 100; decimal stampStart = cost.StampDutyStartingpoint; if (cost.StampDutyTypeID.HasValue) { int stampType = cost.StampDutyTypeID.Value; #region old code //if (stampType == (int)Types.GetValueTypeEnum.SingleSell && // request.BuySell == Types.TransactionDirection.Selling) //{ // decimal stampVal = stamp * dealAmount; // if (stampVal < stampStart) // stampVal = stampStart; // stampVal = Utils.Round(stampVal); // result.StampDuty = stampVal; //} #endregion 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; } } /// 2.佣金 //public decimal Commision { get; set; } if (cost.Commision.HasValue) { decimal comm = cost.Commision.Value / 100; decimal commVal = comm * dealAmount; decimal commStart = cost.CommisionStartingpoint; if (commVal < commStart) { commVal = commStart; } commVal = Utils.Round(commVal); result.Commision = commVal; } /// 3.过户费 //public decimal TransferToll { get; set; } decimal trans = cost.TransferToll / 100; int transType = cost.TransferTollTypeID; decimal transVal = 0; //过户费类型 [按股] [按成交额] switch (transType) { case (int)Types.GetValueTypeEnum.Thigh: transVal = trans * orderAmount; break; case (int)Types.GetValueTypeEnum.Turnover: transVal = trans * dealAmount; break; } transVal = Utils.Round(transVal); if (cost.TransferTollStartingpoint.HasValue) { decimal transStart = cost.TransferTollStartingpoint.Value; if (transVal < transStart) { transVal = transStart; } } transVal = Utils.Round(transVal); result.TransferToll = transVal; /// 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.PoundageSingleValue.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; } } /// 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; } /// 6.结算费 if (cost.ClearingFees.HasValue) { decimal clear = cost.ClearingFees.Value / 100; decimal clearval = clear * dealAmount; clearval = Utils.Round(clearval); result.ClearingFees = clearval; } /// 7.交易系统使用费(港股) if (cost.SystemToll.HasValue) { result.TradeSystemFees = cost.SystemToll.Value; } 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); }