コード例 #1
0
ファイル: USeSystemConfig.cs プロジェクト: handayu/TFS-WebKit
        public OrderMarginSetting Clone()
        {
            OrderMarginSetting setting = new OrderMarginSetting();

            setting.MaxUseRate = this.MaxUseRate;

            return(setting);
        }
コード例 #2
0
 // <summary>
 /// 获取保证金设定。
 /// </summary>
 /// <returns></returns>
 public OrderMarginSetting GetOrderMarginSetting()
 {
     Debug.Assert(m_systemSetting != null);
     lock (m_syncObj)
     {
         OrderMarginSetting setting = m_systemSetting.OrderMargin.Clone();
         return(setting);
     }
 }
コード例 #3
0
        /// <summary>
        /// 校验保证金。
        /// </summary>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        private bool VerifyMargin(ArbitrageOpenArgument openArg, out string errorMessage)
        {
            errorMessage = string.Empty;
            USeOrderDriver orderDriver = USeManager.Instance.OrderDriver;

            try
            {
                OrderMarginSetting marginSetting = USeManager.Instance.SystemConfigManager.GetOrderMarginSetting();
                USeFundDetail      fundDetail    = orderDriver.QueryFundDetailInfo();
                if (fundDetail == null)
                {
                    errorMessage = "查询资金信息失败";
                    return(false);
                }

                decimal evaluateMargin = EvaluateMargin(openArg);                                   // 评估当前开仓参数可能占用保证金

                decimal investorMaxUse = fundDetail.DynamicBenefit * marginSetting.MaxUseRate;      // 账户最大占用保证金
                decimal usedMargin     = USeManager.Instance.AutoTraderManager.CalculatUseMargin(); // 当前套利单占用保证金

                if (investorMaxUse < usedMargin + evaluateMargin)
                {
                    errorMessage = string.Format("套利单预计占用{0}保证金,当前账户占用保证金超出设定预警阀值", evaluateMargin.ToString("#,0"));
                    return(false);
                }

                if (fundDetail.Available < evaluateMargin)
                {
                    errorMessage = string.Format("套利单预计占用{0}保证金,当前账户可用余额不足", evaluateMargin.ToString("#,0"));
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
                errorMessage = "校验保证金失败";
                return(false);
            }
        }