OrderDetail.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. using System.Linq;
  2. using System.Runtime.Remoting.Activation;
  3. using Muchinfo.MTPClient.Data.Enums;
  4. using Muchinfo.MTPClient.Data.Helper;
  5. using Muchinfo.MTPClient.Resources;
  6. using System.Text;
  7. namespace Muchinfo.MTPClient.Data.Model.Account
  8. {
  9. using System;
  10. /// <summary>
  11. /// 限价单
  12. /// </summary>
  13. public class OrderDetail : OrderBase
  14. {
  15. #region Fields
  16. /// <summary>
  17. /// 有效期
  18. /// </summary>
  19. private DateTime _expirationDate;
  20. /// <summary>
  21. /// 商品
  22. /// </summary>
  23. private string _goods;
  24. /// <summary>
  25. /// 限价
  26. /// </summary>
  27. private decimal _limit;
  28. /// <summary>
  29. /// 订单号
  30. /// </summary>
  31. private long _orderNumber;
  32. /// <summary>
  33. /// 止损价
  34. /// </summary>
  35. private decimal _stopLoss;
  36. /// <summary>
  37. ///止盈价
  38. /// </summary>
  39. private decimal _stopProfit;
  40. //手续费
  41. private decimal _charge;
  42. private eChannelOrderStatus _status;
  43. /// <summary>
  44. /// 委托价格
  45. /// </summary>
  46. private decimal _entrustPrice;
  47. /// <summary>
  48. /// 市场名称
  49. /// </summary>
  50. private string _marketName;
  51. #endregion Fields
  52. #region Properties
  53. /// <summary>
  54. /// 委托来源
  55. /// </summary>
  56. /// <value>The channelordersrc.</value>
  57. [PropertyDisc("ChannelOrderSrc")]
  58. public eChannelOrderSrc ChannelOrderSrc { get; set; }
  59. /// <summary>
  60. /// 资金账户Id
  61. /// </summary>
  62. [PropertyDisc("AccountID")]
  63. public ulong AccountId { get; set; }
  64. /// <summary>
  65. /// 委托时间
  66. /// </summary>
  67. [PropertyDisc("OrderTime")]
  68. public DateTime EntrustTime { get; set; }
  69. public string EntrustTimeDisplay
  70. {
  71. get
  72. {
  73. if (EntrustTime != null)
  74. {
  75. return EntrustTime.ToString("yyyy-MM-dd HH:mm:ss");
  76. }
  77. else
  78. {
  79. return "-";
  80. }
  81. }
  82. }
  83. /// <summary>
  84. /// 建平
  85. /// </summary>
  86. [PropertyDisc("ChannelBuildType")]
  87. public eChannelBuildType BuildType { get; set; }
  88. public string BuildTypeDisplay
  89. {
  90. get { return BuildType.Discription(); }
  91. }
  92. ///// <summary>
  93. ///// 对冲标志
  94. ///// </summary>
  95. //[PropertyDisc("HedgeFlag")]
  96. //public eHedgeFlag HedgeFlag { get; set; }
  97. /// <summary>
  98. /// 委托价格
  99. /// </summary>
  100. [PropertyDisc("OrderPrice")]
  101. public decimal EntrustPrice
  102. {
  103. get { return _entrustPrice; }
  104. set { Set(() => EntrustPrice, ref _entrustPrice, value); }
  105. }
  106. /// <summary>
  107. /// 委托数量
  108. /// </summary>
  109. public decimal EntrustQty { get { return OpenOrderQty + CloseOrderQty; } }
  110. [PropertyDisc("OpenOrderQty")]
  111. public decimal OpenOrderQty { get; set; }
  112. [PropertyDisc("CloseOrderQty")]
  113. public decimal CloseOrderQty { get; set; }
  114. /// <summary>
  115. /// 成交数量
  116. /// </summary>
  117. public decimal TradeQty { get { return OpenTradeQty + CloseTradeQty; } }
  118. [PropertyDisc("OpenTradeQty")]
  119. public decimal OpenTradeQty { get; set; }
  120. [PropertyDisc("CloseTradeQty")]
  121. public decimal CloseTradeQty { get; set; }
  122. /// <summary>
  123. /// 显示状态
  124. /// </summary>
  125. public string DisplayStatus
  126. {
  127. get
  128. {
  129. return Status.Discription();
  130. }
  131. }
  132. /// <summary>
  133. /// 委托单号
  134. /// </summary>
  135. [PropertyDisc("OrderID")]
  136. public long OrderID { get; set; }
  137. /// <summary>
  138. /// 订单所属交易类型
  139. /// </summary>
  140. [PropertyDisc("MarketType")]
  141. public eTradeMode MarketType { get; set; }
  142. /// <summary>
  143. /// 资金模式
  144. /// </summary>
  145. [PropertyDisc("Moneymode")]
  146. public eMoneyMode Moneymode { get; set; }
  147. /// <summary>
  148. /// 时间校验类型
  149. /// </summary>
  150. [PropertyDisc("ValidType")]
  151. public ExpirationType VailType
  152. {
  153. get;
  154. set;
  155. }
  156. /// <summary>
  157. /// 获取或设置有效期
  158. /// Changes to that property's value raise the PropertyChanged event.
  159. /// </summary>
  160. [PropertyDisc("ValidTime")]
  161. public DateTime ExpirationDate
  162. {
  163. get { return _expirationDate; }
  164. set { Set(() => ExpirationDate, ref _expirationDate, value); }
  165. }
  166. /// <summary>
  167. /// 获取或设置 止损价
  168. /// Changes to that property's value raise the PropertyChanged event.
  169. /// </summary>
  170. [PropertyDisc("SlPrice")]
  171. public decimal StopLoss
  172. {
  173. get { return _stopLoss; }
  174. set { Set(() => StopLoss, ref _stopLoss, value); }
  175. }
  176. /// <summary>
  177. /// 显示格式化止损价
  178. /// </summary>
  179. public string DisplayStopLoss
  180. {
  181. get
  182. {
  183. if (StopLoss == 0) { return "-"; }
  184. return StopLoss.ToString();
  185. }
  186. }
  187. /// <summary>
  188. /// 获取或设置止盈价
  189. /// Changes to that property's value raise the PropertyChanged event.
  190. /// </summary>
  191. [PropertyDisc("SpPrice")]
  192. public decimal StopProfit
  193. {
  194. get { return _stopProfit; }
  195. set { Set(() => StopProfit, ref _stopProfit, value); }
  196. }
  197. /// <summary>
  198. /// 显示格式化止盈价
  199. /// </summary>
  200. public string DisplayStopProfit
  201. {
  202. get
  203. {
  204. if (StopProfit == 0) { return "-"; }
  205. return StopProfit.ToString();
  206. }
  207. }
  208. /// <summary>
  209. /// 状态
  210. /// </summary>
  211. [PropertyDisc("ChannelInnerOrderStatus")]
  212. public eChannelOrderStatus Status
  213. {
  214. get { return _status; }
  215. set { Set(() => Status, ref _status, value); }
  216. }
  217. ///// <summary>
  218. ///// 订单类型描述
  219. ///// </summary>
  220. //public string DisplayOrderType
  221. //{
  222. // get { return BuildType.Discription(); }
  223. //}
  224. public string StrVailType
  225. {
  226. get { return VailType.Discription(); }
  227. }
  228. /// <summary>
  229. /// 历史状态
  230. /// </summary>
  231. public string DisplayHistoryStatus
  232. {
  233. get
  234. {
  235. return Status.Discription();
  236. }
  237. }
  238. /// <summary>
  239. /// 关联委托单号
  240. /// </summary>
  241. private long _relationTicket;
  242. [PropertyDisc("RelationTicket")]
  243. public long RelationTicket
  244. {
  245. get
  246. {
  247. return _relationTicket;
  248. }
  249. set
  250. {
  251. Set(() => RelationTicket, ref _relationTicket, value);
  252. }
  253. }
  254. public string DisplayRelationID
  255. {
  256. get
  257. {
  258. if (_relationTicket == 0)
  259. {
  260. return "--";
  261. }
  262. return _relationTicket + string.Empty;
  263. }
  264. }
  265. private decimal _canCancelQty;
  266. /// <summary>
  267. /// 可撤数量
  268. /// </summary>
  269. public decimal CanCancelQty
  270. {
  271. get { return _canCancelQty; }
  272. set { Set(() => CanCancelQty, ref _canCancelQty, value); }
  273. }
  274. private decimal _canceledQty;
  275. /// <summary>
  276. /// 已撤数量
  277. /// </summary>
  278. [PropertyDisc("CancelQty")]
  279. public decimal CanceledQty
  280. {
  281. get { return _canceledQty; }
  282. set { Set(() => CanceledQty, ref _canceledQty, value); }
  283. }
  284. private decimal _completeQty; //UnTradeQty
  285. /// <summary>
  286. /// 成交数量
  287. /// </summary>
  288. [PropertyDisc("TradeQty")]
  289. public decimal CompleteQty
  290. {
  291. get { return _completeQty; }
  292. set { Set(() => CompleteQty, ref _completeQty, value); }
  293. }
  294. /// <summary>
  295. /// 公开发售数量
  296. /// </summary>
  297. [PropertyDisc("PublicIssueTradeQty")]
  298. public decimal PublicIssueTradeQty { get; set; }
  299. /// <summary>
  300. /// 优先成交数量
  301. /// </summary>
  302. [PropertyDisc("PreTradeQty")]
  303. public decimal PreTradeQty { get; set; }
  304. /// <summary>
  305. /// 未成交数量
  306. /// </summary>
  307. public decimal UnTradeQty
  308. {
  309. get
  310. {
  311. return EntrustQty - CompleteQty - CanceledQty;
  312. }
  313. }
  314. /// <summary>
  315. /// 冻结保证金
  316. /// </summary>
  317. private decimal _freezeMargin;
  318. /// <summary>
  319. /// 冻结保证金
  320. /// </summary>
  321. [PropertyDisc("FrozenMargin")]
  322. public decimal FreezeMargin
  323. {
  324. get
  325. {
  326. return _freezeMargin;
  327. }
  328. set
  329. {
  330. Set(() => FreezeMargin, ref _freezeMargin, value);
  331. }
  332. }
  333. /// <summary>
  334. /// 冻结保证金[固定保留两位小数]
  335. /// </summary>
  336. public string FreezeMarginDisplay
  337. {
  338. get
  339. {
  340. return FreezeMargin.ToString("f2");
  341. }
  342. }
  343. private eOrderOperateType _operateType;
  344. /// <summary>
  345. /// 操作类型
  346. /// </summary>
  347. [PropertyDisc("OperateType")]
  348. public eOrderOperateType OperateType
  349. {
  350. get { return _operateType; }
  351. set { _operateType = value; }
  352. }
  353. /// <summary>
  354. /// 所属机构
  355. /// </summary>
  356. [PropertyDisc("AreaName")]
  357. public string AreaName { get; set; }
  358. public string EntrustPriceDisplay
  359. {
  360. get
  361. {
  362. if (ePriceMode.PRICEMODE_MARKET == PriceMode) // 市价,显示市价2个字
  363. {
  364. return Client_Resource.EntrustOrderFrame_Market;
  365. }
  366. else
  367. {
  368. return DisplayEntrustPrice;
  369. }
  370. }
  371. }
  372. /// <summary>
  373. /// 显示格式化
  374. /// </summary>
  375. public string DisplayEntrustPrice
  376. {
  377. get
  378. {
  379. string result = EntrustPrice.ToString(PriceExpFormat);//服务端已做小数位处理
  380. //if (eTradeMode.TRADEMODE_MARKETMAKE == MarketType)
  381. //{
  382. // switch (BuildType)
  383. // {
  384. // case eChannelBuildType.CHANNELBUILDTYPE_CLOSE:
  385. // //case eBuildType.BUILDTYPE_CLOSETHENOPEN:
  386. // result = "-";
  387. // break;
  388. // default:
  389. // result = EntrustPrice.ToString(PriceFormat);
  390. // //result = EntrustPrice.ToString(); //服务端已做小数位处理
  391. // break;
  392. // }
  393. //}
  394. //else if (eTradeMode.TRADEMODE_BIDDINGMARKETMAKE == MarketType)
  395. //{
  396. // result = PriceMode == ePriceMode.PRICEMODE_MARKET ? "-" : result;
  397. //}
  398. return result;
  399. }
  400. }
  401. private ePriceMode _ePriceMode = ePriceMode.PRICEMODE_LIMIT;
  402. /// <summary>
  403. /// 价格类型
  404. /// </summary>
  405. [PropertyDisc("PriceMode")]
  406. public ePriceMode PriceMode
  407. {
  408. get
  409. {
  410. return _ePriceMode;
  411. }
  412. set
  413. {
  414. _ePriceMode = value;
  415. }
  416. }
  417. private eListingSelectType _eSelectType = eListingSelectType.LISTINGSELECTTYPE_DELISTING;
  418. [PropertyDisc("ListingSelectType")]
  419. public eListingSelectType ListingSelectType
  420. {
  421. get
  422. {
  423. return _eSelectType;
  424. }
  425. set
  426. {
  427. Set(() => ListingSelectType, ref _eSelectType, value);
  428. RaisePropertyChanged(() => DisplayListingSelectType);
  429. }
  430. }
  431. public string DisplayListingSelectType
  432. {
  433. get
  434. {
  435. return ListingSelectType.Discription();
  436. }
  437. }
  438. public string DisplayOpenDirection
  439. {
  440. get
  441. {
  442. return Direction.Discription();
  443. }
  444. }
  445. /// <summary>
  446. /// 显示历史委托价格
  447. /// </summary>
  448. public string DisplayHistoryEntrustPrice
  449. {
  450. get
  451. {
  452. return EntrustPrice.ToString(PriceExpFormat);
  453. }
  454. }
  455. /// <summary>
  456. /// 市场名称
  457. /// </summary>
  458. public string MarketName
  459. {
  460. get { return _marketName; }
  461. set { Set(() => MarketName, ref _marketName, value); }
  462. }
  463. private uint _marketID;
  464. /// <summary>
  465. /// 市场ID
  466. /// </summary>
  467. [PropertyDisc("MarketID")]
  468. public uint MarketID
  469. {
  470. get { return _marketID; }
  471. set { Set(() => MarketID, ref _marketID, value); }
  472. }
  473. /// <summary>
  474. /// 委托交易日
  475. /// </summary>
  476. [PropertyDisc("TradeDate")]
  477. public DateTime EntrustTradeDate { get; set; }
  478. /// <summary>
  479. /// 有效时间
  480. /// </summary>
  481. [PropertyDisc("ValidTime")]
  482. public string ValidTime { get; set; }
  483. /// <summary>
  484. /// 平仓模式
  485. /// </summary>
  486. [PropertyDisc("CloseMode")]
  487. public TradeCloseMode TradeCloseMode { get; set; }
  488. /// <summary>
  489. /// 发售成交数量
  490. /// </summary>
  491. [PropertyDisc("IMTradeqty")]
  492. public long IMTradeqty { get; set; }
  493. private string _retDesc;
  494. /// <summary>
  495. /// 描述--委托单的描述
  496. /// </summary>
  497. [PropertyDisc("RetDesc")]
  498. public string RetDesc
  499. {
  500. get
  501. {
  502. return _retDesc ?? "--";
  503. }
  504. set { Set(() => RetDesc, ref _retDesc, value); }
  505. }
  506. /// <summary>
  507. /// 订单取消
  508. /// </summary>
  509. public decimal IMCanceledQty
  510. {
  511. get
  512. {
  513. if (Status == eChannelOrderStatus.ORDERSTATUS_CANCELED)
  514. {
  515. return CanceledQty;
  516. }
  517. return 0;
  518. }
  519. }
  520. /// <summary>
  521. /// 未成交状态集合(1,2)
  522. /// </summary>
  523. public string UnTradeStatus { get; set; }
  524. /// <summary>
  525. /// 是否可撤单
  526. /// </summary>
  527. public bool IsCancel
  528. {
  529. get
  530. {
  531. //委托状态 - 3:委托成功 7:部分成交 且委托来源不为交易服务的 可撤单
  532. return ((Status == eChannelOrderStatus.ORDERSTATUS_SUCCEED || Status == eChannelOrderStatus.ORDERSTATUS_REQUEST) && ChannelOrderSrc != eChannelOrderSrc.CHANNELORDERSRC_TRADE);
  533. }
  534. }
  535. private DateTime _cancelTime;
  536. /// <summary>
  537. /// hedge_innerOrderCancel表中的ActionTime字段表示撤单时间
  538. /// </summary>
  539. [PropertyDisc("CancelTime")]
  540. public DateTime CancelTime
  541. {
  542. get
  543. {
  544. return _cancelTime;
  545. }
  546. set
  547. {
  548. Set(() => CancelTime, ref _cancelTime, value);
  549. RaisePropertyChanged(() => CancelTimeDisplay);
  550. }
  551. }
  552. public string CancelTimeDisplay
  553. {
  554. get
  555. {
  556. string time = CancelTime.ToString("yyyy-MM-dd HH:mm:ss");
  557. if (@"0001-01-01 00:00:00".Equals(time))// 数据库中没有值得时候,通用查询会返回这样的数据下来。特殊处理一下
  558. {
  559. return "--";
  560. }
  561. else
  562. {
  563. return time;
  564. }
  565. }
  566. }
  567. #endregion Properties
  568. #region 常量
  569. private readonly string c_CloseToday = Client_Resource.Domain_TodayClose;
  570. private readonly string c_CloseHistory = Client_Resource.Domain_HistoryClose;
  571. private readonly string c_CloseAll = Client_Resource.Domain_CloseAll;
  572. private readonly string c_OrderMode_STD = Client_Resource.Domain_NoDeal_PendingOrder;
  573. private readonly string c_MovingSl = Client_Resource.Domain_Stop_Trriger;
  574. private readonly string c_Reverse = Client_Resource.Domain_BackhandOpen_AllowSpreads;
  575. private readonly string c_StopLossProfit = Client_Resource.Domain_Stop_OnlyProfit_AllowSpreads;
  576. #endregion
  577. }
  578. }