SPSLOrderModel.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using Muchinfo.MTPClient.Data.Enums;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using Muchinfo.MTPClient.Data.Helper;
  7. namespace Muchinfo.MTPClient.Data.Model.Account
  8. {
  9. /// <summary>
  10. /// 止盈止损单对象
  11. /// </summary>
  12. public class SPSLOrderModel
  13. {
  14. #region 查询返回字段
  15. [PropertyDisc("OrderId")]
  16. public ulong OrderId { get; set; }
  17. [PropertyDisc("AccountId")]
  18. public long AccountId { get; set; }
  19. [PropertyDisc("LoginId")]
  20. public long LoginId { get; set; }
  21. [PropertyDisc("GoodsId")]
  22. public uint GoodsId { get; set; }
  23. [PropertyDisc("MarketId")]
  24. public uint MarketId { get; set; }
  25. [PropertyDisc("OrderQty")]
  26. public decimal OrderQty { get; set; }
  27. [PropertyDisc("ValidType")]
  28. public ExpirationType ValidType { get; set; }
  29. [PropertyDisc("SPSLType")]
  30. public SPSLOrderType SPSLType { get; set; }
  31. [PropertyDisc("PriceType")]
  32. public ChannelPriceMode PriceType { get; set; }
  33. [PropertyDisc("TriggerType")]
  34. public SPSLTriggerType TriggerType { get; set; }
  35. [PropertyDisc("OrderSrc")]
  36. public eOrderSrc OrderSrc { get; set; }
  37. [PropertyDisc("BuyOrSell")]
  38. public Direction BuyOrSell { get; set; }
  39. [PropertyDisc("SPPrice")]
  40. public decimal SPPrice { get; set; }
  41. [PropertyDisc("SLPrice")]
  42. public decimal SLPrice { get; set; }
  43. [PropertyDisc("Status")]
  44. public SPSLOrderStatus Status { get; set; }
  45. [PropertyDisc("CreateTime")]
  46. public DateTime CreateTime { get; set; }
  47. [PropertyDisc("UpdateTime")]
  48. public DateTime UpdateTime { get; set; }
  49. #endregion
  50. /// <summary>
  51. /// 单据商品
  52. /// </summary>
  53. public QuoteGoods QuoteGoods { get; set; }
  54. /// <summary>
  55. /// Gets the goods code.
  56. /// </summary>
  57. /// <value>The goods code.</value>
  58. public string GoodsCode
  59. {
  60. get { return QuoteGoods == null ? string.Empty : QuoteGoods.GoodsCode; }
  61. }
  62. /// <summary>
  63. /// Gets the name of the goods.
  64. /// </summary>
  65. /// <value>The name of the goods.</value>
  66. public string GoodsName
  67. {
  68. get { return QuoteGoods == null ? string.Empty : QuoteGoods.Name; }
  69. }
  70. /// <summary>
  71. /// Gets the direction display.
  72. /// </summary>
  73. /// <value>The direction display.</value>
  74. public string DirectionDisplay
  75. {
  76. // 止损止盈单显示的是持仓方向 <- 下止损止盈单时方向使用的已经是持仓方向,这里不用再取反
  77. get
  78. {
  79. //var buyOrSell = BuyOrSell == Direction.Ask ? Direction.Bid : Direction.Ask;
  80. return BuyOrSell.Discription();
  81. }
  82. }
  83. /// <summary>
  84. /// Gets the SPSL type display.
  85. /// </summary>
  86. /// <value>The SPSL type display.</value>
  87. public string SPSLTypeDisplay
  88. {
  89. get
  90. {
  91. switch (SPSLType)
  92. {
  93. case SPSLOrderType.SPOrder:
  94. return "止盈";
  95. case SPSLOrderType.SLOrder:
  96. return "止损";
  97. case SPSLOrderType.Cancel:
  98. return "撤单";
  99. case SPSLOrderType.SPSL:
  100. return "止盈止损";
  101. default:
  102. return SPSLType.Discription("spsltype");
  103. }
  104. //更新协议后使用
  105. return SPSLType.Discription("spsltype");
  106. }
  107. }
  108. /// <summary>
  109. /// Gets the trigger type display.
  110. /// </summary>
  111. /// <value>The trigger type display.</value>
  112. public string TriggerTypeDisplay
  113. {
  114. get { return TriggerType.Discription("triggertype"); }
  115. }
  116. /// <summary>
  117. /// Gets the trigger type display.
  118. /// </summary>
  119. /// <value>The trigger type display.</value>
  120. public string PriceDisplay
  121. {
  122. get
  123. {
  124. var spPrice = SPPrice > 0 ? SPPrice.ToString(PriceExpFormat) : "-";
  125. var slPrice = SLPrice > 0 ? SLPrice.ToString(PriceExpFormat) : "-";
  126. return spPrice + "/" + slPrice;
  127. }
  128. }
  129. /// <summary>
  130. /// Gets the price type display.
  131. /// </summary>
  132. /// <value>The price type display.</value>
  133. public string PriceTypeDisplay
  134. {
  135. get { return PriceType.Discription("pricetype"); }
  136. }
  137. /// <summary>
  138. /// Gets the status display.
  139. /// </summary>
  140. /// <value>The status display.</value>
  141. public string StatusDisplay
  142. {
  143. get { return Status.Discription("spslstatus"); }
  144. }
  145. /// <summary>
  146. /// Gets the valid type display.
  147. /// </summary>
  148. /// <value>The valid type display.</value>
  149. public string ValidTypeDisplay
  150. {
  151. get { return ValidType.Discription(); }
  152. }
  153. /// <summary>
  154. /// Gets the create time display.
  155. /// </summary>
  156. /// <value>The create time display.</value>
  157. public string CreateTimeDisplay
  158. {
  159. get { return CreateTime.ToString("yyyy-MM-dd HH:mm:ss"); }
  160. }
  161. /// <summary>
  162. /// Gets a value indicating whether this instance is cancel.
  163. /// </summary>
  164. /// <value><c>true</c> if this instance is cancel; otherwise, <c>false</c>.</value>
  165. public bool IsCancel
  166. {
  167. //OrderSrc = 5:交易服务下的止盈止损单的不能撤单
  168. get { return Status == SPSLOrderStatus.NotTrigger && OrderSrc != eOrderSrc.ORDERSRC_TRADE; }
  169. }
  170. /// <summary>
  171. /// Gets the price exp format.
  172. /// </summary>
  173. /// <value>The price exp format.</value>
  174. public string PriceExpFormat
  175. {
  176. get
  177. {
  178. if (this.QuoteGoods == null || this.QuoteGoods.GoodsParameters == null)
  179. {
  180. // return "F0";
  181. //}
  182. //if (this.QuoteGoods.GoodsParameters.HqExchFigures < 3)
  183. //{
  184. return "F2";
  185. }
  186. else
  187. {
  188. return QuoteGoods.FormatPrice;
  189. }
  190. }
  191. }
  192. }
  193. }