/// <summary> /// 构建期货撤单回报 /// </summary> /// <param name="tet"></param> /// <param name="rde"></param> /// <param name="tm"></param> /// <param name="isInternalCancelOrder"></param> /// <returns></returns> public static QH_TodayTradeTableInfo BuildQHCancelRpt(QH_TodayEntrustTableInfo tet, CancelOrderEntity rde, ReckoningTransaction tm, bool isInternalCancelOrder) { string result = string.Empty; //当为价格错误的撤单时,直接作为废单,不记录到数据库中。 if (rde.OrderVolume == -1) { return(null); } //成交回报实体 var qhDealrpt = new QH_TodayTradeTableInfo(); qhDealrpt.TradeNumber = rde.Id; //不再自己构建id,使用撤单回报的id,一一对应 //成交时间 qhDealrpt.TradeTime = DateTime.Now; //成交价 qhDealrpt.TradePrice = 0; //成交量 qhDealrpt.TradeAmount = Convert.ToInt32(rde.OrderVolume); //股东代码 qhDealrpt.TradeAccount = tet.TradeAccount; //资金帐户 qhDealrpt.CapitalAccount = tet.CapitalAccount; //成交回报类型 if (isInternalCancelOrder) { qhDealrpt.TradeTypeId = (int)Types.DealRptType.DRTInternalCanceled; } else { qhDealrpt.TradeTypeId = (int)Types.DealRptType.DRTCanceled; } //现货名称 qhDealrpt.ContractCode = tet.ContractCode; //交易手续费 qhDealrpt.TradeProceduresFee = 0; //保证金 qhDealrpt.Margin = 0; //委托价格 qhDealrpt.EntrustPrice = tet.EntrustPrice; //委托单号 qhDealrpt.EntrustNumber = tet.EntrustNumber; //投组标识 qhDealrpt.PortfolioLogo = tet.PortfolioLogo; //货币类型 qhDealrpt.CurrencyTypeId = tet.CurrencyTypeId; //开平方向 qhDealrpt.OpenCloseTypeId = tet.OpenCloseTypeId; //买卖方向 qhDealrpt.BuySellTypeId = tet.BuySellTypeId; //成交单位 qhDealrpt.TradeUnitId = tet.TradeUnitId; //2009-12-03 add 李健华 qhDealrpt.MarketProfitLoss = 0; //========== QH_TodayTradeTableDal qh_TodayTradeTableDal = new QH_TodayTradeTableDal(); // var provider = new SqlQhTodayTradeTableProvider(TransactionFactory.RC_ConnectionString, true, string.Empty); //provider.Insert(tm, qhDealrpt); qh_TodayTradeTableDal.Add(qhDealrpt, tm); return(qhDealrpt); }
/// <summary> /// 构建股指期货成交回报 /// </summary> /// <param name="tet"></param> /// <param name="sdbe"></param> /// <param name="qhcr"></param> /// <param name="dMargin"></param> /// <param name="tm"></param> /// <param name="marketProfitLoss"></param> /// <param name="dealRptType">成交类型</param> /// <returns></returns> public static QH_TodayTradeTableInfo BuildGZQHDealRpt(QH_TodayEntrustTableInfo tet, FutureDealBackEntity sdbe, QHCostResult qhcr, decimal dMargin, decimal marketProfitLoss, ReckoningTransaction tm, Types.DealRptType dealRptType) { string result = string.Empty; //成交回报实体 var qhDealrpt = new QH_TodayTradeTableInfo(); //xhDealrpt.TradeNumber = this.BuildXHDealOrderNo(); qhDealrpt.TradeNumber = sdbe.Id; //不再自己构建id,使用成交回报的id,一一对应 //成交时间 qhDealrpt.TradeTime = sdbe.DealTime; //成交价 qhDealrpt.TradePrice = sdbe.DealPrice; //成交量 qhDealrpt.TradeAmount = Convert.ToInt32(sdbe.DealAmount); //成交单位 qhDealrpt.TradeUnitId = tet.TradeUnitId; //股东代码 qhDealrpt.TradeAccount = tet.TradeAccount; //资金帐户 qhDealrpt.CapitalAccount = tet.CapitalAccount; //成交回报类型 // qhDealrpt.TradeTypeId = (int)Types.DealRptType.DRTDealed; qhDealrpt.TradeTypeId = (int)dealRptType; //现货名称 qhDealrpt.ContractCode = tet.ContractCode; //现货代码 //qhDealrpt = tet.ContractName; //交易手续费 qhDealrpt.TradeProceduresFee = qhcr.Cosing; //保证金 //qhDealrpt.Margin = 0; // dMargin; //update date 2009-12-03 不管开平仓都记录保证金 //if (tet.OpenCloseTypeId == (int) Types.FutureOpenCloseType.OpenPosition) qhDealrpt.Margin = dMargin; //============= //委托价格 qhDealrpt.EntrustPrice = tet.EntrustPrice; //委托单号 qhDealrpt.EntrustNumber = tet.EntrustNumber; //投组标识 qhDealrpt.PortfolioLogo = tet.PortfolioLogo; //货币类型 qhDealrpt.CurrencyTypeId = tet.CurrencyTypeId; qhDealrpt.BuySellTypeId = tet.BuySellTypeId; qhDealrpt.OpenCloseTypeId = tet.OpenCloseTypeId; //add 李健华 增加每笔盯市盈亏 qhDealrpt.MarketProfitLoss = marketProfitLoss; //========== QH_TodayTradeTableDal qhTodayTradeTableDal = new QH_TodayTradeTableDal(); if (qhTodayTradeTableDal.Exists(qhDealrpt.TradeNumber)) { string format = "BuildGZQHDealRpt数据库已经存在TradeNumber={0}"; string desc = string.Format(format, qhDealrpt.TradeNumber); LogHelper.WriteDebug(desc); return(null); } try { qhTodayTradeTableDal.Add(qhDealrpt, tm); } catch (Exception ex) { LogHelper.WriteError(ex.Message, ex); qhDealrpt = null; } return(qhDealrpt); }