Beispiel #1
0
        private void InternalDoMarginCheck(QH_HoldAccountTableInfo hold)
        {
            try
            {
                var capitalAccountInfo = AccountManager.Instance.GetCapitalAccountByHoldAccount(hold.UserAccountDistributeLogo);

                string capitalAccount = capitalAccountInfo.UserAccountDistributeLogo;
                int    currencyType   = hold.TradeCurrencyType;

                var capMem  = MemoryDataManager.QHCapitalMemoryList.GetByCapitalAccountAndCurrencyType(capitalAccount, currencyType);
                var capital = capMem.Data;

                decimal realMarginTotal = hold.Margin;
                decimal marginTotal     = capital.MarginTotal;

                if (marginTotal != realMarginTotal)
                {
                    QH_CapitalAccountTable_DeltaInfo delta = new QH_CapitalAccountTable_DeltaInfo();

                    delta.CapitalAccountLogoId = capital.CapitalAccountLogoId;
                    delta.MarginTotalDelta     = realMarginTotal - marginTotal;
                    capMem.AddDelta(delta);

                    string format2 =
                        "GZQHReckonUnitManager.DoMarginCheck修正股指期货总保证金[初始总保证金={0},实际总保证金={1},资金账户ID={2}]";
                    string desc = string.Format(format2, marginTotal, realMarginTotal, capital.CapitalAccountLogoId);
                    LogHelper.WriteDebug(desc);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex.Message, ex);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public QH_HoldAccountTableInfo GetQhAccountHoldTableWithNoLock(string strHoldAccount, string strCode,
                                                                       int iCurrType, int BuySellType)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(
                "select AccountHoldLogoId,HistoryHoldAmount,HistoryFreezeAmount,HoldAveragePrice,TodayHoldAmount,TradeCurrencyType,TodayHoldAveragePrice,UserAccountDistributeLogo,BuySellTypeId,TodayFreezeAmount,Contract,CostPrice,BreakevenPrice,Margin,ProfitLoss,OpenAveragePrice from QH_HoldAccountTable WITH (NOLOCK)");
            strSql.Append(
                " where TradeCurrencyType=@TradeCurrencyType AND UserAccountDistributeLogo=@UserAccountDistributeLogo AND Contract=@Contract  AND BuySellTypeId=@BuySellTypeId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "TradeCurrencyType", DbType.Int32, iCurrType);
            db.AddInParameter(dbCommand, "UserAccountDistributeLogo", DbType.String, strHoldAccount);
            db.AddInParameter(dbCommand, "Contract", DbType.String, strCode);
            db.AddInParameter(dbCommand, "BuySellTypeId", DbType.Int32, BuySellType);
            QH_HoldAccountTableInfo model = null;

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(QH_HoldAccountTableInfo model, ReckoningTransaction tm)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update QH_HoldAccountTable set ");
            strSql.Append("HistoryHoldAmount=@HistoryHoldAmount,");
            strSql.Append("HistoryFreezeAmount=@HistoryFreezeAmount,");
            strSql.Append("HoldAveragePrice=@HoldAveragePrice,");
            strSql.Append("TodayHoldAmount=@TodayHoldAmount,");
            strSql.Append("TradeCurrencyType=@TradeCurrencyType,");
            strSql.Append("TodayHoldAveragePrice=@TodayHoldAveragePrice,");
            strSql.Append("UserAccountDistributeLogo=@UserAccountDistributeLogo,");
            strSql.Append("BuySellTypeId=@BuySellTypeId,");
            strSql.Append("TodayFreezeAmount=@TodayFreezeAmount,");
            strSql.Append("Contract=@Contract,");
            strSql.Append("CostPrice=@CostPrice,");
            strSql.Append("BreakevenPrice=@BreakevenPrice,");
            strSql.Append("Margin=@Margin,");
            strSql.Append("ProfitLoss=@ProfitLoss,");
            strSql.Append("OpenAveragePrice=@OpenAveragePrice");
            strSql.Append(" where AccountHoldLogoId=@AccountHoldLogoId ");
            Database      db        = tm.Database;
            DbTransaction trans     = tm.Transaction;
            DbCommand     dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "AccountHoldLogoId", DbType.Int32, model.AccountHoldLogoId);
            db.AddInParameter(dbCommand, "HistoryHoldAmount", DbType.Decimal, model.HistoryHoldAmount);
            db.AddInParameter(dbCommand, "HistoryFreezeAmount", DbType.Decimal, model.HistoryFreezeAmount);
            db.AddInParameter(dbCommand, "HoldAveragePrice", DbType.Decimal, model.HoldAveragePrice);
            db.AddInParameter(dbCommand, "TodayHoldAmount", DbType.Decimal, model.TodayHoldAmount);
            db.AddInParameter(dbCommand, "TradeCurrencyType", DbType.Int32, model.TradeCurrencyType);
            db.AddInParameter(dbCommand, "TodayHoldAveragePrice", DbType.Decimal, model.TodayHoldAveragePrice);
            db.AddInParameter(dbCommand, "UserAccountDistributeLogo", DbType.AnsiString, model.UserAccountDistributeLogo);
            db.AddInParameter(dbCommand, "BuySellTypeId", DbType.Int32, model.BuySellTypeId);
            db.AddInParameter(dbCommand, "TodayFreezeAmount", DbType.Decimal, model.TodayFreezeAmount);
            db.AddInParameter(dbCommand, "Contract", DbType.AnsiString, model.Contract);
            db.AddInParameter(dbCommand, "CostPrice", DbType.Decimal, model.CostPrice);
            db.AddInParameter(dbCommand, "BreakevenPrice", DbType.Decimal, model.BreakevenPrice);
            db.AddInParameter(dbCommand, "Margin", DbType.Decimal, model.Margin);
            db.AddInParameter(dbCommand, "ProfitLoss", DbType.Decimal, model.ProfitLoss);
            db.AddInParameter(dbCommand, "OpenAveragePrice", DbType.Decimal, model.OpenAveragePrice);
            db.ExecuteNonQuery(dbCommand, trans);
        }
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public QH_HoldAccountTableInfo ReaderBind2(IDataReader dataReader)
        {
            QH_HoldAccountTableInfo model = new QH_HoldAccountTableInfo();
            object ojb;

            model.UserAccountDistributeLogo = dataReader["UserAccountDistributeLogo"].ToString();

            ojb = dataReader["TradeCurrencyType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TradeCurrencyType = (int)ojb;
            }

            ojb = dataReader["Margin"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Margin = (decimal)ojb;
            }

            return(model);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool AddRecord(QH_HoldAccountTableInfo model, ReckoningTransaction tm)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into QH_HoldAccountTable(");
            strSql.Append(
                "HistoryHoldAmount,HistoryFreezeAmount,HoldAveragePrice,TodayHoldAmount,TradeCurrencyType,TodayHoldAveragePrice,UserAccountDistributeLogo,BuySellTypeId,TodayFreezeAmount,Contract,CostPrice,BreakevenPrice,Margin,ProfitLoss,OpenAveragePrice)");

            strSql.Append(" values (");
            strSql.Append(
                "@HistoryHoldAmount,@HistoryFreezeAmount,@HoldAveragePrice,@TodayHoldAmount,@TradeCurrencyType,@TodayHoldAveragePrice,@UserAccountDistributeLogo,@BuySellTypeId,@TodayFreezeAmount,@Contract,@CostPrice,@BreakevenPrice,@Margin,@ProfitLoss,@OpenAveragePrice)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "HistoryHoldAmount", DbType.Decimal, model.HistoryHoldAmount);
            db.AddInParameter(dbCommand, "HistoryFreezeAmount", DbType.Decimal, model.HistoryFreezeAmount);
            db.AddInParameter(dbCommand, "HoldAveragePrice", DbType.Decimal, model.HoldAveragePrice);
            db.AddInParameter(dbCommand, "TodayHoldAmount", DbType.Decimal, model.TodayHoldAmount);
            db.AddInParameter(dbCommand, "TradeCurrencyType", DbType.Int32, model.TradeCurrencyType);
            db.AddInParameter(dbCommand, "TodayHoldAveragePrice", DbType.Decimal, model.TodayHoldAveragePrice);
            db.AddInParameter(dbCommand, "UserAccountDistributeLogo", DbType.AnsiString, model.UserAccountDistributeLogo);
            db.AddInParameter(dbCommand, "BuySellTypeId", DbType.Int32, model.BuySellTypeId);
            db.AddInParameter(dbCommand, "TodayFreezeAmount", DbType.Decimal, model.TodayFreezeAmount);
            db.AddInParameter(dbCommand, "Contract", DbType.AnsiString, model.Contract);
            db.AddInParameter(dbCommand, "CostPrice", DbType.Decimal, model.CostPrice);
            db.AddInParameter(dbCommand, "BreakevenPrice", DbType.Decimal, model.BreakevenPrice);
            db.AddInParameter(dbCommand, "Margin", DbType.Decimal, model.Margin);
            db.AddInParameter(dbCommand, "ProfitLoss", DbType.Decimal, model.ProfitLoss);
            db.AddInParameter(dbCommand, "OpenAveragePrice", DbType.Decimal, model.OpenAveragePrice);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(false);
            }
            model.AccountHoldLogoId = result;
            return(true);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public QH_HoldAccountTableInfo GetModel(int AccountHoldLogoId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(
                "select AccountHoldLogoId,HistoryHoldAmount,HistoryFreezeAmount,HoldAveragePrice,TodayHoldAmount,TradeCurrencyType,TodayHoldAveragePrice,UserAccountDistributeLogo,BuySellTypeId,TodayFreezeAmount,Contract,CostPrice,BreakevenPrice,Margin,ProfitLoss,OpenAveragePrice from QH_HoldAccountTable ");
            strSql.Append(" where AccountHoldLogoId=@AccountHoldLogoId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "AccountHoldLogoId", DbType.Int32, AccountHoldLogoId);
            QH_HoldAccountTableInfo model = null;

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public QH_HoldAccountTableInfo ReaderBind(IDataReader dataReader)
        {
            QH_HoldAccountTableInfo model = new QH_HoldAccountTableInfo();
            object ojb;

            ojb = dataReader["AccountHoldLogoId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AccountHoldLogoId = (int)ojb;
            }
            ojb = dataReader["HistoryHoldAmount"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.HistoryHoldAmount = (decimal)ojb;
            }
            ojb = dataReader["HistoryFreezeAmount"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.HistoryFreezeAmount = (decimal)ojb;
            }
            ojb = dataReader["HoldAveragePrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.HoldAveragePrice = (decimal)ojb;
            }
            ojb = dataReader["TodayHoldAmount"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TodayHoldAmount = (decimal)ojb;
            }
            ojb = dataReader["TradeCurrencyType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TradeCurrencyType = (int)ojb;
            }
            ojb = dataReader["TodayHoldAveragePrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TodayHoldAveragePrice = (decimal)ojb;
            }
            model.UserAccountDistributeLogo = dataReader["UserAccountDistributeLogo"].ToString();
            ojb = dataReader["BuySellTypeId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BuySellTypeId = (int)ojb;
            }
            ojb = dataReader["TodayFreezeAmount"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TodayFreezeAmount = (decimal)ojb;
            }
            model.Contract = dataReader["Contract"].ToString();
            ojb            = dataReader["CostPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CostPrice = (decimal)ojb;
            }
            ojb = dataReader["BreakevenPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BreakevenPrice = (decimal)ojb;
            }
            ojb = dataReader["Margin"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Margin = (decimal)ojb;
            }
            ojb = dataReader["ProfitLoss"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ProfitLoss = (decimal)ojb;
            }
            ojb = dataReader["OpenAveragePrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.OpenAveragePrice = (decimal)ojb;
            }
            return(model);
        }
        /// <summary>
        /// 查找欲平仓的合约
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        private List <QH_HoldAccountTableInfo> FindWillCLosedContract(List <QH_HoldAccountTableInfo> list)
        {
            List <QH_HoldAccountTableInfo> result = new List <QH_HoldAccountTableInfo>();
            QH_HoldAccountTableInfo        temp   = null;

            if (list.Count == 1)
            {
                result.Add(list[0]);
                return(result);
            }
            // SortedList<

            for (int i = 0; i < list.Count - 1; i++) //降序排序
            {
                for (int j = i + 1; j < list.Count; j++)
                {
                    if (list[i].HistoryHoldAmount < list[j].HistoryHoldAmount)
                    {
                        temp    = list[j];
                        list[j] = list[i];
                        list[i] = temp;
                    }
                }
            }
            Dictionary <string, List <QH_HoldAccountTableInfo> > _dictMaxQhAccountTable = null;

            if (list[0].HistoryHoldAmount == list[1].HistoryHoldAmount) //不存在最大的合约
            {
                _dictMaxQhAccountTable = new Dictionary <string, List <QH_HoldAccountTableInfo> >();
                List <QH_HoldAccountTableInfo> temp1 = null;
                temp1 = new List <QH_HoldAccountTableInfo>();
                temp1.Add(list[0]);
                _dictMaxQhAccountTable.Add(list[0].Contract, temp1);
                for (int m = 0; m < list.Count - 1; m++)
                {
                    if (list[m].HistoryHoldAmount == list[m + 1].HistoryHoldAmount)
                    {
                        if (!_dictMaxQhAccountTable.TryGetValue(list[m + 1].Contract, out temp1))
                        {
                            temp1 = new List <QH_HoldAccountTableInfo>();
                            temp1.Add(list[m + 1]);
                            _dictMaxQhAccountTable.Add(list[m + 1].Contract, temp1);
                        }
                        else
                        {
                            _dictMaxQhAccountTable[list[m + 1].Contract].Add(list[m + 1]);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                //比较静头寸亏损最大的合约
                List <string> contractArry = new List <string>(_dictMaxQhAccountTable.Keys);

                decimal kProfitloss = 0;
                decimal nProfitloss = 0;
                string  temp2       = "";
                for (int k = 0; k < contractArry.Count - 1; k++)
                {
                    for (int n = k + 1; n < contractArry.Count; n++)
                    {
                        kProfitloss = getProfitLoss(_dictMaxQhAccountTable[contractArry[k]]);
                        nProfitloss = getProfitLoss(_dictMaxQhAccountTable[contractArry[n]]);
                        if (kProfitloss < nProfitloss)
                        {
                            temp2           = contractArry[n];
                            contractArry[n] = contractArry[k];
                            contractArry[k] = temp2;
                        }
                    }
                }

                return(_dictMaxQhAccountTable[contractArry[0]]);
            }
            else
            {
                result.Add(list[0]);
                return(result);
            }

            //return null;
        }
        /// <summary>
        /// 商品期货强行平仓
        /// Create by:董鹏
        /// Create Date:2010-02-04
        /// </summary>
        /// <param name="orderAccepter">委托接收对象</param>
        /// <param name="holdTable">持仓实体</param>
        /// <param name="price">委托价格</param>
        /// <param name="amount">委托数量</param>
        /// <param name="isExpiredContract">是否是过期的合约需要平仓</param>
        private void CloseCommoditiesContract(OrderAccepter orderAccepter, QH_HoldAccountTableInfo holdTable, float price, float amount, Types.QHForcedCloseType closeType, Entity.Contants.Types.FutureOpenCloseType closeType2)
        {
            if (holdTable == null)
            {
                return;
            }
            if (holdTable.HistoryHoldAmount == 0 && closeType2 == ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.ClosePosition)
            {
                return;
            }
            if (holdTable.TodayHoldAmount == 0 && closeType2 == ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.CloseTodayPosition)
            {
                return;
            }

            MercantileFuturesOrderRequest2 request = null;

            request = new MercantileFuturesOrderRequest2();
            string type = "";

            switch (closeType)
            {
            case Types.QHForcedCloseType.Expired:
                // request.IsExpiredContract = true;
                type = "过期合约持仓检查平仓";
                break;

            case Types.QHForcedCloseType.CapitalCheck:
                //request.IsCapitalCheckContract = true;
                type = "资金检查平仓";
                break;

            case Types.QHForcedCloseType.OverHoldLimit:
                //request.IsOverHoldLimitContract = true;
                type = "持仓限制检查平仓";
                break;

            case Types.QHForcedCloseType.NotModMinUnit:
                //request.IsNotModMinUnitContract = true;
                type = "最小交割单位整数倍持仓检查平仓";
                break;
            }

            request.QHForcedCloseType  = closeType; //盘前检查强行平仓类型
            request.IsForcedCloseOrder = true;      //是否盘前检查强行平仓

            //{
            //    request = new MercantileFuturesOrderRequest2 { IsExpiredContract = true, IsCapitalCheckContract = false };
            //}
            //else
            //{
            //    request = new MercantileFuturesOrderRequest2 { IsExpiredContract = false, IsCapitalCheckContract = true };
            //}

            var buySellType = holdTable.BuySellTypeId == (int)Types.TransactionDirection.Buying
                                  ? Types.TransactionDirection.Selling
                                  : Types.TransactionDirection.Buying;

            request.BuySell       = buySellType;
            request.Code          = holdTable.Contract;
            request.FundAccountId = capitalAccount.UserAccountDistributeLogo;
            request.OpenCloseType = closeType2;

            request.OrderAmount = amount;//(float)holdTable.HistoryHoldAmount;

            //和刘丹确认过,不是过期合约平仓或者价格为0时,取当日的涨停价或跌停价报盘,买平用涨停价,卖平用跌停价,add by 董鹏 2010-02-23
            //2010-04-02 和刘丹、苏婷再次讨论,定为先取行情最新价,若取不到在使用涨跌停价 update by 董鹏 2010-04-02
            if (closeType != Types.QHForcedCloseType.Expired || price == 0)
            {
                string errMsg;
                int    errcount = 0;

                //获取行情最新成交价
                MarketDataLevel marketData = null;
                while (marketData == null)
                {
                    marketData = RealTimeMarketUtil.GetInstance().GetLastPriceByCode(holdTable.Contract, (int)Types.BreedClassTypeEnum.CommodityFuture, out errMsg);
                    errcount++;
                    if (errcount > 10)
                    {
                        LogHelper.WriteDebug("期货强行平仓,无法获取到行情最新成交价。CloseCommoditiesContract");
                        break;
                    }
                    if (marketData == null)
                    {
                        Thread.Sleep(10000);
                    }
                }
                if (marketData != null && marketData.LastPrice != 0)
                {
                    price = (float)marketData.LastPrice;
                }
                else
                {
                    //取不到行情成交价,取涨跌停板价
                    HighLowRangeValue hlValue = null;

                    while (hlValue == null)
                    {
                        hlValue = MCService.HLRangeProcessor.GetHighLowRangeValueByCommodityCode(holdTable.Contract, 0);
                        errcount++;
                        if (errcount > 10)
                        {
                            LogHelper.WriteDebug("期货强行平仓,无法获取到涨跌停板价格。CloseCommoditiesContract");
                            return;
                        }
                        if (hlValue == null)
                        {
                            Thread.Sleep(10000);
                        }
                    }
                    price = holdTable.BuySellTypeId == (int)Types.TransactionDirection.Buying
                                      ? (float)hlValue.HighRangeValue
                                      : (float)hlValue.LowRangeValue;
                }
            }
            request.OrderPrice    = price;
            request.OrderUnitType = Types.UnitType.Hand;
            request.OrderWay      = Entity.Contants.Types.OrderPriceType.OPTLimited;

            string format = "FutureDayChecker开盘持仓检查强制平仓[UserAccountDistributeLogo={0},AccountHoldLogoId={1},Code={2}, Price={3}, 平仓类型={4}]-委托信息:" + request;
            string msg    = string.Format(format, holdTable.UserAccountDistributeLogo, holdTable.AccountHoldLogoId, holdTable.Contract, price, type);

            LogHelper.WriteDebug(msg + holdTable);

            UA_UserAccountAllocationTableDal ua_UserAccountAllocationTableDal = new UA_UserAccountAllocationTableDal();
            //设置为其所属的交易员
            var userAccountAllocationTable = ua_UserAccountAllocationTableDal.GetModel(capitalAccount.UserAccountDistributeLogo);

            if (userAccountAllocationTable == null)
            {
                string msg2 = "开盘检查强行平仓失败!无法获取资金账户信息,ID=" + capitalAccount.UserAccountDistributeLogo;
                LogHelper.WriteInfo(msg2);
                return;
            }
            UA_UserBasicInformationTableDal ua_UserBasicInformationTableDal = new UA_UserBasicInformationTableDal();
            var user = ua_UserBasicInformationTableDal.GetModel(userAccountAllocationTable.UserID);

            if (user == null)
            {
                string msg3 = "开盘检查强行平仓失败!无法获取交易员信息,UserID=" + userAccountAllocationTable.UserID;
                LogHelper.WriteInfo(msg3);
                return;
            }

            request.TraderId       = user.UserID;
            request.TraderPassword = user.Password;

            orderAccepter.DoMercantileFuturesOrder(request);
        }
        /// <summary>
        /// 平仓股指期货合约
        /// </summary>
        /// <param name="orderAccepter"></param>
        /// <param name="holdTable">持仓合约</param>
        /// <param name="price">价格</param>
        /// <param name="isExpiredContract">是否是过期的合约需要平仓</param>
        private void CloseStockIndexContract(OrderAccepter orderAccepter, QH_HoldAccountTableInfo holdTable, float price, bool isExpiredContract)
        {
            if (holdTable == null)
            {
                return;
            }

            //if (holdTable.HistoryHoldAmount<0.00m)
            //    return;

            if (holdTable.HistoryHoldAmount == 0)
            {
                return;
            }

            StockIndexFuturesOrderRequest request = null;

            if (isExpiredContract)
            {
                request = new StockIndexFuturesOrderRequest2 {
                    IsForcedCloseOrder = true, QHForcedCloseType = Types.QHForcedCloseType.Expired
                };
            }
            else
            {
                request = new StockIndexFuturesOrderRequest2 {
                    IsForcedCloseOrder = true, QHForcedCloseType = Types.QHForcedCloseType.CapitalCheck
                };
            }

            var buySellType = holdTable.BuySellTypeId == (int)Types.TransactionDirection.Buying
                                  ? Types.TransactionDirection.Selling
                                  : Types.TransactionDirection.Buying;

            request.BuySell       = buySellType;
            request.Code          = holdTable.Contract;
            request.FundAccountId = capitalAccount.UserAccountDistributeLogo;
            request.OpenCloseType = Entity.Contants.Types.FutureOpenCloseType.ClosePosition;

            request.OrderAmount = (float)holdTable.HistoryHoldAmount;

            request.OrderPrice    = price;
            request.OrderUnitType = Types.UnitType.Hand;
            request.OrderWay      = price == 0
                                   ? Entity.Contants.Types.OrderPriceType.OPTMarketPrice
                                   : Entity.Contants.Types.OrderPriceType.OPTLimited;

            string type   = isExpiredContract ? "持仓检查平仓" : "资金检查平仓";
            string format =
                "FutureDayChecker开盘持仓检查强制平仓[UserAccountDistributeLogo={0},AccountHoldLogoId={1},Code={2}, Price={3}, 平仓类型={4}]-委托信息:" +
                request;
            string msg = string.Format(format, holdTable.UserAccountDistributeLogo, holdTable.AccountHoldLogoId,
                                       holdTable.Contract, price, type);

            LogHelper.WriteDebug(msg + holdTable);
            UA_UserAccountAllocationTableDal ua_UserAccountAllocationTableDal = new UA_UserAccountAllocationTableDal();
            //设置为其所属的交易员
            var userAccountAllocationTable =
                ua_UserAccountAllocationTableDal.GetModel(
                    capitalAccount.UserAccountDistributeLogo);

            if (userAccountAllocationTable == null)
            {
                string msg2 = "开盘检查强行平仓失败!无法获取资金账户信息,ID=" + capitalAccount.UserAccountDistributeLogo;
                LogHelper.WriteInfo(msg2);
                return;
            }
            UA_UserBasicInformationTableDal ua_UserBasicInformationTableDal = new UA_UserBasicInformationTableDal();
            var user =
                ua_UserBasicInformationTableDal.GetModel(userAccountAllocationTable.UserID);

            if (user == null)
            {
                string msg3 = "开盘检查强行平仓失败!无法获取交易员信息,UserID=" + userAccountAllocationTable.UserID;
                LogHelper.WriteInfo(msg3);
                return;
            }

            request.TraderId       = user.UserID;
            request.TraderPassword = user.Password;

            orderAccepter.DoStockIndexFuturesOrder(request);
        }