/// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                QH_SIFBail bail = new QH_SIFBail();
                if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                {
                    bail.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                }
                else
                {
                    ShowMessageBox.ShowInformation("请选择品种!");
                    this.cmbBreedClassID.Focus();
                    return;
                }

                if (InputTest.DecimalTest(this.txtMinScale.Text))
                {
                    bail.BailScale = Convert.ToDecimal(this.txtMinScale.Text);
                }
                else
                {
                    ShowMessageBox.ShowInformation("请输入数字!");
                    this.txtMinScale.Focus();
                    return;
                }

                bool result = FuturesManageCommon.AddQHCFMinScaleValue(bail);
                if (result)
                {
                    ShowMessageBox.ShowInformation("添加成功!");
                    FireSaved(this, new EventArgs());
                }
                else
                {
                    ShowMessageBox.ShowInformation("添加失败!");
                }
            }
            catch (Exception ex)
            {
                string      errCode   = "GL-6402";
                string      errMsg    = "设置商品期货_最低保证金比例失败!";
                VTException exception = new VTException(errCode, errMsg, ex);
                LogHelper.WriteError(exception.ToString(), exception.InnerException);
                return;
            }
        }
Пример #2
0
 /// <summary>
 /// 添加商品期货_最低保证金比例
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddQHCFMinScaleValue(QH_SIFBail model)
 {
     try
     {
         QH_SIFBailDAL bailDal = new QH_SIFBailDAL();
         if (bailDal.GetModel(model.BreedClassID) == null)
         {
             return(bailDal.Add(model));
         }
         else
         {
             return(bailDal.Update(model));
         }
     }
     catch (Exception ex)
     {
         string      errCode   = "GL-6600";
         string      errMsg    = "设置商品期货_保证金比例失败!";
         VTException exception = new VTException(errCode, errMsg, ex);
         LogHelper.WriteError(exception.ToString(), exception.InnerException);
         return(false);
     }
 }
Пример #3
0
        /// <summary>
        /// 通过持仓和保证金控制类型来获取具体的保证金比例
        /// </summary>
        /// <param name="values">保证金比例列表</param>
        /// <param name="findVal">类型值(持仓或者日期)</param>
        /// <param name="breedClassID">合约代码所属品种类型</param>
        /// <returns>保证金比例</returns>
        private static decimal GetScale(IList <QH_CFBailScaleValue> values, decimal findVal, int breedClassID)
        {
            QH_CFBailScaleValue scaleValue = null;

            //不用再过滤直接,因为之前的缓存已经作过处理
            //List<QH_CFBailScaleValue> lists = AssemblingFilterCFBail(values);
            // foreach (QH_CFBailScaleValue value in lists)
            foreach (QH_CFBailScaleValue value in values)
            {
                if (CheckScaleFieldRange(findVal, value))
                {
                    scaleValue = value;
                    break;
                }
            }
            QH_SIFBail sifBail = MCService.FuturesTradeRules.GetSIFBailByBreedClassID(breedClassID);

            if (sifBail == null)
            {
                LogHelper.WriteDebug("Debug_Test_Bail_05:无法获取最低交易保证金比例");
                return(-1);
            }
            LogHelper.WriteDebug("Debug_Test_Bail_05:获取最低交易保证金比例" + sifBail.BailScale);

            if (scaleValue == null)
            {
                LogHelper.WriteDebug("Debug_Test_Bail_06:无法获取保证金比例区间范围值,返回最低保证金");
                return(sifBail.BailScale);
            }
            if (scaleValue.BailScale.Value < sifBail.BailScale)
            {
                LogHelper.WriteDebug("Debug_Test_Bail_06:获取保证金比例区间范围值比最低保证金比例还低直接返回最低保证金比例");
            }

            return(scaleValue.BailScale.Value);
        }
        /// <summary>
        /// 添加商品期货_最低保证金比例
        /// </summary>
        /// <param name="model">商品期货_保证金比例实体</param>
        /// <returns></returns>
        public static bool AddQHCFMinScaleValue(QH_SIFBail model)
        {
            QH_CFBailScaleValueBLL qH_CFBailScaleValueBLL = new QH_CFBailScaleValueBLL();

            return(qH_CFBailScaleValueBLL.AddQHCFMinScaleValue(model));
        }
