private int PO_BuildCapitalFreezeRecord(decimal predealCapital, decimal predealCost, Types.TransactionDirection buySellType, ReckoningTransaction tm) { HK_CapitalAccountFreezeInfo caft = new HK_CapitalAccountFreezeInfo(); caft.EntrustNumber = EntrustNumber; //委托单号 //卖不产生冻结金额,只有费用 if (buySellType == Types.TransactionDirection.Buying) { caft.FreezeCapitalAmount = predealCapital; //冻结 预成交金额 } caft.FreezeCost = predealCost; //冻结 预成交费用 caft.FreezeTime = DateTime.Now; //冻结时间 caft.ThawTime = DateTime.Now; //解冻时间 caft.FreezeTypeLogo = (int)Entity.Contants.Types.FreezeType.DelegateFreeze; //冻结类型 caft.OweCosting = 0; caft.CapitalAccountLogo = CapitalAccountId; string format = "港股资金冻结处理HKBuyOrderLogicFlow.PO_BuildCapitalFreezeRecord[委托单号={0},冻结时间={1},解冻时间={2},冻结类型={3},预成交金额={4},预成交费用={5},资金账户ID={6}]"; string desc = string.Format(format, caft.EntrustNumber, caft.FreezeTime, caft.ThawTime, caft.FreezeTypeLogo, caft.FreezeCapitalAmount, caft.FreezeCost, CapitalAccountId); LogHelper.WriteDebug(desc); HK_CapitalAccountFreezeDal dal = new HK_CapitalAccountFreezeDal(); return(dal.Add(caft, tm.Database, tm.Transaction)); }
public LocalFutureOpenValidater(StockIndexFuturesOrderRequest request) { //this.request = request; this.traderId = request.TraderId; this.code = request.Code; this.buysell = request.BuySell; }
/// <summary> /// 获取现货交易费用 /// </summary> /// <param name="code">商品代码</param> /// <param name="price">委托价格</param> /// <param name="amount">委托数量</param> /// <param name="unitType">委托单位类型</param> /// <param name="buySell">买卖方向</param> /// <returns>现货交易费用结果</returns> public static XHCostResult ComputeXHCost(string code, float price, int amount, Types.UnitType unitType, Types.TransactionDirection buySell) { StockOrderRequest request = new StockOrderRequest(); request.Code = code; request.OrderPrice = price; request.OrderAmount = amount; request.OrderUnitType = unitType; request.BuySell = buySell; return(ComputeXHCost(request)); }
/// <summary> /// 构造函数 /// </summary> /// <param name="direction"></param> public EntrustOrderData(Types.TransactionDirection direction) { transactionDirection = direction; entrustOrderList = new Dictionary <string, List <T> >(); }
public HighLowRangeValue GetHKHighLowRangeValueByCommodityCode(string code, decimal orderPrice, Types.HKPriceType priceType, Types.TransactionDirection tranType) { return(accountClient.GetHKHighLowRangeValueByCommodityCode(code, orderPrice, priceType, tranType)); }
/// <summary> /// 获取保本价 /// </summary> /// <param name="code">商品代码</param> /// <param name="costPrice">成本价</param> /// <param name="amount">总持仓量(计价单位)</param> /// <param name="buySellType">买卖方向(仅期货有用)</param> /// <returns>保本价</returns> public static decimal GetHoldPrice(string code, decimal costPrice, decimal amount, Types.TransactionDirection buySellType) { string errCode = "GT-1704"; string errMsg = "无法获取指定商品的保本价。"; int?breedClassType = MCService.CommonPara.GetBreedClassTypeEnumByCommodityCode(code); if (!breedClassType.HasValue) { return(0); } Types.BreedClassTypeEnum breedClassTypeEnum; try { breedClassTypeEnum = (Types.BreedClassTypeEnum)breedClassType.Value; } catch (Exception ex) { VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception); throw exception; } try { //费用——过户费:沪A股,成交面个的1%,深A股免收。起点1元。你的600股,过户费=600×0.001=0.6<1元,所以过户费是1元 //印花税——单项收费,只有卖股票收。 //佣金(5.93)=佣金费率×成交金额=佣金费率×6594 所以你的佣金费率≈万分之九 //此次你买入股票总支出金额=股票成交金额+佣金+过户费+印花税=6594+5.930+1+0=6600.93 //所以你的买入成本价=总金额/买入数量=6600.93/600=11.00155 //设卖出价格P //卖出收入>买入总支出 //600×P-过户费(1)-印花税(600×P×0.001)-佣金(P×600×0.0009)>6600.93 //598.86×P-1>6600.93 //P>11.02416 保本价11.024 switch (breedClassTypeEnum) { case Types.BreedClassTypeEnum.Stock: return(GetStockHoldPrice(code, costPrice, amount)); case Types.BreedClassTypeEnum.CommodityFuture: return(GetFutureHoldPrice(code, costPrice, amount, buySellType)); case Types.BreedClassTypeEnum.StockIndexFuture: return(GetStockFutureHoldPrice(code, costPrice, amount, buySellType)); } } catch (Exception ex) { VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception); throw exception; } return(0); }
/// <summary> /// 获取股指期货保本价(目前使用商品期货的方法) /// </summary> /// <param name="code">商品代码</param> /// <param name="costPrice">成本价</param> /// <param name="amount">总持仓量</param> /// <param name="buySellType">买卖方向</param> /// <returns>保本价</returns> private static decimal GetStockFutureHoldPrice(string code, decimal costPrice, decimal amount, Types.TransactionDirection buySellType) { return(GetFutureHoldPrice(code, costPrice, amount, buySellType)); }
/// <summary> /// 获取期货保本价 /// </summary> /// <param name="code">商品代码</param> /// <param name="costPrice">成本价</param> /// <param name="amount">总持仓量</param> /// <param name="buySellType">买卖方向</param> /// <returns>保本价</returns> private static decimal GetFutureHoldPrice(string code, decimal costPrice, decimal amount, Types.TransactionDirection buySellType) { int?bc = MCService.CommonPara.GetBreedClassIdByCommodityCode(code); //QHCostResult result = null; if (!bc.HasValue) { return(0); } int breedClassId = bc.Value; QH_FutureCosts cost = MCService.FuturesTradeRules.GetFutureCostsByBreedClassID(breedClassId); #region old code ////成交单位比率 //decimal trade = 0; //if (cost.TradeUnitCharge.HasValue) //{ // trade = cost.TradeUnitCharge.Value / 100; // trade = Utils.Round(trade); //} ////decimal tradeVal = trade; ////成交金额比率 //decimal turn = 0; //if (cost.TurnoverRateOfServiceCharge.HasValue) //{ // turn = cost.TurnoverRateOfServiceCharge.Value / 100; // turn = Utils.Round(turn); //} ////decimal turnVal = turn * orderPrice ; //decimal holdPrice = 0; //if (buySellType == Types.TransactionDirection.Buying) //{ // holdPrice = (costPrice + trade) / (1 - turn); //} //else //{ // holdPrice = (costPrice + trade) / (1 + turn); //} //holdPrice = Utils.Round(holdPrice); //return holdPrice; #endregion //单笔费用 decimal cosing = 0; //按类型计算比例 //计算笔费用=费用比例*成交量*成交价/成交量--->费用比例*成交价 switch ((Types.FutrueCostType)Enum.Parse(typeof(Types.FutrueCostType), cost.CostType.ToString())) { case Types.FutrueCostType.TradeUnitCharge: //cosing = cost.TurnoverRateOfServiceCharge * amount / amount;////按成交额计算笔费用=费用比例*总持仓量*成交价/总持仓量--->费用比例*成交价 cosing = cost.TurnoverRateOfServiceCharge; break; case Types.FutrueCostType.TurnoverRateOfSerCha: cosing = cost.TurnoverRateOfServiceCharge / 100; //cosing = cosing * amount * costPrice / amount;//按成交额计算笔费用=费用比例*总持仓量*成交价/总持仓量--->费用比例*成交价 cosing = cosing * costPrice; break; } decimal holdPrice = 0; //买 //保本价=(成本价*持仓量+费用)/持仓量 //卖 //保本价=(成本价*持仓量-费用)/持仓量 if (buySellType == Types.TransactionDirection.Buying) { //保本价=(成本价*持仓量+成交单位比率*持仓量<或者成交金额比率*成本价*持仓量>)/持仓量 //==>保本价=(成本价+成交单位比率<或者成交金额比率*成本价>) holdPrice = costPrice + cosing; } else { //保本价=(成本价*持仓量-成交单位比率*持仓量<或者成交金额比率*成本价*持仓量>)/持仓量 //==>保本价=(成本价-成交单位比率<或者成交金额比率*成本价>) holdPrice = costPrice - cosing; } //holdPrice = costPrice + cosing; holdPrice = Utils.Round(holdPrice); return(holdPrice); }