GoodsInfo.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using MuchInfo.Chart.Data.EnumTypes;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace MuchInfo.Chart.Data.Models
  5. {
  6. /// <summary>
  7. /// 商品信息类
  8. /// </summary>
  9. public class GoodsInfo
  10. {
  11. #region Constructors
  12. /// <summary>
  13. /// 初始化商品信息实例
  14. /// </summary>
  15. /// <param name="exchangeCode">交易所代码</param>
  16. /// <param name="goodsCode">商品代码</param>
  17. /// <param name="goodsType">商品类型</param>
  18. /// <param name="preClose">昨日收盘价</param>
  19. /// <param name="openCloseTimes">结算计划</param>
  20. /// <param name="minUnit">报价小数位数</param>
  21. public GoodsInfo(int exchangeCode, string goodsCode, GoodsType goodsType, float preClose, List<OpenCloseTime> openCloseTimes, int minUnit)
  22. {
  23. this.ExchangeCode = exchangeCode;
  24. this.GoodsCode = goodsCode;
  25. this.GoodsType = goodsType;
  26. this.PreClose = preClose;
  27. this.OpenCloseTimes = openCloseTimes ?? new List<OpenCloseTime>(){new OpenCloseTime()
  28. {
  29. OpenTime = DateTime.Now.Date,
  30. CloseTime = DateTime.Now.Date.AddHours(24).AddSeconds(-1),
  31. }};
  32. this.MinUnit = minUnit;
  33. }
  34. #endregion Constructors
  35. #region Properties
  36. #region Public Properties
  37. /// <summary>
  38. /// 商品显示名
  39. /// </summary>
  40. public string DisplayName
  41. {
  42. get;
  43. set;
  44. }
  45. /// <summary>
  46. /// 交易所代码
  47. /// </summary>
  48. public int ExchangeCode
  49. {
  50. get;
  51. set;
  52. }
  53. /// <summary>
  54. /// 商品代码
  55. /// </summary>
  56. public string GoodsCode
  57. {
  58. get;
  59. set;
  60. }
  61. /// <summary>
  62. /// 商品类型
  63. /// </summary>
  64. public GoodsType GoodsType
  65. {
  66. get;
  67. set;
  68. }
  69. /// <summary>
  70. /// 收盘时间对集合-给分时线用
  71. /// </summary>
  72. public List<OpenCloseTime> OpenCloseTimes
  73. {
  74. get;
  75. set;
  76. }
  77. /// <summary>
  78. /// 昨日收盘价-给分时线用
  79. /// </summary>
  80. public float PreClose
  81. {
  82. get;
  83. set;
  84. }
  85. /// <summary>
  86. /// 报价小数位数
  87. /// </summary>
  88. public int MinUnit
  89. {
  90. get;
  91. set;
  92. }
  93. #endregion Public Properties
  94. #region Internal Properties
  95. /// <summary>
  96. /// 商品标识
  97. /// </summary>
  98. public string Symbol
  99. {
  100. get
  101. {
  102. //统一使用此格式,包括行情组件,图表组件,统一客户端及各服务
  103. return ExchangeCode.ToString().PadLeft(3, ' ') + GoodsCode.PadLeft(6, ' ');
  104. }
  105. }
  106. public string DisplaySymbol
  107. {
  108. get
  109. {
  110. var symbol = ExchangeCode + GoodsCode.Trim();
  111. return string.IsNullOrEmpty(DisplayName) ? "(" + symbol + ")" : ("(" + DisplayName + "-" + symbol + ")");
  112. }
  113. }
  114. #endregion Internal Properties
  115. #endregion Properties
  116. }
  117. /// <summary>
  118. /// 开收盘时间对
  119. /// </summary>
  120. public class OpenCloseTime
  121. {
  122. #region Properties
  123. #region Public Properties
  124. /// <summary>
  125. /// 收盘时间
  126. /// </summary>
  127. public DateTime CloseTime
  128. {
  129. get;
  130. set;
  131. }
  132. /// <summary>
  133. /// 开盘时间
  134. /// </summary>
  135. public DateTime OpenTime
  136. {
  137. get;
  138. set;
  139. }
  140. #endregion Public Properties
  141. #endregion Properties
  142. }
  143. }