Пример #5
0
        /// <summary>
        /// 处理费交割月份的合约
        /// </summary>
        /// <param name="code">合约代码</param>
        /// <param name="year">合约年</param>
        /// <param name="month">合约月</param>
        /// <param name="compareDate">要比较的日期</param>
        /// <param name="breedClassID">合约代码所属品种类型</param>
        /// <returns>保证金比例</returns>
        private static decimal ProcessNonDeliveryMonth(string code, int year, int month, DateTime compareDate, int breedClassID)
        {
            string errCode = "GT-8482";
            string errMsg  = "无法根据期货商品代码获取其对应的保证金比例。";


            IList <QH_CFBailScaleValue> values = GetBailScaleValues(code, breedClassID);

            if (values == null || values.Count <= 0)
            {
                throw new VTException(errCode, errMsg);
            }

            IRealtimeMarketService service = RealTimeMarketUtil.GetRealMarketService(); //RealtimeMarketServiceFactory.GetService();
            //FutData futData = service.GetFutData(code);
            MerFutData merFutData = service.GetMercantileFutData(code);

            if (merFutData == null)
            {
                errMsg = "处理交割月合约保证金时无法获取行情。";
                throw new VTException(errCode, errMsg);
            }

            //持仓量
            decimal openInterest = (decimal)merFutData.OpenInterest;

            //判断当前月份是那种交割月份类型
            Types.QHCFPositionMonthType monthType = FutureService.CheckMonthType(year, month, compareDate);

            IList <QH_CFBailScaleValue> scaleValues;

            #region  前三个月交割月份
            //如果是前三
            if (monthType == Types.QHCFPositionMonthType.OnDeliAgoThreeMonth)
            {
                scaleValues = FindScaleValuesByMonthType(values, monthType);

                //是前三
                if (scaleValues.Count > 0)
                {
                    return(GetScaleByBailType(scaleValues, openInterest, compareDate, breedClassID));
                }

                //否则就是一般月份
                scaleValues = FindScaleValuesByMonthType(values, Types.QHCFPositionMonthType.GeneralMonth);
                if (scaleValues.Count > 0)
                {
                    return(GetScaleByBailType(scaleValues, openInterest, compareDate, breedClassID));
                }
            }
            #endregion

            #region 前二
            //如果是前二
            if (monthType == Types.QHCFPositionMonthType.OnDeliAgoTwoMonth)
            {
                scaleValues = FindScaleValuesByMonthType(values, monthType);

                //是前二
                if (scaleValues.Count > 0)
                {
                    return(GetScaleByBailType(scaleValues, openInterest, compareDate, breedClassID));
                }

                //否则就是一般月份
                scaleValues = FindScaleValuesByMonthType(values, Types.QHCFPositionMonthType.GeneralMonth);
                if (scaleValues.Count > 0)
                {
                    return(GetScaleByBailType(scaleValues, openInterest, compareDate, breedClassID));
                }
            }
            #endregion

            #region 前一

            //如果是前一
            if (monthType == Types.QHCFPositionMonthType.OnDeliAgoMonth)
            {
                scaleValues = FindScaleValuesByMonthType(values, monthType);

                //是前一
                if (scaleValues.Count > 0)
                {
                    return(GetScaleByBailType(scaleValues, openInterest, compareDate, breedClassID));
                }

                //否则就是一般月份
                scaleValues = FindScaleValuesByMonthType(values, Types.QHCFPositionMonthType.GeneralMonth);
                if (scaleValues.Count > 0)
                {
                    return(GetScaleByBailType(scaleValues, openInterest, compareDate, breedClassID));
                }
            }
            #endregion

            #region 一般月份
            //如果是一般月份
            if (monthType == Types.QHCFPositionMonthType.GeneralMonth)
            {
                scaleValues = FindScaleValuesByMonthType(values, monthType);

                //是一般月份
                if (scaleValues.Count > 0)
                {
                    return(GetScaleByBailType(scaleValues, openInterest, compareDate, breedClassID));
                }
            }
            #endregion

            #region 最低保证金
            QH_SIFBail sifBail = MCService.FuturesTradeRules.GetSIFBailByBreedClassID(breedClassID);
            if (sifBail == null)
            {
                LogHelper.WriteError("Debug_Test_Bail_ProcessNonDeliveryMonth_01:无法获取最低交易保证金比例", new Exception(""));
                return(-1);
            }
            else
            {
                LogHelper.WriteDebug("Debug_Test_Bail_ProcessNonDeliveryMonth_02:无对应的保证金比例区间范围值获取最低交易保证金比例" + sifBail.BailScale);

                return(sifBail.BailScale);
            }
            #endregion

            //return -1;
        }
