/// <summary> /// 创建一个今日成交记录 /// </summary> /// <param name="registerTable">登记表实体</param> /// <param name="intNum">分红过户量</param>里 /// <returns>今日成交实体</returns> private static XH_TodayTradeTableInfo GetTodayTradeTable(XH_MelonCutRegisterTableInfo registerTable, int intNum) { XH_TodayTradeTableInfo todayTradeTable = new XH_TodayTradeTableInfo(); todayTradeTable.TradeNumber = Guid.NewGuid().ToString(); todayTradeTable.BuySellTypeId = (int)GTA.VTS.Common.CommonObject.Types.TransactionDirection.Buying; todayTradeTable.StockAccount = registerTable.UserAccountDistributeLogo; todayTradeTable.TradeTypeId = (int)Types.DealRptType.DRTTransfer; todayTradeTable.CurrencyTypeId = registerTable.TradeCurrencyType; todayTradeTable.TradeUnitId = MCService.GetPriceUnit(registerTable.Code); todayTradeTable.TradeAmount = intNum; todayTradeTable.TradeTime = DateTime.Now; CM_BourseType bourseType = MCService.CommonPara.GetBourseTypeByCommodityCode(registerTable.Code); if (bourseType != null) { } CM_Commodity commodity = MCService.CommonPara.GetCommodityByCommodityCode(registerTable.Code); todayTradeTable.SpotCode = registerTable.Code; if (commodity != null) { } CM_BreedClass breedClass = MCService.CommonPara.GetBreedClassByCommodityCode(registerTable.Code); if (breedClass != null) { } return(todayTradeTable); }
/// <summary> /// 构造器 /// </summary> /// <param name="args"></param> /// <param name="commodity"></param> /// <param name="breedClassType"></param> public OrderCacheMessageAccpetItem(ScheduleEventArgs args, CM_Commodity commodity, Types.BreedClassTypeEnum breedClassType) { Args = args; Commodity = commodity; BreedClassType = breedClassType; }
/// <summary> /// 7.根据商品编号获取所属的商品类别 /// </summary> /// <param name="commodityCode">商品代码</param> /// <param name="type">是不是港股</param> /// <returns></returns> public static CM_BreedClass GetBreedClassByCommodityCode(string commodityCode, int type) { if (string.IsNullOrEmpty(commodityCode)) { return(null); } if (type == 1) {//非港股 CM_Commodity commodity = CommonDataCacheProxy.Instanse.GetCacheCommodityByCode(commodityCode); if (commodity == null || !commodity.BreedClassID.HasValue) { return(null); } return(CommonDataCacheProxy.Instanse.GetCacheCM_BreedClassByKey(commodity.BreedClassID.Value)); } else {//港股 HK_Commodity commodity = CommonDataCacheProxy.Instanse.GetCacheHKCommodityByCode(commodityCode); if (commodity == null || !commodity.BreedClassID.HasValue) { return(null); } return(CommonDataCacheProxy.Instanse.GetCacheCM_BreedClassByKey(commodity.BreedClassID.Value)); } }
/// <summary> /// 检测交易员的品种交易权限 /// </summary> /// <param name="errMsg"></param> /// <returns></returns> private bool CheckTradeRight(out string errMsg) { errMsg = ""; try { IList <UM_DealerTradeBreedClass> list = MCService.CommonPara.GetTransactionRightTable(int.Parse(this.request.TraderId)); CM_Commodity code = MCService.CommonPara.GetCommodityByCommodityCode(this.request.Code); foreach (UM_DealerTradeBreedClass tradeBreedClass in list) { if ((int)tradeBreedClass.BreedClassID == (int)code.BreedClassID) { return(true); } } errMsg = "交易员没有该品种的交易权限!"; } catch (Exception ex) { errMsg = "无法进行交易品种权限有效性验证。"; string errCode = "GT-1207"; errMsg = errCode + ":" + errMsg; LogHelper.WriteError(errMsg, ex); } return(false); }
/// <summary> /// 返回期货规则 /// </summary> /// <param name="code">代码</param> /// <returns></returns> public static QH_FuturesTradeRules GetQH_FuturesTradeRulesByCommodityCode(string code) { CM_Commodity commodity = CommonDataCacheProxy.Instanse.GetCacheCommodityByCode(code); if (commodity == null) { return(null); } var breedClassID = (int)commodity.BreedClassID; return(CommonDataCacheProxy.Instanse.GetCacheQH_FuturesTradeRulesByKey(breedClassID)); }
/// <summary> /// 根据期货Code判断是否为新品种期货合约上市 /// </summary> /// <param name="code"></param> /// <returns></returns> public static bool IsNewBreedClassByCode(string code) { CM_Commodity commodity = CommonDataCacheProxy.Instanse.GetCacheCommodityByCode(code); if (commodity == null && !commodity.BreedClassID.HasValue) { return(false); } //List<CM_Commodity> itemsAll =CommonDataCacheProxy.Instanse.GetAllCommodity(); List <CM_Commodity> items = new List <CM_Commodity>(); items = CommonDataCacheProxy.Instanse.GetCacheCommodityByBreedClassID(commodity.BreedClassID.Value); //foreach (CM_Commodity item in itemsAll) //{ // if (item.BreedClassID == commodity.BreedClassID) // { // items.Add(item); // } //} //为了防止items==null if (items != null && items.Count == 1) { if (commodity.MarketDate.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) { return(true); } } else { //是否有比当前更早的代码 bool flag = false; //为了防止items==null if (items != null) { foreach (CM_Commodity item in items) { if (item.CommodityCode.CompareTo(commodity.CommodityCode) < 0) { flag = true; break; } } } if (!flag) { if (commodity.MarketDate.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) { return(true); } } } return(false); }
/// <summary> /// 根据期货合约代码判断是否为季月合约上市首日 /// </summary> /// <param name="code">合约代码</param> /// <returns></returns> public static bool IsNewQuarterMonthContract(string code) { //if (!IsNewMonthBreedClassByCode(code) && !IsNewBreedClassByCode(code)) //{ // return false; //} CM_Commodity cm = CommonDataCacheProxy.Instanse.GetCacheCommodityByCode(code); if (cm.MarketDate.Date != DateTime.Now.Date) { return(false); } int year; int month; GetAgreementTime(code, out year, out month); switch (DateTime.Now.Month) { case 1: if (year == DateTime.Now.Year && month == 9) { return(true); } break; case 4: if (year == DateTime.Now.Year && month == 12) { return(true); } break; case 7: if (year == DateTime.Now.AddYears(1).Year&& month == 3) { return(true); } break; case 10: if (year == DateTime.Now.AddYears(1).Year&& month == 6) { return(true); } break; } return(false); }
/// <summary> /// 根据商品代码返回所属交易所 /// </summary> /// <param name="code">代码</param> /// <returns></returns> public static CM_BourseType GetCM_BourseTypeByCommodityCode(string code) { CM_Commodity commodity = CommonDataCacheProxy.Instanse.GetCacheCommodityByCode(code); if (commodity == null || commodity.BreedClassID.HasValue == false) { return(null); } CM_BreedClass breedClassEntry = CommonDataCacheProxy.Instanse.GetCacheCM_BreedClassByKey((int)commodity.BreedClassID); if (breedClassEntry == null || breedClassEntry.BourseTypeID.HasValue == false) { return(null); } return(CommonDataCacheProxy.Instanse.GetCacheCM_BourseTypeByKey((int)breedClassEntry.BourseTypeID)); }
/// <summary> /// 根据商品Code判断是否为新股上市,这里只要是比较上市时间是否为当前时间 /// </summary> /// <param name="code">代码</param> /// <returns></returns> public static bool IsNewMarketyByCode(string code) { CM_Commodity item = CommonDataCacheProxy.Instanse.GetCacheCommodityByCode(code); if (item == null) { return(false); } else if (item.MarketDate.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) { return(true); } else { return(false); } }
/// <summary> /// 根据商品Code判断是否为新月份期货合约上市 /// </summary> /// <param name="code">代码</param> /// <returns></returns> public static bool IsNewMonthBreedClassByCode(string code) { CM_Commodity commodity = CommonDataCacheProxy.Instanse.GetCacheCommodityByCode(code); if (commodity == null) { return(false); } //List<CM_Commodity> itemsAll = GetAllCommonDataFromManagerCenter.GetAllCommodity(); List <CM_Commodity> items = new List <CM_Commodity>(); items = CommonDataCacheProxy.Instanse.GetCacheCommodityByBreedClassID(commodity.BreedClassID.Value); //foreach (CM_Commodity item in itemsAll) //{ // if (item.BreedClassID == commodity.BreedClassID) // { // items.Add(item); // } //} //为了防止items==null //同品种有1个以上的代码,并且有比当前代码更早的 if (items != null && items.Count > 1) { bool flag = false; foreach (CM_Commodity item in items) { if (item.CommodityCode.CompareTo(commodity.CommodityCode) < 0) { flag = true; break; } } if (flag) { if (commodity.MarketDate.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) { return(true); } } } return(false); }
/// <summary> /// 确定按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { //根据状态进行操作 1:添加 2:修改 if (m_EditType == 1) { #region 添加操作 try { CM_Commodity cM_Commodity = new CM_Commodity(); if (!string.IsNullOrEmpty(this.txtCommodityCode.Text)) { if (!CommonParameterSetCommon.IsExistCommodityCode(this.txtCommodityCode.Text)) { ShowMessageBox.ShowInformation("代码已经存在!"); return; } if (InputTest.zeroXHAndQHStartIntTest(this.txtCommodityCode.Text)) { if (this.txtCommodityCode.Text.Length == 6 || this.txtCommodityCode.Text.Length == 5) { cM_Commodity.CommodityCode = this.txtCommodityCode.Text; } else { ShowMessageBox.ShowInformation("代码长度是5或6!"); return; } } else { ShowMessageBox.ShowInformation("请输入期货代码简称+数字或6个数字!"); return; } } else { ShowMessageBox.ShowInformation("请输入代码!"); return; } if (!string.IsNullOrEmpty(this.txtCommodityName.Text)) { if (!CommonParameterSetCommon.IsExistCommodityName(this.txtCommodityName.Text)) { ShowMessageBox.ShowInformation("代码名称已经存在!"); return; } cM_Commodity.CommodityName = this.txtCommodityName.Text; } else { ShowMessageBox.ShowInformation("请输入代码名称!"); return; } if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text)) { cM_Commodity.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex; } else { //cM_Commodity.BreedClassID = AppGlobalVariable.INIT_INT; ShowMessageBox.ShowInformation("请选择品种类型!"); return; } if (!string.IsNullOrEmpty(this.txtLabelCommodityCode.Text)) { cM_Commodity.LabelCommodityCode = this.txtLabelCommodityCode.Text; } else { cM_Commodity.LabelCommodityCode = AppGlobalVariable.INIT_STRING; } if (!string.IsNullOrEmpty(this.txtGoerScale.Text)) { cM_Commodity.GoerScale = Convert.ToDecimal(this.txtGoerScale.Text); } else { cM_Commodity.GoerScale = AppGlobalVariable.INIT_DECIMAL; } //if (!string.IsNullOrEmpty(this.txtStockPinYin.Text)) //{ //cM_Commodity.StockPinYin = this.txtStockPinYin.Text; //} //else //{ // cM_Commodity.StockPinYin = AppGlobalVariable.INIT_STRING; // //ShowMessageBox.ShowInformation("拼音简称不能为空!"); // //return; //} if (!string.IsNullOrEmpty(this.txtStockPinYin.Text)) { if (m_DiffBreeadClassType) { cM_Commodity.StockPinYin = this.txtStockPinYin.Text; } else { cM_Commodity.StockPinYin = AppGlobalVariable.INIT_STRING; } } else { if (m_DiffBreeadClassType) { ShowMessageBox.ShowInformation("拼音简称不能为空!"); return; } else { cM_Commodity.StockPinYin = AppGlobalVariable.INIT_STRING; //期货时此值为空 } } if (!string.IsNullOrEmpty(this.dtMarketDate.Text)) { cM_Commodity.MarketDate = Convert.ToDateTime(this.dtMarketDate.Text); } else { //cM_Commodity.MarketDate = AppGlobalVariable.INIT_DATETIME; ShowMessageBox.ShowInformation("请选择上市日期!"); return; } if (!string.IsNullOrEmpty(this.txtturnovervolume.Text)) { if (m_DiffBreeadClassType) { if (InputTest.intTest(this.txtturnovervolume.Text)) { cM_Commodity.turnovervolume = Convert.ToDouble(this.txtturnovervolume.Text); } else { ShowMessageBox.ShowInformation("请输入正整数!"); return; } } else { cM_Commodity.turnovervolume = null; //期货时此值为空 } } else { if (m_DiffBreeadClassType) { ShowMessageBox.ShowInformation("请输入流通股数!"); return; } else { cM_Commodity.turnovervolume = null; //期货时此值为空 } } cM_Commodity.IsExpired = AppGlobalVariable.INIT_INT; //默认int初始值 // cM_Commodity.ISSysDefaultCode = AppGlobalVariable.INIT_INT;//用户添加的代码不是系统默认代码 cM_Commodity.ISSysDefaultCode = (int)GTA.VTS.Common.CommonObject.Types.IsYesOrNo.No; //用户添加的代码不是系统默认代码 m_Result = CommonParameterSetCommon.AddCMCommodity(cM_Commodity); if (m_Result) { ShowMessageBox.ShowInformation("添加成功!"); this.ClearAll(); this.QueryCMCommodity(); } else { ShowMessageBox.ShowInformation("添加失败!"); } } catch (Exception ex) { string errCode = "GL-4201"; string errMsg = "添加交易商品失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return; } #endregion } else if (m_EditType == 2) { #region 修改商品操作 try { CM_Commodity cM_Commodity = new CM_Commodity(); if (string.IsNullOrEmpty(this.txtCommodityCode.Text)) { ShowMessageBox.ShowInformation("请选择更新数据!"); return; } cM_Commodity.CommodityCode = this.txtCommodityCode.Text; if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text)) { cM_Commodity.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex; } else { //cM_Commodity.BreedClassID = AppGlobalVariable.INIT_INT; ShowMessageBox.ShowInformation("请选择品种类型!"); return; } if (!string.IsNullOrEmpty(dtMarketDate.Text)) { cM_Commodity.MarketDate = dtMarketDate.DateTime; } cM_Commodity.IsExpired = AppGlobalVariable.INIT_INT; //默认int初始值 //cM_Commodity.ISSysDefaultCode = AppGlobalVariable.INIT_INT;//用户添加的代码不是系统默认代码 cM_Commodity.ISSysDefaultCode = m_ISSysDefaultCode; //当是修改时不改变原来的系统默认代码默认值 m_Result = CommonParameterSetCommon.UpdateCMCommodity(cM_Commodity); if (m_Result) { ShowMessageBox.ShowInformation("修改成功!"); this.ClearAll(); } else { ShowMessageBox.ShowInformation("修改失败!"); } m_ISSysDefaultCode = AppGlobalVariable.INIT_INT; this.QueryCMCommodity(); } catch (Exception ex) { string errCode = "GL-4203"; string errMsg = "修改交易商品失败!"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); return; } #endregion } }
protected override void DetailProcess(ScheduleEventArgs args, CM_Commodity commodity, Types.BreedClassTypeEnum breedClassTypeEnum) { //ScheduleMessageBuffer.InsertQueueItem(new OrderCacheMessageAccpetItem(args, commodity, breedClassTypeEnum)); }
/// <summary> /// 交易月份类型为本月下月随后的两个季度月份的代码更新 /// </summary> /// <param name="breedclass"></param> private void SpecialQHCodeUpdate(int breedclass) { try { //根据品种ID,找到品种的前缀代码 string QH_PrefixCode = GetQH_PrefixCodeByID(breedclass); //根据品种ID,找到品种的名称 string QH_breedclassName = GetBreedClassNameByID(breedclass); string OldCode = string.Empty; string NewCode = string.Empty; //1,2,3, 4,5,6, 7,8,9 ,10,11,12 //1,2,3, 6, // 2,3, 6, 9, // 3, 4, 6, 9, // 4,5,6, 9, // 5,6, 9, 12, // 6, 7, 9, 12, // 7,8,9, 12, // 3, 8,9, 12, // 3, 9, 10, 12, // 3, 10,11,12, // 3, 6, 11,12, //1, 3, 6, 12, //1,2,3, 6, //add 李健华 2010-01-15 //比如今天之前是,1001,1002,1003,1006,今天之后是1002,1003,1006,1009, //下一个月1002到期后就是,1004,1006,1009,1010 //保证3,6,9,12中有连续2个的季月,以及连续的两个自然月,总共4个合约是不变的。 //============== switch (System.DateTime.Now.Month) { case 1: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "01"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "09"; break; case 2: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "02"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "04"; break; case 3: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "03"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "05"; break; case 4: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "04"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "12"; break; case 5: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "05"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "07"; break; case 6: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "06"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "08"; break; case 7: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "07"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "03"; break; case 8: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "08"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "10"; break; case 9: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "09"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "11"; break; case 10: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "10"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "06"; break; case 11: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "11"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "01"; break; case 12: OldCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now) + "12"; NewCode = QH_PrefixCode + GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "02"; break; } CM_CommodityDAL CommodityDAL = new CM_CommodityDAL(); RC_TradeCommodityAssignDAL TradeCommodityAssignDAL = new RC_TradeCommodityAssignDAL(); CM_Commodity CM_Commodity = CommodityDAL.GetModel(OldCode); if (CM_Commodity == null) { CM_Commodity = new CM_Commodity(); } CM_Commodity.CommodityCode = NewCode; CM_Commodity.MarketDate = DateTime.Parse(System.DateTime.Now.AddDays(1).ToShortDateString()); //若第二天是非交易日则顺延一天 add by 董鹏 2010-03-31 while (!JudgmentIsTrandingDay(CM_Commodity.MarketDate, breedclass)) { CM_Commodity.MarketDate = CM_Commodity.MarketDate.AddDays(1); } CM_Commodity.CommodityName = NewCode; //QH_breedclassName + NewCode.Substring(NewCode.Length - 4); CM_Commodity.BreedClassID = breedclass; CM_Commodity.GoerScale = decimal.MaxValue; CM_Commodity.LabelCommodityCode = null; CM_Commodity.StockPinYin = null; CM_Commodity.turnovervolume = null; CM_Commodity.IsExpired = (int)Types.IsYesOrNo.No; //新增期货代码时,默认代码没有过期 CM_Commodity.ISSysDefaultCode = (int)Types.IsYesOrNo.Yes; //新增期货代码时,默认是系统代码 bool _result = CommodityDAL.Add(CM_Commodity); if (!_result) { LogHelper.WriteDebug("SpecialQHCodeUpdate()方法中的添加代码失败"); return; } //更新代码分配表 TradeCommodityAssignDAL.Update(OldCode, NewCode); // CommodityDAL.Delete(OldCode); //根据2009-7-22需求过期代码添加标识 int isExpired = (int)Types.IsYesOrNo.Yes;//旧代码状态设置为过期 bool _resultUpdate = CommodityDAL.Update(OldCode, isExpired); if (!_resultUpdate) { LogHelper.WriteDebug("SpecialQHCodeUpdate()方法中的更新代码失败"); } //调用把期货新增的代码自动添加到可交易商品_撮合机_分配表中的方法 QHCodeAutoRCTradeCommodityAssign(NewCode, breedclass); } catch (Exception ex) { string errCode = "GL-7003"; string errMsg = "执行更新方法SpecialQHCodeUpdate()失败"; VTException exception = new VTException(errCode, errMsg, ex); LogHelper.WriteError(exception.ToString(), exception.InnerException); } }
/// <summary> /// 添加期货品种时初始化一个周期的和约代码 /// </summary> /// <param name="BreedClassID"></param> public void QHCommdityCodeInit(int BreedClassID) { CommodityCodeUpdate CCP = new CommodityCodeUpdate(); //根据品种ID,找到品种的前缀代码 string QH_PrefixCode = CCP.GetQH_PrefixCodeByID(BreedClassID); //根据品种ID,找到品种的名称 string QH_breedclassName = CCP.GetBreedClassNameByID(BreedClassID); #region 创建代码规则管理器 add by 董鹏 2010-03-10 //根据品种获取交易所 CM_BreedClassBLL bc = new CM_BreedClassBLL(); CM_BourseTypeBLL bt = new CM_BourseTypeBLL(); var bourseType = bt.GetModel(bc.GetModel(BreedClassID).BourseTypeID.Value); //创建代码规则管理 CodeRulesManager codeRule; if (bourseType.CodeRulesType.HasValue) { LogHelper.WriteDebug("===开始自动生成代码,代码规则类型:" + bourseType.CodeRulesType.ToString()); codeRule = new CodeRulesManager((Types.CodeRulesType)bourseType.CodeRulesType.Value); } else { LogHelper.WriteDebug("===开始自动生成代码,没有获取到交易所对应的代码规则,交易所:" + bourseType.BourseTypeName); codeRule = new CodeRulesManager(null); } #endregion CM_CommodityDAL CommodityDAL = new CM_CommodityDAL(); CM_Commodity CM_Commodity = new CM_Commodity(); CM_Commodity.BreedClassID = BreedClassID; CM_Commodity.GoerScale = decimal.MaxValue; CM_Commodity.LabelCommodityCode = null; CM_Commodity.StockPinYin = null; CM_Commodity.MarketDate = DateTime.Now.AddYears(-1); //暂时将日期定为一年前 DateTime.MaxValue; CM_Commodity.turnovervolume = null; CM_Commodity.IsExpired = (int)Types.IsYesOrNo.No; //初始化期货代码时,默认没有过期 CM_Commodity.ISSysDefaultCode = (int)Types.IsYesOrNo.Yes; //新增期货代码时,默认代码没有过期 QH_AgreementDeliveryMonthDAL AgreementDeliveryMonthDAL = new QH_AgreementDeliveryMonthDAL(); List <QH_AgreementDeliveryMonth> L = AgreementDeliveryMonthDAL.GetListArray(string.Format("BreedClassID={0}", BreedClassID)); foreach (QH_AgreementDeliveryMonth AgreementDeliveryMonth in L) { if ((int)AgreementDeliveryMonth.MonthID > System.DateTime.Now.Month && (int)AgreementDeliveryMonth.MonthID <= 12) { //string Code = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + // CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID); //使用代码规则管理器生成代码 string Code = codeRule.GetCode(QH_PrefixCode, DateTime.Now.Year.ToString(), CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID)); CM_Commodity.CommodityCode = Code; CM_Commodity.CommodityName = Code;// QH_breedclassName + Code.Substring(Code.Length - 4); CommodityDAL.Add(CM_Commodity); } if ((int)AgreementDeliveryMonth.MonthID < System.DateTime.Now.Month) { //string Code = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + // CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID); //使用代码规则管理器生成代码 string Code = codeRule.GetCode(QH_PrefixCode, DateTime.Now.AddYears(1).Year.ToString(), CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID)); CM_Commodity.CommodityCode = Code; CM_Commodity.CommodityName = Code;// QH_breedclassName + Code.Substring(Code.Length - 4); CommodityDAL.Add(CM_Commodity); } if ((int)AgreementDeliveryMonth.MonthID == System.DateTime.Now.Month) { int lasttradingday = CCP.GetLastTradingDay(CCP.GetLastTradingDayEntity(BreedClassID), BreedClassID); string Code = string.Empty; if (System.DateTime.Now.Day < lasttradingday) { // Code = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + //CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID); //使用代码规则管理器生成代码 Code = codeRule.GetCode(QH_PrefixCode, DateTime.Now.Year.ToString(), CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID)); } else { // Code = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + //CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID); //使用代码规则管理器生成代码 Code = codeRule.GetCode(QH_PrefixCode, DateTime.Now.AddYears(1).Year.ToString(), CommodityCodeUpdate.GetTwoLenMonth((int)AgreementDeliveryMonth.MonthID)); } CM_Commodity.CommodityCode = Code; CM_Commodity.CommodityName = Code;// QH_breedclassName + Code.Substring(Code.Length - 4); CommodityDAL.Add(CM_Commodity); } if ((int)AgreementDeliveryMonth.MonthID == 13) { SpecialQHCodeInit(BreedClassID, QH_PrefixCode, QH_breedclassName); } } }
private void SpecialQHCodeInit(int BreedClassID, string QH_PrefixCode, string QH_breedclassName) { //1,2,3, 4,5,6, 7,8,9 ,10,11,12 //1,2,3, 6, // 2,3, 6, 9, // 3, 4, 6, 9, // 4,5,6, 9, // 5,6, 9, 12, // 6, 7, 9, 12, // 7,8,9, 12, // 3, 8,9, 12, // 3, 9, 10, 12, // 3, 10,11,12, // 3, 6, 11,12, //1, 3, 6, 12, //1,2,3, 6, CommodityCodeUpdate CCP = new CommodityCodeUpdate(); int lasttradingday = CCP.GetLastTradingDay(CCP.GetLastTradingDayEntity(BreedClassID), BreedClassID); string Code1 = string.Empty; string Code2 = string.Empty; string Code3 = string.Empty; string Code4 = string.Empty; #region switch (System.DateTime.Now.Month) { case 1: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "02"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "03"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "06"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "01"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "09"; } break; case 2: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "03"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "06"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "09"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "02"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "04"; } break; case 3: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "04"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "06"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "09"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "03"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "05"; } break; case 4: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "05"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "06"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "09"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "04"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "12"; } break; case 5: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "06"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "09"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "12"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "05"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "07"; } break; case 6: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "07"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "09"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "12"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "06"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "08"; } break; case 7: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "08"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "09"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "12"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "07"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "03"; } break; case 8: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "09"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "12"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "03"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "08"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "10"; } break; case 9: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "10"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "12"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "03"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "09"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "11"; } break; case 10: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "11"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "12"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "03"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "10"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "06"; } break; case 11: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "12"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "03"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "06"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "11"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "01"; } break; case 12: Code2 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "01"; Code3 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "03"; Code4 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "06"; if (System.DateTime.Now.Day < lasttradingday) { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now) + "12"; } else { Code1 = QH_PrefixCode + CommodityCodeUpdate.GetTwoLenYear(System.DateTime.Now.AddYears(1)) + "02"; } break; } #endregion CM_CommodityDAL CommodityDAL = new CM_CommodityDAL(); CM_Commodity CM_Commodity = new CM_Commodity(); CM_Commodity.BreedClassID = BreedClassID; CM_Commodity.GoerScale = decimal.MaxValue; CM_Commodity.LabelCommodityCode = null; CM_Commodity.StockPinYin = null; CM_Commodity.MarketDate = DateTime.MaxValue; CM_Commodity.turnovervolume = null; CM_Commodity.IsExpired = (int)Types.IsYesOrNo.No; //初始化期货代码时,默认代码没有过期 CM_Commodity.ISSysDefaultCode = (int)Types.IsYesOrNo.Yes; //初始化期货代码时,默认是系统代码 CM_Commodity.CommodityCode = Code1; CM_Commodity.CommodityName = Code1; // QH_breedclassName + Code1.Substring(Code1.Length - 4); CommodityDAL.Add(CM_Commodity); CM_Commodity.CommodityCode = Code2; CM_Commodity.CommodityName = Code2;// QH_breedclassName + Code2.Substring(Code2.Length - 4); CommodityDAL.Add(CM_Commodity); CM_Commodity.CommodityCode = Code3; CM_Commodity.CommodityName = Code3;// QH_breedclassName + Code3.Substring(Code3.Length - 4); CommodityDAL.Add(CM_Commodity); CM_Commodity.CommodityCode = Code4; CM_Commodity.CommodityName = Code4;// QH_breedclassName + Code4.Substring(Code4.Length - 4); CommodityDAL.Add(CM_Commodity); }
protected override void DetailProcess(ScheduleEventArgs args, CM_Commodity commodity, Types.BreedClassTypeEnum breedClassTypeEnum) { }
/// <summary> /// 每一个商品代码处理入口 /// </summary> /// <param name="args">任务参数</param> /// <param name="commodity">商品</param> /// <param name="breedClassTypeEnum">品种类型名称 1.股票现货 2.商品期货 3.股指期货</param> protected abstract void DetailProcess(ScheduleEventArgs args, CM_Commodity commodity, Types.BreedClassTypeEnum breedClassTypeEnum);
/// <summary> /// 获取合约持仓限制 /// </summary> /// <param name="code">合约代码</param> /// <param name="positionValueType">持仓限制类型</param> /// <returns>持仓限制</returns> public static PositionLimitValueInfo GetFuturePostionLimit(string code, out Types.QHPositionValueType positionValueType) { string errCode = "GT-8491"; string errMsg = "期货商品代码不存在。"; CM_Commodity commodity = MCService.CommonPara.GetCommodityByCommodityCode(code); if (commodity == null) { throw new VTException(errCode, errMsg); } errCode = "GT-8492"; errMsg = "无法根据期货商品代码获取其对应的持仓限制。"; int year; int month; try { FutureService.GetAgreementTime(code, out year, out month); } catch (Exception ex) { throw new VTException(errCode, errMsg, ex); } DateTime now = DateTime.Now; errCode = "GT-8493"; errMsg = code + "合约已经过期。"; positionValueType = Types.QHPositionValueType.Scales; //合约已过期 if (year < now.Year) { throw new VTException(errCode, errMsg); } //本年度合约 if (year == now.Year) { //合约已过期 if (month < now.Month) { throw new VTException(errCode, errMsg); } return(ProcessCurrentYear(code, year, month, out positionValueType)); } //下年度合约 if (year > now.Year) { return(ProcessNextYear(code, year, month, out positionValueType)); } PositionLimitValueInfo info = new PositionLimitValueInfo(); info.PositionValue = -1; info.IsMinMultiple = false; info.MinMultipleValue = 0; //return -1; return(info); }
/// <summary> /// 期货代码更新 /// Update by: 董鹏 /// Update Date: 2010-03-10 /// Desc: 使用代码规则管理器生成代码 /// </summary> /// <param name="breedclass">品种ID</param> /// <param name="LastTradingDayEntity">期货最后交易日实体</param> public void QHCodeUpdata(int breedclass, QH_LastTradingDay LastTradingDayEntity) { try { //根据品种ID,找到品种的代码名称 string QH_Prefixname = GetQH_PrefixCodeByID(breedclass); //根据品种ID,找到品种的名称 string QH_breedclassName = GetBreedClassNameByID(breedclass); //根据品种获取交易所 CM_BreedClassBLL bc = new CM_BreedClassBLL(); CM_BourseTypeBLL bt = new CM_BourseTypeBLL(); var bourseType = bt.GetModel(bc.GetModel(breedclass).BourseTypeID.Value); //创建代码规则管理 CodeRulesManager codeRule; if (bourseType.CodeRulesType.HasValue) { LogHelper.WriteDebug("===开始自动生成代码,代码规则类型:" + bourseType.CodeRulesType.ToString()); codeRule = new CodeRulesManager((Types.CodeRulesType)bourseType.CodeRulesType.Value); } else { LogHelper.WriteDebug("===开始自动生成代码,没有获取到交易所对应的代码规则,交易所:" + bourseType.BourseTypeName); codeRule = new CodeRulesManager(null); } CM_CommodityDAL CommodityDAL = new CM_CommodityDAL(); RC_TradeCommodityAssignDAL TradeCommodityAssignDAL = new RC_TradeCommodityAssignDAL(); string Old_QH_codename; string New_QH_codename; if ((int)LastTradingDayEntity.LastTradingDayTypeID == (int)Types.QHLastTradingDayType.DeliMonthAgoMonthLastTradeDay) { //Old_QH_codename = QH_Prefixname + GetTwoLenYear(DateTime.Now) + // GetTwoLenMonth(DateTime.Now.AddMonths(1)); //New_QH_codename = QH_Prefixname + GetTwoLenYear(DateTime.Now.AddYears(1)) + // GetTwoLenMonth(DateTime.Now.AddMonths(1)); //使用代码规则管理器生成代码 Old_QH_codename = codeRule.GetCode(QH_Prefixname, DateTime.Now.Year.ToString(), DateTime.Now.AddMonths(1).Month.ToString().PadLeft(2, '0')); New_QH_codename = codeRule.GetCode(QH_Prefixname, DateTime.Now.AddYears(1).Year.ToString(), DateTime.Now.AddMonths(1).Month.ToString().PadLeft(2, '0')); } else { //Old_QH_codename = QH_Prefixname + GetTwoLenYear(DateTime.Now) + GetTwoLenMonth(DateTime.Now); //New_QH_codename = QH_Prefixname + GetTwoLenYear(DateTime.Now.AddYears(1)) + // GetTwoLenMonth(DateTime.Now); //使用代码规则管理器生成代码 Old_QH_codename = codeRule.GetCode(QH_Prefixname, DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString().PadLeft(2, '0')); New_QH_codename = codeRule.GetCode(QH_Prefixname, DateTime.Now.AddYears(1).Year.ToString(), DateTime.Now.Month.ToString().PadLeft(2, '0')); } CM_Commodity CM_Commodity = CommodityDAL.GetModel(Old_QH_codename); if (CM_Commodity == null) { CM_Commodity = new CM_Commodity(); } CM_Commodity.CommodityCode = New_QH_codename; CM_Commodity.MarketDate = DateTime.Parse(System.DateTime.Now.AddDays(1).ToShortDateString()); //若第二天是非交易日则顺延一天 add by 董鹏 2010-03-31 while (!JudgmentIsTrandingDay(CM_Commodity.MarketDate, breedclass)) { CM_Commodity.MarketDate = CM_Commodity.MarketDate.AddDays(1); } //根据确认结果 期货名称等于期货代码 CM_Commodity.CommodityName = New_QH_codename;// QH_breedclassName + New_QH_codename.Substring(New_QH_codename.Length - 4); CM_Commodity.BreedClassID = breedclass; CM_Commodity.GoerScale = decimal.MaxValue; CM_Commodity.LabelCommodityCode = null; CM_Commodity.StockPinYin = null; CM_Commodity.turnovervolume = null; CM_Commodity.IsExpired = (int)Types.IsYesOrNo.No; //新增期货代码时,默认代码没有过期 CM_Commodity.ISSysDefaultCode = (int)Types.IsYesOrNo.Yes; //新增期货代码时,默认是系统代码 #region old //bool _result = CommodityDAL.Add(CM_Commodity); //if (!_result) //{ // LogHelper.WriteDebug("添加代码失败"); // return; //} ////更新代码分配表 //TradeCommodityAssignDAL.Update(Old_QH_codename, New_QH_codename); ////CommodityDAL.Delete(Old_QH_codename); ////根据2009-7-22需求过期代码添加标识 //int isExpired = (int)Types.IsYesOrNo.Yes;//旧代码状态设置为过期 //bool _resultUpdate = CommodityDAL.Update(Old_QH_codename, isExpired); //if (!_resultUpdate) //{ // LogHelper.WriteDebug("更新代码失败"); //} ////调用把期货新增的代码自动添加到可交易商品_撮合机_分配表中的方法 //QHCodeAutoRCTradeCommodityAssign(New_QH_codename, breedclass); #endregion //前面的bool值实际上没有用处,改为直接抛出异常,并增加日志记录 update by 董鹏 2010-03-31 LogHelper.WriteDebug("===生成新代码:" + New_QH_codename); //添加新代码 CommodityDAL.Add(CM_Commodity); LogHelper.WriteDebug("===更新代码分配表"); //更新代码分配表 TradeCommodityAssignDAL.Update(Old_QH_codename, New_QH_codename); LogHelper.WriteDebug("===设置代码过期:" + Old_QH_codename); //旧代码状态设置为过期 int isExpired = (int)Types.IsYesOrNo.Yes; CommodityDAL.Update(Old_QH_codename, isExpired); LogHelper.WriteDebug("===将代码添加到撮合机分配表中"); //如果新代码未分配,将代码添加到撮合机分配表中 QHCodeAutoRCTradeCommodityAssign(New_QH_codename, breedclass); LogHelper.WriteDebug("===新代码:" + New_QH_codename + "完成生成并分配到撮合机,旧代码:" + Old_QH_codename + "完成从撮合机分配表中移除并设为过期。"); } catch (Exception ex) { string errCode = "GL-7002"; string errMsg = "执行更新方法QHCodeUpdata()失败"; //VTException exception = new VTException(errCode, errMsg, ex); //LogHelper.WriteError(exception.ToString(), exception.InnerException); LogHelper.WriteError(errCode + ":" + errMsg, ex); } }
/// <summary> /// 获取合约保证金 /// </summary> /// <param name="code">合约代码</param> /// <returns>保证金比例</returns> public static decimal GetFutureBailScale(string code) { string errCode = "GT-8481"; string errMsg = code + "商品期货商品代码不存在。"; CM_Commodity commodity = MCService.CommonPara.GetCommodityByCommodityCode(code); if (commodity == null) { throw new VTException(errCode, errMsg); } if (commodity.BreedClassID.HasValue == false) { errMsg = "商品期货商品代码品种类型为null。"; throw new VTException(errCode, errMsg); } errCode = "GT-8482"; errMsg = "无法根据期货商品代码获取其对应的保证金比例。"; int year; int month; try { FutureService.GetAgreementTime(code, out year, out month); } catch (Exception ex) { throw new VTException(errCode, errMsg, ex); } DateTime now = DateTime.Now; errCode = "GT-8483"; errMsg = code + "合约已经过期。"; decimal bailScace = -1; ////合约已过期 //if (year < now.Year) //{ // throw new VTException(errCode, errMsg); //} //合约已经过期 if (FutureService.CheckQHContractIsExpired(code)) { LogHelper.WriteDebug("Debug_Test_Bail_001:合约已经过期正在按交割月份比例获取" + code + "保证金比例"); //过期合约直接返回交易割月份的其中一记录的比例,即按交易月份获取 //这是为了盘后清算在这样的需要 bailScace = ProcessCurrentYear(code, year, now.Month, now, commodity.BreedClassID.Value); return(bailScace); } #region 如果是正在清算的时候要调整这个区间值所以要把日期向后推 if (ScheduleManagement.ScheduleManager.IsFutureReckoning) { //每日收盘后,如果某期货合约在T+1日所处期间符合调整交易保证金要求的, //该期货合约的所有持仓在T+0日收盘结算时按照新的交易保证金标准收取相应的交易保证金。 //例如合约SR1011自交割月份前一个月第11日交易保证金由8%调整到15%, //则在第11日的前一个交易日收盘结算时就按照15%的保证金比例收取交易保证金。 #region 如果是正在清算的时候要调整这个区间值即 //如果当前正在清算并且是正在做故障恢复清算那么时间应该是做故障恢复清算的时间 if (ScheduleManagement.ScheduleManager.IsFaultRecoveryFutureReckoning) { now = ScheduleManagement.ScheduleManager.CurrentFaultRecoveryFutureReckoningDate; } now = FutureService.GetNowDayBackwardTradeDay(now, commodity.BreedClassID.Value); //当计算的日期回来是下一年的时候如当前2010-12-31那么1012这个合约的推算下一个交易日为11年1月份 //或者月份也超过了交割月也不用调整 //那么这时就不能再调整这个日期,直接按交割月当前日期计算即可 if (now.Year > year || now.Month > month) { now = DateTime.Now; } #endregion } #endregion //本年度合约 if (year == now.Year) { //合约已过期 if (month < now.Month) { throw new VTException(errCode, errMsg); } LogHelper.WriteDebug("Debug_Test_Bail_01:正在获取商品期货代码本年度合约" + code + "保证金比例"); bailScace = ProcessCurrentYear(code, year, month, now, commodity.BreedClassID.Value); LogHelper.WriteDebug("Debug_Test_Bail_End:获取到合约" + code + "保证金比例" + bailScace); return(bailScace); } //下年度合约 if (year > now.Year) { LogHelper.WriteDebug("Debug_Test_Bail_01:正在获取商品期货代码下年度合约" + code + "保证金比例"); bailScace = ProcessNextYear(code, year, month, now, commodity.BreedClassID.Value); LogHelper.WriteDebug("Debug_Test_Bail_End:获取到合约" + code + "保证金比例" + bailScace); return(bailScace); } LogHelper.WriteDebug("Debug_Test_Bail_End:合约" + code + "无类型保证金比例"); return(-1); }