HoldingSummaryNew.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. using System.Collections.Generic;
  2. using System.Windows.Documents;
  3. using Muchinfo.MTPClient.Data.Enums;
  4. using Muchinfo.MTPClient.Data.Helper;
  5. using System;
  6. namespace Muchinfo.MTPClient.Data.Model.Account
  7. {
  8. public class HoldingSummaryNew : OrderBase
  9. {
  10. [PropertyDisc("AccountID")]
  11. public ulong AccountId
  12. {
  13. get;
  14. set;
  15. }
  16. /// <summary>
  17. /// 期初持仓数量
  18. /// </summary>
  19. private decimal _positionQty;
  20. /// <summary>
  21. /// 期初持仓数量
  22. /// Changes to that property's value raise the PropertyChanged event.
  23. /// </summary>
  24. [PropertyDisc("PositionQty")]
  25. public decimal PositionQty
  26. {
  27. get { return _positionQty; }
  28. set { Set(() => PositionQty, ref _positionQty, value); }
  29. }
  30. /// <summary>
  31. /// 期初持仓总金额
  32. /// </summary>
  33. private decimal _holderAmount;
  34. /// <summary>
  35. /// 期初持仓总金额
  36. /// </summary>
  37. [PropertyDisc("HolderAmount")]
  38. public decimal HolderAmount
  39. {
  40. get{ return _holderAmount; }
  41. set { Set(() => HolderAmount, ref _holderAmount, value); }
  42. }
  43. /// <summary>
  44. /// 当前持仓数量
  45. /// </summary>
  46. private decimal _curPositionQty;
  47. /// <summary>
  48. /// 当前持仓数量
  49. /// Changes to that property's value raise the PropertyChanged event.
  50. /// </summary>
  51. [PropertyDisc("CurPositionQty")]
  52. public decimal CurPositionQty
  53. {
  54. get { return _curPositionQty; }
  55. set
  56. {
  57. Set(() => CurPositionQty, ref _curPositionQty, value);
  58. RaisePropertyChanged(() => AvailQty);
  59. }
  60. }
  61. private decimal _availQty;
  62. public decimal AvailQty
  63. {
  64. get
  65. {
  66. _availQty=_curPositionQty - _frozenQty - _otherFrozenQty;
  67. return _availQty;
  68. }
  69. set { Set(() => AvailQty, ref _availQty, value); }
  70. }
  71. /// <summary>
  72. /// 当前持仓总金额
  73. /// </summary>
  74. private decimal _curHolderAmount;
  75. /// <summary>
  76. /// 当前持仓总金额
  77. /// Changes to that property's value raise the PropertyChanged event.
  78. /// </summary>
  79. [PropertyDisc("CurHolderAmount")]
  80. public decimal CurHolderAmount
  81. {
  82. get { return _curHolderAmount; }
  83. set
  84. {
  85. Set(() => CurHolderAmount, ref _curHolderAmount, value);
  86. RaisePropertyChanged(() => GoodsPaymentDisplay);
  87. RaisePropertyChanged(() => ProfitPercen);
  88. }
  89. }
  90. /// <summary>
  91. /// 持仓冻结数量
  92. /// </summary>
  93. private decimal _frozenQty;
  94. /// <summary>
  95. /// 持仓冻结数量
  96. /// Changes to that property's value raise the PropertyChanged event.
  97. /// </summary>
  98. [PropertyDisc("FrozenQty")]
  99. public decimal FrozenQty
  100. {
  101. get { return _frozenQty; }
  102. set
  103. {
  104. Set(() => FrozenQty, ref _frozenQty, value);
  105. RaisePropertyChanged(() => AvailQty);
  106. }
  107. }
  108. /// <summary>
  109. /// 其他冻结数量
  110. /// </summary>
  111. private decimal _otherFrozenQty;
  112. /// <summary>
  113. /// 其他冻结数量
  114. /// </summary>
  115. [PropertyDisc("OtherFrozenQty")]
  116. public decimal OtherFrozenQty
  117. {
  118. get { return _otherFrozenQty; }
  119. set
  120. {
  121. Set(() => OtherFrozenQty, ref _otherFrozenQty, value);
  122. RaisePropertyChanged(() => AvailQty);
  123. }
  124. }
  125. private decimal _openReqQty;
  126. [PropertyDisc("OpenReqQty")]
  127. public decimal OpenReqQty
  128. {
  129. get { return _openReqQty; }
  130. set { Set(() => OpenReqQty, ref _openReqQty, value); }
  131. }
  132. private decimal _openTotalQty;
  133. [PropertyDisc("OpenTotalQty")]
  134. public decimal OpenTotalQty
  135. {
  136. get { return _openTotalQty; }
  137. set { Set(() => OpenTotalQty, ref _openTotalQty, value); }
  138. }
  139. private decimal _closeTotalQty;
  140. [PropertyDisc("CloseTotalQty")]
  141. public decimal CloseTotalQty
  142. {
  143. get { return _closeTotalQty; }
  144. set { Set(() => CloseTotalQty, ref _closeTotalQty, value); }
  145. }
  146. /// <summary>
  147. /// 持仓均价
  148. /// </summary>
  149. private decimal _holdingAVGPrice;
  150. /// <summary>
  151. /// 获取或设置 持仓均价
  152. /// Changes to that property's value raise the PropertyChanged event.
  153. /// </summary>
  154. public decimal HoldingAVGPrice
  155. {
  156. get { return _holdingAVGPrice; }
  157. set
  158. {
  159. Set(() => HoldingAVGPrice, ref _holdingAVGPrice, value);
  160. RaisePropertyChanged(() => DisplayHoldingAVGPrice);
  161. }
  162. }
  163. /// <summary>
  164. /// 显示持仓均价
  165. /// </summary>
  166. public string DisplayHoldingAVGPrice
  167. {
  168. get
  169. {
  170. if (HoldingAVGPrice > 0)
  171. {
  172. return HoldingAVGPrice.ToString(PriceExpFormat);
  173. }
  174. else
  175. {
  176. return "-";
  177. }
  178. }
  179. }
  180. [PropertyDisc("AgreeUnit")]
  181. public decimal AgreeUnit { get; set; }
  182. /// <summary>
  183. /// 交割标志
  184. /// </summary>
  185. [PropertyDisc("DeliveryFlag")]
  186. public eDeliveryFlag DeliveryFlag
  187. {
  188. get;
  189. set;
  190. }
  191. public string StrOpenDirection
  192. {
  193. get
  194. {
  195. return Direction.Discription();
  196. }
  197. }
  198. /// <summary>
  199. /// 最新价
  200. /// </summary>
  201. private decimal _latestPrice;
  202. /// <summary>
  203. /// 获取或设置 最新价
  204. /// Changes to that property's value raise the PropertyChanged event.
  205. /// </summary>
  206. public decimal LatestPrice
  207. {
  208. get
  209. {
  210. return _latestPrice;
  211. }
  212. set
  213. {
  214. Set(() => LatestPrice, ref _latestPrice, value);
  215. RaisePropertyChanged(() => DisplayLatestPrice);
  216. RaisePropertyChanged(() => MarketValue);
  217. }
  218. }
  219. /// <summary>
  220. /// 显示最新价
  221. /// </summary>
  222. public string DisplayLatestPrice
  223. {
  224. get
  225. {
  226. if (LatestPrice > 0)
  227. {
  228. return LatestPrice.ToString(PriceFormat);
  229. }
  230. else
  231. {
  232. return "-";
  233. }
  234. }
  235. }
  236. public string GoodsPaymentDisplay
  237. {
  238. get
  239. {
  240. if (CurHolderAmount != 0)
  241. {
  242. return CurHolderAmount.ToString("f2");
  243. }
  244. else
  245. {
  246. return "-";
  247. }
  248. }
  249. }
  250. private decimal _marketValue;
  251. /// <summary>
  252. /// 市值=最新价*持有总量*合约单位;
  253. /// </summary>
  254. public decimal MarketValue
  255. {
  256. get { return _marketValue; }
  257. set
  258. {
  259. Set(() => MarketValue, ref _marketValue, value);
  260. RaisePropertyChanged(() => MarketValueDisplay);
  261. RaisePropertyChanged(() => ProfitPercen);
  262. }
  263. }
  264. public string MarketValueDisplay
  265. {
  266. get
  267. {
  268. if (MarketValue != 0)
  269. {
  270. return MarketValue.ToString("f2");
  271. }
  272. else
  273. {
  274. return "-";
  275. }
  276. }
  277. }
  278. /// <summary>
  279. /// 浮动盈亏
  280. /// </summary>
  281. private decimal _pLFloat;
  282. /// <summary>
  283. /// 获取或设置 浮动盈亏
  284. /// Changes to that property's value raise the PropertyChanged event.
  285. /// </summary>
  286. public decimal PLFloat
  287. {
  288. get
  289. {
  290. return _pLFloat;
  291. }
  292. set
  293. {
  294. Set(() => PLFloat, ref _pLFloat, value);
  295. RaisePropertyChanged(() => DisplayPLFloat);
  296. RaisePropertyChanged(() => SumFloatPL);
  297. }
  298. }
  299. /// <summary>
  300. /// 显示 浮动盈亏
  301. /// </summary>
  302. public string DisplayPLFloat
  303. {
  304. get
  305. {
  306. if (PLFloat != decimal.Zero)
  307. {
  308. return PLFloat.ToString(PriceExpFormat);
  309. }
  310. else
  311. {
  312. return "-";
  313. }
  314. }
  315. }
  316. /// <summary>
  317. /// 盈亏比例=(市值—货款)/ 货款 * 100% ;
  318. /// </summary>
  319. public string ProfitPercen
  320. {
  321. get
  322. {
  323. if (CurHolderAmount != 0 && MarketValue != 0)
  324. {
  325. return ((MarketValue - CurHolderAmount) / CurHolderAmount).ToString("P2");
  326. }
  327. else
  328. {
  329. return "-";
  330. }
  331. }
  332. }
  333. private decimal _sumFloatPL;
  334. /// <summary>
  335. /// 盈亏汇总
  336. /// </summary>
  337. public decimal SumFloatPL
  338. {
  339. get { return _sumFloatPL; }
  340. set { Set(() => SumFloatPL, ref _sumFloatPL, value); }
  341. }
  342. /// <summary>
  343. /// 是否可平仓
  344. /// </summary>
  345. public bool IsCanClose
  346. {
  347. get
  348. {
  349. return AvailQty > 0;
  350. }
  351. }
  352. public bool IsShowDelivery
  353. {
  354. get
  355. {
  356. return DeliveryFlag == eDeliveryFlag.DELIVERYFLAG_YES && Direction == Direction.Bid;
  357. }
  358. }
  359. }
  360. }