Commission.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. using Muchinfo.MTPClient.Data.Enums;
  2. using Muchinfo.MTPClient.Resources;
  3. namespace Muchinfo.MTPClient.Data.Model
  4. {
  5. /// <summary>
  6. /// 委托盘
  7. /// @author: yxw
  8. /// @time: 2014-03-13
  9. /// </summary>
  10. public class Commission
  11. {
  12. public Commission() { }
  13. public Commission(Direction direction)
  14. {
  15. //Price = 1;
  16. //Volume = 2;
  17. //Order = 3;
  18. this.Direction = direction;
  19. }
  20. public Commission(decimal price, int volume)
  21. {
  22. Price = price;
  23. Volume = volume;
  24. }
  25. public Direction Direction { get; set; }
  26. public int Index { get; set; }
  27. /// <summary>
  28. /// 价格
  29. /// </summary>
  30. public decimal Price { get; set; }
  31. /// <summary>
  32. /// 数量
  33. /// </summary>
  34. public long Volume { get; set; }
  35. /// <summary>
  36. /// 单数
  37. /// </summary>
  38. public int Order { get; set; }
  39. /// <summary>
  40. /// 昨收
  41. /// </summary>
  42. public decimal LastClose { get; set; }
  43. /// <summary>
  44. /// 显示格式化价格
  45. /// </summary>
  46. public string DisplayPrice
  47. {
  48. get
  49. {
  50. if (Price <= 0)
  51. {
  52. return "-";
  53. }
  54. else
  55. {
  56. return Price.ToString(FormatString);
  57. }
  58. }
  59. }
  60. /// <summary>
  61. /// 格式化字符串
  62. /// </summary>
  63. public string FormatString
  64. {
  65. get;
  66. set;
  67. }
  68. /// <summary>
  69. /// 显示成交量
  70. /// </summary>
  71. public string DisplayVolume
  72. {
  73. get
  74. {
  75. if (this.Volume <= 0)
  76. {
  77. return "-";
  78. }
  79. if (this.Volume <= 999999)
  80. {
  81. return this.Volume.ToString();
  82. }
  83. else if (this.Volume <= 9999999)
  84. {
  85. return System.Math.Round(((decimal)this.Volume / 10000), 2).ToString() + Client_Resource.Domain_TenThousand;
  86. }
  87. else if (this.Volume <= 99999999)
  88. {
  89. return System.Math.Round(((decimal)this.Volume / 10000), 0).ToString() + Client_Resource.Domain_TenThousand;
  90. }
  91. else if (this.Volume <= 99999999999)
  92. {
  93. return System.Math.Round(((decimal)this.Volume / 100000000), 2).ToString() + Client_Resource.Domain_OneHundredmillion;
  94. }
  95. else
  96. {
  97. return System.Math.Round(((decimal)this.Volume / 100000000), 0).ToString() + Client_Resource.Domain_OneHundredmillion;
  98. }
  99. }
  100. }
  101. /// <summary>
  102. /// 当前价格与昨收比是涨还是跌。
  103. /// </summary>
  104. public PriceStatus PriceStatus
  105. {
  106. get
  107. {
  108. if (this.Price <= 0)
  109. {
  110. return PriceStatus.equal;
  111. }
  112. if (this.Price > this.LastClose)
  113. {
  114. return PriceStatus.up;
  115. }
  116. else if (this.Price < this.LastClose)
  117. {
  118. return PriceStatus.down;
  119. }
  120. else
  121. {
  122. return PriceStatus.equal;
  123. }
  124. }
  125. }
  126. /// <summary>
  127. /// 比较对象是否发生更改
  128. /// </summary>
  129. /// <param name="value">The value.</param>
  130. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  131. public bool Equals(Commission value)
  132. {
  133. if (this.Price != value.Price)
  134. {
  135. return false;
  136. }
  137. if (this.Volume != value.Volume)
  138. {
  139. return false;
  140. }
  141. if (this.Order != value.Order)
  142. {
  143. return false;
  144. }
  145. return true;
  146. }
  147. public string IndexChinese
  148. {
  149. get
  150. {
  151. switch (this.Index)
  152. {
  153. case 1:
  154. return Client_Resource.Model_One;
  155. case 2:
  156. return Client_Resource.Model_Two;
  157. case 3:
  158. return Client_Resource.Model_Three;
  159. case 4:
  160. return Client_Resource.Model_Four;
  161. case 5:
  162. return Client_Resource.Model_Five;
  163. default:
  164. return Client_Resource.Model_Zero;
  165. }
  166. }
  167. }
  168. /// <summary>
  169. /// 显示五档标题
  170. /// </summary>
  171. public string DisplayOrder
  172. {
  173. get
  174. {
  175. return string.Format("{0}{1}",
  176. Direction == Direction.Bid ? Client_Resource.Text_Buy : Client_Resource.Text_Sell, IndexChinese);
  177. }
  178. }
  179. public PriceLevel PriceLevel
  180. {
  181. get
  182. {
  183. if (Index == 1)
  184. {
  185. }
  186. return PriceLevel.AnOthers;
  187. }
  188. }
  189. }
  190. /// <summary>
  191. /// 价格状态
  192. /// </summary>
  193. public enum PriceStatus
  194. {
  195. up=0,
  196. equal=1,
  197. down=2,
  198. }
  199. /// <summary>
  200. /// 價格档案
  201. /// </summary>
  202. public enum PriceLevel
  203. {
  204. Ask1=1,
  205. Bid1=2,
  206. AnOthers=3,
  207. }
  208. public class EntructInfo
  209. {
  210. /// <summary>
  211. /// 委托账号
  212. /// </summary>
  213. public string AccountCode { get; set; }
  214. /// <summary>
  215. /// 委托数量
  216. /// </summary>
  217. public string Qty { get; set; }
  218. /// <summary>
  219. /// 显示的账号
  220. /// </summary>
  221. public string AccountDisplay
  222. {
  223. get
  224. {
  225. var result = "****";
  226. var str = AccountCode ;
  227. if (str.Length <= 4)
  228. {
  229. return result;
  230. }
  231. else
  232. {
  233. var tem = str.Substring(2, str.Length - 4);
  234. return str.Replace(tem, result);
  235. }
  236. }
  237. }
  238. }
  239. /// <summary>
  240. /// 显示大力士方式
  241. /// </summary>
  242. public enum QueueShowType
  243. {
  244. /// <summary>
  245. /// 不显示
  246. /// </summary>
  247. None=0,
  248. /// <summary>
  249. /// 竞价
  250. /// </summary>
  251. Bid=1,
  252. /// <summary>
  253. /// 混合显示
  254. /// </summary>
  255. BidMake=2,
  256. /// <summary>
  257. /// 竞价,混合显示
  258. /// </summary>
  259. All=3
  260. }
  261. }