コード例 #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
        /// <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);
        }