HoldOrder.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. using Muchinfo.MTPClient.Data.Enums;
  2. using Muchinfo.MTPClient.Data.Helper;
  3. using Muchinfo.MTPClient.Resources;
  4. namespace Muchinfo.MTPClient.Data.Model.Account
  5. {
  6. using System;
  7. /// <summary>
  8. /// 持仓明细表
  9. /// </summary>
  10. public class HoldingOrder : OrderBase
  11. {
  12. #region Fields
  13. /// <summary>
  14. /// 手续费
  15. /// </summary>
  16. private decimal _charge;
  17. /// <summary>
  18. /// 平仓价
  19. /// </summary>
  20. private decimal _closePrice;
  21. ///// <summary>
  22. ///// 商品
  23. ///// </summary>
  24. //private string _goods;
  25. /// <summary>
  26. /// 持仓价
  27. /// </summary>
  28. private decimal _holdingPrice;
  29. /// <summary>
  30. /// 数量
  31. /// </summary>
  32. private decimal _lot;
  33. /// <summary>
  34. /// 建仓时间
  35. /// </summary>
  36. private DateTime _openDate;
  37. private Direction _openDirection;
  38. /// <summary>
  39. /// 建仓价
  40. /// </summary>
  41. private decimal _openPrice;
  42. /// <summary>
  43. /// 订单号
  44. /// </summary>
  45. private long _orderId;
  46. /// <summary>
  47. /// 浮动盈亏
  48. /// </summary>
  49. private decimal _pLFloat;
  50. /// <summary>
  51. /// 止损价
  52. /// </summary>
  53. private decimal _stopLoss;
  54. /// <summary>
  55. ///止盈价
  56. /// </summary>
  57. private decimal _stopProfit;
  58. /// <summary>
  59. /// 建仓单号
  60. /// </summary>
  61. private int _openOrder;
  62. /// <summary>
  63. /// 递延费
  64. /// </summary>
  65. private decimal _interest;
  66. /// <summary>
  67. /// 市场名称
  68. /// </summary>
  69. private string _marketName;
  70. #endregion Fields
  71. #region Properties
  72. #region Public Properties
  73. /// <summary>
  74. /// Sets and gets 手续费
  75. /// Changes to that property's value raise the PropertyChanged event.
  76. /// </summary>
  77. [PropertyDisc("Charge")]
  78. public decimal Charge
  79. {
  80. get { return _charge; }
  81. set { Set(() => Charge, ref _charge, value); }
  82. }
  83. /// <summary>
  84. /// 冻结头寸
  85. /// </summary>
  86. private decimal _positionFzQty;
  87. /// <summary>
  88. /// 冻结头寸
  89. /// </summary>
  90. [PropertyDisc("PositionFzQty")]
  91. public decimal PositionFzQty
  92. {
  93. get { return _positionFzQty; }
  94. set { Set(() => PositionFzQty, ref _positionFzQty, value); }
  95. }
  96. /// <summary>
  97. /// 所属机构
  98. /// </summary>
  99. [PropertyDisc("AreaName")]
  100. public string AreaName { get; set; }
  101. /// <summary>
  102. /// 合约单位
  103. /// </summary>
  104. [PropertyDisc("currentAgreeunit")]
  105. public int currentAgreeunit { get; set; }
  106. /// <summary>
  107. /// Sets and gets 平仓价
  108. /// Changes to that property's value raise the PropertyChanged event.
  109. /// </summary>
  110. public decimal ClosePrice
  111. {
  112. get
  113. {
  114. return _closePrice;
  115. }
  116. set
  117. {
  118. Set(() => ClosePrice, ref _closePrice, value);
  119. RaisePropertyChanged(() => DisplayClosePrice);
  120. }
  121. }
  122. public decimal ContrayClosePrice { get; set; }
  123. /// <summary>
  124. /// 格式化平仓价
  125. /// </summary>
  126. public string DisplayClosePrice
  127. {
  128. get
  129. {
  130. //if (ClosePrice > 0 && MarketType != eTradeMode.TRADEMODE_SALE)
  131. if (ClosePrice > 0)
  132. {
  133. return ClosePrice.ToString(PriceFormat);
  134. }
  135. else
  136. {
  137. return "-";
  138. }
  139. }
  140. }
  141. /// <summary>
  142. /// 显示建仓日期
  143. /// </summary>
  144. public string DisplayOpenDate
  145. {
  146. get
  147. {
  148. if (_openDate==DateTime.MinValue)
  149. {
  150. return "--";
  151. }
  152. return _openDate.ToString("yyyy-MM-dd HH:mm:ss");
  153. }
  154. }
  155. private decimal _usedMargin; //占用保证金
  156. /// <summary>
  157. /// 占用保证金
  158. /// </summary>
  159. [PropertyDisc("UsedMargin")]
  160. public decimal UsedMargin
  161. {
  162. get { return _usedMargin; }
  163. set { Set(() => UsedMargin, ref _usedMargin, value); }
  164. }
  165. /// <summary>
  166. /// 占用保证金[固定保留两位]
  167. /// </summary>
  168. public string UsedMarginDisplay
  169. {
  170. get
  171. {
  172. return UsedMargin.ToString("f2");
  173. }
  174. }
  175. /// <summary>
  176. /// Sets and gets 持仓价
  177. /// Changes to that property's value raise the PropertyChanged event.
  178. /// </summary>
  179. [PropertyDisc("HolderPrice")]
  180. public decimal HoldingPrice
  181. {
  182. get
  183. {
  184. return _holdingPrice;
  185. }
  186. set
  187. {
  188. Set(() => HoldingPrice, ref _holdingPrice, value);
  189. }
  190. }
  191. /// <summary>
  192. /// 格式化持仓价
  193. /// </summary>
  194. public string DisplayHoldingPrice
  195. {
  196. get
  197. {
  198. return HoldingPrice.ToString(PriceFormat);
  199. }
  200. }
  201. /// <summary>
  202. /// Sets and gets 持仓 数量(包括锁仓数量).
  203. ///
  204. /// </summary>
  205. [PropertyDisc("Qty")]
  206. public decimal Lot
  207. {
  208. get { return _lot; }
  209. set { Set(() => Lot, ref _lot, value); }
  210. }
  211. /// <summary>
  212. /// 建仓时间
  213. /// Changes to that property's value raise the PropertyChanged event.
  214. /// </summary>
  215. [PropertyDisc("OpenTime")]
  216. public DateTime OpenDate
  217. {
  218. get { return _openDate; }
  219. set { Set(() => OpenDate, ref _openDate, value); }
  220. }
  221. /// <summary>HoldingMargin
  222. /// 显示建仓日期
  223. /// </summary>
  224. public string StrOpenDirection
  225. {
  226. get
  227. {
  228. return Direction.Discription();
  229. //switch (OpenDirection)
  230. //{
  231. // case Direction.Ask:
  232. // return Client_Resource.Domain_SellOut;
  233. // case Direction.Bid:
  234. // return Client_Resource.Model_Buyin;
  235. // default:
  236. // return Client_Resource.Model_Buyin;
  237. //}
  238. }
  239. }
  240. /// <summary>
  241. /// Sets and gets 建仓价
  242. /// Changes to that property's value raise the PropertyChanged event.
  243. /// </summary>
  244. [PropertyDisc("OpenPrice")]
  245. public decimal OpenPrice
  246. {
  247. get { return _openPrice; }
  248. set { Set(() => OpenPrice, ref _openPrice, value); }
  249. }
  250. /// <summary>
  251. /// 显示委托价格
  252. /// </summary>
  253. public string DisplayOpenPrice
  254. {
  255. get { return OpenPrice.ToString(PriceFormat); }
  256. }
  257. /// <summary>
  258. /// Sets and gets the orderNumber property.
  259. /// Changes to that property's value raise the PropertyChanged event.
  260. /// </summary>
  261. [PropertyDisc("OrderID")]
  262. public long OrderID
  263. {
  264. get { return _orderId; }
  265. set { Set(() => OrderID, ref _orderId, value); }
  266. }
  267. /// <summary>
  268. /// Sets and gets 浮动盈亏
  269. /// Changes to that property's value raise the PropertyChanged event.
  270. /// </summary>
  271. public decimal PLFloat
  272. {
  273. get { return _pLFloat; }
  274. set { Set(() => PLFloat, ref _pLFloat, value); }
  275. }
  276. /// <summary>
  277. /// Sets and gets 止损价
  278. /// Changes to that property's value raise the PropertyChanged event.
  279. /// </summary>
  280. [PropertyDisc("SlPrice")]
  281. public decimal StopLoss
  282. {
  283. get { return _stopLoss; }
  284. set { Set(() => StopLoss, ref _stopLoss, value); }
  285. }
  286. /// <summary>
  287. /// 显示格式化止损价
  288. /// </summary>
  289. public string DisplayStopLoss
  290. {
  291. get
  292. {
  293. if (StopLoss == 0)
  294. {
  295. return "--";
  296. }
  297. return StopLoss.ToString(PriceFormat);
  298. }
  299. }
  300. /// <summary>
  301. /// Sets and gets 止盈价
  302. /// Changes to that property's value raise the PropertyChanged event.
  303. /// </summary>
  304. [PropertyDisc("SpPrice")]
  305. public decimal StopProfit
  306. {
  307. get { return _stopProfit; }
  308. set { Set(() => StopProfit, ref _stopProfit, value); }
  309. }
  310. /// <summary>
  311. /// 显示格式化 止盈
  312. /// </summary>
  313. public string DisplayStopProfit
  314. {
  315. get
  316. {
  317. if (StopProfit == 0)
  318. {
  319. return "--";
  320. }
  321. return StopProfit.ToString(PriceFormat);
  322. }
  323. }
  324. private decimal _availQty;
  325. /// <summary>
  326. /// 可用数量
  327. /// </summary>
  328. [PropertyDisc("enableQty")]
  329. public decimal AvailQty
  330. {
  331. get { return _availQty; }
  332. set
  333. {
  334. Set(() => AvailQty, ref _availQty, value);
  335. }
  336. }
  337. /// <summary>
  338. /// 保证金金额
  339. /// </summary>
  340. private decimal _marginAccount;
  341. private decimal _reckonPl;
  342. /// <summary>
  343. /// 结算盈亏
  344. /// </summary>
  345. [PropertyDisc("ReckonPL")]
  346. public decimal ReckonPL
  347. {
  348. get { return _reckonPl; }
  349. set { Set(() => ReckonPL, ref _reckonPl, value); }
  350. }
  351. public TradeAccount TradeAccount
  352. {
  353. get;
  354. set;
  355. }
  356. /// <summary>
  357. /// 递延费
  358. /// </summary>
  359. [PropertyDisc("Interest")]
  360. public decimal Interest
  361. {
  362. get { return _interest; }
  363. set { Set(() => Interest, ref _interest, value); }
  364. }
  365. /// <summary>
  366. /// 成交数数量
  367. /// </summary>
  368. [PropertyDisc("TradeQty")]
  369. public decimal TradeQty { get; set; }
  370. /// <summary>
  371. /// 市场名称
  372. /// </summary>
  373. public string MarketName
  374. {
  375. get { return _marketName; }
  376. set { Set(() => MarketName, ref _marketName, value); }
  377. }
  378. private string _settlementMember;
  379. /// <summary>
  380. /// 特别会员ID
  381. /// </summary>
  382. public string SettlementMember
  383. {
  384. get { return _settlementMember; }
  385. set { Set(() => SettlementMember, ref _settlementMember, value); }
  386. }
  387. private string _settlementMemberName;
  388. /// <summary>
  389. /// 特别会员名字
  390. /// </summary>
  391. public string SettlementMemberName
  392. {
  393. get
  394. {
  395. return _settlementMemberName;
  396. }
  397. set
  398. {
  399. Set(() => SettlementMemberName, ref _settlementMemberName, value);
  400. }
  401. }
  402. /// <summary>
  403. /// 冻结数量
  404. /// </summary>
  405. //[PropertyDisc("FreezeQty")]
  406. //public decimal FrozenQty { get; set; }
  407. /// <summary>
  408. /// 操作类型
  409. /// </summary>
  410. public eOrderOperateType OrderOperate
  411. {
  412. get;
  413. set;
  414. }
  415. /// <summary>
  416. /// 操作员
  417. /// </summary>
  418. [PropertyDisc("OperatorId")]
  419. public ulong OperatorID
  420. {
  421. get;
  422. set;
  423. }
  424. private HoldStatus _holdStatus;
  425. /// <summary>
  426. /// 持仓金额
  427. /// </summary>
  428. [PropertyDisc("HolderAmount")]
  429. public decimal HoldAmount { get; set; }
  430. /// <summary>
  431. /// 锁仓的持仓金额
  432. /// </summary>
  433. [PropertyDisc("lockHolderAmount")]
  434. public decimal lockHolderAmount { get; set; }
  435. /// <summary>
  436. /// 建仓金额
  437. /// </summary>
  438. [PropertyDisc("TradeAmount")]
  439. public decimal OpenAmount { get; set; }
  440. /// <summary>
  441. /// 持仓状态
  442. /// </summary>
  443. public HoldStatus HoldStatus
  444. {
  445. get { return _holdStatus; }
  446. set { _holdStatus = value; }
  447. }
  448. private DateTime _tradeDate;
  449. /// <summary>
  450. /// 交易日
  451. /// </summary>
  452. public DateTime TradeDate
  453. {
  454. get { return _tradeDate; }
  455. set { _tradeDate = value; }
  456. }
  457. /// <summary>
  458. /// 账号ID
  459. /// </summary>
  460. [PropertyDisc("AccountId")]
  461. public ulong Accountid { get; set; }
  462. /// <summary>
  463. /// 持仓状态显示
  464. /// </summary>
  465. public string HoldStatusDisplay
  466. {
  467. get
  468. {
  469. switch (HoldStatus)
  470. {
  471. case HoldStatus.NODELIVERY:
  472. return "--";
  473. default:
  474. return Client_Resource.Model_DeliveryFreeze;
  475. }
  476. }
  477. }
  478. /// <summary>
  479. /// 显示到表单中操作类型
  480. /// </summary>
  481. public string OrderOperateDisplay
  482. {
  483. get
  484. {
  485. return OperatorID == Accountid ? Client_Resource.Model_UserPlaceOrder : Client_Resource.Model_SystemPlaceOrder;
  486. //switch (OrderOperate)
  487. //{
  488. // case OrderOperateType.UserOrder:
  489. // return Client_Resource.Model_UserPlaceOrder;
  490. // case OrderOperateType.SystemOrder:
  491. // return Client_Resource.Model_SystemPlaceOrder;
  492. // default:
  493. // return Client_Resource.Model_UserPlaceOrder;
  494. //}
  495. }
  496. }
  497. /// <summary>
  498. /// 关联委托单据号(平仓委托)
  499. /// </summary>
  500. [PropertyDisc("RelationTicket")]
  501. public long RelationTicket { get; set; }
  502. /// <summary>
  503. /// 订单所属交易类型
  504. /// </summary>
  505. [PropertyDisc("MarketType")]
  506. public eTradeMode MarketType { get; set; }
  507. /// <summary>
  508. /// 锁仓数量
  509. /// </summary>
  510. [PropertyDisc("LockQty")]
  511. public decimal LockQty { get; set; }
  512. /// <summary>
  513. /// 当前市值
  514. /// </summary>
  515. public decimal CurrentAmount { get; set; }
  516. private decimal _sumFloatPL;
  517. /// <summary>
  518. /// 盈亏汇总
  519. /// </summary>
  520. public decimal SumFloatPL
  521. {
  522. get { return _sumFloatPL; }
  523. set { Set(() => SumFloatPL, ref _sumFloatPL, value); }
  524. }
  525. /// <summary>
  526. /// 持仓天数
  527. /// </summary>
  528. [PropertyDisc("holderdays")]
  529. public int HolderDays { get; set; }
  530. /// <summary>
  531. /// /最小持仓天数
  532. /// </summary>
  533. [PropertyDisc("MinHOLDERDAYS")]
  534. public int MinHolderDays { get; set; }
  535. /// <summary>
  536. /// T+N 冻结
  537. /// </summary>
  538. [PropertyDisc("tnfreezeqty")]
  539. public decimal tnFreezeqty { get; set; }
  540. /// <summary>
  541. /// 是否可以平仓,T+N后可平仓
  542. /// </summary>
  543. public bool IsCanClose
  544. {
  545. get
  546. {
  547. return HolderDays - MinHolderDays >=0; ///持仓天数超过最小持仓天数
  548. }
  549. }
  550. /// <summary>
  551. /// 可平数量
  552. /// </summary>
  553. public decimal CloseQty
  554. {
  555. get
  556. {
  557. return IsCanClose ? AvailQty : 0;
  558. }
  559. }
  560. /// <summary>
  561. /// 显示商品最小持仓天数
  562. /// </summary>
  563. public string CloseDaysDisplay
  564. {
  565. get
  566. {
  567. return string.Format(Client_Resource.Content_ShowCloseDays, MinHolderDays);
  568. }
  569. }
  570. public bool IsCanButtunCloseVbs
  571. {
  572. get
  573. {
  574. //return MarketType != eTradeMode.TRADEMODE_SALE;
  575. return true;
  576. }
  577. }
  578. #region 小数位
  579. /// <summary>
  580. /// 价格小数位
  581. /// </summary>
  582. [PropertyDisc("decimalplace")]
  583. public int DecimalPlace { get; set; }
  584. public override string PriceExpFormat
  585. {
  586. get
  587. {
  588. if (DecimalPlace < 3)
  589. {
  590. return "F2";
  591. }
  592. else
  593. {
  594. return PriceFormat;
  595. }
  596. }
  597. }
  598. public override string PriceFormat
  599. {
  600. get
  601. {
  602. if (DecimalPlace > 0 && DecimalPlace < 20)
  603. {
  604. return "F" + DecimalPlace;
  605. }
  606. else
  607. {
  608. return "F2";
  609. }
  610. }
  611. }
  612. #endregion
  613. #endregion Public Properties
  614. #endregion Properties
  615. #region 全额持仓字段MTP2.0
  616. private uint _HolderQty = uint.MaxValue;
  617. /// <summary>
  618. /// 持仓数量
  619. /// </summary>
  620. public uint HolderQty
  621. {
  622. get { return _HolderQty; }
  623. set { _HolderQty = value; }
  624. }
  625. private uint _limitCount = uint.MaxValue;
  626. /// <summary>
  627. /// 受限数量
  628. /// </summary>
  629. public uint limitCount
  630. {
  631. get { return _limitCount; }
  632. set { _limitCount = value; }
  633. }
  634. private uint _FreezeQty = uint.MaxValue;
  635. /// <summary>
  636. /// 冻结数量
  637. /// </summary>
  638. public uint FreezeQty
  639. {
  640. get { return _FreezeQty; }
  641. set { _FreezeQty = value; }
  642. }
  643. #endregion
  644. #region 保证金持仓字段MTP2.0
  645. private uint _BuyFrozenQty = uint.MaxValue;
  646. /// <summary>
  647. /// 买持仓冻结
  648. /// </summary>
  649. public uint BuyFrozenQty
  650. {
  651. get { return _BuyFrozenQty; }
  652. set { _BuyFrozenQty = value; }
  653. }
  654. private uint _BuyOtherFrozenQty = uint.MaxValue;
  655. /// <summary>
  656. /// 买持仓其他冻结
  657. /// </summary>
  658. public uint BuyOtherFrozenQty
  659. {
  660. get { return _BuyOtherFrozenQty; }
  661. set { _BuyOtherFrozenQty = value; }
  662. }
  663. private uint _SellFrozenQty = uint.MaxValue;
  664. /// <summary>
  665. /// 卖持仓冻结
  666. /// </summary>
  667. public uint SellFrozenQty
  668. {
  669. get { return _SellFrozenQty; }
  670. set { _SellFrozenQty = value; }
  671. }
  672. private uint _SellOtherFrozenQty = uint.MaxValue;
  673. /// <summary>
  674. /// 卖持仓其他冻结
  675. /// </summary>
  676. public uint SellOtherFrozenQty
  677. {
  678. get { return _SellOtherFrozenQty; }
  679. set { _SellOtherFrozenQty = value; }
  680. }
  681. private uint _BuyCurPositionQty = uint.MaxValue;
  682. /// <summary>
  683. /// 买当前持仓数量
  684. /// </summary>
  685. public uint BuyCurPositionQty
  686. {
  687. get { return _BuyCurPositionQty; }
  688. set { _BuyCurPositionQty = value; }
  689. }
  690. private double _BuyCurHolderAmount = int.MinValue;
  691. /// <summary>
  692. /// 买当前持仓金额
  693. /// </summary>
  694. public double BuyCurHolderAmount
  695. {
  696. get { return _BuyCurHolderAmount; }
  697. set { _BuyCurHolderAmount = value; }
  698. }
  699. private uint _SellCurPositionQty = uint.MaxValue;
  700. /// <summary>
  701. /// 卖当前持仓数量
  702. /// </summary>
  703. public uint SellCurPositionQty
  704. {
  705. get { return _SellCurPositionQty; }
  706. set { _SellCurPositionQty = value; }
  707. }
  708. private double _SellCurHolderAmount = int.MinValue;
  709. /// <summary>
  710. /// 卖当前持仓金额
  711. /// </summary>
  712. public double SellCurHolderAmount
  713. {
  714. get { return _SellCurHolderAmount; }
  715. set { _SellCurHolderAmount = value; }
  716. }
  717. #endregion
  718. }
  719. }