using System; using System.Collections.Generic; using System.Linq; using System.Text; //---------------------------------------------------------------- //Module Name: $safeprojectname$ //Purpose: //CopyRight: Muchinfo //History: //---------------------------------------------------------------- //DateTime 2016/7/25 10:06:43 //Author //Description Create //---------------------------------------------------------------- using Muchinfo.MTPClient.Data; using Muchinfo.MTPClient.Data.Enums; using Muchinfo.MTPClient.Data.Model; using Muchinfo.MTPClient.Data.Model.Account; using Muchinfo.MTPClient.Data.Model.GoodRules; using Muchinfo.MTPClient.Infrastructure.Cache; using Muchinfo.MTPClient.Infrastructure.Utilities; using Muchinfo.MTPClient.Resources; namespace Muchinfo.MTPClient.Trade.ViewModels { public class MixTradeViewModel : BidTradeViewModel { public MixTradeViewModel(QuoteGoods goods, Direction direction) : base(goods, direction) { SetEntrustPriceRange(); } public MixTradeViewModel(QuoteGoods goods, OrderBase orderBase) : base(goods, orderBase) { SetEntrustPriceRange(); } /// /// 设置默认价格模式[读取数据库配置--设置] /// protected override void setDefaultPriceMode() { PriceMode = ePriceMode.PRICEMODE_LIMIT;//【客户需求】若商品为竞价模式,则默认成交的价格类型为“限价” if (ApplicationParameter.XMarketDefaultPriceMode == 0 && IsMarketPriceVisibity) { PriceMode = ePriceMode.PRICEMODE_MARKET; } } public override void PostOrder( Action successAction, Action errorAction) { var entrustOrder = BuildEntrustOrder(); entrustOrder.SLPrice = StopLossChecked ? StopLoss : 0; entrustOrder.SPPrice = StopProfitChecked ? StopProfit : 0; entrustOrder.CurtQuotePrice = Direction == Direction.Ask ? _currentGoods.AskPrice : _currentGoods.BidPrice; //限价平时,如果关联单号不为0,就改单&& SelectOrder != null && (SelectOrder.StopLoss > 0||SelectOrder.StopProfit > 0 #region 2.0 注销BY DK //if (entrustOrder.PriceMode == ePriceMode.PRICEMODE_LIMIT && this.OpenCloseMode == OpenCloseMode.BUILDTYPE_CLOSE && this.GoodsOrderMode == GoodsOrderMode.Order) //{ // //entrustOrder.RelationTicket = SelectOrder.OrderID; // entrustOrder.BuildType = OpenCloseMode.BUILDTYPE_CLOSETHENOPEN; // entrustOrder.BuyOrSell = SelectOrder.Direction; //} //if (entrustOrder.BuildType == OpenCloseMode.BUILDTYPE_CLOSETHENOPEN) //{ // _orderService.MixModifyEntrustOrder(entrustOrder, successAction, errorAction); //} //else //{ // // _orderService.MixMarketEntrustOrder(entrustOrder, successAction, errorAction); // _orderService.MakeMarketEntrustOrder(entrustOrder, successAction, errorAction); //} #endregion } public override bool IsShowRaiseFall { get { if (this.CurrentGoods==null) { return false; } else { return !this.CurrentGoods.IsQuoteValid; } } } public override bool IsMarketPriceVisibity { get { var result= ApplicationParameter.XMarketShowMarketPrice == 1; return result; } } /// /// 是否可以修改数量-即期-限价-平仓-不支持部分平仓 /// public override bool IsEnableChangeLot { get { if (PriceMode == ePriceMode.PRICEMODE_LIMIT && this.GoodsOrderMode == GoodsOrderMode.Order) { return false; } else { return true; } } } /// /// 是否可按商品平仓 (不可按商品平仓) /// //public override bool IsCanGoodsEdit //{ // get // { // return this.PriceMode == ePriceMode.PRICEMODE_MARKET; // } //} /// /// 设置计算数量价格 /// /// protected override decimal OrderPriceSetting() { var price = ExecutePrice; if (IsShowRaiseFall) { price = base.OrderPriceSetting(); } else { if (PriceMode == ePriceMode.PRICEMODE_MARKET) { #region 市价:买一价卖一价 price = decimal.Zero; if (BidCommissions != null && Direction == Direction.Ask) { price = BidCommissions.Find(x => x.Index == 1).Price; //卖跌停价//买一价 } if (AskCommissions != null && Direction == Direction.Bid) { price = AskCommissions.Find(x => x.Index == 1).Price; //卖跌停价//卖一价 } #endregion if (price == decimal.Zero) { price = CurrentGoods.LastClose; ////取昨收价 } } } return price; } public override bool IsStopPLVsb { get { return this.PriceMode == ePriceMode.PRICEMODE_LIMIT && (this.OpenCloseMode ==OpenCloseMode.BUILDTYPE_OPEN || this.OpenCloseMode==OpenCloseMode.BUILDTYPE_CLOSE && this.GoodsOrderMode == GoodsOrderMode.Order); } } /// /// 是否显示价格项 /// public override bool IsExecutePriceVbs { get { if (PriceMode == ePriceMode.PRICEMODE_MARKET) { return false; } else { return !(OpenCloseMode == OpenCloseMode.BUILDTYPE_CLOSE && this.GoodsOrderMode == GoodsOrderMode.Order); } } } public override ePriceMode PriceMode { get { return _priceMode; } set { Set(() => PriceMode, ref _priceMode, value); DefautEntrustPrice(); CheckedVisibleEnable(); SetMinMaxQtyVaule(); //设置数量 } } #region 止盈止损 /// /// 建仓方向 /// public bool IsBidDirection { get { if (OpenCloseMode == OpenCloseMode.BUILDTYPE_CLOSE) ////平仓的持仓方向 { return Direction == Direction.Ask; } else { return Direction == Direction.Bid; } } } /// /// 止盈跟据买卖设置符号方向 /// public string ProfitChar { get { if (IsBidDirection) { // StopProfit = (decimal)(MaxProfit - (decimal)PriceMinUnit); // StopLoss = (decimal)(MaxLoss + (decimal)PriceMinUnit); return "≥";//">"; } else { return "≤";//"<"; // StopProfit = (decimal)(MaxProfit + (decimal)PriceMinUnit); // StopLoss = (decimal)(MaxLoss - (decimal)PriceMinUnit); } } } /// /// 止损跟据买卖设置符号方向 /// public string LossChar { get { if (IsBidDirection) { return "≤";//"<"; } else { return "≥";//">"; } } } //private decimal _maxLoss; //private decimal _maxProfit; private decimal _stopLoss; /// /// StopLossChecked /// private bool _stopLossChecked; private decimal _stopProfit; /// /// StopProfitChecked /// private bool _stopProfitChecked; /// /// Sets and gets the StopLoss property. /// Changes to that property's value raise the PropertyChanged event. /// public decimal StopLoss { get { return _stopLoss; } set { Set(() => StopLoss, ref _stopLoss, value); RaisePropertyChanged(() => StopLossPips); } } /// /// 止损点数 /// public string StopLossPips { get { if (_stopLoss == 0 || PipsPrice == 0) { return "-"; } if (IsBidDirection) { return (int)((_stopLoss - PipsPrice) * GetBasePips()) + string.Empty; } else { return (int)((PipsPrice - _stopLoss) * GetBasePips()) + string.Empty; } } } /// /// Sets and gets the StopLossChecked property. /// Changes to that property's value raise the PropertyChanged event. /// public bool StopLossChecked { get { return _stopLossChecked; } set { Set(() => StopLossChecked, ref _stopLossChecked, value); // StopLoss = _stopLossChecked ? ExecutePrice : 0; //StopLoss = _stopProfitChecked ? 0 : 0; if (IsBidDirection) { StopLoss = (decimal)(MaxLoss - MinUint); } else { StopLoss = (decimal)(MaxLoss + MinUint); } //StopLoss = _stopProfitChecked ? 0 : 0; } } /// /// Sets and gets the StopProfit property. /// Changes to that property's value raise the PropertyChanged event. /// public decimal StopProfit { get { return _stopProfit; } set { Set(() => StopProfit, ref _stopProfit, value); RaisePropertyChanged(() => StopProfitPips); } } /// /// 止盈点数 /// public string StopProfitPips { get { if (_stopProfit == 0 || PipsPrice == 0) { return "-"; } if (IsBidDirection) { return (int)((_stopProfit - PipsPrice) * GetBasePips()) + string.Empty; } else { return (int)((PipsPrice - _stopProfit) * GetBasePips()) + string.Empty; } } } /// /// Sets and gets the StopProfitChecked property. /// Changes to that property's value raise the PropertyChanged event. /// public bool StopProfitChecked { get { return _stopProfitChecked; } set { Set(() => StopProfitChecked, ref _stopProfitChecked, value); // StopProfit = _stopProfitChecked ? ExecutePrice : 0; if (IsBidDirection) { StopProfit = (decimal)(MaxProfit + MinUint); } else { StopProfit = (decimal)(MaxProfit - MinUint); } } } public decimal MinUint { get { int temp = 0; if (this._currentGoods != null && this._currentGoods.GoodsParameters != null) { temp = _currentGoods.GoodsParameters.HqExchFigures; } return Convert.ToDecimal(1 / Math.Pow(10, temp)); } } /// /// 以点数计算 /// /// private decimal GetBasePips() { int temp = 0; if (this._currentGoods != null && this._currentGoods.GoodsParameters != null) { temp = _currentGoods.GoodsParameters.HqExchFigures; } return Convert.ToDecimal(Math.Pow(10, temp)); } /// 设置最大止损价 /// public decimal MaxLoss { get; set; } /// /// 格式化最大止损价 /// public string DisplayMaxLoss { get { return MaxLoss.ToString(_currentGoods.FormatPrice); } } /// /// 格式化最大止盈价 /// public string DisplayMaxProfit { get { return MaxProfit.ToString(_currentGoods.FormatPrice); } } /// /// 设置最大止盈价 /// public decimal MaxProfit { get; set; } private decimal _maxLimit; /// /// 限价最大值 /// public decimal MaxLimit { get { return _maxLimit; } set { Set(() => MaxLimit, ref _maxLimit, value); RaisePropertyChanged(() => DisplayMaxLimit); } } /// /// 格式化 限价最大值 /// public string DisplayMaxLimit { get { if (MaxLimit <= 0) { return "-"; } return MaxLimit.ToString(_currentGoods.FormatPrice); } } private decimal _minLimit; /// /// 限价最小值 /// public decimal MinLimit { get { return _minLimit; } set { Set(() => MinLimit, ref _minLimit, value); RaisePropertyChanged(() => DisplayMinLimit); } } /// /// 格式化 限价最小值 /// public string DisplayMinLimit { get { if (MinLimit <= 0) { return "-"; } return MinLimit.ToString(_currentGoods.FormatPrice); } } private decimal _pipsPrice; /// /// 计算点数价格 /// public decimal PipsPrice { get { return _pipsPrice; } set { _pipsPrice = value; RaisePropertyChanged(() => StopLossPips); RaisePropertyChanged(() => StopProfitPips); } } public override decimal ExecutePrice { get { return _executePrice; } set { Set(() => ExecutePrice, ref _executePrice, value); SetProfitLoss(); SetMinMaxQtyVaule(); } } public override GoodsOrderMode GoodsOrderMode { get { return _goodsOrderMode; } set { if (value == GoodsOrderMode.unSet) { return; } // var needInit = value != _goodsOrderMode; Set(() => GoodsOrderMode, ref _goodsOrderMode, value); CheckedVisibleEnable(); SetMinMaxQtyVaule(); //设置数量 //if (needInit) //{ // SetInitVaules(); //} } } /// /// 是否可显示人价格范围 默认不显示 /// public override bool IsPriceRangeVsb { get { if (_currentGoods == null || _currentGoods.AskPrice == 0 || _currentGoods.BidPrice == 0) { return false; } return this.PriceMode == ePriceMode.PRICEMODE_LIMIT && (this.OpenCloseMode == OpenCloseMode.BUILDTYPE_OPEN || (OpenCloseMode == OpenCloseMode.BUILDTYPE_CLOSE && GoodsOrderMode == GoodsOrderMode.Goods));//|| OpenCloseMode == OpenCloseMode.BUILDTYPE_CLOSETHENOPEN } } public void SetProfitLoss() { MaxProfit = GetProfit(); MaxLoss = GetLoss(); RaisePropertyChanged(() => ProfitChar); RaisePropertyChanged(() => LossChar); RaisePropertyChanged(() => DisplayMaxProfit); RaisePropertyChanged(() => DisplayMaxLoss); SetEntrustPriceRange(); PipsPrice = this.OpenCloseMode == OpenCloseMode.BUILDTYPE_CLOSE && SelectOrder !=null? SelectOrder.HoldingPrice : ExecutePrice; } //下限价买建仓单时,止损价 < 委托价-(买点差-卖点差+止损卖点差) * 最小变动单位; //下限价卖建仓单时,止损价 > 限价 - (卖点差-买点差-止损买点差)* 最小变动单位。 ///// ///// 限价止盈买点差 ///// //TRADERULE_XLIMITSPBUYPT = 4705, ///// ///// 限价止盈卖点差 ///// //TRADERULE_XLIMITSPSELLPT = 4706, /// /// 获取止盈价 /// /// private decimal GetProfit() { if (this.OpenCloseMode == OpenCloseMode.BUILDTYPE_OPEN )//|| this.OpenCloseMode == OpenCloseMode.BUILDTYPE_CLOSETHENOPEN) { #region 建仓 if (this.Direction == Direction.Bid) { //止损价 < 限价-(买点差-卖点差+止损卖点差) * 最小变动单位 // _currentGoods.GoodsParameters.GoodsStatus != GoodsStatusType.Open if (_currentGoods == null || _currentGoods.GoodsParameters == null) return 0; if (_currentGoods.GoodsParameters.HqExchFigures < 20 && _currentGoods.GoodsParameters.HqExchFigures > -20) { // ||_orderQuoteGoods.GoodsParameters.GoodsStatus != GoodsStatusType.Open var ptSubObj = CacheManager.GetTradeRule((int)_currentGoods.GoodsId, (int)eTradeRule.TRADERULE_SPPT); var ptSub = ptSubObj == null ? 0 : ptSubObj.FeeValue; var value = ( ptSub) / (decimal) Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures); return (_executePrice + value); } return _executePrice; } else { //止损价 > 限价 -(卖点差-买点差-止损买点差)* 最小变动单位 //_currentGoods.GoodsParameters.GoodsStatus != GoodsStatusType.Open if (_currentGoods == null || _currentGoods.GoodsParameters == null) return 0; var ptSubObj = CacheManager.GetTradeRule((int)_currentGoods.GoodsId, (int)eTradeRule.TRADERULE_SPPT); var ptSub = ptSubObj == null ? 0 : ptSubObj.FeeValue; if (_currentGoods.GoodsParameters.HqExchFigures < 20 && _currentGoods.GoodsParameters.HqExchFigures > -20) { var value = ( ptSub) / (decimal) Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures); return (_executePrice - value); } return _executePrice; } #endregion } else { //if (this.SelectOrder != null) //{ // return this.SelectOrder.HoldingPrice; //} //return _currentGoods.CurrentPrice; bool flag = _currentGoods.GoodsParameters.HqExchFigures < 20 && _currentGoods.GoodsParameters.HqExchFigures > -20; if (this.Direction == Direction.Ask) { //止盈价 > 买价 + (止盈点差 * 最小变动单位) //止盈价 >= 买价 + (止盈卖点差 * 最小变动单位) // ||_orderQuoteGoods.GoodsParameters.GoodsStatus != GoodsStatusType.Open var buyptSub = CacheManager.GetTradeRule((int)_currentGoods.GoodsId, (int)eTradeRule.TRADERULE_SPPT); var ptSub = buyptSub == null ? 0 : buyptSub.FeeValue; return _currentGoods.BidPrice + (flag ? ptSub / (decimal)Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures) : 0); } else { //止盈价 < 卖价 - (止盈点差 * 最小变动单位) //止盈价 <= 卖价 - (止盈买点差 * 最小变动单位) //||_orderQuoteGoods.GoodsParameters.GoodsStatus != GoodsStatusType.Open var sellptSub = CacheManager.GetTradeRule((int)_currentGoods.GoodsId, (int)eTradeRule.TRADERULE_SPPT); var ptSub = sellptSub == null ? 0 : sellptSub.FeeValue; return _currentGoods.AskPrice - (flag ? ptSub / (decimal) Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures) : 0); } } } // TRADERULE_XLIMITSLBUYPT = 4703, ///// ///// 限价止损卖点差 ///// //TRADERULE_XLIMITSLSELLPT = 4704, /// /// 获取止损价 /// /// private decimal GetLoss() { if (this.OpenCloseMode == OpenCloseMode.BUILDTYPE_OPEN )//|| this.OpenCloseMode == OpenCloseMode.BUILDTYPE_CLOSETHENOPEN) { #region 建仓 if (this.Direction == Direction.Bid) { //止损价 < 限价-(买点差-卖点差+止损卖点差) * 最小变动单位 // _currentGoods.GoodsParameters.GoodsStatus != GoodsStatusType.Open if (_currentGoods == null || _currentGoods.GoodsParameters == null) return 0; if (_currentGoods.GoodsParameters.HqExchFigures < 20 && _currentGoods.GoodsParameters.HqExchFigures > -20) { // ||_orderQuoteGoods.GoodsParameters.GoodsStatus != GoodsStatusType.Open var ptSubObj = CacheManager.GetTradeRule((int)_currentGoods.GoodsId, (int)eTradeRule.TRADERULE_SPPT); var ptSub = ptSubObj == null ? 0 : ptSubObj.FeeValue; var value = ( ptSub) / (decimal) Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures); return (_executePrice - value); } return _executePrice; } else { //止损价 > 限价 -(卖点差-买点差-止损买点差)* 最小变动单位 //_currentGoods.GoodsParameters.GoodsStatus != GoodsStatusType.Open if (_currentGoods == null || _currentGoods.GoodsParameters == null) return 0; var ptSubObj = CacheManager.GetTradeRule((int)_currentGoods.GoodsId, (int)eTradeRule.TRADERULE_SPPT); var ptSub = ptSubObj == null ? 0 : ptSubObj.FeeValue; if (_currentGoods.GoodsParameters.HqExchFigures < 20 && _currentGoods.GoodsParameters.HqExchFigures > -20) { var value = ( ptSub) / (decimal) Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures); return (_executePrice + value); } return _executePrice; } #endregion } else { bool flag = _currentGoods.GoodsParameters.HqExchFigures < 20 && _currentGoods.GoodsParameters.HqExchFigures > -20; if (this.Direction == Direction.Ask) { //止损价 < =卖价 - (止损卖点差 * 最小变动单位) //||_orderQuoteGoods.GoodsParameters.GoodsStatus != GoodsStatusType.Open var ptSubObj = CacheManager.GetTradeRule((int)_currentGoods.GoodsId, (int)eTradeRule.TRADERULE_SPPT); var ptSub = ptSubObj == null ? 0 : ptSubObj.FeeValue; return (_currentGoods.BidPrice - (flag ? ptSub / (decimal)Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures) : 0)); } else { //止损价 > =买价 + (止损买点差 * 最小变动单位) //||_orderQuoteGoods.GoodsParameters.GoodsStatus != GoodsStatusType.Open var ptSubObj = CacheManager.GetTradeRule((int)_currentGoods.GoodsId, (int)eTradeRule.TRADERULE_SPPT); var ptSub = ptSubObj == null ? 0 : ptSubObj.FeeValue; return (_currentGoods.AskPrice + (flag ? ptSub / (decimal)Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures) : 0)); } } } /// /// 设置限价的范围 /// protected override void SetEntrustPriceRange() { if (_currentGoods != null && _currentGoods.GoodsParameters != null) { RaisePropertyChanged(()=>IsPriceRangeVsb); bool flag = _currentGoods.GoodsParameters.HqExchFigures < 20 && _currentGoods.GoodsParameters.HqExchFigures > -20; GoodsFeeType foodsfeeType; if (this.OpenCloseMode == OpenCloseMode.BUILDTYPE_OPEN)// || this.OpenCloseMode == OpenCloseMode.BUILDTYPE_CLOSETHENOPEN) { foodsfeeType = CacheManager.GetTradeRule((int) _currentGoods.GoodsId, (int)(Direction==Direction.Ask? eTradeRule.TRADERULE_SLPT:eTradeRule.TRADERULE_SPPT)); if (Direction == Direction.Ask) { //限价 》 限价上限(max(买价, 卖价) + 限价卖点差*最小变动单位) //限价 《 限价下限(min(买价, 卖价) - 限价卖点差*最小变动单位) var ptSub = foodsfeeType == null ? 0 : foodsfeeType.FeeValue; MinLimit = _currentGoods.BidPrice; //Math.Max(_currentGoods.BidPrice, _currentGoods.AskPrice); // MinLimit = Math.Min(_currentGoods.BidPrice, _currentGoods.AskPrice) - _currentGoods.GoodsParameters.LimitOpenSellptSub / (decimal) //EntructPriceRange = QuotePrice - // _currentGoods.GoodsParameters.LimitOpenSellptSub / (decimal) // Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures); MaxLimit = _currentGoods.BidPrice + (flag ? ptSub / (decimal) Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures) : 0); } else { // 限 价 >= 【卖一价】 或 =< 【卖一价 - (限价买入买点差*最小变动单位)】 var ptSub = foodsfeeType == null ? 0 : foodsfeeType.FeeValue; MinLimit = _currentGoods.AskPrice-(flag ? ptSub / (decimal) Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures) : 0) ; MaxLimit = _currentGoods.AskPrice; } } else { foodsfeeType = CacheManager.GetTradeRule((int) _currentGoods.GoodsId, (Direction==Direction.Ask? 4708:4707)); if (Direction == Direction.Bid) { //限价 》 限价上限(max(买价, 卖价) + 限价卖点差*最小变动单位) //限价 《 限价下限(min(买价, 卖价) - 限价卖点差*最小变动单位) var ptSub = foodsfeeType == null ? 0 : foodsfeeType.FeeValue; MaxLimit = _currentGoods.AskPrice; //Math.Max(_currentGoods.BidPrice, _currentGoods.AskPrice); // MinLimit = Math.Min(_currentGoods.BidPrice, _currentGoods.AskPrice) - _currentGoods.GoodsParameters.LimitOpenSellptSub / (decimal) //EntructPriceRange = QuotePrice - // _currentGoods.GoodsParameters.LimitOpenSellptSub / (decimal) // Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures); MinLimit = _currentGoods.AskPrice - (flag ? ptSub / (decimal) Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures) : 0); } else { //限价 》 限价上限(max(买价, 卖价) + 限价买点差 * 最小变动单位) //限价 《 限价下限(min(买价, 卖价) - 限价买点差 * 最小变动单位) var ptSub = foodsfeeType == null ? 0 : foodsfeeType.FeeValue; MaxLimit = (flag ? ptSub / (decimal) Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures) : 0) + _currentGoods.BidPrice; MinLimit = _currentGoods.BidPrice; } } } //if (flag) //{ // PriceMinUnit = 1 / Math.Pow(10, _currentGoods.GoodsParameters.HqExchFigures); //} } public override void CheckedVisibleEnable() { base.CheckedVisibleEnable(); if (_priceMode == ePriceMode.PRICEMODE_LIMIT && OpenCloseMode == OpenCloseMode.BUILDTYPE_CLOSE&&_goodsOrderMode==GoodsOrderMode.Order) //限价只能按单平 { ////设置原止损止盈 if (SelectOrder != null) { StopLossChecked = SelectOrder.StopLoss > 0;///设置了止损 this.StopLoss = SelectOrder.StopLoss; StopProfitChecked = SelectOrder.StopProfit > 0;///设置了止损 this.StopProfit = SelectOrder.StopProfit; } SetProfitLoss(); } } /// /// 设置平仓最大最小数量 /// protected override void SetCloseQty() { var minQty = _goodsService.GetGoodsParamerRule((int)_currentGoods.GoodsId, _currentGoods.TradeMode, GoodsTradeConts.MINOPENTRADEQTY); MinLot = minQty == null ? defaut_minLot : minQty.FeeValue; decimal tempMaxLot = CalcAvailCloseQty(); //按单平仓 if (this.GoodsOrderMode == GoodsOrderMode.Order) { MaxLot = SelectOrder == null || !SelectOrder.IsCanClose ? 0 : SelectOrder.AvailQty; if (this.PriceMode == ePriceMode.PRICEMODE_LIMIT) { MaxLot = Math.Min(tempMaxLot, MaxLot); Lot = MaxLot; //#23420 投资者下做市商品的持仓,P+X交割申报配对成功,冻结头寸成功,选择做市商品进行限制平仓,报错:3093[头寸不足] } //MaxLot = SelectOrder == null || !SelectOrder.IsCanClose ? 0 : SelectOrder.AvailQty; ////未达持仓天数,不可平 //MaxLot = Math.Min(tempMaxLot, MaxLot); } else { //按寸头平仓 MaxLot = tempMaxLot; } } #endregion public override bool Validated(ref string msg) { if (!base.Validated(ref msg)) { return false; } bool isProfitLoss = false; if (PriceMode==ePriceMode.PRICEMODE_LIMIT) { if (OpenCloseMode != OpenCloseMode.BUILDTYPE_CLOSE) { if (IsShowRaiseFall&&(ExecutePrice > this.UpPrice || ExecutePrice < LowPrice)) { msg = Client_Resource.ExecutePrice_IsNotInRaiseFallRange; return false; } isProfitLoss = true; if (ExecutePrice > MinLimit && ExecutePrice < MaxLimit) { msg = Client_Resource.ErrorEntrustPrice; return false; } } else { if (GoodsOrderMode == GoodsOrderMode.Order) { isProfitLoss = true; if (!StopProfitChecked && !StopLossChecked) { msg = Client_Resource.xmacth_stopProfitLossSetError; return false; } } else { if (ExecutePrice > MinLimit && ExecutePrice < MaxLimit) { msg = Client_Resource.ErrorEntrustPrice; return false; } } } if (isProfitLoss && StopProfitChecked) ////止盈 { //止盈 if (!this.IsBidDirection) { if (this.StopProfit > this.MaxProfit) { msg = Muchinfo.MTPClient.Resources.Client_Resource.Trade_ProfitIsOut; return false; } } else { if (this.StopProfit < this.MaxProfit) { msg = Muchinfo.MTPClient.Resources.Client_Resource.Trade_ProfitIsOut; return false; } } if (this.StopProfit <= 0) { msg = Muchinfo.MTPClient.Resources.Client_Resource.Trade_ProfitLessThanZero; return false; } if (IsShowRaiseFall && (StopProfit > this.UpPrice || StopProfit < LowPrice)) { msg = Client_Resource.ProfitPrice_IsNotInRaiseFallRange; return false; } } if (isProfitLoss && StopLossChecked) ////止损 { if (!this.IsBidDirection) { if (this.StopLoss < this.MaxLoss) { msg = Muchinfo.MTPClient.Resources.Client_Resource.Trade_StopIsOut; return false; } } else { if (this.StopLoss > this.MaxLoss) { msg = Muchinfo.MTPClient.Resources.Client_Resource.Trade_StopIsOut; return false; } } if (this.StopLoss <= 0) { msg = Muchinfo.MTPClient.Resources.Client_Resource.Trade_StopLessThanZero; return false; } if (IsShowRaiseFall && (StopLoss > this.UpPrice || StopLoss < LowPrice)) { msg = Client_Resource.LossPrice_IsNotInRaiseFallRange; return false; } } } return true; } } }