using GalaSoft.MvvmLight.Messaging; using Muchinfo.MTPClient.Data.Enums; using Muchinfo.MTPClient.Resources; using System; using System.Windows.Media; using Newtonsoft.Json; using System.Collections.Generic; namespace Muchinfo.MTPClient.Data.Model { /// /// QuoteGoods类 /// public partial class QuoteGoods : Goods, ICloneable { #region Fields /// /// 卖价 /// private decimal _askPrice; /// /// 卖量 /// private long _askVolume; /// /// 均价 /// private decimal _averagePrice; /// /// 买价 /// private decimal _bidPrice; /// /// 买量 /// private long _bidVolume; ///// ///// 代码 ///// //private int _code; /// /// 现价 /// private decimal _currentPrice; /// /// 现量 /// private long _currentVolume; /// /// 时间 /// private DateTime _date; /// /// 日增仓 /// private decimal _dayAddPositions; /// /// 交收日 /// private DateTime _deliveryDate; /// /// 交易所名称 /// private string _exchangeName; /// /// 最高 /// private decimal _high; /// /// 内盘 /// private int _inSize; /// /// 昨收 /// private decimal _lastClose; /// /// 昨持仓量 /// private long _lastPositions; /// /// 昨结算 /// private decimal _lastSettlement; /// /// 最低 /// private decimal _low; /// /// 流通市值 /// private decimal _marketCapitalizations; /// /// 流通股本 /// private long _negotiableShares; /// /// 今开 /// private decimal _open; /// /// 外盘 /// private int _outSize; /// /// 持仓 /// private long _positions; /// /// 市盈率 /// private decimal _priceEarningRatio; /// /// 量比 /// private decimal _quantityRelativeRatio; /// /// 结算 /// private decimal _settlement; /// /// 分类名称 /// private string _sortName; /// /// 总股本 /// private long _totalEquity; /// /// 总额 /// private decimal _totalTurnover; /// /// 总量 /// private long _totalVolume; /// /// 成交额 /// private decimal _tradeTurnover; /// /// 换手率 /// private decimal _turnoverRate; /// /// 成交量 /// private long _volume; /// /// 委比 /// private double _weiBi; /// /// 委差 /// //private int _weiCha; private GoodsParameters _goodsParameters; #endregion Fields #region Constructors /// /// 实例化报价商品 /// /// 交易所代码 /// 商品代码 /// 报价分组 /// 报价分组 public QuoteGoods(string exchangeCode, string goodsCode, string goodshqCode, QuoteCategoryType category) : base(exchangeCode, goodsCode, goodshqCode) { this.Category = category; // Messenger.Default.Register(this, MessengerTokens.NotifyQuoteGoodsColorChanged, (flag) => { RaisePropertyChanged(() => IncreaseValue); RaisePropertyChanged(() => BidPriceColor); RaisePropertyChanged(() => AskPriceColor); RaisePropertyChanged(() => HighColor); RaisePropertyChanged(() => LowColor); RaisePropertyChanged(() => IncreaseValue); RaisePropertyChanged(() => IncreaseValueColor); RaisePropertyChanged(() => IncreasePercentColor); }); } #endregion Constructors #region Properties #region Public Properties /// /// 振幅 ((最高-最低)/昨收) /// public decimal Amplitude { get { if (_lastClose != 0) { return (_high - _low) / _lastClose; } else { return (_high - _low); } } } /// /// 卖价 /// public decimal AskPrice { get { return _askPrice; } set { Set(() => AskPrice, ref _askPrice, value); RaisePropertyChanged(() => AskPriceDisplay); RaisePropertyChanged(() => AskPriceColor); IsAskPriceBorder = !IsAskPriceBorder; } } /// /// 合约单位名称 /// public string AgreeUnitDisplay { get; set; } /// /// /// 查询回来的商品参数 /// public GoodsParameters GoodsParameters { get { return _goodsParameters; } set { _goodsParameters = value; } } /// /// 卖量 /// public long AskVolume { get { return _askVolume; } set { Set(() => AskVolume, ref _askVolume, value); RaisePropertyChanged(() => AskVolumeDisplay); } } /// /// 均价 /// public decimal AveragePrice { get { return _averagePrice; } set { Set(() => AveragePrice, ref _averagePrice, value); RaisePropertyChanged(() => AveragePriceDisplay); RaisePropertyChanged(() => AveragePriceColor); } } /// /// 买价 /// public decimal BidPrice { get { return _bidPrice; } set { Set(() => BidPrice, ref _bidPrice, value); RaisePropertyChanged(() => BidPriceDisplay); RaisePropertyChanged(() => BidPriceColor); IsBidPriceBorder = !IsBidPriceBorder; } } /// /// 买量 /// public long BidVolume { get { return _bidVolume; } set { Set(() => BidVolume, ref _bidVolume, value); RaisePropertyChanged(() => BidVolumeDisplay); } } /// /// 获取和设置报价商品分组 /// public QuoteCategoryType Category { get; set; } /// /// 现价/最新价 /// public decimal CurrentPrice { get { return _currentPrice; } set { Set(() => CurrentPrice, ref _currentPrice, value); RaisePropertyChanged(() => CurrentPriceDisplay); RaisePropertyChanged(() => IncreasePercentDisplay); RaisePropertyChanged(() => IncreaseValueDisplay); RaisePropertyChanged(() => IncreasePercentColor); RaisePropertyChanged(() => IncreaseValueColor); RaisePropertyChanged(() => CurrentPriceColor); RaisePropertyChanged(() => IncreaseValue); IsCurrentPriceBorder = !IsCurrentPriceBorder; } } /// /// 现量() /// public long CurrentVolume { get { return _currentVolume; } set { Set(() => CurrentVolume, ref _currentVolume, value); RaisePropertyChanged(() => CurrentVolumeDisplay); } } /// /// 时间 /// public DateTime Date { get { return _date; } set { Set(() => Date, ref _date, value); RaisePropertyChanged(() => DateDisplay); } } /// /// 日增仓 /// public decimal DayAddPositions { get { return _dayAddPositions; } set { Set(() => DayAddPositions, ref _dayAddPositions, value); RaisePropertyChanged(() => DayAddPositionsDisplay); } } /// /// 交收日 /// public DateTime DeliveryDate { get { return _deliveryDate; } set { Set(() => DeliveryDate, ref _deliveryDate, value); RaisePropertyChanged(() => DeliveryDateDisplay); } } /// /// 交易所名称 /// public string ExchangeName { get { return StringDisplay(_exchangeName); } set { Set(() => ExchangeName, ref _exchangeName, value); } } /// /// 最高 /// public decimal High { get { return _high; } set { Set(() => High, ref _high, value); RaisePropertyChanged(() => AmplitudeDisplay); RaisePropertyChanged(() => HighDisplay); RaisePropertyChanged(() => HighColor); } } /// /// 涨幅%((现价-昨收)/昨收) /// public decimal IncreasePercent { get { if (_lastClose != 0) { return (_currentPrice - _lastClose) / _lastClose; } return (_currentPrice - _lastClose); } } /// /// 涨跌(现价-昨收) /// public decimal IncreaseValue { get { var value = (_currentPrice - _lastClose); return value; } } /// /// 内盘 /// public int InSize { get { return _inSize; } set { Set(() => InSize, ref _inSize, value); RaisePropertyChanged(() => InSizeDisplay); } } /// /// 昨收 /// public decimal LastClose { get { return _lastClose; } set { Set(() => LastClose, ref _lastClose, value); RaisePropertyChanged(() => LastCloseDisplay); RaisePropertyChanged(() => AmplitudeDisplay); RaisePropertyChanged(() => IncreasePercentDisplay); RaisePropertyChanged(() => IncreasePercentColor); RaisePropertyChanged(() => IncreaseValueDisplay); RaisePropertyChanged(() => IncreaseValueColor); } } /// /// 昨持仓量 /// public long LastPositions { get { return _lastPositions; } set { Set(() => LastPositions, ref _lastPositions, value); RaisePropertyChanged(() => LastPositionsDisplay); RaisePropertyChanged(() => TurnoverRateDisplay); } } /// /// 昨结算 /// public decimal LastSettlement { get { return _lastSettlement; } set { Set(() => LastSettlement, ref _lastSettlement, value); RaisePropertyChanged(() => LastSettlementDisplay); } } private decimal _deliveryPrice; /// /// 交收价格 /// public decimal DeliveryPrice { get { return _deliveryPrice; } set { Set(() => DeliveryPrice, ref _deliveryPrice, value); RaisePropertyChanged(() => DeliveryPriceDisplay); } } /// /// 最低 /// public decimal Low { get { return _low; } set { Set(() => Low, ref _low, value); RaisePropertyChanged(() => AmplitudeDisplay); RaisePropertyChanged(() => LowDisplay); RaisePropertyChanged(() => LowColor); } } /// /// 流通市值 /// public decimal MarketCapitalizations { get { return _marketCapitalizations; } set { Set(() => MarketCapitalizations, ref _marketCapitalizations, value); RaisePropertyChanged(() => MarketCapitalizationsDisplay); } } /// /// 流通股本 /// public long NegotiableShares { get { return _negotiableShares; } set { Set(() => NegotiableShares, ref _negotiableShares, value); RaisePropertyChanged(() => NegotiableSharesDisplay); } } /// /// 今开 /// public decimal Open { get { return _open; } set { Set(() => Open, ref _open, value); RaisePropertyChanged(() => OpenDisplay); RaisePropertyChanged(() => OpenColor); } } /// /// 外盘 /// public int OutSize { get { return _outSize; } set { Set(() => OutSize, ref _outSize, value); RaisePropertyChanged(() => OutSizeDisplay); } } /// /// 持仓量 /// public long Positions { get { return _positions; } set { Set(() => Positions, ref _positions, value); RaisePropertyChanged(() => PositionsDisplay); } } /// /// 市盈率 /// public decimal PriceEarningRatio { get { return _priceEarningRatio; } set { Set(() => PriceEarningRatio, ref _priceEarningRatio, value); RaisePropertyChanged(() => PriceEarningRatioDisplay); } } /// /// 量比 /// public decimal QuantityRelativeRatio { get { return _quantityRelativeRatio; } set { Set(() => QuantityRelativeRatio, ref _quantityRelativeRatio, value); RaisePropertyChanged(() => QuantityRelativeRatioColor); } } /// /// 结算 /// public decimal Settlement { get { return _settlement; } set { Set(() => Settlement, ref _settlement, value); RaisePropertyChanged(() => SettlementDisplay); } } /// /// 分类 /// public string SortName { get { return StringDisplay(_sortName); } set { Set(() => SortName, ref _sortName, value); } } /// /// 总股本 /// public long TotalEquity { get { return _totalEquity; } set { Set(() => TotalEquity, ref _totalEquity, value); RaisePropertyChanged(() => TotalEquityDisplay); } } /// /// 总额 /// public decimal TotalTurnover { get { return _totalTurnover; } set { Set(() => TotalTurnover, ref _totalTurnover, value); RaisePropertyChanged(() => TotalTurnoverDisplay); } } /// /// 总量 /// public long TotalVolume { get { return _totalVolume; } set { Set(() => TotalVolume, ref _totalVolume, value); RaisePropertyChanged(() => TotalVolumeDisplay); RaisePropertyChanged(() => TurnoverRateDisplay); } } /// /// 总量是否变化 /// public bool IsChangedByTotalVolume { get; set; } /// /// 成交额 /// public decimal TradeTurnover { get { return _tradeTurnover; } set { Set(() => TradeTurnover, ref _tradeTurnover, value); RaisePropertyChanged(() => TradeTurnoverDisplay); } } /// /// 换手率 /// public decimal TurnoverRate { get { return _turnoverRate; } set { Set(() => TurnoverRate, ref _turnoverRate, value); } } /// /// 委比 /// public double WeiBi { get { double total = 0; for (int i = 0; i < BidList.Length && i < AskList.Length; i++) { total += BidList[i].Volume + AskList[i].Volume; } if (total == 0) { return 100; } _weiBi = WeiCha / total * 100; return _weiBi; } } /// /// 委差 /// public double WeiCha { get { double weiCha = 0d; for (int i = 0; i < BidList.Length && i < AskList.Length; i++) { weiCha += BidList[i].Volume - AskList[i].Volume; } return weiCha; } } #region yxw private Commission[] _bidList = new Commission[5] { new Commission(Direction.Bid), new Commission(Direction.Bid), new Commission(Direction.Bid), new Commission(Direction.Bid), new Commission(Direction.Bid) }; /// /// 买 /// [JsonIgnore] public Commission[] BidList { get { return _bidList; } set { _bidList = value; } } private Commission[] _askList = new Commission[5] { new Commission(Direction.Ask), new Commission(Direction.Ask), new Commission(Direction.Ask), new Commission(Direction.Ask), new Commission(Direction.Ask) }; /// /// 卖 /// [JsonIgnore] public Commission[] AskList { get { return _askList; } set { _askList = value; } } #endregion /// /// 商品来源(包含)类型之和 /// public int ContainsGoodsSrc { get; set; } #endregion Public Properties #endregion Properties #region Methods #region Public Methods /// /// 获取买卖档 /// /// 获取买档 /// 买卖排名 /// Commission. public Commission GetBidOrAsk(bool isAsk, int level) { level--; if (level < 0) { return null; } if (isAsk) { if (level >= AskList.Length) { return null; } return AskList[level]; } else { if (level >= BidList.Length) { return null; } return BidList[level]; } } /// /// 交易模式 /// public eTradeMode TradeMode { get; set; } /// /// 交易属性NEW 2.0 /// public eTradeProperty TradeProperty { get; set; } /// /// Gets the abbreviated. /// /// A val. /// The format string. /// System.String. public string GetAbbreviated(double aVal, string formatString = "") { string result = string.Empty; if (aVal.Equals(0)) { result = DefaultString; } var value = Math.Abs(aVal); if (value <= 999999) { result = value.ToString(); } else if (value <= 9999999) { result = System.Math.Round(((decimal)value / 10000), 2).ToString() + Client_Resource.Domain_TenThousand; } else if (value <= 99999999) { result = System.Math.Round(((decimal)value / 10000), 0).ToString() + Client_Resource.Domain_TenThousand; } else if (value <= 99999999999) { result = System.Math.Round(((decimal)value / 100000000), 2).ToString() + Client_Resource.Domain_OneHundredmillion; } else { result = System.Math.Round(((decimal)value / 100000000), 0).ToString() + Client_Resource.Domain_OneHundredmillion; } return result; } public string GetAbbreviatedEx(long aVal,bool defaultzero=true) { if (aVal == 0) { return defaultzero ? "0" : "-"; } else if (aVal <= 999999) { return aVal.ToString(); } else if (aVal <= 9999999) { return System.Math.Round(((decimal)aVal / 10000), 2).ToString() + Client_Resource.Domain_TenThousand; } else if (aVal <= 99999999) { return System.Math.Round(((decimal)aVal / 10000), 0).ToString() + Client_Resource.Domain_TenThousand; } else if (aVal <= 99999999999) { return System.Math.Round(((decimal)aVal / 100000000), 2).ToString() + Client_Resource.Domain_OneHundredmillion; } else { return System.Math.Round(((decimal)aVal / 100000000), 0).ToString() + Client_Resource.Domain_OneHundredmillion; } } /// /// Gets the abbreviated. /// /// A val. /// The format string. /// System.String. public string GetAbbreviated(decimal aVal, string formatString = "") { return GetAbbreviated((double)aVal, formatString); } /// /// 更新对象属性值(只更新需要字段) /// /// The item. public void UpdateFrom(QuoteGoods item, bool IsHistory) { double decimalPlace = (double)this.DecimalPlaces; item.CurrentPrice = decimal.Multiply(item.CurrentPrice, (decimal)Math.Pow(0.1, decimalPlace)); item.BidPrice = decimal.Multiply(item.BidPrice, (decimal)Math.Pow(0.1, decimalPlace)); item.AskPrice = decimal.Multiply(item.AskPrice, (decimal)Math.Pow(0.1, decimalPlace)); item.BidList[0].Price = decimal.Multiply(item.BidList[0].Price, (decimal)Math.Pow(0.1, decimalPlace)); item.BidList[1].Price = decimal.Multiply(item.BidList[1].Price, (decimal)Math.Pow(0.1, decimalPlace)); item.BidList[2].Price = decimal.Multiply(item.BidList[2].Price, (decimal)Math.Pow(0.1, decimalPlace)); item.BidList[3].Price = decimal.Multiply(item.BidList[3].Price, (decimal)Math.Pow(0.1, decimalPlace)); item.BidList[4].Price = decimal.Multiply(item.BidList[4].Price, (decimal)Math.Pow(0.1, decimalPlace)); item.AskList[0].Price = decimal.Multiply(item.AskList[0].Price, (decimal)Math.Pow(0.1, decimalPlace)); item.AskList[1].Price = decimal.Multiply(item.AskList[1].Price, (decimal)Math.Pow(0.1, decimalPlace)); item.AskList[2].Price = decimal.Multiply(item.AskList[2].Price, (decimal)Math.Pow(0.1, decimalPlace)); item.AskList[3].Price = decimal.Multiply(item.AskList[3].Price, (decimal)Math.Pow(0.1, decimalPlace)); item.AskList[4].Price = decimal.Multiply(item.AskList[4].Price, (decimal)Math.Pow(0.1, decimalPlace)); item.LastClose = decimal.Multiply(item.LastClose, (decimal)Math.Pow(0.1, decimalPlace)); item.DeliveryPrice = decimal.Multiply(item.DeliveryPrice, (decimal)Math.Pow(0.1, decimalPlace)); item.High = decimal.Multiply(item.High, (decimal)Math.Pow(0.1, decimalPlace)); item.Low = decimal.Multiply(item.Low, (decimal)Math.Pow(0.1, decimalPlace)); item.Open = decimal.Multiply(item.Open, (decimal)Math.Pow(0.1, decimalPlace)); item.TotalTurnover = decimal.Multiply(item.TotalTurnover, (decimal)Math.Pow(0.1, decimalPlace)); item.TradeTurnover = decimal.Multiply(item.TradeTurnover, (decimal)Math.Pow(0.1, decimalPlace)); item.FallsPrice = decimal.Multiply(item.FallsPrice, (decimal)Math.Pow(0.1, decimalPlace)); item.RaisesPrice = decimal.Multiply(item.RaisesPrice, (decimal)Math.Pow(0.1, decimalPlace)); item.Settlement = decimal.Multiply(item.Settlement, (decimal)Math.Pow(0.1, decimalPlace)); item.LastSettlement = decimal.Multiply(item.LastSettlement, (decimal)Math.Pow(0.1, decimalPlace)); ////最先赋值昨收,以便计算其它字段颜色,以名LastClose Setter里使用太多属性通知改变 ////最先赋值昨收,以便计算其它字段颜色,以名LastClose Setter里使用太多属性通知改变 int roundInt = this.GoodsParameters != null ? this.GoodsParameters.HqExchFigures : 0; if (item.LastClose != 0 && !this.LastClose.Equals(item.LastClose)) { ///暂时注释昨收,使用昨结算与分析系统保持一致 // this.LastClose = Math.Round(item.LastClose, roundInt, MidpointRounding.AwayFromZero); // this.LastSettlement = Math.Round(item.LastSettlement, roundInt, MidpointRounding.AwayFromZero); } if (item.LastSettlement != 0 && !this.LastSettlement.Equals(item.LastSettlement)) { this.LastSettlement = Math.Round(item.LastSettlement, roundInt, MidpointRounding.AwayFromZero); this.LastClose = Math.Round(item.LastSettlement, roundInt, MidpointRounding.AwayFromZero); ///暂时注释昨收,使用昨结算与分析系统保持一致 } if (item.LastPositions != 0 && !this.LastPositions.Equals(item.LastPositions)) { this.LastPositions = item.LastPositions; } if (item.RaisesPrice != 0 && !this.RaisesPrice.Equals(item.RaisesPrice)) { this.RaisesPrice = item.RaisesPrice; } if (item.FallsPrice != 0 && !this.FallsPrice.Equals(item.FallsPrice)) { this.FallsPrice = item.FallsPrice; } if (item.Inventory != 0 && !this.Inventory.Equals(item.Inventory)) { this.Inventory = item.Inventory; } if (item.CurrentPrice > 0 && DateTime.MinValue.Equals(item.Date)) { //现价大于0 且日期为最小值 丢掉 return; } ////只更新需要字段 ////if (item.BidPrice != 0 && !this.BidPrice.Equals(item.BidPrice)) this.BidPrice = Math.Round(item.BidPrice, roundInt, MidpointRounding.AwayFromZero); //item.BidPrice; ////if (item.AskPrice != 0 && !this.AskPrice.Equals(item.AskPrice)) this.AskPrice = Math.Round(item.AskPrice, roundInt, MidpointRounding.AwayFromZero); //item.AskPrice; #region 显示最新的行情 if (item.Date >= this.Date) { if (!this.BidPrice.Equals(item.BidPrice)) { this.BidPrice = Math.Round(item.BidPrice, roundInt, MidpointRounding.AwayFromZero); } if (!this.AskPrice.Equals(item.AskPrice)) { this.AskPrice = Math.Round(item.AskPrice, roundInt, MidpointRounding.AwayFromZero); } if (item.CurrentPrice != 0 && !this.CurrentPrice.Equals(item.CurrentPrice)) { this.CurrentPrice = Math.Round(item.CurrentPrice, roundInt, MidpointRounding.AwayFromZero); } #region yxw 添加买卖档变更 if (!item.BidList[0].Equals(this.BidList[0])) { this.BidList[0] = item.BidList[0]; this.BidList[0].LastClose = this.LastClose; } if (!item.BidList[1].Equals(this.BidList[1])) { this.BidList[1] = item.BidList[1]; this.BidList[1].LastClose = this.LastClose; } if (!item.BidList[2].Equals(this.BidList[2])) { this.BidList[2] = item.BidList[2]; this.BidList[2].LastClose = this.LastClose; } if (!item.BidList[3].Equals(this.BidList[3])) { this.BidList[3] = item.BidList[3]; this.BidList[3].LastClose = this.LastClose; } if (!item.BidList[4].Equals(this.BidList[4])) { this.BidList[4] = item.BidList[4]; this.BidList[4].LastClose = this.LastClose; } if (!item.AskList[0].Equals(this.AskList[0])) { this.AskList[0] = item.AskList[0]; this.AskList[0].LastClose = this.LastClose; } if (!item.AskList[1].Equals(this.AskList[1])) { this.AskList[1] = item.AskList[1]; this.AskList[1].LastClose = this.LastClose; } if (!item.AskList[2].Equals(this.AskList[2])) { this.AskList[2] = item.AskList[2]; this.AskList[2].LastClose = this.LastClose; } if (!item.AskList[3].Equals(this.AskList[3])) { this.AskList[3] = item.AskList[3]; this.AskList[3].LastClose = this.LastClose; } if (!item.AskList[4].Equals(this.AskList[4])) { this.AskList[4] = item.AskList[4]; this.AskList[4].LastClose = this.LastClose; } #endregion } #endregion this.Date = item.Date; if (item.Open != 0 && !this.Open.Equals(item.Open)) { this.Open = Math.Round(item.Open, roundInt, MidpointRounding.AwayFromZero); //item.Open; } if (item.High != 0 && !this.High.Equals(item.High)) { this.High = Math.Round(item.High, roundInt, MidpointRounding.AwayFromZero); //item.High; } if (item.Low != 0 && !this.Low.Equals(item.Low)) { this.Low = Math.Round(item.Low, roundInt, MidpointRounding.AwayFromZero);// item.Low; } if (item.Positions != 0 && !this.Positions.Equals(item.Positions)) { this.Positions = item.Positions; } if (item.TotalVolume != 0 && !this.TotalVolume.Equals(item.TotalVolume)) { this.TotalVolume = item.TotalVolume; } if (item.TotalTurnover != 0 && !this.TotalTurnover.Equals(item.TotalTurnover)) { this.TotalTurnover = item.TotalTurnover; } if ( !this.BidVolume.Equals(item.BidVolume)) { this.BidVolume = item.BidVolume; } if ( !this.AskVolume.Equals(item.AskVolume)) { this.AskVolume = item.AskVolume; } if (item.DayAddPositions != 0 && !this.DayAddPositions.Equals(item.DayAddPositions)) { this.DayAddPositions = item.DayAddPositions; } if (item.TradeTurnover != 0 && !this.TradeTurnover.Equals(item.TradeTurnover)) { this.TradeTurnover = item.TradeTurnover; } if (item.AveragePrice != 0 && !this.AveragePrice.Equals(item.AveragePrice)) { this.AveragePrice = item.AveragePrice; } if (item.QuantityRelativeRatio != 0 && !this.QuantityRelativeRatio.Equals(item.QuantityRelativeRatio)) { this.QuantityRelativeRatio = item.QuantityRelativeRatio; } if (item.TurnoverRate != 0 && !this.TurnoverRate.Equals(item.TurnoverRate)) { this.TurnoverRate = item.TurnoverRate; } if (item.PriceEarningRatio != 0 && !this.PriceEarningRatio.Equals(item.PriceEarningRatio)) { this.PriceEarningRatio = item.PriceEarningRatio; } //to confirm if (item.NegotiableShares != 0 && !this.NegotiableShares.Equals(item.NegotiableShares)) this.NegotiableShares = item.NegotiableShares; if (item.MarketCapitalizations != 0 && !this.MarketCapitalizations.Equals(item.MarketCapitalizations)) this.MarketCapitalizations = item.MarketCapitalizations; if (item.TotalEquity != 0 && !this.TotalEquity.Equals(item.TotalEquity)) this.TotalEquity = item.TotalEquity; if (item.InSize != 0 && !this.InSize.Equals(item.InSize)) { this.InSize = item.InSize; } if (item.OutSize != 0 && !this.OutSize.Equals(item.OutSize)) { this.OutSize = item.OutSize; } ////if (item.WeiBi != 0 && !this.WeiBi.Equals(item.WeiBi)) this.WeiBi = item.WeiBi; ////if (item.WeiCha != 0 && !this.WeiCha.Equals(item.WeiCha)) this.WeiCha = item.WeiCha; ////to confirm if (item.NegotiableShares != 0 && !this.NegotiableShares.Equals(item.NegotiableShares)) { this.NegotiableShares = item.NegotiableShares; } if (item.MarketCapitalizations != 0 && !this.MarketCapitalizations.Equals(item.MarketCapitalizations)) { this.MarketCapitalizations = item.MarketCapitalizations; } if (item.TotalEquity != 0 && !this.TotalEquity.Equals(item.TotalEquity)) { this.TotalEquity = item.TotalEquity; } //if (item.AskQueueInfo != null && !this.AskQueueInfo.Equals(item.AskQueueInfo)) //{ this.AskQueueInfo = item.AskQueueInfo; //} //if (item.BidQueueInfo != null && !this.BidQueueInfo.Equals(item.BidQueueInfo)) //{ this.BidQueueInfo = item.BidQueueInfo; // } this.CurrentVolume = item.CurrentVolume; ////当前量 //根据现价更新最高最低价 if (CurrentPrice >= 0 && CurrentPrice > High) { High = CurrentPrice; } if (CurrentPrice >= 0 && (CurrentPrice < Low || Low <= 0)) { Low = CurrentPrice; } if (this.Open == 0) //第一笔成交价为开盘价 { this.Open = CurrentPrice; } } /// /// 更新除了最新价外的数据 /// /// public void UpdateWithoutCurPrice(QuoteGoods item) { //根据现价更新最高最低价 if (CurrentPrice >= 0 && CurrentPrice > High) { High = CurrentPrice; } if (CurrentPrice >= 0 && (CurrentPrice < Low || Low <= 0)) { Low = CurrentPrice; } } ///// ///// 从盘面数据更新 ///// ///// The day quote. //public void UpdateFromDayQuote(DayQuote dayQuote) //{ // if (dayQuote == null) // { // return; // } // ////最先赋值昨收,以便计算其它字段颜色,以名LastClose Setter里使用太多属性通知改变 // this.LastClose = dayQuote.PreClose; // if (dayQuote.LastTime >= this.Date) //比当前时间小的不更新当前价格 // { // this.AskPrice = dayQuote.Ask; // this.AskVolume = dayQuote.AskVolume; // this.BidPrice = dayQuote.Bid; // this.BidVolume = dayQuote.BidVolume; // this.CurrentPrice = dayQuote.Last; // #region 买卖档 yxw // #region 买卖价格 // this.BidList[0].Price = dayQuote.Bid; // this.BidList[1].Price = dayQuote.Bid2; // this.BidList[2].Price = dayQuote.Bid3; // this.BidList[3].Price = dayQuote.Bid4; // this.BidList[4].Price = dayQuote.Bid5; // this.AskList[0].Price = dayQuote.Ask; // this.AskList[1].Price = dayQuote.Ask2; // this.AskList[2].Price = dayQuote.Ask3; // this.AskList[3].Price = dayQuote.Ask4; // this.AskList[4].Price = dayQuote.Ask5; // #endregion // #region 买卖量 // this.BidList[0].Volume = dayQuote.BidVolume; // this.BidList[1].Volume = dayQuote.BidVolume2; // this.BidList[2].Volume = dayQuote.BidVolume3; // this.BidList[3].Volume = dayQuote.BidVolume4; // this.BidList[4].Volume = dayQuote.BidVolume5; // this.AskList[0].Volume = dayQuote.AskVolume; // this.AskList[1].Volume = dayQuote.AskVolume2; // this.AskList[2].Volume = dayQuote.AskVolume3; // this.AskList[3].Volume = dayQuote.AskVolume4; // this.AskList[4].Volume = dayQuote.AskVolume5; // #endregion // #endregion // } // this.CurrentVolume = dayQuote.LastVolume; // this.Date = dayQuote.LastTime; // this.High = dayQuote.Highest; // this.LastSettlement = dayQuote.PreSettle; // this.Low = dayQuote.Lowest; // this.Open = dayQuote.Opened; // this.Positions = dayQuote.PreHoldVolume; // this.Settlement = dayQuote.Settle; // this.TotalTurnover = dayQuote.TotalTurnover; // this.TotalVolume = dayQuote.TotalVolume; //} /// /// 清盘面 /// public void ClearQuote() { ////最先赋值昨收,以便计算其它字段颜色,以名LastClose Setter里使用太多属性通知改变 this.LastClose = this.CurrentPrice; this.Date = DateTime.MinValue; this.AskPrice = 0; this.AskVolume = 0; this.BidPrice = 0; this.BidVolume = 0; this.CurrentPrice = 0; this.CurrentVolume = 0; this.High = 0; this.LastSettlement = Settlement; this.Low = 0; this.Open = 0; this.Settlement = 0; this.TotalTurnover = 0; this.TotalVolume = 0; LastPositions = this.Positions; this.Positions = 0; #region 买卖档 yxw #region 买卖价格 this.BidList[0].Price = 0; this.BidList[1].Price = 0; this.BidList[2].Price = 0; this.BidList[3].Price = 0; this.BidList[4].Price = 0; this.AskList[0].Price = 0; this.AskList[1].Price = 0; this.AskList[2].Price = 0; this.AskList[3].Price = 0; this.AskList[4].Price = 0; #endregion #region 买卖量 this.BidList[0].Volume = 0; this.BidList[1].Volume = 0; this.BidList[2].Volume = 0; this.BidList[3].Volume = 0; this.BidList[4].Volume = 0; this.AskList[0].Volume = 0; this.AskList[1].Volume = 0; this.AskList[2].Volume = 0; this.AskList[3].Volume = 0; this.AskList[4].Volume = 0; #endregion #endregion } #endregion Public Methods #region Private Methods /// /// Gets the brush. /// /// The source. /// The destination. /// Brush. private Brush GetBrush(decimal source, decimal destination) { if (source == 0) { return DefaultBrush; } if (source > destination) { return AscBrush; } if (source < destination) { return DecBrush; } return DefaultBrush; } /// /// Gets the brush. /// /// The source. /// The destination. /// Brush. private Brush GetBrush(double source, double destination) { if (source == 0) { return DefaultBrush; } if (source > destination) { return AscBrush; } if (source < destination) { return DecBrush; } return DefaultBrush; } /// /// 获取默认格式化字符串 /// /// System.String. public string GetDefaultFormat() { if (this.Category == QuoteCategoryType.Forex) { return "#0.0000"; } return "#0.00"; } #endregion Private Methods #endregion Methods /// /// 克隆对象 /// /// public object Clone() { var temp = this.MemberwiseClone() as QuoteGoods; if (temp == null) { return null; } this.AskList.CopyTo(temp.AskList, 0); return temp; } /// /// 商品是否有行情 /// public bool IsShowQuote { get { if (this.GoodsParameters == null) { return false; } ////todo:商品运行状态通知实现后再使用下面代码 return true; //// return (this.GoodsParameters.RunStatus == MarketGoodsStatus.List || this.GoodsParameters.RunStatus == MarketGoodsStatus.MARKET_OPEN); } } /// /// 交割商品名称(关联交易商品 存放交割商品名称) /// public string DeliveryGoodsName { get; set; } /// /// 交割商品名称/代码 /// public string DeliveryGoodsNameCode { get { return DeliveryGoodsName + " " + DeliveryGoodsCode; } } #region NEW FIELD MTP2.0 /// /// 主辅商品比的主手数 /// public uint XDeliveryRatio { get; set; } /// /// 主辅商品比的辅手数 /// public uint PDeliveryRatio1 { get; set; } public uint PDeliveryRatio2 { get; set; } public uint P1Type { get; set; } public uint P2Type { get; set; } public uint P1value { get; set; } public uint P2value { get; set; } /// /// 下单类型。普通下单/摘牌下单 /// public eOrderFormType formType { get; set; } /// /// 挂牌、摘牌属性=》委托单号 /// public long OrderId_Listing { get; set; } /// /// 挂牌、摘牌属性=》委托价格 /// public decimal OrderPrice_Listing { get; set; } /// /// 最后交易日期 /// public string LastTradeDate { get; set; } /// /// 交割商品代码(关联交易商品 存放交割商品代码) /// public string DeliveryGoodsCode { get; set; } /// /// 交割商品ID(关联交易商品 存放交割商品ID) /// public uint DeliveryGoodsId { get; set; } /// /// 交割起始日期NEW /// public string BeginDate { get; set; } /// /// 交割结束日期NEW /// public string EndDate { get; set; } /// /// 辅助交易商品ID /// public uint PGoodsID1 { get; set; } /// /// 辅助商品2 /// public uint PGoodsID2 { get; set; } /// /// 最小交割手数 /// public uint MinDeliveryQty { get; set; } /// /// 商品单位式NEW /// public string GoodsUnit { get; set; } /// /// 合约单位NEW /// public uint AgreeUnit { get; set; } /// /// 报价货币NEW /// public string Currency { get; set; } /// /// 是否交割 0:不交割1:要交割 /// public uint DeliveryFlag { get; set; } /// /// 交割商品单位 string /// public string DeliveryGoodsUnit { get; set; } /// /// 商品要素列表 /// public List GoodsPMList { get; set; } #endregion private double _inventory; /// /// 总库存量 /// public double Inventory { get { return _inventory; } set { Set(() => Inventory, ref _inventory, value); RaisePropertyChanged(() => InventoryDisplay); } } /// /// 五档买委托队列 /// public string BidQueueInfo { get; set; } /// /// 五档卖委托队列 /// public string AskQueueInfo { get; set; } /// /// 外部行情是否有效 /// public bool IsQuoteValid { get; set; } public uint ClosePriceMode { get; set; } public double ClosePriceParam { get; set; } public uint Currencyid { get; set; } public uint DelistingMode { get; set; } public uint GoodsStatus { get; set; } public uint GoodsType { get; set; } public uint GroupID { get; set; } public uint InnerDealMode { get; set; } public uint IsBuyLimited { get; set; } public uint Lotsize { get; set; } public uint QtyDecimalPlace { get; set; } public uint QuoteMinUnit { get; set; } /// /// 交易日 /// public string TradeDate { get; set; } } }