Exemplo n.º 1
0
        protected override void FillCommandList()
        {
            //0.交易员权限--交易员是否有此品种的交易权限
            HKStockTraderRightsCommand hkStockTraderRightsCommand = new HKStockTraderRightsCommand(this.BreedClassID);

            AddCommand(hkStockTraderRightsCommand);

            HKStockZeroVolumeOfBusinessCommand zeroVolumeOfBusinessCommand = new HKStockZeroVolumeOfBusinessCommand(this.BreedClassID);

            AddCommand(zeroVolumeOfBusinessCommand);

            //1.最小交易单位(计价单位)因为牵涉到持仓,所以分离出来,由外部单独进行调用
            //StockMinVolumeOfBusinessCommand minVolumeOfBusinessCommand = new StockMinVolumeOfBusinessCommand(this.BreedClassID);
            //AddCommand(minVolumeOfBusinessCommand);

            //2.最大委托量
            HKStockMaxLeaveQuantityRangeValueCommand stockMaxLeaveQuantityRangeValueCommand =
                new HKStockMaxLeaveQuantityRangeValueCommand(this.BreedClassID);

            AddCommand(stockMaxLeaveQuantityRangeValueCommand);

            //3.最小变动价位
            HKStockMinChangePriceValueCommand stockMinChangePriceValueCommand =
                new HKStockMinChangePriceValueCommand(this.BreedClassID);

            AddCommand(stockMinChangePriceValueCommand);

            //4.涨跌幅
            HKStockSpotHighLowCommand stockSpotHighLowCommand = new HKStockSpotHighLowCommand(this.BreedClassID);

            AddCommand(stockSpotHighLowCommand);
        }
        /// <summary>
        /// 根据改单请求和改单类型,改单委托的买卖方向,检验相关验证方法
        /// </summary>
        /// <param name="hkModifyOrder"></param>
        /// <param name="modifyType"></param>
        /// <param name="entrusInfo"></param>
        /// <param name="strMessage"></param>
        /// <returns></returns>
        public bool Validate(HKModifyOrderRequest hkModifyOrder, HK_TodayEntrustInfo entrusInfo, int breedClassID,
                             ref string strMessage)
        {
            BreedClassID = breedClassID;
            bool reust      = false;
            int  modifyType = 0; //改单类型

            #region 判断改单类型

            //未注报
            if (entrusInfo.OrderStatusID == (int)Types.OrderStateType.DOSUnRequired)
            {
                modifyType = 1;
            }


            //已报、部成
            if (entrusInfo.OrderStatusID == (int)Types.OrderStateType.DOSIsRequired ||
                entrusInfo.OrderStatusID == (int)Types.OrderStateType.DOSPartDealed)
            {
                if ((decimal)hkModifyOrder.OrderPrice == entrusInfo.EntrustPrice &&
                    hkModifyOrder.OrderAmount < entrusInfo.EntrustAmount)
                {
                    modifyType = 2;
                }
                else
                {
                    modifyType = 3;
                }
            }

            #endregion

            if (modifyType == 0)
            {
                strMessage = "GT-2250:[港股改单委托验证]当前委托无法改单";
                return(false);
            }

            #region 为适用之前的方法组装下单请求实体

            HKOrderRequest request = new HKOrderRequest();
            request.Code          = hkModifyOrder.Code;
            request.ChannelID     = hkModifyOrder.ChannelID;
            request.BuySell       = (CommonObject.Types.TransactionDirection)entrusInfo.BuySellTypeID;
            request.OrderAmount   = hkModifyOrder.OrderAmount;
            request.OrderPrice    = hkModifyOrder.OrderPrice;
            request.FundAccountId = entrusInfo.CapitalAccount;
            request.OrderUnitType = (GTA.VTS.Common.CommonObject.Types.UnitType)entrusInfo.TradeUnitID;
            request.OrderWay      = (GTA.VTS.Common.CommonObject.Types.HKPriceType)entrusInfo.OrderPriceType;

            #endregion

            #region 1.零股检验

            //零股检验
            HKStockZeroVolumeOfBusinessCommand zerovolume = new HKStockZeroVolumeOfBusinessCommand(BreedClassID);
            reust = zerovolume.Validate(request, ref strMessage);
            if (!reust)
            {
                return(false);
            }

            #endregion

            #region 2.单笔最大委托量检验命令

            //单笔最大委托量检验命令
            HKStockMaxLeaveQuantityRangeValueCommand maxLeave =
                new HKStockMaxLeaveQuantityRangeValueCommand(BreedClassID);
            reust = maxLeave.Validate(request, ref strMessage);
            if (!reust)
            {
                return(false);
            }

            #endregion

            #region 3.不是第二种类型量减的并且价格有改动的验证最小变动价格

            //不是第二种类型量减的并且价格有改动的验证最小变动价格
            if (modifyType != 2 && (decimal)hkModifyOrder.OrderPrice != entrusInfo.EntrustPrice)
            {
                HKStockMinChangePriceValueCommand minChange = new HKStockMinChangePriceValueCommand(BreedClassID);
                reust = minChange.Validate(request, ref strMessage);
                if (!reust)
                {
                    return(false);
                }
            }

            #endregion

            #region 委托量有所改变则验证相关持仓(宋涛1116:此处不需要进行校验,等待原委托撤单成功后,由新单校验处检验)

            ////if (modifyType != 2)
            //{
            //if (hkModifyOrder.OrderAmount != entrusInfo.EntrustAmount)
            //{
            //    if (entrusInfo.BuySellTypeID == (int)Types.TransactionDirection.Buying)
            //    {
            //        reust = PO_HoldValidate_Buy(ref strMessage, entrusInfo, request);
            //    }
            //    else
            //    {
            //        reust = PO_HoldValidate_Sell(ref strMessage, entrusInfo, request);
            //    }
            //    if (!reust)
            //    {
            //        return false;
            //    }
            //}
            ////}

            //不考虑持仓量,只考虑委托最小单位的验证
            HKModifyStockMinVolumeOfBusinessCommand minVolume = new HKModifyStockMinVolumeOfBusinessCommand(BreedClassID);
            reust = minVolume.Validate(request, ref strMessage);
            if (!reust)
            {
                return(false);
            }

            #endregion

            return(true);
        }