/// <summary> /// 校验入口 /// </summary> /// <param name="errMsg">错误信息</param> /// <returns>是否成功</returns> public bool Check(out string errMsg) { bool result = Initialize(Types.BreedClassTypeEnum.HKStock, request.TraderId, request.Code, out errMsg); //基础验证,包括商品的基础验证,账户的基础验证 if (result) { result = CheckTraderAvalible(out errMsg); } //如果是在交易时间内,那么检查停牌,连续3次,预下单不检查 if (ValidateCenter.IsMatchTradingTime(Types.BreedClassTypeEnum.HKStock, request.Code)) { if (result) { result = CheckStopTrading(ref errMsg); if (!result) { result = CheckStopTrading(ref errMsg); } if (!result) { result = CheckStopTrading(ref errMsg); } } } return(result); }
/// <summary> /// 校验入口 /// </summary> /// <param name="errMsg">错误信息</param> /// <returns>是否成功</returns> public bool Check(out string errMsg) { bool result = Initialize(request.TraderId, request.Code, out errMsg); //检查品种交易权限 //if(result) //{ // result = CheckTradeRight(out errMsg); //} //基础验证,包括商品的基础验证,账户的基础验证 if (result) { result = CheckTraderAvalible(out errMsg); } ////检查资金 //if(result) //{ // result = CheckFuncTable(ref errMsg); //} ////检查持仓 //if (result) //{ // result = CheckHoldTable(ref errMsg); //} //如果是在交易时间内,那么检查停牌,连续3次,预下单不检查 if (ValidateCenter.IsMatchTradingTime(request.Code)) { if (result) { result = CheckStopTrading(ref errMsg); if (!result) { result = CheckStopTrading(ref errMsg); } if (!result) { result = CheckStopTrading(ref errMsg); } } } return(result); }
/// <summary> /// 校验入口 /// </summary> /// <param name="errMsg">错误信息</param> /// <param name="breedType">品种类型(这里是因为这里两种获取的行情实体方法有区别)</param> /// <returns>是否成功</returns> public bool Check(out string errMsg, Types.BreedClassTypeEnum breedType) { bool result = Initialize(traderId, code, out errMsg); //基础验证,包括商品的基础验证,账户的基础验证 if (result) { result = CheckTraderAvalible(out errMsg); } //检查资金 //if (result) //{ // result = CheckFuncTable(ref errMsg); //} ////检查持仓 //if (result) //{ // result = CheckHoldTable(ref errMsg); //} //如果是在交易时间内,那么检查停牌,连续3次,预下单不检查 if (ValidateCenter.IsMatchTradingTime(code)) { if (result) { result = CheckStopTrading(ref errMsg, breedType); if (!result) { result = CheckStopTrading(ref errMsg, breedType); } if (!result) { result = CheckStopTrading(ref errMsg, breedType); } } } return(result); }
/// <summary> /// 处理Type1类型改单-未报 /// </summary> /// <param name="request">改单委托</param> private void ProcessType1(HKModifyOrderRequest request) { LogHelper.WriteDebug("M————>ModifyOrderProcessor.ProcessType1接收类型1改单请求" + request); //如果不在交易时间内,那么直接到缓存中删除原来的委托,生成新委托 if (!ValidateCenter.IsMatchTradingTime(Types.BreedClassTypeEnum.HKStock, request.Code)) { LogHelper.WriteDebug("类型1改单请求" + request + "不在交易时间时间内,直接到缓存中删除原来的委托,生成新委托"); //1.删除缓存中的委托信息 OrderOfferCenter.Instance._orderCache.DeleteHKOrder(request.Code, request.EntrustNubmer); //2.进行内存撤单 var tet = HKDataAccess.GetTodayEntrustTable(request.EntrustNubmer); OrderOfferCenter.Instance.IntelnalCancelHKOrder(tet, "预委托被改单,作废"); //tet.OrderStatusID = (int)Entity.Contants.Types.OrderStateType.DOSCanceled; //tet.OrderMessage = "未报的委托被改单,作废"; //HKDataAccess.UpdateEntrustTable(tet); //3.回推原始委托变化到前台 ReckonEndObject <HK_TodayEntrustInfo, HK_TodayTradeInfo> reckonEndObject = new ReckonEndObject <HK_TodayEntrustInfo, HK_TodayTradeInfo>(); reckonEndObject.IsSuccess = true; reckonEndObject.EntrustTable = tet; reckonEndObject.TradeTableList = new List <HK_TodayTradeInfo>(); reckonEndObject.TradeID = request.TraderId; reckonEndObject.Message = ""; CounterOrderService.Instance.AcceptHKDealOrder(reckonEndObject); ProcessType1_NewOrder(request); } else { //否则的话,放入类型1改单缓存,等原始委托报盘时再处理 LogHelper.WriteDebug("M————>ModifyOrderProcessor.ProcessType1类型1改单请求在交易时间内,放入缓存等待报盘时查找核对" + request); AddType1Reqest(request); } }
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); }