using MuchInfo.Chart.Data.EnumTypes; using System; using System.Collections.Generic; namespace MuchInfo.Chart.Data.Models { /// /// 商品信息类 /// public class GoodsInfo { #region Constructors /// /// 初始化商品信息实例 /// /// 交易所代码 /// 商品代码 /// 商品类型 /// 昨日收盘价 /// 结算计划 /// 报价小数位数 public GoodsInfo(int exchangeCode, string goodsCode, GoodsType goodsType, float preClose, List openCloseTimes, int minUnit) { this.ExchangeCode = exchangeCode; this.GoodsCode = goodsCode; this.GoodsType = goodsType; this.PreClose = preClose; this.OpenCloseTimes = openCloseTimes ?? new List(){new OpenCloseTime() { OpenTime = DateTime.Now.Date, CloseTime = DateTime.Now.Date.AddHours(24).AddSeconds(-1), }}; this.MinUnit = minUnit; } #endregion Constructors #region Properties #region Public Properties /// /// 商品显示名 /// public string DisplayName { get; set; } /// /// 交易所代码 /// public int ExchangeCode { get; set; } /// /// 商品代码 /// public string GoodsCode { get; set; } /// /// 商品类型 /// public GoodsType GoodsType { get; set; } /// /// 收盘时间对集合-给分时线用 /// public List OpenCloseTimes { get; set; } /// /// 昨日收盘价-给分时线用 /// public float PreClose { get; set; } /// /// 报价小数位数 /// public int MinUnit { get; set; } #endregion Public Properties #region Internal Properties /// /// 商品标识 /// public string Symbol { get { //统一使用此格式,包括行情组件,图表组件,统一客户端及各服务 return ExchangeCode.ToString().PadLeft(3, ' ') + GoodsCode.PadLeft(6, ' '); } } public string DisplaySymbol { get { var symbol = ExchangeCode + GoodsCode.Trim(); return string.IsNullOrEmpty(DisplayName) ? "(" + symbol + ")" : ("(" + DisplayName + "-" + symbol + ")"); } } #endregion Internal Properties #endregion Properties } /// /// 开收盘时间对 /// public class OpenCloseTime { #region Properties #region Public Properties /// /// 收盘时间 /// public DateTime CloseTime { get; set; } /// /// 开盘时间 /// public DateTime OpenTime { get; set; } #endregion Public Properties #endregion Properties } }