Пример #6
0
        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (m_EditType == 1)
            {
                #region 添加操作
                try
                {
                    if (
                        FuturesManageCommon.ExistsSIFBail(
                            ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex) &&
                        FuturesManageCommon.ExistsSIFPosition(
                            ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex))
                    {
                        ShowMessageBox.ShowInformation("此品种的持仓限制和保证金已存在!");
                        return;
                    }
                    QH_SIFBail     qH_SIFBail     = new QH_SIFBail();
                    QH_SIFPosition qH_SIFPosition = new QH_SIFPosition();
                    if (!string.IsNullOrEmpty(this.txtUnilateralPositions.Text))
                    {
                        if (InputTest.intTest(this.txtUnilateralPositions.Text))
                        {
                            qH_SIFPosition.UnilateralPositions = Convert.ToInt32(this.txtUnilateralPositions.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入数字且第一位数不能为0!");
                            return;
                        }
                    }
                    else
                    {
                        //qH_SIFPosition.UnilateralPositions = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("请填单边持仓量!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                    {
                        qH_SIFBail.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    }
                    else
                    {
                        qH_SIFBail.BreedClassID = AppGlobalVariable.INIT_INT;
                    }
                    if (!string.IsNullOrEmpty(this.txtBailScale.Text))
                    {
                        if (InputTest.DecimalTest(this.txtBailScale.Text))
                        {
                            qH_SIFBail.BailScale = Convert.ToDecimal(this.txtBailScale.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                            return;
                        }
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("请填写保证金!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(this.cmbBreedClassID.Text))
                    {
                        qH_SIFPosition.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    }
                    else
                    {
                        qH_SIFPosition.BreedClassID = AppGlobalVariable.INIT_INT;
                    }
                    m_Result = FuturesManageCommon.AddQHSIFPositionAndQHSIFBail(qH_SIFPosition, qH_SIFBail);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("添加成功!");
                        this.ClearAll();
                        this.QueryQHSIFPositionAndBail();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("添加失败!");
                    }
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-6481";
                    string      errMsg    = "添加股指期货持仓限制和品种_股指期货_保证金失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }
                #endregion
            }
            else if (m_EditType == 2)
            {
                #region 修改操作
                try
                {
                    this.cmbBreedClassID.Enabled = false;
                    QH_SIFBail     qH_SIFBail     = new QH_SIFBail();
                    QH_SIFPosition qH_SIFPosition = new QH_SIFPosition();
                    if (m_BreedClassID == AppGlobalVariable.INIT_INT)
                    {
                        ShowMessageBox.ShowInformation("请选择更新数据!");
                        return;
                    }
                    //qH_FutureCosts.BreedClassID = m_BreedClassID;
                    qH_SIFBail.BreedClassID     = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    qH_SIFPosition.BreedClassID = ((UComboItem)this.cmbBreedClassID.SelectedItem).ValueIndex;
                    if (!string.IsNullOrEmpty(this.txtUnilateralPositions.Text))
                    {
                        if (InputTest.intTest(this.txtUnilateralPositions.Text))
                        {
                            qH_SIFPosition.UnilateralPositions = Convert.ToInt32(this.txtUnilateralPositions.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("请输入数字且第一位数不能为0!");
                            return;
                        }
                    }
                    else
                    {
                        // qH_SIFPosition.UnilateralPositions = AppGlobalVariable.INIT_INT;
                        ShowMessageBox.ShowInformation("请填单边持仓量!");
                        return;
                    }
                    if (!string.IsNullOrEmpty(this.txtBailScale.Text))
                    {
                        if (InputTest.DecimalTest(this.txtBailScale.Text))
                        {
                            qH_SIFBail.BailScale = Convert.ToDecimal(this.txtBailScale.Text);
                        }
                        else
                        {
                            ShowMessageBox.ShowInformation("格式不正确(只能包含数字和小数点)!");
                            return;
                        }
                    }
                    else
                    {
                        //qH_SIFBail.BailScale = AppGlobalVariable.INIT_DECIMAL;
                        ShowMessageBox.ShowInformation("请填写保证金!");
                        return;
                    }
                    m_Result = FuturesManageCommon.UpdateQHSIFPositionAndQHSIFBail(qH_SIFPosition, qH_SIFBail);
                    if (m_Result)
                    {
                        ShowMessageBox.ShowInformation("修改成功!");
                        this.ClearAll();
                    }
                    else
                    {
                        ShowMessageBox.ShowInformation("修改失败!");
                    }
                    this.QueryQHSIFPositionAndBail();
                }
                catch (Exception ex)
                {
                    string      errCode   = "GL-6482";
                    string      errMsg    = "修改股指期货持仓限制和品种_股指期货_保证金失败!";
                    VTException exception = new VTException(errCode, errMsg, ex);
                    LogHelper.WriteError(exception.ToString(), exception.InnerException);
                    return;
                }
                #endregion
            }
        }