コード例 #1
0
        public void DoStockIndexFuturesOrderTest1()
        {
            OrderAccepter target = new OrderAccepter();        // TODO: 初始化为适当的值
            StockIndexFuturesOrderRequest futuresorder = null; // TODO: 初始化为适当的值

            futuresorder = new StockIndexFuturesOrderRequest();
            //赋值
            futuresorder.BuySell        = Types.TransactionDirection.Buying;
            futuresorder.Code           = "IF0904";
            futuresorder.ChannelID      = "0";
            futuresorder.FundAccountId  = "010000002406";
            futuresorder.OpenCloseType  = ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.OpenPosition;
            futuresorder.OrderAmount    = 1;
            futuresorder.OrderPrice     = 2505;
            futuresorder.OrderUnitType  = GTA.VTS.Common.CommonObject.Types.UnitType.Hand;
            futuresorder.OrderWay       = ReckoningCounter.Entity.Contants.Types.OrderPriceType.OPTLimited;
            futuresorder.TraderId       = "24";
            futuresorder.TraderPassword = "******";
            futuresorder.PortfoliosId   = "0";

            OrderResponse expected = new OrderResponse(); //null; // TODO: 初始化为适当的值

            expected.OrderId = "123456789";               //仅测试
            OrderResponse actual;

            actual = target.DoStockIndexFuturesOrder(futuresorder);
            Assert.AreNotEqual(expected, actual);
            // Assert.Inconclusive("验证此测试方法的正确性。");
        }
コード例 #2
0
        public void DoStockIndexFuturesOrderTest()
        {
            OrderAccepter target = new OrderAccepter();        // TODO: Initialize to an appropriate value
            StockIndexFuturesOrderRequest futuresorder = null; // TODO: Initialize to an appropriate value
            OrderResponse expected = null;                     // TODO: Initialize to an appropriate value
            OrderResponse actual;

            actual = target.DoStockIndexFuturesOrder(futuresorder);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
コード例 #3
0
        public void DoStockOrderTest()
        {
            InitRealtimeMarketComponent();
            OrderAccepter     target     = new OrderAccepter();      // TODO: Initialize to an appropriate value
            StockOrderRequest stockorder = BuildStockOrderRequest(); // TODO: Initialize to an appropriate value
            OrderResponse     expected   = null;                     // TODO: Initialize to an appropriate value
            OrderResponse     actual;

            actual = target.DoStockOrder(stockorder);
            Assert.IsNotNull(actual.OrderId);
        }
コード例 #4
0
        public void CancelStockOrderTest()
        {
            OrderAccepter target          = new OrderAccepter(); // TODO: Initialize to an appropriate value
            string        OrderId         = string.Empty;        // TODO: Initialize to an appropriate value
            string        message         = string.Empty;        // TODO: Initialize to an appropriate value
            string        messageExpected = string.Empty;        // TODO: Initialize to an appropriate value
            bool          expected        = false;               // TODO: Initialize to an appropriate value
            bool          actual;

            //actual = target.CancelStockOrder(OrderId, ref message);
            //Assert.AreEqual(messageExpected, message);
            //Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
コード例 #5
0
        public OrderResponse Process(HKModifyOrderRequest hkOrder)
        {
            LogHelper.WriteDebug("M——>ModifyOrderProcessor.Process接收改单入口" + hkOrder);

            bool          canModifyOrder  = false;
            OrderResponse orResult        = new OrderResponse();
            string        strErrorMessage = "";

            //hkOrder.ID = HKCommonLogic.BuildHKOrderNo();
            hkOrder.ID = Guid.NewGuid().ToString();

            #region 原始单位及成交量转换

            var            code        = hkOrder.Code;
            var            oriUnitType = hkOrder.OrderUnitType;
            decimal        scale;
            Types.UnitType matchUnitType;

            bool canConvert = OrderAccepter.ConvertUnitType(Types.BreedClassTypeEnum.HKStock, code, oriUnitType, out scale, out matchUnitType);
            if (!canConvert)
            {
                strErrorMessage = @"GT-2450:[港股委托]无法进行行情单位转换.";
                goto EndProcess;
            }
            LogHelper.WriteDebug("委托单:" + hkOrder.EntrustNubmer + "当前改单获取到的转换倍数为: " + scale);
            hkOrder.OrderUnitType = matchUnitType;
            hkOrder.OrderAmount   = hkOrder.OrderAmount * (float)scale;

            #endregion

            //记录改单操作记录数据
            bool canSave = HKDataAccess.AddHKModifyOrderRequest(hkOrder);
            if (!canSave)
            {
                strErrorMessage = @"GT-2451:[港股改单委托]无法保持改单委托,请查看错误日志.";
                LogHelper.WriteInfo(strErrorMessage + "," + hkOrder);

                goto EndProcess;
            }

            #region 校验

            if ((string.IsNullOrEmpty(hkOrder.TraderId) && string.IsNullOrEmpty(hkOrder.FundAccountId)))
            {
                strErrorMessage = @"GT-2452:[港股改单委托]交易员ID或资金帐户无效.";
                LogHelper.WriteInfo(strErrorMessage + "," + hkOrder);

                goto EndProcess;
            }

            //柜台委托时间判断
            if (!ValidateCenter.IsCountTradingTime(Types.BreedClassTypeEnum.HKStock, hkOrder.Code, ref strErrorMessage))
            {
                LogHelper.WriteInfo("ModifyOrderProcessor.Process" + strErrorMessage);
                string oriMsg = "当前时间不接受委托";
                if (strErrorMessage.Length > 0)
                {
                    oriMsg = strErrorMessage;
                }

                strErrorMessage = @"GT-2453:[港股改单委托]" + oriMsg;
                LogHelper.WriteInfo(strErrorMessage + "," + hkOrder);
                goto EndProcess;
            }

            HK_TodayEntrustInfo tet = HKDataAccess.GetTodayEntrustTable(hkOrder.EntrustNubmer);
            if (tet == null)
            {
                strErrorMessage = "GT-2454:[港股改单委托]无委托对象信息";
                LogHelper.WriteInfo(strErrorMessage + "," + hkOrder);

                goto EndProcess;
            }

            if ((float)tet.EntrustPrice == hkOrder.OrderPrice && tet.EntrustAmount == (int)hkOrder.OrderAmount)
            {
                strErrorMessage = "GT-2455:[港股改单委托]无效改单,改单量、改单价与原始委托相同";
                LogHelper.WriteInfo(strErrorMessage + "," + hkOrder);

                goto EndProcess;
            }

            //港股改单规则检验,这里有些与真实下单有些重复,但这样可以提高改单的成功率
            if (!McValidater.GetInstance().ValidateHKModifyOrderRule(hkOrder, tet, ref strErrorMessage))
            {
                LogHelper.WriteInfo(strErrorMessage + "," + hkOrder);
                goto EndProcess;
            }

            #endregion

            //未报
            if (tet.OrderStatusID == (int)Entity.Contants.Types.OrderStateType.DOSUnRequired)
            {
                ProcessType1(hkOrder);
                canModifyOrder = true;
                goto EndProcess;
            }

            #region 已报、部成

            if (tet.OrderStatusID == (int)Entity.Contants.Types.OrderStateType.DOSIsRequired ||
                tet.OrderStatusID == (int)Entity.Contants.Types.OrderStateType.DOSPartDealed)
            {
                //如果不在交易时间内,那么直接到缓存中删除原来的委托,生成新委托
                if (!ValidateCenter.IsMatchTradingTime(Types.BreedClassTypeEnum.HKStock, hkOrder.Code))
                {
                    strErrorMessage = "GT-2456:[港股改单委托]不在交易时间内";
                    LogHelper.WriteInfo(strErrorMessage + "," + hkOrder);

                    goto EndProcess;
                }

                if ((decimal)hkOrder.OrderPrice == tet.EntrustPrice && hkOrder.OrderAmount < tet.EntrustAmount)
                {
                    ProcessType2(hkOrder);
                    canModifyOrder = true;
                }
                else
                {
                    ProcessType3(hkOrder);
                    canModifyOrder = true;
                    goto EndProcess;
                }
            }

            #endregion

EndProcess:
            //结束
            if (canModifyOrder)
            {
                hkOrder.ModifyOrderDateTime = DateTime.Now;
                orResult.OrderDatetime      = DateTime.Now;
            }
            else
            {
                int  type            = 0;
                bool canGetErrorCode = Utils.GetErrorCode(strErrorMessage, out type);
                if (canGetErrorCode)
                {
                    orResult.ErrorType = type;
                }

                hkOrder.Message       = strErrorMessage;
                orResult.OrderMessage = strErrorMessage;
            }

            //更新改单委托
            HKDataAccess.UpdateModifyOrderRequest(hkOrder);

            orResult.IsSuccess = canModifyOrder;
            orResult.OrderId   = hkOrder.ID;
            return(orResult);
        }
コード例 #6
0
        public void OrderAccepterConstructorTest()
        {
            OrderAccepter target = new OrderAccepter();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
        /// <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);
        }
コード例 #9
0
        /// <summary>
        /// 进行持仓检查,对已经过期的合约按昨日结算价进行强制平仓
        /// </summary>
        private void CheckHoldTable()
        {
            //LogHelper.WriteDebug("FutureDayChecker.CheckHoldTable开始检查持仓表");

            OrderAccepter          orderAccepter = OrderAccepterService.Service;
            QH_HoldAccountTableDal dal           = new QH_HoldAccountTableDal();

            string where = string.Format("UserAccountDistributeLogo = '{0}'", holdAccount.UserAccountDistributeLogo);
            List <QH_HoldAccountTableInfo> listCheck = dal.GetListArray(where);

            // DataRepository.QhHoldAccountTableProvider.GetByUserAccountDistributeLogo(
            //     holdAccount.UserAccountDistributeLogo);

            if (Utils.IsNullOrEmpty(listCheck))
            {
                return;
            }

            decimal price = 0;
            List <QH_HoldAccountTableInfo> list = new List <QH_HoldAccountTableInfo>();

            //这里是要分开处理,已经是过期的合约前面就已经强行平仓掉就没有后面的持仓限制和最小单位整数倍的判断
            foreach (var holdTable in listCheck)
            {
                //如果不是交易日,不进行强行平仓 add by 董鹏 2010-05-05
                if (!CommonParaProxy.GetInstance().IsTradeDate(holdTable.Contract))
                {
                    continue;
                }
                if (MCService.IsExpireLastedTradeDate(holdTable.Contract))
                {
                    //在最后交易日 进行平仓
                    //string msg = "";
                    //bool canGetPrice = MCService.GetFutureYesterdayPreSettlementPrice(holdTable.Contract, out price,
                    //                                                                  ref msg);
                    //if (!canGetPrice)
                    //{
                    //    string format = "FutureDayChecker.CheckHoldTable无法获取合约{0}的昨日收盘结算价,错误信息:{1}";
                    //    string msg2 = string.Format(format, holdTable.Contract, msg);
                    //    LogHelper.WriteDebug(msg2);
                    //    continue;
                    //}

                    //每天清算后,持仓均价就是结算价
                    price = holdTable.HoldAveragePrice;

                    #region  账户类型进行商品期货、股指期货平仓 add by 董鹏 2010-02-03
                    UA_UserAccountAllocationTableDal accDal = new UA_UserAccountAllocationTableDal();
                    var acc = accDal.GetModel(holdTable.UserAccountDistributeLogo);
                    if (acc.AccountTypeLogo == (int)Types.AccountType.CommodityFuturesHoldCode)
                    {
                        //此处原来只有HistoryHoldAmount,造成未清算成功的持仓平不掉,因此加上TodayHoldAmount;
                        //而TodayFreezeAmount清算是否成功都没有影响 -- update by 董鹏 2010-03-29
                        //CloseCommoditiesContract(orderAccepter, holdTable, (float)price, (float)(holdTable.HistoryHoldAmount + holdTable.TodayHoldAmount), Types.QHForcedCloseType.Expired);
                        //平历史
                        CloseCommoditiesContract(orderAccepter, holdTable, (float)price, (float)holdTable.HistoryHoldAmount, Types.QHForcedCloseType.Expired, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.ClosePosition);
                        //平今
                        CloseCommoditiesContract(orderAccepter, holdTable, (float)price, (float)holdTable.TodayHoldAmount, Types.QHForcedCloseType.Expired, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.CloseTodayPosition);
                    }
                    if (acc.AccountTypeLogo == (int)Types.AccountType.StockFuturesHoldCode)
                    {
                        CloseStockIndexContract(orderAccepter, holdTable, (float)price, true);
                    }
                    #endregion
                    //CloseStockIndexContract(orderAccepter, holdTable, (float)price, true);
                }
                else
                {
                    list.Add(holdTable);
                }
            }


            #region 商品期货进行持仓限制、最小交割单位整数倍检验,并平仓超出量 add by 董鹏 2010-02-04
            if (holdAccount.AccountTypeLogo == (int)Types.AccountType.CommodityFuturesHoldCode)
            {
                LogHelper.WriteDebug("---->商品期货持仓限制、最小小交割单位整数倍验证,UserAccountDistributeLogo=" + holdAccount.UserAccountDistributeLogo);
                List <QH_HoldAccountTableInfo> listCloseContract;

                price = 0;

                //记录超出持仓限制的量:<持仓记录主键,超出量>
                Dictionary <int, decimal> dicAmount;
                // 超过最大持仓限制
                listCloseContract = FindWillClosedContractOverMaxHoldLimit(list, out dicAmount);
                foreach (var holdTable in listCloseContract)
                {
                    CloseCommoditiesContract(orderAccepter, holdTable, (float)price, (float)dicAmount[holdTable.AccountHoldLogoId], Types.QHForcedCloseType.OverHoldLimit, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.ClosePosition);
                    //进行了持仓限制平仓的不再进行最小交割单位验证,下次持仓检查的时候才进行。
                    list.Remove(holdTable);
                }
                //超出最小交割量整数倍
                listCloseContract = FindWillClosedContractNotModMinUnitLimit(list, out dicAmount);
                foreach (var holdTable in listCloseContract)
                {
                    CloseCommoditiesContract(orderAccepter, holdTable, (float)price, (float)dicAmount[holdTable.AccountHoldLogoId], Types.QHForcedCloseType.NotModMinUnit, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.ClosePosition);
                }
            }
            #endregion
            //LogHelper.WriteDebug("FutureDayChecker.CheckHoldTable结束检查持仓表");
        }
コード例 #10
0
        /// <summary>
        /// 检查资金表,可用资金小于0的走资金强行平仓流程
        /// </summary>
        private void CheckCapitalTable(object state)
        {
            //LogHelper.WriteDebug("FutureDayChecker.CheckFundTable开始检查资金表");
            QH_CapitalAccountTableDal dal = new QH_CapitalAccountTableDal();

            //TList<QhCapitalAccountTable> list =
            //  DataRepository.QhCapitalAccountTableProvider.GetByUserAccountDistributeLogo(
            //      capitalAccount.UserAccountDistributeLogo);
            string where = string.Format("UserAccountDistributeLogo = '{0}' ", capitalAccount.UserAccountDistributeLogo);
            List <QH_CapitalAccountTableInfo> list = dal.GetListArray(where);

            if (Utils.IsNullOrEmpty(list))
            {
                return;
            }

            foreach (QH_CapitalAccountTableInfo accountTable in list)
            {
                //if (accountTable.AvailableCapital<0.00m)
                //    continue;

                List <QH_HoldAccountTableInfo> listCloseContract;
                OrderAccepter orderAccepter = OrderAccepterService.Service;

                if (accountTable.AvailableCapital < 0)
                {
                    if (accountTable.TradeCurrencyType < 0.00m)
                    {
                        continue;
                    }

                    List <QH_HoldAccountTableInfo> list2 = GetHoldAccountTableList(holdAccount.UserAccountDistributeLogo, accountTable.TradeCurrencyType);
                    if (Utils.IsNullOrEmpty(list2))
                    {
                        continue;
                    }

                    listCloseContract = FindWillCLosedContract(list2);

                    foreach (var holdTable in listCloseContract)
                    {
                        //如果不是交易日,不进行强行平仓 add by 董鹏 2010-05-05
                        if (!CommonParaProxy.GetInstance().IsTradeDate(holdTable.Contract))
                        {
                            continue;
                        }

                        //CloseStockIndexContract(orderAccepter, holdTable, 0, false);
                        #region  账户类型进行商品期货、股指期货平仓 add by 董鹏 2010-02-03
                        if (holdAccount.AccountTypeLogo == (int)Types.AccountType.CommodityFuturesHoldCode)
                        {
                            //此处原来只有HistoryHoldAmount,造成未清算成功的持仓平不掉,因此加上TodayHoldAmount;
                            //而TodayFreezeAmount清算是否成功都没有影响 -- update by 董鹏 2010-03-29
                            //平历史
                            CloseCommoditiesContract(orderAccepter, holdTable, 0, (float)holdTable.HistoryHoldAmount, Types.QHForcedCloseType.CapitalCheck, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.ClosePosition);
                            //平今
                            CloseCommoditiesContract(orderAccepter, holdTable, 0, (float)holdTable.TodayHoldAmount, Types.QHForcedCloseType.CapitalCheck, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.CloseTodayPosition);
                        }
                        if (holdAccount.AccountTypeLogo == (int)Types.AccountType.StockFuturesHoldCode)
                        {
                            CloseStockIndexContract(orderAccepter, holdTable, (float)holdTable.HoldAveragePrice, false);
                        }
                        #endregion
                    }
                }
            }

            //LogHelper.WriteDebug("FutureDayChecker.CheckFundTable结束检查资金表");
        }